.ora-code.com

Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
Dynamic SQL

Dynamic SQL

2006-04-06       - By Reidy, Ron
Reply:     1     2     3     4     5     6     7     8     9     10  

You cannot test for NULL with the '=, <>, !=', etc. operators.  The correct
syntax is "... IS NOT NULL".



Also, what is not working?





-- --Original Message-- --
From: oracle-l-bounce@(protected) [mailto:oracle-l-bounce@(protected)] On
Behalf Of ora_forum
Sent: Thursday, April 06, 2006 9:53 AM
To: oracle-l@(protected)
Subject: Dynamic SQL



Hi All:

Could you tell me what I'm doing wrong?

I need pass different schema owner in SQL, also in some tables there are
multiple records will be returned.



DECLARE
m_dated DATE;
m_count NUMBER(10);
m_details varchar2(4000);
m_moduser varchar2(250);
BEGIN
FOR r IN (SELECT owner FROM all_tables WHERE table_name=upper('Audittrail')
order by owner)
LOOP
FOR n IN (SELECT ROWID FROM r.Audittrail where action=8)
LOOP
IF ROWID<>'NULL' or ROWID<>0 THEN
EXECUTE IMMEDIATE 'SELECT Dated, Details, Moduser FROM ' || R.owner ||'
.Audittrail where rowid='||n||'.rowid' into m_dated, m_details, m_moduser;
dbms_output.put_line ( m_dated,m_details, m_moduser);
ELSE
NULL;
END IF;
END LOOP;
END LOOP;
END;
/



Thanks.

