Forum OpenACS Q&A: ERROR: parser: parse error at or near "*"

Hi All,

I'm new to this, and was unsure what this error means and what I can do to fix it - I'm working through the tutorials available on the OpenACS Documentation (Chapter 8)

This is the error I get when i check my package on http://127.0.0.1:8000/note

I've restarted the server and still get this error...

Any help would be great, thanks
  NM
Collapse
Posted by Randy O'Meara on
NM,

You haven't provided quite enough information to say for certain what the problem is. However, this sounds very much like you're executing a DB query, the Query Dispatcher is not able to locate your named query, and your program is failing when the "{*SQL*}" dummy argument is parsed. You'll see the same dummy argument appearing throughout the toolkit just for this purpose. It's supposed to flag an error very close to the missing query to get your dubugging started in the right general area.

Anyhow, assuming that this is the cause of your error, analysis of your server error file will show that the qd could not find the named query. Why? Probably due to a mistyped query name, misplaced or mis-named query file, or syntax.

The query ("notes_query" from chapter 8) lives in index.xql while your code lives in index.tcl and your display template resides in index.adp. All of these files must reside in the same directory, namely the "www" directory. Check all of these carefully to be certain that a typo hasn't "crept" in.

Randy

Collapse
Posted by Nathan Mickson on
Thanks Randy, I accidently named the index.xql file with extension .sql instead

But now having fixed that and reloaded i get this error:

Request Error

Database operation "select" failed (exception NSDB, "Query was not a statement returning rows.")

ERROR:  Relation "samplenote" does not exist

SQL:
    select note_id,
          title,
          body
      from samplenote

order by title asc

    while executing
"ns_pg_bind select nsdb0 {
    select note_id,
          title,
          body
      from samplenote

order by title asc
    }"
    ("uplevel" body line 1)
    invoked from within
"uplevel $ulevel [list ns_pg_bind $type $db $sql"
    invoked from within
"db_exec select $Tdb $full_statement_name $sql_qry"
    invoked from within
"set selection [db_exec select $Tdb $full_statement_name $sql_qry]"
    ("uplevel" body line 3)
    invoked from within
"uplevel 1 $code_block "
    invoked from within
"db_with_handle Tdb {
    # Execute the query
        set selection [db_exec select $Tdb $full_statement_name $sql_qry]
    set Tcount 0
    set Tband_count 0
    ..."
    (procedure "ad_table" line 7)
    invoked from within
"ad_table -Torderby $orderby notes_query { *SQL* } $table_def"
    invoked from within
"set table_html [ad_table -Torderby $orderby notes_query { *SQL* } $table_def]"
    ("uplevel" body line 24)
    invoked from within
"uplevel {
          ad_page_contract {
    This is the main page for the package.  It displays all of the Notes and provides links to edit them and to cr..."
    (procedure "code::tcl::/web/service0/packages/samplenote/www/index" line 2)
    invoked from within
"code::tcl::$__adp_stub"
    invoked from within
"if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init tcl $__adp_stub
..."
    ("uplevel" body line 3)
    invoked from within
"uplevel {

    if { [file exists $__adp_stub.tcl] } {

      # ensure that data source preparation procedure exists and is up-to-date
      adp_init t..."
    (procedure "adp_prepare" line 2)
    invoked from within
"adp_prepare "
    (procedure "template::adp_parse" line 30)
    invoked from within
"template::adp_parse [file root [ad_conn file]] {}"
    (procedure "adp_parse_ad_conn_file" line 7)
    invoked from within
"$handler"
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
    $handler
      } ad_script_abort val {
    # do nothing
      }"
    invoked from within
"rp_serve_concrete_file [ad_conn file]"
    (procedure "rp_serve_abstract_file" line 60)
    invoked from within
"rp_serve_abstract_file "$root/$path""
    ("uplevel" body line 2)
    invoked from within
"uplevel $code"
    invoked from within
"ad_try {
    rp_serve_abstract_file "$root/$path"
    set tcl_url2file([ad_conn url]) [ad_conn file]
    set tcl_url2path_info([ad_conn url]) [ad_conn path_inf..."

Would you be able to tell me what this is all about?

NM

Collapse
Posted by Jarkko Laine on
NM,

The error is due that your query doesn't return any rows (probably because the table is still empty) and the db_* proc you're using requires that at least one row is returned. It's a common error when you accidentally use db_1row instead of db_0or1row. Could you post the part of your code that bombs here?

Collapse
Posted by Nathan Mickson on
the code i've used has been taken from the online tutorial available at:

https://openacs.org/doc/openacs-4-6-3/tutorial-pages.html

i've basically cut and paste the code and followed the instructions, but keep getting unexpected errors

thanks for any help

Collapse
Posted by Robert Locke on
Actually, the error appears to be that the "samplenotes" table does not exist:

    ERROR:  Relation "samplenote" does not exist

I haven't seen the tutorial, but I imagine it should have been created either manually or when you installed the package.

Collapse
Posted by Robert Locke on
Ok, I looked at the documentation and at the very end of:

    https://openacs.org/doc/openacs-4-6-3/tutorial-database.html

You are told:

    "Once both scripts are working without errors, run the create script one last time and proceed."

Did you run the create script one last time?  Was there an error?  That should have created the "samplenote" table.

Good luck...

Oops, maybe I should start drinking coffee, too :) Or learn to read.