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: using bind variables for procedures/packages

RE: using bind variables for procedures/packages

From: Cary Millsap <cary.millsap_at_hotsos.com>
Date: Wed, 20 Aug 2003 18:49:24 -0800
Message-ID: <F001.005CBD67.20030820184924@fatcity.com>


Consult the Descartes/Bunce "Programming the Perl DBI" book. See the section about how to use '?' as a placeholder in your SQL text. You'll end up with code that looks a little bit like this:

my $sql = "begin run_proc(?, ?); end;";
my $sth = $dbh->prepare($sql, {ora_check_sql => 0}); ...
# then, inside the loop that runs this thing lots of times... while (my ($foo, $blah) = whatever()) {

        $sth->execute($foo, $blah);
}

This code will result in a single parse call, and however many execute calls with different bind values you deem appropriate. (By the way, without the ora_check_sql setting, the prepare() method would cause Oracle to perform two parse calls instead of just one.)

Cary Millsap
Hotsos Enterprises, Ltd.
http://www.hotsos.com

Upcoming events:
- Hotsos Clinic 101 in Sydney

-----Original Message-----
Benny Pei
Sent: Wednesday, August 20, 2003 8:14 PM To: Multiple recipients of list ORACLE-L

Hi,

I know how to do it for regulard query statement but I wasn't sure how to do it with procedures and packages.

I have this procedure. e.g.

I have this procedure
'begin
  run_proc ('foo','blah');
end;
'

the procedure will be called either in a perl script. How would I change it so that it uses bind variables? Because it will be executed many times every hour and every day.

thanks,

benny



Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Benny Pei
  INET: bplegend_at_yahoo.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).


-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Cary Millsap
  INET: cary.millsap_at_hotsos.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 Wed Aug 20 2003 - 21:49:24 CDT

Original text of this message

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