DBMS_SQL.PARSE EXECUTES the cursor? (was Re: Developer question)

  • From: "Taylor, Chris David" <ChrisDavid.Taylor@xxxxxxxxxxxxxxx>
  • To: "'Dunbar, Norman (Capgemini)'" <norman.dunbar.capgemini@xxxxxxxxxxxxxxxxxxxxxxxxx>, "'oracle-l@xxxxxxxxxxxxx'" <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 5 Dec 2011 10:48:19 -0600

Interesting.


It appears that dbms_sql.parse executes the actual CURSOR in 10g.



I'm guessing this is expected behavior even though DBMS_SQL has a separate 
EXECUTE procedure?



SQL> create table test1

  2  (val1 number)

  3  /



Table created.



SQL> declare

  2      cursor_name INTEGER;

  3  BEGIN

  4      cursor_name := dbms_sql.open_cursor;

  5      DBMS_SQL.PARSE(cursor_name, 'drop table test1', DBMS_SQL.NATIVE);

  6      DBMS_SQL.CLOSE_CURSOR(cursor_name);

  7  EXCEPTION

  8  WHEN OTHERS THEN

  9      DBMS_SQL.CLOSE_CURSOR(cursor_name);

10      raise;

11  END;

12  /



PL/SQL procedure successfully completed.



SQL> select * from test1

  2  /

select * from test1

             *

ERROR at line 1:

ORA-00942: table or view does not exist







Chris Taylor

Sr. Oracle DBA

Ingram Barge Company

Nashville, TN 37205



"Quality is never an accident; it is always the result of intelligent effort."

-- John Ruskin (English Writer 1819-1900)



CONFIDENTIALITY NOTICE: This e-mail and any attachments are confidential and 
may also be privileged. If you are not the named recipient, please notify the 
sender immediately and delete the contents of this message without disclosing 
the contents to anyone, using them for any purpose, or storing or copying the 
information on any medium.



Hi Chris,



take a look at DBMS_SQL.Parse() - if you want to do it in PL/SQL that is. For 
other tools such as Perl, C++, etc, then it's all down to what options the tool 
itself provides in its Oracle Interface utilities.



HTH



Cheers,

Norm.





Norman Dunbar

Contract Senior Oracle DBA

Capgemini Database Build Team

Internal : 7 28 2051

External : 0113 231 2051



>> -----Original Message-----

>> From: oracle-l-bounce@xxxxxxxxxxxxx

>> [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Taylor, Chris

>> David

>> Sent: 05 December 2011 15:37

>> To: 'oracle-l@xxxxxxxxxxxxx'

>> Subject: Developer question

>>

>> I'm forwarding this to the list because I don't know an answer off

>> the top of my head and Google isn't being much help due to the nature

>> of the search.

>> Developer wants to know if you can prepare a statement in a string

>> variable like 'execute someproc();' and check the validity of the

>> statement without executing it. (PARSE it only)

>>

>> I *thought* there was a way in Oracle to parse a statement without

>> executing it but I can't figure it out at the moment.

>>

>>

>> Chris Taylor

>> Sr. Oracle DBA

>> Ingram Barge Company

>> Nashville, TN 37205

>>

>> "Quality is never an accident; it is always the result of intelligent

>> effort."

>> -- John Ruskin (English Writer 1819-1900)

>>

>> CONFIDENTIALITY NOTICE: This e-mail and any attachments are

>> confidential and may also be privileged. If you are not the named

>> recipient, please notify the sender immediately and delete the

>> contents of this message without disclosing the contents to anyone,

>> using them for any purpose, or storing or copying the information on

>> any medium.

>>

>>

>> --

>> //www.freelists.org/webpage/oracle-l

>>

>>

>>



Information in this message may be confidential and may be legally privileged. 
If you have received this message by mistake, please notify the sender 
immediately, delete it and do not copy it to anyone else.



We have checked this email and its attachments for viruses. But you should 
still check any attachment before opening it.

We may have to make this message and any reply to it public if asked to under 
the Freedom of Information Act, Data Protection Act or for litigation.  Email 
messages and attachments sent to or from any Environment Agency address may 
also be accessed by someone other than the sender or recipient, for business 
purposes.



If we have sent you information and you wish to use it please read our terms 
and conditions which you can get by calling us on 08708 506 506.  Find out more 
about the Environment Agency at 
www.environment-agency.gov.uk<http://www.environment-agency.gov.uk>





--

//www.freelists.org/webpage/oracle-l







--
//www.freelists.org/webpage/oracle-l


Other related posts: