Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: PL/SQL help

RE: PL/SQL help

From: Lord, David - CSG <David.Lord_at_hayscsg.com>
Date: Fri, 20 Sep 2002 00:28:18 -0800
Message-ID: <F001.004D498E.20020920002818@fatcity.com>


Ron

We've run into this problem and haven't really found a satisfactory answer. It sounds like a job for dbms_sql, but the docs say its slower than native dynamic sql. Has anyone tested this? One other alternative I can think of (but have never tried) is to use dummy conditions in the sql; something like: -

c_sql := 'select col1 from atable where col2 = :1 and :2 is null and :3 is null';

--
David Lord


> -----Original Message-----
> From: Ron Thomas [mailto:rthomas_at_hypercom.com]
> Sent: 19 September 2002 19:53
> To: Multiple recipients of list ORACLE-L
> Subject: PL/SQL help
>
>
>
> I am building a dynamic sql statement which will contain
> varying number of bind variables depending
> on user selection criteria. As an example, the sql statement may be:
>
> c_sql := 'select col1 from atable where col2 = :1' ;
>
> or it may be
>
> c_sql := 'select col1 from atable where col2 = :1 and col2
> between :2 and :3' ;
>
> or it may be ... etc. I am trying to avoid ugly code such as:
>
> IF case1 THEN
> OPEN csr FOR c_sql USING var1 ;
> ELSIF case2 THEN
> OPEN csr FOR c_sql USING var1, var2, var3 ;
> ELSIF .....
> END IF ;
>
> Once the sql statement is created, it will be opened/closed
> multiple times, so I want to use bind
> variables to avoid parsing.
>
> So I thought, hum, sounds like a job for EXECUTE IMMEDIATE,
> but in the various incarnations I tried,
> could not get it to work. The FM have not been much help
> (still looking tho).
>
> What am I missing?
>
> Thanks,
> Ron Thomas
> Hypercom, Inc
> rthomas_at_hypercom.com
> Each new user of a new system uncovers a new class of bugs.
> -- Kernighan
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Ron Thomas
> INET: rthomas_at_hypercom.com
>
> Fat City Network Services -- 858-538-5051 http://www.fatcity.com
> San Diego, California -- Mailing list and web hosting services
> ---------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
>
********************************************************************** This message (including any attachments) is confidential and may be legally privileged. If you are not the intended recipient, you should not disclose, copy or use any part of it - please delete all copies immediately and notify the Hays Group Email Helpdesk at email.helpdesk_at_hays.plc.uk Any information, statements or opinions contained in this message (including any attachments) are given by the author. They are not given on behalf of Hays unless subsequently confirmed by an individual other than the author who is duly authorised to represent Hays. A member of the Hays plc group of companies. Hays plc is registered in England and Wales number 2150950. Registered Office Hays House Millmead Guildford Surrey GU2 4HJ. ********************************************************************** -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Lord, David - CSG INET: David.Lord_at_hayscsg.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Received on Fri Sep 20 2002 - 03:28:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US