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: <Paula_Stankus_at_doh.state.fl.us>
Date: Fri, 20 Sep 2002 12:20:07 -0800
Message-ID: <F001.004D58D2.20020920122007@fatcity.com>






RE: PL/SQL help



Go to Tom Kyte's sight and look for contexts - he explains a way to build sql statements using native dynamic sql and refcursors and contexts where the select statement and predicate is variable and the output might also be variable.  I get there by searching www.yahoo.com for asktom

-----Original Message-----
From: Ron Thomas [mailto:rthomas@hypercom.com]
Sent: Friday, September 20, 2002 2:06 PM
To: Multiple recipients of list ORACLE-L
Subject: RE: PL/SQL help



David-

I've thought of both dbms_sql and dummy conditions too.  Oracle Application reports use the dummy
conditions all the time.

I'm off to see if you can set cursor_sharing at the session level and not use bind params.

I'm assuming no one else has figured this out either due to the lack of response.

Ron Thomas
Hypercom, Inc
rthomas@hypercom.com
Each new user of a new system uncovers a new class of bugs. -- Kernighan


                                                                                                                 
                      root@fatcity.com                                                                           
                                               To:       ORACLE-L@fatcity.com                                    
                      09/20/02 01:28 AM        cc:                                                               
                      Please respond to        Subject:  RE: PL/SQL help                                         
                      ORACLE-L                                                                                   
                                                                                                                 
                                                                                                                 




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@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@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@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@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@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@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@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).




--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Ron Thomas
  INET: rthomas@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@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).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: Paula_Stankus_at_doh.state.fl.us

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 - 15:20:07 CDT

Original text of this message

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