Newbie (View sql statement before execute immediate)

Here is a sample:
<code>
drop table dummy;
create table dummy(county varchar2(20)
,fiscalyear number(4,0)
,wavkeyid number(4,0));
Insert into dummy(county,fiscalyear,wavkeyid)
values('Jefferson',2012,59);
commit;
</code>
I am trying to use a bind variable in the SQL statement.
I would like to see the statement before it is executed.
Example
Select county from dummy where wavkeyid=59 and fiscalyear=2012
Is there a way for me to see the line above?
<code>
PROCEDURE test_BindVar
AS
v_message_tx varchar2(200);
v_wavkeyid_nr number:=59;
v_county_tx varchar2(40);
BEGIN
v_message_tx:='Select county from dummy '||
' where wavkeyid=:x and fiscalyear=2012 ';
dbms_output.put_line
('v_message_tx '||v_message_tx);
execute immediate v_message_tx into v_county_tx using v_wavkeyid_nr;
dbms_output.put_line
('v_county_tx '||v_county_tx );
END;
</code>
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
"CORE 10.2.0.4.0 Production"
TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
TIA
Steve42

you missed the forum you are in ;)
"SQL Developer (Not for general SQL/PLSQL questions)"
recommend to post your question to the related forum on OTN.

Similar Messages

  • Changing sql-statement before executing query

    I want to change the sql-statement of a query just before it is executed.
    I have tried it with a query redirector/sessionevent listener, but I could get it to work.
    Do you have any examples.
    I want to change the tablename in a sql-statement like this:
    before
    select id from emp
    after
    select id from emp_v
    Any examples out there to do this?

    ... I am using SAP NetWeaver BI 7.0
    Monique

  • Problem in Update statement using Execute Immediate

    Hi All,
    I am facing problem in update statement.
    I am creating dynamic sql and use "execute immediate" statement to execute a update statement.
    But it is not updating any thing there in the table.
    I have created a query like :
    update_query='Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
    Execute immediate update_query using V_Id;
    commit;
    But it is not updating the table.
    I have a question , is execute immediate only does insert and delete?
    Thanks
    Ashok

    SQL> select * from t;
                     TID P
                     101 N
    SQL> declare
      2     V_Id          number := 101;
      3     Table_Name    varchar2(30) := 'T';
      4     update_query  varchar2(1000);
      5  begin
      6     update_query := 'Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
      7     Execute immediate update_query using V_Id;
      8     commit;
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> select * from t;
                     TID P
                     101 Y                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Need help in resolving the below error - SQL statement to execute cannot be

    Here is my CO as below , which creates a callable statement.
    try {
    OAApplicationModule oaapplicationmodule = pageContext.getApplicationModule(webBean);
    OADBTransactionImpl t = (OADBTransactionImpl)oaapplicationmodule.getOADBTransaction();
    OracleCallableStatement proc = (OracleCallableStatement)t.createCallableStatement(lquery, -1);
    proc.execute();
    t.commit();
    catch(SQLException sqlexception)
    throw OAException.wrapperException(sqlexception);
    After running the page , getting the below error ... ( Please find the below error stack )
    I reffered the developement guide but did not get helpful things.
    Please provide me any clues on the same.
    Regards Raghu
    -- Error Stack ---------------------------------------------------------
    Error Page
    Exception Details.
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27123: SQL error during call statement preparation. Statement: null
         at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:888)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1145)
         at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(OAPageErrorHandler.java:1408)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2637)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
         at OA.jspService(OA.jsp:40)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    ## Detail 0 ##
    java.sql.SQLException: SQL statement to execute cannot be empty or null
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
         at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:1138)
         at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:1054)
         at oracle.jbo.server.DBTransactionImpl.createCallableStatement(DBTransactionImpl.java:3033)
         at cisco.oracle.apps.xxchr.element.server.webui.XXCHRElementSetSearchCO.processFormRequest(XXCHRElementSetSearchCO.java:343)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
         at OA.jspService(OA.jsp:40)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    java.sql.SQLException: SQL statement to execute cannot be empty or null
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
         at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:1138)
         at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:1054)
         at oracle.jbo.server.DBTransactionImpl.createCallableStatement(DBTransactionImpl.java:3033)
         at cisco.oracle.apps.xxchr.element.server.webui.XXCHRElementSetSearchCO.processFormRequest(XXCHRElementSetSearchCO.java:343)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
         at OA.jspService(OA.jsp:40)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:534)
    Edited by: Raghu on Sep 14, 2010 2:58 AM

    check the code pasted by me again
    Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();
    Connection conn = oaapplicationmodule.getOADBTransaction().getJdbcConnection(); //Right oneThanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • View the reports sql statement before execution

    Hi
    I am developing reports with dynamic sql statements.
    How can I view the complete reports sql statement which is sent to the database?
    Thanks
    Juerg

    You can turn on the trace functionality. That will display the actual SQL statements sent to the database in the trace file.

  • Max no. of Update SQL statements before a commit

    In Oracle 10.2 what is maximum number of UPDATE statements that I can execute before issuing commit.
    If maximum is there either by no. of SQL statements or size in KB, what will happen if I go above this number.
    Thanks in advance for your response.
    Edited by: vbforums on Feb 21, 2011 3:50 PM

    sb92075 wrote:
    I executed 5000+ update statements from Java in one shotI am curious.
    Does each UPDATE change only a single row?
    I'll ask a different way.
    Can a single UPDATE statement change all desired rows?yes
    SQL> conn scott/tiger
    Connected.
    SQL> select table_name from user_tables;
    TABLE_NAME
    EMP
    DEPT
    SQL> create table mytest(cola varchar2(1));
    Table created.
    SQL> insert into mytest values ('A');
    1 row created.
    SQL> insert into mytest values ('A');
    1 row created.
    SQL> insert into mytest values ('A');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from mytest;
    C
    A
    A
    A
    SQL> update mytest set cola='B' where cola='A';
    3 rows updated.
    SQL> commit;
    Commit complete.
    SQL> select i * from mytest;
    C
    B
    B
    B
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@vmlnx01 dbs]$ exit
    logout

  • Unable to INSERT PL/SQL  record with EXECUTE IMMEDIATE

    Hi All,
    I am selecting data from a source table and after some modification inserting into a target table. Source and target table name are available at run time. You can say only source table structure is fixed.
    I have crated a pl/sql table of type source record and inserting record by record in target table using execute immediate. But I am not able to write
    EXECUTE IMMEDIATE string USING pl_sql_table(index); and getting error as
    PLS-00457: expressions have to be of SQL types
    Please see the part of code below. Is it possible to use FORALL with dynamic sql like
    FORALL pl_sql_table.FIRST .. pl_sql_table.COUNT
    EXECUTE IMMEDIATE .... pl_sql_table(j); -- Like this.
    Please suggest why I am not able to write record here. I also want to replace 'INSERT in a loop' with a single INSERT statement out of the loop, to upload whole pl_sql table into target table in one go.
    Thanks,
    Ravi
    DECLARE
        TYPE rec_tab_CMP IS RECORD
         model_id          NUMBER(38),   
         absolute_rank          NUMBER(5)         
        v_rec_tab_CMP  rec_tab_CMP;
        TYPE t_rec_tab_CMP IS TABLE OF v_rec_tab_CMP%TYPE INDEX BY BINARY_INTEGER;
        v_records_CMP               t_rec_tab_CMP;
        rc                          SYS_REFCURSOR;
        v_old_table_name            VARCHAR2(30); -- passed from parameter 
        v_new_table_name            VARCHAR2(30); -- passed from parameter 
        dyn_str                     VARCHAR2(500);
        v_columns_str               VARCHAR2(200) := ' model_id, absolute_rank ';
    BEGIN
           EXECUTE IMMEDIATE 'CREATE TABLE '|| v_new_table_name || ' AS SELECT * FROM ' || v_old_table_name ||' WHERE 1 = 2 ' ;
         OPEN rc FOR 'SELECT '|| v_columns_str ||' FROM '|| v_old_table_name;
         FETCH rc BULK COLLECT INTO v_records_CMP;
         FOR j IN 1..v_records_CMP.COUNT
         LOOP
            v_records_CMP(j).model_id := 1; -- Do someting here, This thing can be performed in SQL stmt directly.
            dyn_str := 'INSERT INTO '|| v_new_table_name ||' ( '|| v_columns_str || ' ) VALUES (:1, :2) ';
            EXECUTE IMMEDIATE dyn_str USING v_records_CMP(j).model_id          ,
                                v_records_CMP(j).absolute_rank     ;
         -- Here in place of two columns I want to use one record like
         -- EXECUTE IMMEDIATE dyn_str USING v_records_CMP(j);
         -- But it is giving me error like
            --          EXECUTE IMMEDIATE dyn_str USING v_records_st(j);
            --   PLS-00457: expressions have to be of SQL types
         END LOOP;
         CLOSE rc;
    END;
    /

    You cannot bind PL/SQL record types to dynamic SQL.
    Possibly you could work around this by declaring the INDEX-BY table of records at package specification level, e.g.
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> CREATE PACKAGE package_name
      2  AS
      3     TYPE tt_emp IS TABLE OF emp%ROWTYPE;
      4     t_emp tt_emp;
      5  END package_name;
      6  /
    Package created.
    SQL> CREATE TABLE new_emp
      2  AS
      3     SELECT *
      4     FROM   emp
      5     WHERE  1 = 0;
    Table created.
    SQL> DECLARE
      2     v_table_name user_tables.table_name%TYPE := 'NEW_EMP';
      3  BEGIN
      4     SELECT *
      5     BULK COLLECT INTO package_name.t_emp
      6     FROM   emp;
      7
      8     EXECUTE IMMEDIATE
      9        'BEGIN ' ||
    10        '   FORALL i IN 1 ..package_name.t_emp.COUNT ' ||
    11        '      INSERT INTO ' || v_table_name ||
    12        '      VALUES package_name.t_emp (i); ' ||
    13        'END;';
    14  END;
    15  /
    PL/SQL procedure successfully completed.
    SQL> SELECT empno, ename
      2  FROM   new_emp;
         EMPNO ENAME
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
          7900 JAMES
          7902 FORD
          7934 MILLER
    14 rows selected.
    SQL>

  • Validate SQL string before executing

    I am attempting to find a way to validate an SQL script file before executing against a database. This is to allow any errors within the script to be identified and fixed before running against a pre-live / live database.
    These scripts may contain both DDL and DML.
    Is there any way to run the script and only have the changes visible to the current user, with all other database users unaffected until the changes have been checked (in a similar way to running an insert / update / delete without committing the changes)? Failing this, are there any tools to check the validity of the statements within an SQL script file?
    Any help with these or alternative solutions would be much appreciated.
    Cheers,
    Steve

    This is not sensible.
    How can you test a DML that creates a table (that does not create the physical table) and then test a DDL that uses that table that was not created and of which no record exist?
    The validity of a SQL statement (DML or DDL) depends on numerous factors, including the state of the database at that specific point in time that it is being run. You may test/check a DML that creates an index and it is fine.. until run on production where it times out as it cannot get a lock on the table in order to create the index.
    Or there is insufficient free space in the tablespace to build the index. Or the index is build in parallel and one of the PQs fail because on an Oracle bug, resulting in the complete DDL failing.
    Etc. Etc.
    If the intention is to be able to test an upgrade/patch/install script for a production database for every single potential problem and error, and then have a 100% guaranteed success rate in running that on production.. er.. excuse me for a moment..
    <mad laughter heard from outside>
    Er.. okay. Back again.
    This will need - no compromises and just for starters - the exact same h/w platform, o/s, Oracle s/w, and duplicated production database (cloned perhaps) as the test platform.
    And if this is not possible or feasible then you should forget about having that script tested in such a fashion in order to have a 100% guarantee of a successful production deployment... and investigate the optimum method to test as far as possible, and build a comprehensive plan for change management and dealing with problems out of this upgrade, on production.

  • 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!

  • SQL statement not executing

    Please enlighten me. This is driving me crazy.
    I don't know if this is a database or java code related problem.
    JVM: 1.4.2
    Database: Oracle 9i
    Objective: trying to add a row into a table
    Problem: 1. SQL statement never gets executed.
    2. Application freezes. I have to terminate it myself.
    Any Ideas?
    void addCourse(){
    try {
        DriverManager.registerDriver ( new oracle.jdbc.driver.OracleDriver () ) ;
       System.out.println("Driver registered");  //---> ok.
    Connection conn = DriverManager.getConnection ( dbPath, username, password ) ;
       System.out.println("Connected");   // -----> it connects fine
       ResultSet rset = stmt.getResultSet();
       System.out.println("getting result set");  //-----> gets the resultSet fine
      Statement stmt = conn.createStatement();
      System.out.println("statement created");  //------> it creates statement
    7 = are the credits. Number on table. Length allowed 5.
    CS 500 = are the course code. Varchar2 on table. Length allowed 20
    Java = Actual course name. Varchar2 on table. Length 30
    3 = credits. Number on table. Length 5.
              // Prepare a statement to insert a record
              String sql = "INSERT INTO course VALUES (7 , 'CS 500', 'Java', 3 )"; //-->ok. Tested it manually 
              // Execute the insert statement
            stmt.executeUpdate(sql);  //----> *** java program freezes right here.***
            System.out.println("sql executed");   //--> Checked table. SQL never gets executed.
    catch ( SQLException ex ) {   //---> no error messages thrown.
    System.err.println(ex.getMessage());
      System.err.println(ex.getErrorCode());
      System.err.println(ex.getSQLState());
    }

    Nothing looks amiss in the code... How long are you waiting before you manually terminate?
    Can you replace the executeUpdate() with execute and change the INSERT to a SELECT? Does that work normally (you should be sure to get at least one row to verify that it is working correctly)? Can you select and update a different table in a different tablespace successfully?
    Couple of possibilities (I know this is weak):
    1) You have hit a deadlock condition because the table is locked by another or same process.
    2) You are running into network problems.
    3) Your insert is being queued up in Oracle's transaction manager (if configured).
    4) Have you tried both the Oracle thin and Oracle OCI driver? Do they both fail without error?
    5) Can you turn off autoupdate and try the insert? Does the executeUpdate() return then?

  • Can't create a sequence within a pl/sql block with execute immediate.

    Hi All. I created a user and granted it the 'create sequence' privilege though a role. In a pl/sql block I try to create a sequence using 'execute immediate' but get a 1031-insufficient privileges error. If I grant create sequence directly to the user, the pl/sql block completes successfully. Can anyone explain this behavior? We're running 11.2 Enterprise Editon.
    Thanks,
    Mark

    In a definer's rights stored procedure (the default), you only have access to privileges that have been granted directly, not via a role.
    There are two basic reasons for that. First, roles can be enabled or disabled, default and non-default, password-protected, etc. so the set of roles a particular user actually has is session-specific. Oracle needs to know at compile time what privileges the owner of the procedure has. The only way to do that (without deferring the privilege check) is to ignore privileges granted through roles.
    Second, since 99% of privilege management DBAs do involves granting and revoking roles, it's helpful that changing role privileges will never cause objects to be marked invalid and recompiled which can have side-effects on applications. DBAs only need to worry about causing problems on those rare cases where they are granting or revoking direct privileges to users.
    You can create an invoker's rights stored procedure by adding the clause (AUTHID CURRENT_USER). That defer's the security check to run-time but allows the procedure to see privileges granted through roles in the current session. But that means that the caller of the procedure would need to have the CREATE SEQUENCE privilege through the role, not the owner of the procedure.
    And just to make the point, dynamic object creation in PL/SQL is almost always a red flag that there is something problematic in your design. If you are creating sequences dynamically, that means that you'd have to refer to them dynamically throughout your code which means that your inserts would need to use dynamic SQL. That's not a particularly easy or safe way to develop code.
    Justin

  • View SQL statements in DB

    Hi,
    I am trying to find where I can find the log for users being unlocked thru a SQL statement and this is viewved in the DB. BUT funny thing is that SU01 doesnt show last changed according to the log.
    I need to know how to view or which table it is in ORACLE table for me to view this information, tks.

    Hi Jack,
    which users do you want to look up in the DB? Users in the ABAP systes are changed using tx SU01 or something similiar. Even if an IDM is being used, most of the will use functionality of the ABAP user management to update this info. In this case, changes will be done to tables like USR* and recorded in different tables like USH*. You would then look up the info in tx SUIM.
    If a user would be unlocked directly on the database using SQL commands, this would result in a direct modification of table USR02. You could spot this by inconsistencies in tabel USR02 and USH02. However I would guess the real modification can only be detected using table logging on table USR02.
    However except for the SAP ABAP system, I would hope no one has access to these tables, so I'm not sure where you are heading to.
    Regards,
    Patrick

  • Check the validity of a SQL statement before execution

    Hi everyone,
    In an applet I have created, I am allowing the user to create a SQL statement which will be sent to a servlet that in turn issues the JDBC request for the SQL statement. My concern is that since my GUI lets the user create more or less any kind of SQL statement (including an illegal one) I need to verify if the user has created the correct SQL. How can this be achieved?
    To recapitulate and summarize, I need to know how I can check the validity of a SQL statement without actually executing it and handling the SQLException. FYI, I am using the mm-mysql driver.
    Thanks,
    Alan

    jschell is correct. Unless you're writing something like an ISQL tool you want to be very careful doing this.
    Having said that Mimer SQL have SQL validators that may do what you want http://developer.mimer.com/validator/index.htm
    They've also got the SQL Validator running as a web service that you can use. Theres example code here showing how to use it.
    http://sqlvalidator.mimer.com/index.html
    At the risk of being accused of selfpromotion you can check out the SQL Validator plugin for SQuirreL SQL CLient. This is a fully functional example of using the Mimer SQL Validation web service. http://squirrel-sql.sourceforge.net/
    Col

  • Logging/viewing SQL statements generated by the SQL Developer IDE?

    I know it is possible to view the SQL statements that the SQL Developer IDE generates to fetch result-sets from the database whenever one performs any action - say expanding the "Tables" node for a database, for example. I would appreciate if someone could point out how this functionality could be enabled.
    Thanks,
    RG

    In 1.0, you could use the AddVMOption -Daudit.trace=db_api option inside the sqldeveloper.conf file.
    In 1.1 however, I don't get output inside the console anymore (for expanding trees, etc.).
    Kris, has this option been replaced by another one? Please let us in on all the fun ;-)
    K.

  • Help With SUBSTR in dynamic SQL statement

    Following is the dynamic SQL statement.
    EXECUTE IMMEDIATE 'UPDATE table_name pml
    SET pml.'|| con_fields.field ||' = SUBSTR(pml.'||con_fields.field||' ||'' ''||
    (SELECT pml1.'||con_fields.field||'
    FROM table_name pml1
    WHERE pml1.grp_id = '||los_concats.grp_id ||'
    AND pml1.row_id = '||los_concats.row_id||'
    AND pml1.loser_flg = ''Y''),1, '||con_fields.max_length||')
    WHERE pml.grp_id = '||los_concats.grp_id ||'
    AND pml.loser_flg IS NULL ';
    what it does is that it updates a particular field. This field is concatenated by a field of a similar record.
    My problem is with SUBSTR function. Since I am concatenating fields I do not want the field to be updated greater than max_length on that field, the reason why I use SUBSTR. the select query inside SUBSTR works alright with one of the AND condition in a WHERE clause not present. When I add that additional condition it gives me this error.
    ORA-00907: missing right parenthesis.
    Is there any way to get around this problem. Does SQL has other than SUBSTR function which can limit the character length.
    Appreciate it.

    The other alternative I thought about was to do this first
    EXECUTE IMMEDIATE 'SELECT pml.'||con_fields.field||'
    FROM table_name pml
    WHERE pml.grp_id = '||los_concats.grp_id||'
    AND pml.row_id = '||los_concats.row_id||'
    AND pml.loser_flg = ''Y''
    ' INTO v_concat_field;
    write into the variable v_concat_field and then use it into the previous script.
    But on this I get SQL Command not properly terminated, I don't get it Why?
    Donald I tried with your suggested script. It works fine with one of the conditions eliminated. I don't understand what the error trying to say?
    Thanks

