Forum OpenACS Q&A: Re: Too stupid to work this out for myself!

Collapse
Posted by Richard Hamilton on
Bart, OK, here is the logfile output for the error. The requested URL taken from the address bar when the error was thrown was:
https://63.246.3.10:8446/purchase/me_product?product_id=5963
me_product.tcl is an exact copy of product.tcl with the same ownership and permissions. The product_id 5963 is valid and should return one row from the query that is throwing the error.

Excerpt from the logfile:
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: Querying '
            select 1
            where 't' = acs_permission__permission_p('5892', '2612', 'read');'
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: dbinit: sql(localhost::militariaexchange): '
            select 1
            where 't' = acs_permission__permission_p('5892', '2612', 'read')
        '
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: ns_getform using encoding iso8859-1 for charset iso-8859-1
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: Querying '
    select *
    from ec_products p, ec_custom_product_field_values v
    where p.product_id = '5963'
    and p.product_id = v.product_id(+);'
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Error: Ns_PgExec: result status: 7 message: ERROR:  parser: parse error at or near "("

[06/Mar/2003:09:36:10][8458.24580][-conn3-] Error: dbinit: error(localhost::militariaexchange,ERROR:  parser: parse error at or near "("
): '
    select *
    from ec_products p, ec_custom_product_field_values v
    where p.product_id = '5963'
    and p.product_id = v.product_id(+)'
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: RP (37.281 ms): error in rp_handler: serving GET /purchase/me_product?product_id=5963
	ad_url "/purchase/me_product" maps to file "/web/militariaexchange/packages/ecommerce/www/me_product.tcl"
errmsg is Database operation "0or1row" failed (exception NSDB, "Query was not a statement returning rows.")
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: Querying '
            select 1
            where 't' = acs_permission__permission_p('5892', '2612', 'admin');'
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: dbinit: sql(localhost::militariaexchange): '
            select 1
            where 't' = acs_permission__permission_p('5892', '2612', 'admin')
        '
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: Querying '
      select apm_parameter_values.attr_value
      from apm_parameters, apm_parameter_values
      where apm_parameter_values.package_id = '177'
      and apm_parameter_values.parameter_id = apm_parameters.parameter_id
      and apm_parameters.parameter_name = 'AutomaticErrorReportingP';'
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: dbinit: sql(localhost::militariaexchange): '
      select apm_parameter_values.attr_value
      from apm_parameters, apm_parameter_values
      where apm_parameter_values.package_id = '177'
      and apm_parameter_values.parameter_id = apm_parameters.parameter_id
      and apm_parameters.parameter_name = 'AutomaticErrorReportingP'
    '
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: Querying '
      select apm_parameter_values.attr_value
      from apm_parameters, apm_parameter_values
      where apm_parameter_values.package_id = '177'
      and apm_parameter_values.parameter_id = apm_parameters.parameter_id
      and apm_parameters.parameter_name = 'EnabledP';'
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Notice: dbinit: sql(localhost::militariaexchange): '
      select apm_parameter_values.attr_value
      from apm_parameters, apm_parameter_values
      where apm_parameter_values.package_id = '177'
      and apm_parameter_values.parameter_id = apm_parameters.parameter_id
      and apm_parameters.parameter_name = 'EnabledP'
    '
[06/Mar/2003:09:36:10][8458.24580][-conn3-] Error: GET http://63.246.3.10:8446/purchase/me_product?product_id=5963
referred by "https://63.246.3.10:8446/purchase/category-browse?category_id=1"
Database operation "0or1row" failed (exception NSDB, "Query was not a statement returning rows.")
    while executing
"ns_pg_bind 0or1row nsdb0 {
    select *
    from ec_products p, ec_custom_product_field_values v
    where p.product_id = :product_id
    and p.produc..."
    ("uplevel" body line 1)
    invoked from within
"uplevel $ulevel [list ns_pg_bind $type $db $sql"
    invoked from within
"db_exec 0or1row $db $full_statement_name $sql"
    invoked from within
"set selection [db_exec 0or1row $db $full_statement_name $sql]"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $code_block "
    invoked from within
"db_with_handle db {
	set selection [db_exec 0or1row $db $full_statement_name $sql]
    }"
    (procedure "db_0or1row" line 22)
    invoked from within
"db_0or1row get_ec_product_info "
    select *
    from ec_products p, ec_custom_product_field_values v
    where p.product_id = :product_id
    and p...."
    ("uplevel" body line 1)
    (procedure "code::tcl::/web/militariaexchange/packages/ecommerce/www/me_..." line 1)
    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..."

Thank you very much.
Richard
Collapse
Posted by Bruno Mattarollo on
 > where p.product_id = '5963'

Excuse my ignorance, but isn't product_id supposed to be an integer? Maybe the problem is there?

Collapse
Posted by Robert Locke on
Hi Bruno,

You're right that integers do not *require* quotes.  However, you can db_quote a constant value of any type, and I think that is what is done with all bind variables.

Collapse
Posted by Dirk Gomez on
Why are bind variables always quoted?!
Collapse
Posted by Jeff Davis on
because in postgres they are not bind variables, they are
really just quoted and interpolated.  There isn't really any
way (short of writing a sql parser and looking at the backend)
to know what the actual datatype is.