Validating SQL without Executing

Hi all
Is there anyway I can check the SQL in ODP.NET without executing it? I think OCI supports all those things.
rgds
Win Htut

Of course you can validate the SQL yourself if you want using DBMS_SQL.PARSE.
Something like
create or replace procedure parse_sql(in_stmt varchar2)
is
cursor_ integer;
stmt_ varchar2(2000);
begin
cursor_ := dbms_sql.open_cursor;
stmt_ := in_stmt;
dbms_sql.parse(cursor_, stmt_, dbms_sql.native);
dbms_sql.close_cursor(cursor_);
exception
when others then
if (dbms_sql.is_open(cursor_)) then
dbms_sql.close_cursor(cursor_);
end if;
raise;
end;
David

Similar Messages

  • Parsing a sql statement without executing it

    Hello everybody,
    I'd like to know a way of parsing sql statements in order to validate them, thus I'd get the error messages beforehand without executing them.
    Here we have the hard task of analyzing several sql scripts and then sending corrections to the development team and thirty party companies before applying them in our production databases. I'm willing to create a web/pl sql program that does such hard task, at least a program that identify basic errors such as missing table owner, non-existing tables, sintax errors and so on...
    Any tip will be of great help!
    Thanks in advance.

    Doing an explain plan will parse the statement prior to calculating the plan. Eg:
    SQL> explain plan for select * dual;
    explain plan for select * dual
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expectedEven easier if you use Toad or some other GUI front end where the explain plan is a click of a button (or a keyboard shortcut) away!

  • XML validation in pl/sql without installing java?

    Hi!
    Is it possible to validate xml documents in pl/sql without installing java in Oracle 10.2?

    What do you mean?
    We can manuplate [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i160550]XML Datatype in SQL, additionaly we can use some packages such as [url http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_xmlgen.htm#sthref11099]DBMS_XMLGEN, [url http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_xmlpar.htm#sthref11213]DBMS_XMLPARSER etc in PL/SQL.

  • How to validate a Query without executing it?

    How to validate a Query without executing it?
    For example if I have:
    ReadAllQuery myQuery = new ReadAllQuery(myClass);
    myQuery.setSelectionCriteria(myExpression);
    What can I do to have must validation as possible been done before executing the query?
    Validation that could be done are:
    - Expression reference fields that really exist in TopLink mapping
    - Literal provided to expression are of compatible type
    - Parameter setting set against the query are all compatible

    Your could prepare the query.
    query.prepareCall(session, record);
    This will do all query validation and generate the SQL for the query.

  • How to control the maximum time that a dynamic sql can execute

    Hi,
    I want to restrict the maximum time that a dynamic sql can execute in a plsql block.
    If the execution is not completed, the execution should be terminated and a exception should be raised.
    Please let me know, if there is any provision for the same in Oracle 10g.
    I was reading about Oracle Resource Database Resource Manager, which talks about restricting the maximum time of execution for Oracle session for a user.
    However I am not sure, if this can be used to control the execution of dynamic sql in a plsql block.
    Please provide some pointers.
    Thank you,
    Warm Regards,
    Navin Srivastava

    navsriva wrote:
    We are building a messaging framework, which is used to send time sensitive messages to boundary system.I assume this means across application/database/server boundaries? Or is the message processing fully localised in the Oracle database instance?
    Every message has a time to live. if the processing of message does not occurs within the specified time, we have to rollback this processing and mark the message in error state.This is a problematic requirement.. Time is not consistent ito data processing on any platform (except real-time ones). For example, messageFoo1 has a TTL (time to live) of 1 sec. It needs to read a number of rows from a table. The mere factor of whether those rows are cached in the database buffer cache, or still residing on disk, will play a major role in execution time. Physical I/O is significantly slower that logical I/O.
    As a result, with the rows on disk, messageFoo1 exceeds the 1s TTL and fails. messageFoo2 is an identical message. It now finds most of the rows that were read by messageFoo1 in the buffer cache, enabling it to complete its processing under 1s.
    What is the business logic behind the fact that given this approach, messageFoo1 failed, and the identical messageFoo2 succeeded? The only difference was physical versus logical I/O. How can that influence the business validation/requirement model?
    If it does, then you need to look instead at a real-time operating system and server platform. Not Windows/Linux/Unix/etc. Not Oracle/SQL-Server/DB2/etc.
    TTL is also not time based in other s/w layers and processing. Take for example the traceroute and ping commands for the Internet Protocol (IP) stack. These commands send an ICMP (Internet Control Message Protocol) packet.
    This packet is constructed with a TTL value too. When TTL is exceeded, the packet expires and the sender receives a notification packet to that regard.
    However, this TTL is not time based, but "+hop+" based. Each server's IP stack that receives an ICMP packet as it is routed through the network, subtracts 1 from the TTL and the forwards the packet (with the new TTL value). When a server's IP stack sees that TTL is zero, it does not forward the packet (with a -1 TTL), but instead responds back to the sender with an ICMP packet informing the sender that the packet's TTL has expired.
    As you can see, this is a very sensible and practical implementation of TTL. Imagine now that this is time based.. and the complexities that will be involved for the IP stack s/w to deal with it in that format.
    Making exact response/execution times part of the actual functional business requirements need to be carefully considered.. as this is very unusual and typically only found in solutions implemented in real-time systems.

  • Validating SQL expressions

    Hello,
    Am researching a way for validating SQL expressions.
    Say I have expressions substr(<tname.coumn_name>,1,2), I want to parse this expression for completeness, meaning whether the expression can be used in a case, decode or a normal select statement as a where clause.
    Is there any functionality available within oracle to achieve this or any pointer to some sample PL/SQL code to achieve this is welcome.
    TIA,
    Prakash. T

    If all we want to do is parsing, without creating a plan_table of any kind and without writing to it, we can use dbms_sql.
    SQL> var s varchar2(100)
    SQL> exec :s := 'select substr(dummy,1,1) from dual'
    PL/SQL procedure successfully completed.
    SQL> declare
      2    l_c pls_integer;
      3  begin
      4    l_c := dbms_sql.open_cursor;
      5    dbms_sql.parse(l_c, :s, dbms_sql.native);
      6  end;
      7  /
    PL/SQL procedure successfully completed.
    SQL> exec :s := 'select substrx(dummy,1,1) from dual'
    PL/SQL procedure successfully completed.
    SQL> /
    declare
    ERROR at line 1:
    ORA-00904: "SUBSTRX": invalid identifier
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 826
    ORA-06512: at "SYS.DBMS_SQL", line 39
    ORA-06512: at line 5It is after all only one additional variable declaration and an extra line of code.

  • Create Partition tables in PL/SQL using Execute Immediate

    Hi
    I have to create a partiton table in PL/SQL using Execute Immediate. I concat the necessary Create Table syntax into a variable and use Execute Immediate variable name. This gives a error ORA-00900: invalid SQL statement. However if i cut and paste the SQL statement from DBMS_OUTPUT, the table creation goes through without any problem.
    What could be the issue. Has anyone face this before please.
    I am using 10G DB

    Thanks for your reply. It is a big code. I am pasting the part required.
    v_sqlstmtout :='CREATE TABLE a_10(MYDATE DATE NOT NULL,ID NUMBER(14) NOT NULL)';
    v_sqlstmtout := v_sqlstmtout || ' PARTITION BY RANGE (MYDATE) ';
    v_sqlstmtout := v_sqlstmtout || 'SUBPARTITION BY HASH(id) ';
    v_sqlstmtout := v_sqlstmtout || 'SUBPARTITION TEMPLATE(';
    v_sqlstmtout := v_sqlstmtout || 'SUBPARTITION SP1,SUBPARTITION SP2) ';
    v_sqlstmtout := v_sqlstmtout || '(PARTITION mth_dummy VALUES LESS THAN ';
    v_sqlstmtout := v_sqlstmtout || '('||V_SQLSTMT3||')' || v_sqlstmt||')';
    EXECUTE IMMEDIATE ''''||v_sqlstmtout||'''';
    variables are substituted through data from different tables.
    The output looks like the following
    CREATE TABLE a_10(MYDATE DATE NOT NULL,ID NUMBER(14) NOT NULL)
    PARTITION BY RANGE (mydate) SUBPARTITION BY HASH(id) SUBPARTITION
    TEMPLATE(SUBPARTITION SP1,SUBPARTITION SP2) (PARTITION mth_dummy VALUES
    LESS THAN ('01-MAY-2006'), PARTITION mth_JAN2007 VALUES LESS THAN
    ('01-FEB-2007'))
    The above is the output from DBMS_OUTPUT. If i run this statement the table is created. Please help..

  • How am I to be able a user to grant access only to see a procedure / function without execute,compile,edit and drop?

    how am I to be able a user to grant access only to see a procedure / function without execute,compile,edit and drop?

    Sorry GregV but thank you, are you sure you can only be done by setting a PC? Can not by giving them certain privileges of a PC?
    PL \ SQL that we use a portable version.
    So actually like this, user A is only used by the X, user A wants to provide read-only access to user B is only used by Y (another PC) to the procedures / functions held user A. How do you?

  • Error in accessing ResultSet - Descriptor index not valid SQL Exception

    Hi
    I am trying to execute a procedure in java and try to access the result set, but it is giving out Descriptor index not valid SQL Exception.
    While printing the first record the error is thrown the code is as follows. Any help would be appreciated. Thanks in Advance.
    1 . The Procedure
    CREATE PROCEDURE library.fetchssncursor()
    RESULT SETS 1
    LANGUAGE SQL
    BEGIN
    DECLARE c1 CURSOR WITH RETURN FOR
    SELECT * FROM VBPLTC.LTCP_DUMMY;
    open c1;
    END;2. Java Class
    public class TestFunction2
    public void getPassThruReport()
         Connection objConnection=null;
         ResultSet rs=null;
         CallableStatement callableStatement=null;
         try
              List returnList=new ArrayList();
              DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
              objConnection = DriverManager.getConnection("URL","USERID","PWD");
              callableStatement  = objConnection.prepareCall("{call fetchssncursor() }");
               System.out.println("Got Connection "+ objConnection.toString()); 
                 callableStatement.execute();
                 rs = callableStatement.getResultSet();
                 // callableStatement.executeQuery (); i also tried this
                if(rs!=null)
                  while(rs.next())
                       System.out.println(rs.getString(1)+","+rs.getString(2)+","+rs.getInt(3)+","+rs.getInt(4));
         catch(SQLException e)
              System.out.println("SQLException "+e);
         catch(Exception e)
              System.out.println("Exception "+e);
         finally
              try
                   if(rs!=null)     
                   rs.close();
                   if(objConnection!=null)
                   objConnection.close();
               catch (SQLException e) {
    public static void main(String args[])
           TestFunction2 obj = new TestFunction2();
           obj.getPassThruReport();
    }3. Output
    Got Connection S101C3DE
    shar,Sharath,123456,1 <------------- records
    SQLException java.sql.SQLException: Descriptor index not valid.(1574
    ****************************************

    http://www-03.ibm.com/servers/eserver/iseries/toolbox/troubleshooting.htm

  • CPU Cost of a Query without executing it?

    Is there any mathematical formula to find CPU cost of a query without executing it? Thanks

    902181 wrote:
    Is there any mathematical formula to find CPU cost of a query without executing it? ThanksAny why do you want the cost? What do you expect it to tell you? How are you planning to apply this in your code? Make sure you understand what cost tells you and what it does not tell you. And use that value in a sane fashion.
    As for an alternative to using EXPLAIN PLAN, you can simply parse a SQL into a cursor without executing it. Then determine the SQL cursor id and address and use DBMS_XPLAN to display its execution plan.
    E.g.
    SQL> create or replace procedure ParseSQL( sqlStatement varchar2 ) is
      2          c       integer;
      3  begin
      4          c := DBMS_SQL.open_cursor;
      5 
      6          DBMS_SQL.parse(
      7                  c,
      8                  sqlStatement,
      9                  DBMS_SQL.native
    10          );
    11 
    12          DBMS_SQL.close_cursor( c );
    13  end;
    14  /
    Procedure created.
    SQL>
    SQL> var sqlID varchar2(100)
    SQL> var childNumber number
    SQL> var sqlText varchar2(4000)
    SQL> begin
      2          ParseSQL( 'select /* TEST1 */  * from emp' );
      3 
      4          select
      5                  sql_text, sql_id, child_number into :sqlText, :sqlID, :childNumber
      6          from    v$sql
      7          where   sql_text like 'select /* TEST1 */%';
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> col PLAN_TABLE_OUTPUT format a50
    SQL> select
      2          rownum, p.plan_table_output
      3  from       TABLE( DBMS_XPLAN.Display_Cursor( :sqlID, :childNumber, 'BASIC,COST' ) ) p;
        ROWNUM PLAN_TABLE_OUTPUT
             1 EXPLAINED SQL STATEMENT:
             2 ------------------------
             3 select /* TEST1 */  * from emp
             4
             5 Plan hash value: 3956160932
             6
             7 -----------------------------------------------
             8 | Id  | Operation         | Name | Cost (%CPU)|
             9 -----------------------------------------------
            10 |   0 | SELECT STATEMENT  |      |     3 (100)|
            11 |   1 |  TABLE ACCESS FULL| EMP  |     3   (0)|
            12 -----------------------------------------------
            13
    13 rows selected.
    SQL> The problem is extracting intelligence from the output as it is raw text. Perhaps not that complex as a where clause can be added to only display line id 0 and then extract the cost value from that line. Regular expressions (not my forte) will likely do this easily.

  • How to delete confirmed schedule lines, without executing the ATP check?

    Sales and Distribution: Concerning ATP (product allocation)
    Situation:
    Step 1: An order is created with priority low. Quantities are confirmed for line items.
    Step 2: A second order is created with a higher priority. No confirmed quantities.
    Rescheduling program (SDV03V02) is then executed. This selects and sorts the orders in the correct order.
    The confirmed quantities for the first (low priority) order should now be freed up, to be able to allocate those quantities to the second (high priority) order.
    The problem I am facing is that the confirmed quantities are NOT released.
    We cannot use BAPI_SALESORDER_CHANGE or SD_SALESDOCUMENT_CHANGE to delete or modify the schedule lines, because these function modules execute the ATP check again. And when that happens, quantities are again confirmed and assigned.
    How can we get rid of the confirmed schedule lines, without executing the ATP check?
    Thanks,
    Edwin.

    Found a solution to the problem:
    In the Rescheduling program we export a parameter to the memory, to make it possible to delete schedule lines without executing the ATP check.
    Deleting of the schedule lines is done with a BAPI, which will call the ATP check automatically for ATP relevant materials. This we want to stop from happening (only when calling the BAPI).
    After the BAPI has been called we FREE the MEMORY ID.
    The parameter is imported again in Customer-Exit EXIT_SAPLATPC_001.
    Transaction.. SMOD
    Enhancement.. ATP00001
    Component.... EXIT_SAPLATPC_001,
    Include...... ZXATPU01.
    The customer exit is used in function AVAILABILITY_CHECK_CONTROLLER, just before calling function 'AVAILABILITY_CHECK'.
    Simply refreshing the ATP tables in the customer-exit, will prevent the ATP check from being executed (because we removed the list containing the materials for which the ATP check needs to be done). As a result, the function 'AVAILABILITY_CHECK' will not be processed.

  • Testing RFC without Executing RFC in SAP R/3

    Hi All,
    Is it possible to test a sender RFC adapter to invoke Web service in SAP XI without executing RFC in R/3. I am facing problems when executing RFC in R/3. So would like to confirm that the other portion ie, from XI to Webservice is working fine. Any help would be much appreciated.
    Thx
    Deno

    Hi Deno,
    Just go in a stepwise manner and you will know here the error is.
    1. First execute RFC and see if it reaches SAP XI.
    2. Check in Transaction SXMB_MONI as to which step is going into error.
    3. If it's not reaching XI ythen there is problem with RFC destination or the RFC adapter config check that.
    Regards
    Vijaya

  • Creating an SCD Type 2 in T SQL without using MERGE

    I am attempting to create an SCD type 2 using T-SQL without MERGE (I'm not allowed to use it as a condition of the development work I am doing). I can use a CTE, but I have not tried that yet.
    I have a temp table that contains ten records that I am testing with. The following is one variant of the code I have used to try and make this work:
    declare 
    @System_User nchar(50)
    ,@CurrentDate datetime 
    ,@MaxCheckDate datetime
    set @System_User = system_user
    set @CurrentDate = getdate()
    --INSERT
    insert dim.slot
    Source_Slot_ID
    ,Slot_Start_DateTime  
    ,Patients_PerSlot
    ,IsSlotSearchable
    ,IsSlotVisible
    ,[Created_Date]
    ,[Created_By]
    select
    src.IdSlot
    ,src.SlotDateTime
    ,src.PatientsPerSlot
    ,src.IsSlotSearchable
    ,src.IsSlotVisible
    ,@CurrentDate
    ,@System_User
    from #TmepSlot src
    left join dim.Slot dest
    on src.IdSlot = dest.Source_Slot_ID
    left join (select source_slot_id, max(created_date) as created_date from dim.slot group by Source_Slot_ID) MaxRecord
    on dest.Source_Slot_ID = MaxRecord.Source_Slot_ID
    and dest.Created_Date = MaxRecord.created_date
    where dest.Source_Slot_ID is null
    or
    src.PatientsPerSlot
    <> dest.Patients_PerSlot
    or
    src.IsSlotSearchable <> dest.IsSlotSearchable
    or
    src.IsSlotVisible
    <> dest.IsSlotVisible
    The problem with this variation is that when I change a value in the source like src.Patients_PerSlot, and then run the query, I get the new record i expect, but when I run the query again, a duplicate record gets created. 
    How do I correctly isolate the correct latest record and add the changed record without inserting that changed record more than once?
    Thank you for your help.
    cdun2

    Hi,
    shouldn't you use an inner join between dest and maxrecord like so:
    from #TmepSlot src
    left join (dim.Slot dest
    inner join (select source_slot_id, max(created_date) as created_date from dim.slot group by Source_Slot_ID) MaxRecord
    on dest.Source_Slot_ID = MaxRecord.Source_Slot_ID
    and dest.Created_Date = MaxRecord.created_date)
    on src.IdSlot = dest.Source_Slot_ID
    where dest.Source_Slot_ID is null
    regards,
    Rudolf
    Rudolf Swiers
    Thanks! I don't remember when I've done a join that way, but it makes sense.
    cdun2

  • How to end a work item exlicitly without executing it?

    i want to find out how to end a workitem explicitly without executing it from the business workplace. we have created a dummy workitem and would like to end it when it is not needed.
    i have set up the terminating event in the workitem task but even though the event is raised the workitem is not ended and the workitem is still in the inbox. i was expecting that when the event is raised the event will end the workitem and it will move into the outbox.
    am i doing something worng? why isnt the workitem getting ended and move to outbox when the terminating event is raised?

    Hi Arghadip,
    thanks for your inputs. That was really useful but in my case i dont have the workitem ID. Actually here is my process, the system creates a workflow when a invoice is created and it is blocked for payment. When the invoice triggers a workflow it does two things in a FORK. One it sends an email and the second it sends a workitem. The workitem is a dummy workitem. When the user reply's to the email a RFC FM is called from the external system which will release the invoice in SAP. Now once this is done we would like to close the workitem which is lying in the business workplace. So i have implemented the terminating event however i guess that doesnt work. When the RFC FM is called externally it releases the Invoice using a BAPI and once it is done i am calling the FM SWE_EVENT_CREATE to raise the event to terminate the event.
    Am i doing something wrong?

  • SQL Query Executing longer time

    Hi , The below SQL query executing longer time . Please help to Improve the query performance. The query continuously running for more than 24 hours and failing with roolback segment error. Not getting the final output. Most of the tables are having milions of records.
    Select distinct
    IBS.ADSL_ACCESS_INFO,
    IBS.LIJ ,
    regexp_substr(OBVS.REFERENTIE_A,'[[:digit:]]+') as O_NUMBER,
    DBS.CKR_NUMMER_CONTRACTANT,
    DBS.DNUMBER
    FROM CD.IBS,
    CD.OIBL,
    CD.IH,
    CD.ODL,
    CD.OH,
    CD.DBS,
    CD.OBVS
    Where IBS.END_DT = To_Date('31129999', 'ddmmyyyy')
    AND OIBL.END_DT = to_date('31129999', 'ddmmyyyy')
    AND DBS.END_DT = to_date('31129999', 'ddmmyyyy')
    AND OBVS.END_DT = to_date('31129999', 'ddmmyyyy')
    AND OBVS.REFERENTIE_A LIKE 'OFM%'
    AND OIBL.INFRA_KEY = IH.INFRA_KEY
    AND OIBL.ORDERS_KEY = OH.ORDERS_KEY
    AND IBS.INFH_ID = IH.INFH_ID
    AND ODL.ORDH_ID = OH.ORDH_ID
    AND DBS.DEBH_ID = ODL.DEBH_ID
    AND OBVS.ORDH_ID = ODL.ORDH_ID
    Order By IBS.LIJ
    All the columns which are present in the where condition are having either Index/key (Primary/unique) except END_DT column.
    Please Advise

    Predicate pushing can help when it greatlly restricts the number of rows - you must experiment - might not work with all predicates pushed (as shown here)
    select distinct
           ibs.adsl_access_info,
           ibs.lij,
           obvs.o_number,
           dbs.ckr_nummer_contractant,
           dbs.dnumber
      from (select infh_id,adsl_access_info,lij
              from cd.ibs
             where end_dt = to_date('31129999','ddmmyyyy')
           ) ibs,
           (select infra_key,orders_key
              from cd.oibl
             where end_dt = to_date('31129999','ddmmyyyy')
           ) oibl,
           (select ordh_id,regexp_substr(obvs.referentie_a,'[[:digit:]]+') as o_number
              from cd.obvs
             where end_dt = to_date('31129999','ddmmyyyy')
               and referentie_a like 'OFM%'
           ) obvs,
           (select debh_id,ckr_nummer_contractant,dnumber
              from cd.dbs
             where end_dt = to_date('31129999','ddmmyyyy')
           ) dbs,
           cd.ih,
           cd.odl,
           cd.oh
    where oibl.infra_key = ih.infra_key
       and oibl.orders_key = oh.orders_key
       and ibs.infh_id = ih.infh_id
       and odl.ordh_id = oh.ordh_id
       and dbs.debh_id = odl.debh_id
       and obvs.ordh_id = odl.ordh_id
    order by ibs.lijRegards
    Etbin

Maybe you are looking for

  • Delivery and Goods Receipt without goods value

    Hi! this is my first post in this forum, hi everybody Now the question: My goal: warehouse manager shouldn't see goods value (prices) of purchased material and final products (sold goods). That means I would like to remove all value data (Unit Price,

  • Problem with while loops, please help!

    I am having quite a bit of trouble with a program im working on. What i am doing is reading files from a directory in a for loop, in this loop the files are being broken into words and entered into a while loop where they are counted, the problem is

  • Iphone repair in another country

    I bought my iphone5s 4 months  before I left Australia to work in China, I won't be back until June 2015. Now my phone is dead due to the malfunction screen. What would be for the warranty, can I get a replacement in China? or I have to wait for anot

  • JDBB SQL create table PreparedStatement

    Hi How can I use preparedSatement to create a variable table? PreparedStatement ps=con.prepareStatement("what is the SQL Code for a table named [?]"); ps.setString(1, tableName); ResultSet r = ps.executeQuery();

  • [svn] 3882: Target Flash player 10 for the team application.

    Revision: 3882 Author: [email protected] Date: 2008-10-24 13:16:42 -0700 (Fri, 24 Oct 2008) Log Message: Target Flash player 10 for the team application. QA: No Doc:No Check-in tests: pass Modified Paths: blazeds/trunk/apps/team/WEB-INF/flex/flex-con