Usage of Xopen SQL states and SQL Exception?

Hi
Is there way to make full use of SQL Exceptions?
Has anybody used sql states from sql exception?
It is specified in the API reference that an sql exception object contains an xopen sql state which is a string. But the states in specs are defined as class, subclass.
The question is how can i make use of these java strings to interpret what exactly happened at the database? Are they really useful? If they are, any utilities which converts these strings to a meaningful message? Any pointers on these question would also help me.
Thanx in adv.
Giridhar

SQLException has inherited a method getMessage() which seems to be quite useful.
For situations where you want to check on a specific one of several possible (or expected) states (like: maybe the table is not yet created ...), I think you can quite fine use getSQLState() and also getErorCode(). Try out in tests, which information is returned by which constellation, then you can use it for making decisions in your program logic.
But be aware, that all these informations probably are DBMS specific!

Similar Messages

  • Capture all SQL statements and archive to file in real time

    Want to Capture all SQL statements and archive to file in real time?
    Oracle Session Manager is the tool just you need.
    Get it at http://www.wangz.net
    This tools monitor how connected sessions use database instance resources in real time. You can obtain an overview of session activity sorted by a statistic of your choosing. For any given session, you can then drill down for more detail. You can further customize the information you display by specifying manual or automatic data refresh, the rate of automatic refresh.
    In addition to these useful monitoring capabilities, OSM allows you to send LAN pop-up message to users of Oracle sessions.
    Features:
    --Capture all SQL statement text and archive to files in real time
    --Pinpoints problematic database sessions and displays detailed performance and resource consumption data.
    --Dynamically list sessions holding locks and other sessions who are waiting for.
    --Support to kill several selected sessions
    --Send LAN pop-up message to users of Oracle sessions
    --Gives hit/miss ratio for library cache,dictionary cache and buffer cache periodically,helps to tune memory
    --Export necessary data into file
    --Modify the dynamic system parameters on the fly
    --Syntax highlight for SQL statements
    --An overview of your current connected instance informaiton,such as Version, SGA,License,etc
    --Find out object according to File Id and Block Id
    Gudu Software
    http://www.wangz.net

    AnkitV wrote:
    Hi All
    I have 3 statements and I am writing some thing to a file using UTL_FILE.PUT_LINE after each statement is over. Each statement takes mentioned time to complete.
    I am opening file in append mode.
    statement1 (takes 2 mins)
    UTL_FILE.PUT_LINE
    statement2 (takes 5 mins)
    UTL_FILE.PUT_LINE
    statement3 (takes 10 mins)
    UTL_FILE.PUT_LINE
    I noticed that I am able to see contents written by UTL_FILE.PUT_LINE only after statement3 is over, not IMMEDIATELY after statement1 and statement2 are done ?
    Can anybody tell me if this is correct behavior or am I missing something here ?Calling procedure must terminate before data is actually written to the file.
    It is expected & correct behavior.

  • Copying and pasting sql statement in sql*plus

    how do you paste sql statement in sql*plus...I have tried the following options, getting the windows interface for this following the documentation below but that didnt work
    http://download.oracle.com/docs/html/A88829_01/ch3.htm
    then i tried creating a simple .txt file with my sql statement and tried running it using @name(where name is the name of the file) and it is giving me the following error SP2-0310: unable to open file "firstscriot.sql

    Hi,
    Using the command-line interface, copying is a pain. Right click on the title bar at the top of the window, then click on "Edit" and "Mark". After you highlight the text you want to copy, you can press the Enter key to copy it.
    To paste, simply right-click. It doesn't matter how the copy buffer got filled (the cumbersome process I described above, using Control-C in Notepad, or whatever).

  • SQL%FOUND and SQL%NOTFOUND

    Hi,
    My friend asked me this question.
    Why we hav these two attributes?SQL%FOUND and SQL%NOTFOUND
    One will always be the opposite of the other.So one will suffice our need, no?
    Thanks..

    declare
         print varchar2(32);
    begin
         delete
         from scott.emp
         where empno = 1000;
         if ( SQL%FOUND ) then
              print := 'found';
         else
              print := 'not_found';
         end if;
         if ( SQL%NOTFOUND ) then
              print := print||' and not_found';
         else
              print := print||' and found';
         end if;
         dbms_output.put_line(print);
         delete
         from scott.emp;
         if ( SQL%FOUND ) then
              print := 'found';
         else
              print := 'not_found';
         end if;
         if ( SQL%NOTFOUND ) then
              print := print||' and not_found';
         else
              print := print||' and found';
         end if;
         dbms_output.put_line(print);
         delete
         from scott.emp;
         if ( SQL%FOUND ) then
              print := 'found';
         else
              print := 'not_found';
         end if;
         if ( SQL%NOTFOUND ) then
              print := print||' and not_found';
         else
              print := print||' and found';
         end if;
         dbms_output.put_line(print);
         rollback;
    end;
    not_found and not_found
    found and found
    not_found and not_foundIt seesm that one is allways the opposite of the ather one. There are no exception.
    Bye Alessandro

  • SQL Report not showing data - available in SQL Workshop and SQL Developer

    I am having an issue with developing a SQL Report in APEX 3.2.1. I run the code in both SQL developer and SQL Workshop and I get data pulled back (both against my development environment). When I run the same code in a SQL Report region, it returns no data available. Does anyone have any idea what would be causing this? Other regions on the page accessing different tables in the same schema return data without issue. Any help would be appreciated.
    Thanks
    Freddie

    Could you explain the last comment a bit more. Here is a bit more info just in case I touch on the info with it. The db schema is BPAMGR, the Workspace is BPAMGR. We use the same schema for all of our reporting. All of our tables are in the same schema. We don't use any tables outside of this schema. Our APEX workspace has been associated to only this schema. The tables are able to be queried by SQL Workshop in the same APEX instance that the report application is under.
    Freddie

  • Can SQL 2000 and SQL 2005 drivers co-exist in PI?

    Hi,
    Currently in our PI environment, we have JDBC Adapter connections to SQL 2000 database servers for which the Driver has already been installed.
    For connecting to new SQL 2005 database servers, I understand that we have to install the SQL 2005 drivers. I also came to know that SQL 2005 Driver is backward compatible and supports JDBC connection to SQL 2000 server.
    But the question I have is whether both the SQL 2000 and SQL 2005 drivers can be installed together in a way that connection to SQL 2000 use the 2000 driver and the connection to 2005 uses 2005 Driver.
    (They have different connection strings)
    Many thanks in advance,
    Regards,
    Rosie Sasidharan

    The SQL Server 2005 JDBC driver is far better than the SQL Server 2000 JDBC driver.  The 2005 JDBC driver primarily consists for one file, sqljdbc.jar.  ( if you want to use windows authentication there is another file you would need based on your platform x64 vs x86 called sqljdbc_auth.dll. If in the connect string you list ;integratedSecurity=true which means integrated security would be used and this second file would be required.  The 2000 driver did not support integrated security.
    The SQL 2000 JDBC driver was made up of the 3 jar files:
    msbase.jar,mssqlserver.jar and msutil.jar.
    If you want to use a Microsoft JDBC driver to connect to SQL Server 2005, than you should use the 2005 driver, sqljdbc.jar.
    Follow the instructions in point 1 of the note #831162 - FAQ: XI 3.0 / PI 7.0 / PI 7.1 JDBC Adapter questions 1 and 13.
    Since the jar are different I assume you can use the both drivers, but it doesnt make sense.

  • After change port for TCPIP PORT for default SQL Server instance (MSSQLSERVER), sql service and sql agent service did not started again

    Hi 
    -when i install default instance MSSQLSERVER i added a domain account as a service account,
    - when i change port for TCPIP PORT , and after sql service and sql agent service did not started again.
    it thrown error 
    The SQL Server (MSSQLSERVER) service failed to start due to the following error: 
    The service did not start due to a logon failure.
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Service Control Manager" Guid="{555908d1-a6d7-4695-8e1e-26931d2012f4}" EventSourceName="Service Control Manager" />
        <EventID Qualifiers="49152">7000</EventID>
        <Version>0</Version>
        <Level>2</Level>
        <Task>0</Task>
        <Opcode>0</Opcode>
    but when i add domain\sqservice account in administrators group these services started,
    1) here  why this change behavior  happened
    2i changed the port 1500
    adil

    HI
    the sql instance service is running with domain/sqlservice account , 
    - i stopped the sql service service
    - when i start it not started again and i found below error message
    Domain and account: MOJPORTAL\spsqlservice
    This service account does not have the required user right "Log on as a service."
    User Action
    Assign "Log on as a service" to the service account on this computer. You can use Local Security Settings (Secpol.msc) to do this.
     If this computer is a node in a cluster, check that this user right is assigned to the Cluster service account on all nodes in the cluster.
    If you have already assigned this user right to the service account, and the user right appears to be removed, 
    check with your domain administrator to find out if a Group Policy object associated with this node might be removing the right.
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Service Control Manager" Guid="{555908d1-a6d7-4695-8e1e-26931d2012f4}" EventSourceName="Service Control Manager" />
        <EventID Qualifiers="49152">7041</EventID>
        <Version>0</Version>
        <Level>2</Level>
        <Task>0</Task>
        <Opcode>0</Opcode>
        <Keywords>0x8080000000000000</Keywords>
        <TimeCreated SystemTime="2015-04-24T17:12:58.326973300Z" />
        <EventRecordID>2177</EventRecordID>
        <Correlation />
        <Execution ProcessID="520" ThreadID="4044" />
        <Channel>System</Channel>
        <Computer>PORTALSQL1.mojportal.com</Computer>
        <Security />
      </System>
      <EventData>
        <Data Name="param1">MSSQL$xSQL</Data>
        <Data Name="param2">xxxL\spsqlservice</Data>
      </EventData>
    </Event>
    adil

  • Modify SQL#4 and SQL#5 DDL Model Defaults

    Hi,
    on FSCM 9.1 , tools 52.0 on Win 2008 server;
    to force statistics gathering in AE we should  do :
    6. Modify SQL#4 and SQL#5 DDL Model Defaults for Oracle Platform to enable option force when updating
    Recommended in :
    RED_PAPER_-_PeopleSoft_Enterprise_Performance_on_Oracle_11g_Database.pdf
    Can you be kind and  tell us how to find them (SQL#4) ?
    Thank you.

    The DDL models are under
    PeopleTools > Utilities > Administration > DDL Model Defaults
    Select the Oracle platform from the search, and you should get a scroll with 5 rows. Rows 4 and 5 should begin with  DBMS_STATS.GATHER_TABLE_STATS
    You can also consider downloading the following tool from Oracle Support:
    pscbo_stats - Improving Statistics in Oracle RDBMS for PeopleSoft Enterprise [ID 1322888.1]
    See PeopleSoft Database Update Statistics for more information.
    Regards,
    Bob

  • Using SQL Statements in Error Exceptions

    Is there any way to include SQL statements within my catch routines (i.e.
    catch (java.io.IOException ex) {
    System.out.println("An error occurred whilst writing to the message buffer: " + ex);
    #sql { INSERT INTO DEBUG_TBL(CURRENT_DT,PROGRAM_ID,DEBUG__MESG) VALUES (SYSDATE,'TEST',:ex) };
    #sql { COMMIT };
    As it stands I get the following error upon compile:
    Error: Unsupported Java type for host item (at position#1): java.io.IOException
    Any help would be greatly appreciated.
    Thx,
    Boybles
    null

    You can use SQL statements in your catch blocks, just not SQL statements that use Java types which do not map to SQL.
    You cannot pass exceptions from Java to SQL. You can catch a SQL exceptions as a SQLException in Java. However, any exception that is thrown by a Java Stored Procedure (including SQLException) is rendered as an "Uncaught Java exception" in SQL.
    When you receive a SQLException there is information about the originator, the error message, etc. in the exception object. See:
    http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/a83723/keyprog5.htm#1004462
    While you cannot insert a Java exception per se into a table, you can extract the message string(s)/code and insert that in a table.

  • Performance between SQL Statement and Dynamic SQL

    Select emp_id
    into id_val
    from emp
    where emp_id = 100
    EXECUTE IMMEDIATE
    'Select '|| t_emp_id ||
    'from emp '
    'where emp_id = 100'
    into id_valWill there be more impact in performance while using Dynamic SQL?

    CP wrote:
    Will there be more impact in performance while using Dynamic SQL?All SQLs are parsed and executed as SQL cursors.
    The 2 SQLs (dynamic and static) results in the exact same SQL cursor. So both methods will use an identical cursor. There are therefore no performance differences ito of how fast that SQL cursor will be.
    If an identical SQL cursor is not found (a soft parse), the SQL engine needs to compile the SQL source code supplied, into a SQL cursor (a hard parse).
    Hard parsing burns a lot of CPU cycles. Soft parsing burns less CPU cycles and is therefore better. However, no parsing at all is the best.
    To explain: if the code creates a cursor (e.g. INSERT INTO tab VALUES( :1, :2, :3 ) for inserting data), it can do it as follows:
    while More Data Found loop
      parse INSERT cursor
      bind variables to INSERT cursor
      execute INSERT cursor
      close INSERT cursor
    end loopIf that INSERT cursor does not yet exists, it will be hard parsed and a cursor created. Each subsequent loop iteration will result in a soft parse.
    However, the code will be far more optimal as follows:
    parse INSERT cursor
    while More Data Found loop
      bind variables to INSERT cursor
      execute INSERT cursor
    end loop
    close INSERT cursorWith this approach the cursor is parsed (hard or soft), once only. The cursor handle is then used again and again. And when the application is done inserting data, the cursor handle is released.
    With dynamic SQL in PL/SQL, you cannot really follow the optimal approach - unless you use DBMS_SQL (a complex cursor interface). With static SQL, the PL/SQL's optimiser can kick in and it can optimise its access to the cursors your code create and minimise parsing all together.
    This is however not the only consideration when using dynamic SQL. Dynamic SQL makes coding a lot more complex. The SQL code can now only be checked at execution time and not at development time. There is the issue of creating shareable SQL cursors using bind variables. There is the risk of SQL injection. Etc.
    So dynamic SQL is seldom a good idea. And IMO, the vast majority of people that post problems here relating to dynamic SQL, are using dynamic SQL unnecessary. For no justified and logical reasons. Creating unstable code, insecure code and non-performing code.

  • Help with sql statements and Java

    Hi,
    How can I create a string kind of like this
    Select * From Students Where Name Like "Bob Burns";
    As the sql statement might indicate I am using MS Access. I seem to be having problems with the double quotes required by the Like operator in MS Access, Java views that as a beginning of a string as oppposed to an actual string value.

    Like this:
        Connection connection = null;
        PreparedStatement stmt = null;
        ResultSet res = null;
        try  {
            connection = ...get from connection pool...;
            String sql = "select ... from ... where name like ?";
            stmt = connection.prepareStatement(sql);
            stmt.setObject(1, "%Bob%", java.sql.Types.VARCHAR);
            res = stmt.executeQuery();
            while (res.next()) { ...the usual...; }
        } finally {
            ...close res, stmt & return connection to pool...
        }You can try stmt.setString() instead of setObject() but rumor has it that some mssql drivers have a bug that makes setString() not work with "like", but oddly enough setObject() works.

  • Xi JDBC Adapter - Query SQL Statement & Update SQL Statement

    Hi!
    I configure the JDBC adapter sender (XI) to take data from Oracle database.
    I set the Query and Update SQL Statement in the Processing parameters of the communication channel in this way:
    Query SQL Statement :
    SELECT * FROM XI_TABLE WHERE STATUS = 'WAIT' ORDER BY ROW_NUM
    Update SQL Statement :
    UPDATE XI_TABLE SET STATUS = 'DONE', DATE = SYSDATE WHERE STATUS = 'WAIT'
    My question is :
    If a new record with the field STATUS = 'WAIT' is added to the table (xi_table) during the time between the execution of the query statement and the start of the update statement, what will happen to that record during the update?
    There is a way to avoid the update of that record? or to pass to the update statement only the record selected in the query statement?
    Please, may you give me some example?
    Thanks,
    Francesco

    hi,
    did you check "Isolation Level for Transaction"
    for the sender jdbc adapter?
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
    Regards,
    michal

  • Re entering sql statements in sql plus

    Hi,
    How to enter and can edit sql statements in sqlplus without re typing sql statements which were previously executed.

    Hi,
    ravi02 wrote:
    Hi,
    How to enter and can edit sql statements in sqlplus without re typing sql statements which were previously executed.Depending on your OS and your version of SQL*Plus, you can recall past SQL*Plus commands the same way you recall past OS commands. On my Windows system, I press the up-arrow key to get old SQL*Plus commands. Then I can press ENTER to run the command verbatim, or I can type over the command (using back-arrow, backspace and delete keys, if I want) to change the command before pressing ENTER.
    That's only good for single-line commands. If you have a statement that needs more than 1 line, type it in a file using any text editor, and the use the SQL*Plus @ command to run it.
    For example, if my SQL statements are saved in file called my_script.sql, which is on the foo\bar folder of the d: drive, I can say
    @d:\foo\bar\my_scriptto run all the commands in the file.
    Depending on your OS, you can do somehting similar.

  • How to see all sql statements on sql commands under history link

    Hi All,
    How to see the all the sql history on sql commands tab.
    I want see all sql statements.
    Where to set if we need to store more sql statments in history.
    We are using Apex3.2 and 10g database(EE).
    Thanks,
    Nr

    I just checked the source code of the SQL commands history region and that report fetches a maximum of 1000 records. I don't know if you change the setting somewhere in the builder, but seeing the code it looks as though 1000 is hard-coded in the report definition(apex 4.0).
    If you need to see all the command history,you can query the original table: APEX_040000.WWV_FLOW_SW_SQL_CMDS
    Note that is an internal table used by apex and hence you might not find any documentation about it(google got me one valid hit: Identifying Inactive Workspaces which seem to confirm the table's use).
    Anyway, here's what you need to do, ask your dba to grant your workspace user select access on this table
    Connect as dba user and run
    GRANT SELECT ON APEX_040000.wwv_flow_sw_sql_cmds to '<WORKSPACE SCHEMA>'Now you can run the following command from your workspace to see the entire command history using
    select * from APEX_040000.WWV_FLOW_SW_SQL_CMDS where parsed_schema = '<WORKSPACE SCHEMA>';You might want to revoke the grant once you have seen the data/taken out an export due to security issues.

  • How exit for a script having set of pl/sql blocks and sql queries

    HI,
    I have set of blocks and sql queries in a script.
    In some cases I want to stop the excution of next statements and blocks.
    As in pl/sql block We can use return , in case of loop we can use exit, so what is to be use in case if sql script which contain set of blocks and sql queries.
    Thanks and Regards in Advance,

    Hi,
    how to exit from the script if confirm_to_continue is set to 'N'.
    i.e in this case I want the preceding statements not to be excuted.
    Please suggest.
    script:
    declare /*BLOCK NO1*/
    begin
    IF &&confirm_to_continue = 'N'
    THEN
    ---exit from from whole script
    RETURN; -- this will only exit from this block
    END IF;
    end;
    host IF EXIST &file_name (del &file_name) ELSE (echo missing)
    declare /*BLOCK NO 2*/
    begin
    end;
    /

Maybe you are looking for