RE: DBMS_SQL.PARSE EXECUTES the cursor? (was Re: Developer question)
Date: Mon, 5 Dec 2011 12:00:04 -0500
Message-ID: <FA10AA8EEB4A52489F35BCD92013C97E0A60A8_at_NSTMC102PEX1.ubsw.net>
Yes, DBMS_SQL.PARSE has always executed DDL.
Paul Baumgartel
UBS AG
Group Finance Accounting Solutions
400 Atlantic Street
Stamford, CT 06904
203.719.4368
paul.baumgartel_at_ubs.com
www.ubs.com
-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Taylor, Chris David
Sent: Monday, December 05, 2011 11:48 AM
To: 'Dunbar, Norman (Capgemini)'; 'oracle-l_at_freelists.org'
Subject: DBMS_SQL.PARSE EXECUTES the cursor? (was Re: Developer
question)
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_at_freelists.org
>> [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Taylor, Chris
>> David
>> Sent: 05 December 2011 15:37
>> To: 'oracle-l_at_freelists.org'
>> 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.
>>
>>
>> --
>> http://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>
-- http://www.freelists.org/webpage/oracle-l -- http://www.freelists.org/webpage/oracle-l Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. -- http://www.freelists.org/webpage/oracle-lReceived on Mon Dec 05 2011 - 11:00:04 CST