__ ____ ____ ____ ____ ____ ____

Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates
starting at 1¢/min. <http://us.rd.yahoo.com/mail_us/taglines/postman7/*http:/us
.rd.yahoo.com/evt=39666/*http:/beta.messenger.yahoo.com>


This electronic message transmission is a PRIVATE communication which contains
information which may be confidential or privileged. The information is
intended
to be for the use of the individual or entity named above. If you are not the
intended recipient, please be aware that any disclosure, copying, distribution
or use of the contents of this information is prohibited. Please notify the
sender  of the delivery error by replying to this message, or notify us by
telephone (877-633-2436, ext. 0), and then delete it from your system.


<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 10 (filtered)">

<style>
<!--
/* Font Definitions */
@(protected)
  {font-family:Tahoma;
  panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
  {margin:0in;
  margin-bottom:.0001pt;
  font-size:12.0pt;
  font-family:"Times New Roman";}
a:link, span.MsoHyperlink
  {color:blue;
  text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
  {color:blue;
  text-decoration:underline;}
p
  {margin-right:0in;
  margin-left:0in;
  font-size:12.0pt;
  font-family:"Times New Roman";}
span.EmailStyle18
  {font-family:Arial;
  color:navy;}
@(protected) Section1
  {size:8.5in 11.0in;
  margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
  {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>You cannot test for NULL with the &#8216;=,
&lt;&gt;, !=&#8217;, etc. operators.  The correct syntax is &#8220;&#8230; IS
NOT NULL&#8221;.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Also, what is not working?</span></font><
/p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-- --Original Message-- --<br>
<b><span style='font-weight:bold'>From:</span></b> oracle-l-bounce@(protected)
[mailto:oracle-l-bounce@(protected)] <b><span style='font-weight:bold'>On
Behalf Of </span></b>ora_forum<br>
<b><span style='font-weight:bold'>Sent:</span></b> Thursday, April 06, 2006
9:53 AM<br>
<b><span style='font-weight:bold'>To:</span></b> oracle-l@(protected)<br>
<b><span style='font-weight:bold'>Subject:</span></b> Dynamic SQL </span></font
></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"
><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"
><span
style='font-size:12.0pt'>Hi All:</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"
><span
style='font-size:12.0pt'>Could you tell me what I'm doing wrong?</span></font><
/p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"
><span
style='font-size:12.0pt'>I need pass different schema owner in SQL, also in
some tables there are multiple records will be returned. </span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"
><span
style='font-size:12.0pt'>&nbsp;</span></font></p>

</div>

<div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue
face="Times New Roman"><span style='font-size:10.0pt;color:blue'>DECLARE<br>
</span></font><font size=2 color=black><span style='font-size:10.0pt;
color:black'>m_dated </span></font><font size=2 color=blue><span
style='font-size:10.0pt;color:blue'>DATE</span></font><font size=2 color=black>
<span
style='font-size:10.0pt;color:black'>;<br>
m_count </span></font><font size=2 color=blue><span style='font-size:10.0pt;
color:blue'>NUMBER</span></font><font size=2 color=black><span
style='font-size:10.0pt;color:black'>(10);<br>
m_details </span></font><font size=2 color=blue><span style='font-size:10.0pt;
color:blue'>varchar2</span></font><font size=2 color=black><span
style='font-size:10.0pt;color:black'>(4000);<br>
m_moduser </span></font><font size=2 color=blue><span style='font-size:10.0pt;
color:blue'>varchar2</span></font><font size=2 color=black><span
style='font-size:10.0pt;color:black'>(250);<br>
</span></font><font size=2 color=blue><span style='font-size:10.0pt;color:blue'
>BEGIN<br>
FOR</span></font><font size=2 color=black><span style='font-size:10.0pt;
color:black'> r </span></font><font size=2 color=blue><span style='font-size:
10.0pt;color:blue'>IN</span></font><font size=2 color=black><span
style='font-size:10.0pt;color:black'> (</span></font><font size=2 color=blue>
<span
style='font-size:10.0pt;color:blue'>SELECT</span></font><font size=2
color=black><span style='font-size:10.0pt;color:black'> owner </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>FROM</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'> all_tables <
/span></font><font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>WHERE</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'> table_name=<
/span></font><font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>upper</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'>(</span></font>
<font
size=2 color=red><span style='font-size:10.0pt;color:red'>'Audittrail'</span><
/font><font
size=2 color=black><span style='font-size:10.0pt;color:black'>) </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>order</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'> </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>by</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'> owner)<br>
</span></font><font size=2 color=blue><span style='font-size:10.0pt;color:blue'
>LOOP<br>
FOR</span></font><font size=2 color=black><span style='font-size:10.0pt;
color:black'> n </span></font><font size=2 color=blue><span style='font-size:
10.0pt;color:blue'>IN</span></font><font size=2 color=black><span
style='font-size:10.0pt;color:black'> (</span></font><font size=2 color=blue>
<span
style='font-size:10.0pt;color:blue'>SELECT</span></font><font size=2
color=black><span style='font-size:10.0pt;color:black'> </span></font><font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>ROWID</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'> </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>FROM</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'> r.Audittrail <
/span></font><font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>where</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'> action=8)<br>
</span></font><font size=2 color=blue><span style='font-size:10.0pt;color:blue'
>LOOP<br>
IF</span></font><font size=2 color=black><span style='font-size:10.0pt;
color:black'> </span></font><font size=2 color=blue><span style='font-size:
10.0pt;color:blue'>ROWID</span></font><font size=2 color=black><span
style='font-size:10.0pt;color:black'>&lt;&gt;</span></font><font size=2
color=red><span style='font-size:10.0pt;color:red'>'NULL'</span></font><font
size=2 color=black><span style='font-size:10.0pt;color:black'> </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>or</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'> </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>ROWID</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'>&lt;&gt;0 </span>
</font><font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>THEN<br>
EXECUTE</span></font><font size=2 color=black><span style='font-size:10.0pt;
color:black'> </span></font><font size=2 color=blue><span style='font-size:
10.0pt;color:blue'>IMMEDIATE</span></font><font size=2 color=black><span
style='font-size:10.0pt;color:black'> </span></font><font size=2 color=red><span
style='font-size:10.0pt;color:red'>'SELECT Dated, Details, Moduser FROM '</span
></font><font
size=2 color=black><span style='font-size:10.0pt;color:black'> || R.owner ||<
/span></font><font
size=2 color=red><span style='font-size:10.0pt;color:red'>'.Audittrail where
rowid='</span></font><font size=2 color=black><span style='font-size:10.0pt;
color:black'>||n||</span></font><font size=2 color=red><span style='font-size:
10.0pt;color:red'>'.rowid'</span></font><font size=2 color=black><span
style='font-size:10.0pt;color:black'> </span></font><font size=2 color=blue>
<span
style='font-size:10.0pt;color:blue'>into</span></font><font size=2 color=black>
<span
style='font-size:10.0pt;color:black'> m_dated, m_details, m_moduser; <br>
dbms_output.put_line ( m_dated,m_details, m_moduser);<br>
</span></font><font size=2 color=blue><span style='font-size:10.0pt;color:blue'
>ELSE<br>
NULL</span></font><font size=2 color=black><span style='font-size:10.0pt;
color:black'>;<br>
</span></font><font size=2 color=blue><span style='font-size:10.0pt;color:blue'
>END</span></font><font
size=2 color=black><span style='font-size:10.0pt;color:black'> </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>IF</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'>;<br>
</span></font><font size=2 color=blue><span style='font-size:10.0pt;color:blue'
>END</span></font><font
size=2 color=black><span style='font-size:10.0pt;color:black'> </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>LOOP</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'>;<br>
</span></font><font size=2 color=blue><span style='font-size:10.0pt;color:blue'
>END</span></font><font
size=2 color=black><span style='font-size:10.0pt;color:black'> </span></font>
<font
size=2 color=blue><span style='font-size:10.0pt;color:blue'>LOOP</span></font>
<font
size=2 color=black><span style='font-size:10.0pt;color:black'>;<br>
</span></font><font size=2 color=blue><span style='font-size:10.0pt;color:blue'
>END</span></font><font
size=2 color=black><span style='font-size:10.0pt;color:black'>;<br>
/</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=blue
face="Times New Roman"><span style='font-size:10.0pt;color:blue'>&nbsp;</span><
/font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=black
face="Times New Roman"><span style='font-size:10.0pt;color:black'>Thanks.</span
></font></p>

</div>

</div>

<div class=MsoNormal align=center style='margin-left:.5in;text-align:center'>
<font
size=3 face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=1 width="100%" align=center>

</span></font></div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"
><span
style='font-size:12.0pt'>Talk is cheap. Use Yahoo! Messenger to make
PC-to-Phone calls. <a
href="http://us.rd.yahoo.com/mail_us/taglines/postman7/*http:/us.rd.yahoo.com
/evt=39666/*http:/beta.messenger.yahoo.com">Great
rates starting at 1¢/min.</a></span></font></p>

</div>

</body>

<P align=left style="MARGIN-RIGHT: 0px"><FONT face=Tahoma size=2><FONT color=
#0000ff>
<HR>
</FONT></FONT><FONT face=Tahoma size=2><FONT color=#0000ff>This electronic
message transmission is a PRIVATE communication which contains information <BR
>which may be confidential or privileged. The information is intended to be for
the use of the individual <BR>or entity named above. If you are not the
intended recipient, please be aware that any disclosure, <BR>copying,
distribution or use of the contents of this information is prohibited. Please
notify the sender <BR>of the delivery error by replying to this message, or
notify us by telephone (877-633-2436, ext. 0), <BR>and then delete it from your
system.</FONT></FONT></P></html>