FAQ
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@freelists.org
On Behalf Of Taylor, Chris
David
Sent: 05 December 2011 15:37
To: 'oracle-l@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.
>>

>>
--
>>

>>

>>



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>

Search Discussions

  • Paul Baumgartel at Dec 5, 2011 at 5:01 pm
    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@ubs.com
    www.ubs.com


    -----Original Message-----
    From: oracle-l-bounce@freelists.org
    On Behalf Of Taylor, Chris David
    Sent: Monday, December 05, 2011 11:48 AM
    To: 'Dunbar, Norman (Capgemini)'; 'oracle-l@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@freelists.org
    On Behalf Of Taylor, Chris
    David
    Sent: 05 December 2011 15:37
    To: 'oracle-l@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.
    >>

    >>
    --
    >>

    >>

    >>



    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-l
  • Adric Norris at Dec 5, 2011 at 5:56 pm
    You're correct that it's expected
    behaviour<http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_sql.htm#ARPLS68277>,
    but only because it's a DDL statement (drop table) rather than DML. DDL is
    run immediately when parsed.
    On Mon, Dec 5, 2011 at 10:48, Taylor, Chris David wrote:

    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> 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.

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouporacle-l @
categoriesoracle
postedDec 5, '11 at 4:50p
activeDec 5, '11 at 5:56p
posts3
users3
websiteoracle.com

People

Translate

site design / logo © 2022 Grokbase