Home » SQL & PL/SQL » SQL & PL/SQL » Dynamic Using Clause (merged 3)
Dynamic Using Clause (merged 3) [message #388390] Tue, 24 February 2009 09:47 Go to next message
bpeasey
Messages: 46
Registered: March 2005
Member
Hi,

We have dynamic SQL using the USING clause. A recent change requires us to now make the USING clause dynamic eg. different list of bind variables depending on how the WHERE clause is constructed.

Treating the USING clause as a string and concatenating it to the rest of the SQL statement is not working.

This is a snippet of the original code:

   WHERE ' || v_WhereClause
   USING p_customer_id,p_order_id;


I tried this:
   v_USING := ' p_parameter_one,p_parameter_two';
   WHERE ' || v_WhereClause || v_USING;

   ORA-00933: SQL Command not properly ended


Any ideas? Thx

BP
Re: Dynamic Using Clause [message #388392 is a reply to message #388390] Tue, 24 February 2009 10:07 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Do not cross/multi-post
Re: Dynamic Using Clause (merged 3) [message #388397 is a reply to message #388390] Tue, 24 February 2009 10:22 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Post a REAL thing and not a piece of nothing.
Of course, "_USING := ' p_parameter_one,p_parameter_two';
WHERE ' || v_WhereClause || v_USING;" is not a SQL command.

Regards
Michel

[Updated on: Tue, 24 February 2009 10:23]

Report message to a moderator

Re: Dynamic Using Clause (merged 3) [message #388491 is a reply to message #388390] Wed, 25 February 2009 00:45 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
If the number of bind-variable start to vary, it is time to stop using USING.
See this thread for an alternative.
Previous Topic: Update and select - need help
Next Topic: Sql query for multiple parameters
Goto Forum:
  


Current Time: Fri Feb 07 21:44:22 CST 2025