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: need execute immediate and script help

RE: need execute immediate and script help

From: Jamadagni, Rajendra <Rajendra.Jamadagni_at_espn.com>
Date: Mon, 21 Jul 2003 16:08:16 -0400
Message-Id: <25977.338737@fatcity.com>


This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible.

------=_NextPartTM-000-71d2afd5-74aa-4e93-a9e8-71ee7bca8140
Content-Type: multipart/alternative;

        boundary="----_=_NextPart_001_01C34FC3.D260B5DA"

------_=_NextPart_001_01C34FC3.D260B5DA

Content-Type: text/plain;

        charset="iso-8859-1"

you want 'select count(*)' ... right?

Raj




Rajendra dot Jamadagni at nospamespn dot com All Views expressed in this email are strictly personal. QOTD: Any clod can have facts, having an opinion is an art !

-----Original Message-----

From: rgaffuri_at_cox.net [mailto:rgaffuri_at_cox.net] Sent: Monday, July 21, 2003 5:00 PM
To: Multiple recipients of list ORACLE-L Subject: need execute immediate and script help

Im calling a script that uses dynamic sql. Im passing in a value as well. I keep getting

SP2-0552: Bind variable "2" not declared.

Here is a code snipped

declare
  v_var1 Varchar2(30) := 'TEST';
  v_var2 VARCHAR2(30) := '&1';
  total number;
begin

execute immediate ' Select * ' ||
                  ' from user_objects '||
                  ' where object_name = :1 '||
                  ' or object_name = :2 '||
                 using v_var1,v_var2

  into total;

end;
/

I call it as follows:

@script HELLO

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: <rgaffuri_at_cox.net
  INET: rgaffuri_at_cox.net

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).
------_=_NextPart_001_01C34FC3.D260B5DA
Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Diso-8859-1"> <META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version = 5.5.2654.45"> <TITLE>RE: need execute immediate and script help</TITLE> </HEAD> <BODY> <P><FONT SIZE=3D2>you want 'select count(*)' ... right?</FONT> </P> <P><FONT SIZE=3D2>Raj</FONT> <BR><FONT = SIZE=3D2>---------------------------------------------------------------=
-----------------</FONT>
<BR><FONT SIZE=3D2>Rajendra dot Jamadagni at nospamespn dot com</FONT> <BR><FONT SIZE=3D2>All Views expressed in this email are strictly = personal.</FONT> <BR><FONT SIZE=3D2>QOTD: Any clod can have facts, having an opinion is = an art !</FONT> </P> <BR> <P><FONT SIZE=3D2>-----Original Message-----</FONT> <BR><FONT SIZE=3D2>From: rgaffuri_at_cox.net [<A = HREF=3D"mailto:rgaffuri_at_cox.net">mailto:rgaffuri_at_cox.net</A>]</FONT> <BR><FONT SIZE=3D2>Sent: Monday, July 21, 2003 5:00 PM</FONT> <BR><FONT SIZE=3D2>To: Multiple recipients of list ORACLE-L</FONT> <BR><FONT SIZE=3D2>Subject: need execute immediate and script = help</FONT> </P> <BR> <P><FONT SIZE=3D2>Im calling a script that uses dynamic sql. Im passing = in a value as well. I keep getting </FONT> </P> <P><FONT SIZE=3D2>SP2-0552: Bind variable &quot;2&quot; not = declared.</FONT> </P> <P><FONT SIZE=3D2>Here is a code snipped</FONT> </P> <P><FONT SIZE=3D2>declare</FONT> <BR><FONT SIZE=3D2>&nbsp; v_var1 Varchar2(30) :=3D 'TEST';</FONT> <BR><FONT SIZE=3D2>&nbsp; v_var2 VARCHAR2(30) :=3D '&amp;1';</FONT> <BR><FONT SIZE=3D2>&nbsp; total number;</FONT> <BR><FONT SIZE=3D2>begin</FONT> </P> <P><FONT SIZE=3D2>execute immediate ' Select * ' ||</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' from user_objects '||</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' where object_name =3D :1 = '||</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' or object_name =3D :2 = '||</FONT> <BR><FONT = SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb= sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using v_var1,v_var2</FONT> <BR><FONT SIZE=3D2>&nbsp; into total;</FONT> </P> <P><FONT SIZE=3D2>end;</FONT> <BR><FONT SIZE=3D2>/</FONT> </P> <P><FONT SIZE=3D2>I call it as follows:</FONT> </P> <P><FONT SIZE=3D2>@script HELLO</FONT> </P> <P><FONT SIZE=3D2>-- </FONT> <BR><FONT SIZE=3D2>Please see the official ORACLE-L FAQ: <A = HREF=3D"http://www.orafaq.net" = TARGET=3D"_blank">http://www.orafaq.net</A></FONT> <BR><FONT SIZE=3D2>-- </FONT> <BR><FONT SIZE=3D2>Author: &lt;rgaffuri_at_cox.net</FONT> <BR><FONT SIZE=3D2>&nbsp; INET: rgaffuri_at_cox.net</FONT> </P> <P><FONT SIZE=3D2>Fat City Network Services&nbsp;&nbsp;&nbsp; -- = 858-538-5051 <A HREF=3D"http://www.fatcity.com" = TARGET=3D"_blank">http://www.fatcity.com</A></FONT> <BR><FONT SIZE=3D2>San Diego, = California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Mailing list = and web hosting services</FONT> <BR><FONT = SIZE=3D2>---------------------------------------------------------------=
------</FONT>
<BR><FONT SIZE=3D2>To REMOVE yourself from this mailing list, send an = E-Mail message</FONT> <BR><FONT SIZE=3D2>to: ListGuru_at_fatcity.com (note EXACT spelling of = 'ListGuru') and in</FONT> <BR><FONT SIZE=3D2>the message BODY, include a line containing: UNSUB = ORACLE-L</FONT> <BR><FONT SIZE=3D2>(or the name of mailing list you want to be removed = from).&nbsp; You may</FONT> <BR><FONT SIZE=3D2>also send the HELP command for other information = (like subscribing).</FONT> </P> </BODY> </HTML>
------_=_NextPart_001_01C34FC3.D260B5DA--

------=_NextPartTM-000-71d2afd5-74aa-4e93-a9e8-71ee7bca8140
Content-Type: text/plain; name="ESPN_Disclaimer.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ESPN_Disclaimer.txt" ********************************************************************This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*********************************************************************2
Received on Mon Jul 21 2003 - 15:08:16 CDT

Original text of this message

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