Maybe you are looking for

  • Why does my App Store app keep crashing in iOS 6?

    I updated my iPhone 4 to iOS 6 and my App Store launches and as soon as I scroll and check out apps, it crashes. Any thoughts? I typically only have one or two Apps open at the same time. I close apps when I don't use them. Could it be a memory probl

  • 9 Pro Extended: Windows XP Scanner funktioniert als User plötzlich nicht mehr

    Hallo Helfer, habe da ein für mich völlig unlogisches Problem: Als Admin kann ich unter Acobe Acrobat 9 Pro extended den Scanner ganz normal nutzen, aber als User bekomme ich immer folgende Fehlermeldung: "Bei der Kommunikation mit dem Scanner ist ei

  • How to remove only the first .Period in a file name using CL.

    Hello! So, I've used code similar to this before to remove special characters.  It works for a period . as well, but, of course removes ALL periods. file=/Users/niles/Desktop/.test.txt; echo $file"${file//[\\.]/}" How do get a reult that only remove

  • Report Script : Parameter for file name?

    hi all, I am using a report script to generate a text file with budget data. This works fine in AAS console but I am automating this process by usning an ESSCMD and batch script. tha batch script will call the ESSCMD script which in turn executes the

  • OWB Repository Assistant

    Estou com um problema na conexão do OWB Repository Assistant onde ao informar o nome do usuário, senha , nome host, porta, serviço Oracle o seguinte erro ocorre em Javaw.exe: "Não foi possÃvel localizar o ponto de entrada do procedimento kpuhhalo