I have received a similar error message, as below, with various modules that use the db_query method. Here is an error I got when trying to upgrade from ubercart bet4 to rc1:

PDOException: SELECT * FROM (SELECT TAB.*, ROWNUM RWN_TO_REMOVE FROM (SELECT n.nid, n.title, p.weight_units FROM {node} n JOIN {uc_products} p ON n.vid = p.vid WHERE n.nid > :current ORDER BY n.nid) TAB) WHERE RWN_TO_REMOVE BETWEEN :oracle_rwn_start AND :oracle_rwn_end (prepared: SELECT * FROM (SELECT TAB.*, ROWNUM RWN_TO_REMOVE FROM (SELECT n.nid, n.title, p.weight_units FROM "NODE" n JOIN "UC_PRODUCTS" p ON n.vid = p.vid WHERE n.nid > :current ORDER BY n.nid) TAB) WHERE RWN_TO_REMOVE BETWEEN :oracle_rwn_start AND :oracle_rwn_end ) e: SQLSTATE[HY000]: General error: 1745 OCIStmtExecute: ORA-01745: invalid host/bind variable name (ext\pdo_oci\oci_statement.c:146) args: Array ( [:current] => 0 [oracle_rwn_start] => 1 [oracle_rwn_end] => 200 ) in uc_order_update_7004() (line 786 of C:\Data\Website\drupal7\sites\all\modules\ubercart\uc_order\uc_order.install).

I was able to get passed it by taking out the call to db_query (see actual code below), and utilizing db_select instead.

db_query_range("SELECT n.nid, n.title, p.weight_units FROM {node} AS n JOIN {uc_products} AS p ON n.vid = p.vid WHERE n.nid > :current ORDER BY n.nid", 0, $limit, array(':current' => $sandbox['current_nid']));

I have also noticed that the use of "AS" in the db_query method to name a table as, produces errors (might have something to do with the issue).

Any idea what might be going wrong?

Thanks!

Comments

cmurph’s picture

Another example of the same kind of error:

PDOException: SELECT COUNT(o.order_total) FROM {uc_orders} o WHERE o.order_status IN (:statuses_completed, :statuses_canceled, :statuses_in_checkout, :statuses_pending, :statuses_processing) AND :start <= created AND created <= :end (prepared: SELECT COUNT(o.order_total) FROM "UC_ORDERS" o WHERE o.order_status IN (:statuses_completed, :statuses_canceled, :statuses_in_checkout, :statuses_pending, :statuses_processing) AND :start <= created AND created <= :end ) e: SQLSTATE[HY000]: General error: 1745 OCIStmtExecute: ORA-01745: invalid host/bind variable name (ext\pdo_oci\oci_statement.c:146) args: Array ( [:start] => 1317873600 [:end] => 1317959999 [:statuses_completed] => completed [:statuses_canceled] => 0 [:statuses_in_checkout] => 0 [:statuses_pending] => 0 [:statuses_processing] => 0 ) in _uc_reports_get_sales() (line 322 of C:\Data\Website\drupal7\sites\all\modules\ubercart\uc_reports\uc_reports.module).

And here is the db_query method:

db_query("SELECT COUNT(o.order_total) FROM {uc_orders} o WHERE o.order_status IN (:statuses) AND :start <= created AND created <= :end", array(':statuses' => $order_statuses, ':start' => $start, ':end' => $end))->fetchField();

Once I put in an actual values for the ":start" and ":end" instead of the variable, I am able to get the SQL to run.

Thanks!

cmurph’s picture

Status: Needs work » Closed (duplicate)

Found out this was a Duplicate of this issue: http://drupal.org/node/1153174