Insert statement is not executing.....

From below procedure the insert statement is not executing....
update statement is working perfectly but insert......
create or replace PROCEDURE PAYMENT(AMT NUMBER,UID NUMBER) IS
AMT1 NUMBER;
AMT NUMBER;
PD VARCHAR2(100);
C1 NUMBER;
PER NUMBER;
ACC1 VARCHAR2(15);
CF NUMBER;
CRF NUMBER;
ACC2 VARCHAR2(15);
begin
SELECT  PAY_DESC INTO PD FROM SUB.PAYMENT_TY WHERE ORD=0;
SELECT NVL(AMOUNT,0) INTO C1 FROM FOOD.MEMBER WHERE LTRIM(RTRIM(UPPER(NAME))) LIKE
LTRIM(RTRIM(UPPER(PD)))
AND USER_ID=UID;
IF NVL(C1,0)>AMT THEN /*CASH*/
C1:=C1-AMT;
SELECT ACCOUNT_CODE INTO ACC1 FROM SUB.MASTER WHERE PAY_CODE=2;
INSERT INTO ACC(AMOUNT_TD,ACC_CODE,EN_DATE,FO_TYPE,PART) VALUES(AMT,ACC1,SYSDATE,'JV','CASH
PERCENTAGE FOR '||45457);
STANDARD.COMMIT;STANDARD.COMMIT;STANDARD.COMMIT;
UPDATE FOOD.MEMBER_DET SET AMOUNT=C1 WHERE USER_ID=UIDAND C_COD=2;
STANDARD.COMMIT;STANDARD.COMMIT;STANDARD.COMMIT;
END IF;
end;the values receiving in insert statement is correct values.
how to resolve this?
Thanks skud...

Check for too many rows or no data found exception.
And also check the number of rows either inserted or updated.
Something like this:
create or replace PROCEDURE PAYMENT(AMT NUMBER,UID NUMBER) IS
  AMT1  NUMBER;
  AMT   NUMBER;
  PD    VARCHAR2(100);
  C1    NUMBER;
  PER   NUMBER;
  ACC1  VARCHAR2(15);
  CF    NUMBER;
  CRF   NUMBER;
  ACC2  VARCHAR2(15);
begin
  begin
    SELECT  PAY_DESC
    INTO PD
    FROM SUB.PAYMENT_TY
    WHERE ORD=0;
    exception
      when too_many_rows then
        dbms_output.put_line('Too many rows in first SELECT');
      when no_data_found then
        dbms_output.put_line('No data found in first select');
  end;
  begin
    SELECT NVL(AMOUNT,0)
    INTO C1
    FROM FOOD.MEMBER
    WHERE LTRIM(RTRIM(UPPER(NAME))) LIKE LTRIM(RTRIM(UPPER(PD)))
    AND USER_ID=UID;
    exception
      when too_many_rows then
        dbms_output.put_line('Too many rows in second SELECT');
      when no_data_found then
        dbms_output.put_line('No data found in second select');
  end;
  IF NVL(C1,0)>AMT THEN /*CASH*/
    C1:=C1-AMT;
    begin
      SELECT ACCOUNT_CODE
      INTO ACC1
      FROM SUB.MASTER
      WHERE PAY_CODE=2;
      exception
        when too_many_rows then
          dbms_output.put_line('Too many rows in third SELECT');
        when no_data_found then
          dbms_output.put_line('No data found in third select');
    end;
    INSERT INTO ACC(AMOUNT_TD,ACC_CODE,EN_DATE,FO_TYPE,PART) VALUES(AMT,ACC1,SYSDATE,'JV','CASH PERCENTAGE FOR '||45457);
    dbms_output.put_line('Insert ' || sql%rowcount);
    COMMIT;
    UPDATE FOOD.MEMBER_DET SET AMOUNT=C1 WHERE USER_ID=UIDAND C_COD=2;
    dbms_output.put_line('Update ' || sql%rowcount);
    commit;
  END IF;
end;
/UNTESTED!!

Similar Messages

  • Insert statement will not work if select statement has less number of colum

    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshad

    user13360241 wrote:
    Hi,
    One of my thread is already resolved on the following URL : unable to insert rows into the table
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
    DECLARE
    S VARCHAR2(200);
    STMT VARCHAR2(500);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    STMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT:=STMT || C.TABLE_NAME;
    EXECUTE IMMEDIATE STMT;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
    Please let me know , how can i execute proper way.
    Thanks.
    Best Regards
    Arshadmore often than not "TEMP" tables are NOT required & are highly inefficient in Oracle.
    Either only specify explicit column in TEMP to get data,
    or provide value for "extra" column in TEMP

  • Insert statement does not insert all records from a partitioned table

    Hi
    I need to insert records in to a table from a partitioned table.I set up a job and to my surprise i found that the insert statement is not inserting all the records on the partitioned table.
    for example when i am using select statement on to a partitioned table
    it gives me 400 records but when i insert it gives me only 100 records.
    can anyone help in this matter.

    INSERT INTO TABLENAME(COLUMNS)
    (SELECT *
    FROM SCHEMA1.TABLENAME1
    JOIN SCHEMA2.TABLENAME2a
    ON CONDITION
    JOIN SCHEMA2.TABLENAME2 b
    ON CONDITION AND CONDITION
    WHERE CONDITION
    AND CONDITION
    AND CONDITION
    AND CONDITION
    AND (CONDITION
    HAVING SUM(COLUMN) > 0
    GROUP BY COLUMNS

  • Insert statement is not working for z table.

    Hi experts,
    My insert statement is not working.
    I have used follwing code to update z table .
    INSERT ztable FROM TABLE gt_table.
    here i have checked gt_table and its filled up with all the records properly.
    now the problem is in this table i have 15 fields and it inserts 14  fields of it but
    the last field is never inserted though in gt_table i can see value for last fields also.
    I have added this field in ztable recently . so i also used se14 to adjust table but still i am facing same problem.
    please help me out.
    thanks,
    Neo

    > > Table maintainance will have nothing to do with
    > this
    > > issue.
    >
    > It does sometimes when you are trying to see the
    > values from SM30 instead of SE16. The value may be
    > there, but it may just not seen in SM30 because the
    > table maintenance hasn't registered the addition of
    > new field.
    >
    > Another place to look at is the activation log to see
    > if there are any warnings issued there.
    You shouldn't use SM30 to view table entries. You use this transaction to maintain the table entries. Pure and Simple.

  • Java.sql.SQLException: statement handle not executed

    hello,
    i am calling a stored procedure and its returns a REF CURSOR and i am getting intermittent exceptions below,
    org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
    xxxx_pkg(?,?)}]; SQL state [99999]; error code [17144]; statement handle not executed; nested exception is java.sql.SQLException: statement handle not executed
    and
    org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
    xxxx_pkg(?,?,?)}]; SQL state [99999]; error code [17009]; Closed Statement; nested exception is java.sql.SQLException: Closed Statement
    any clue what could be the issue,
    Regards
    GG

    its pretty simple have a java class calling hibernateTemplate's findByNamedQueryAndNamedParam method by passing the procedure name and binding parameters/values, and here is the stack
    org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [{call
    xxx_pkg(?,?)}]; SQL state [99999]; error code [17144]; statement handle not executed; nested exception is java.sql.SQLException: statement handle not executed
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
    at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
    at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
    at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    at org.springframework.orm.hibernate3.HibernateTemplate.findByNamedQueryAndNamedParam(HibernateTemplate.java:1006)
    Caused by: java.sql.SQLException: statement handle not executed
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:229)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:403)
    at oracle.jdbc.driver.T4CStatement.doDescribe(T4CStatement.java:701)
    at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3355)
    at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:2009)
    at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:494)
    at org.hibernate.type.StringType.get(StringType.java:18)
    at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)
    at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)
    at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81)
    at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2091)
    at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380)
    at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)
    at org.hibernate.loader.Loader.getRow(Loader.java:1206)
    at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
    at org.hibernate.loader.Loader.doQuery(Loader.java:701)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
    at org.hibernate.loader.Loader.doList(Loader.java:2217)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2108)
    at org.hibernate.loader.Loader.list(Loader.java:2103)
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1696)
    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
    at org.springframework.orm.hibernate3.HibernateTemplate$34.doInHibernate(HibernateTemplate.java:1015)
    at org.springframework.orm.hibernate3.HibernateTemplate$34.doInHibernate(HibernateTemplate.java:1)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)

  • ORA-24338: statement handle not executed

    Hi,
    My front end programming platform is .NET. Oracle DataBase is 10g.
    I have written this package:
    CREATE OR REPLACE package body USER_NAME.PACKAGE_TEST1 as
    procedure getname(id1 number,tb_cursor out md_cursor)
    as
    begin
    open tb_cursor for select name from testtable1 where id1=id;
    close tb_cursor;
    end getname;
    end package_test1;In the front end i am using DataReader to fetch data.
    But while Executing reader an error occurs that is "ORA-24338: statement handle not executed".
    But when i remove "close tb_cursor" programm runs successfully.
    What is the reason for that error ?

    user12222356 wrote:
    Tubby wrote:
    A ref cursor is nothing more than a pointer to a statement (query).
    So no, you do not want to make 1000 procedure calls. You want your ref cursor to be opened for a query that contains 1000 rows. The client calls your procedure ONE TIME and processes the entirety of the ref cursor (1000 rows), then closes the cursor that your procedure so graciously opened for them.But according to .NET(my front end platform) documentation DataReader fetches data from database row by row .each row at a time.That means when the procedure was first called REF CURSOR was opened and was open till all data are fetched.Means at the begining itself query was executed and all data was fetched and stored temporarily in the database, and then DataReader fetched those data row by row..i.e., after first call to procedure only fetching of data is done. NO opening,NO closing ,NO select query execution (that was referenced by REf CURSOR). And when all rows are fetched that open cursor is closed . Is my concept right here ?YOU opened the cursor (in your procedure).
    The select query execution IS the ref cursor being processed by your DataReader.
    The data is not temporarily stored in the database ... it persists there (unless someone deletes it) ... so that statement wasn't really correct. DataReader would just be reading the rows from the database (via the ref cursor)
    I would assume DataReader will close the cursor for you, but i really don't know ... you'd have to ask a .not person about that.

  • Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed

    Hi,
    I am facing a problem while adding a new parameter n my JSP Report JDBC query based on a ref-cursor from a stored procedure define in a package in database.
    No problem at database level, I have added the new parameter in package specification and Package body for that procedure and compile my package, it complies without any error and warning.
    but when I open the report and add parameter in the report JDBC query window, then it is generating a error message,
    "Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed "
    and I am unable to add the new parameter in report.
    e.g.
    Actual which was working is:
    My-package.My-procedure(:P1,:P2,:P3 ,:P4,:P5,:P6,:P7)
    I want to do this:
    My-package.My-procedure(:P1,:P2,:P3 ,:P4,:P5,:P6,:P7,:P8)
    but unable to do due to this error message:
    ("Err 62007: SQL Error: 99999 ORA-24338: Statement Handle not Executed ")
    Reports Builder 10g:
    Database 10g:
    Operating system windows XP:
    using JDBC Query base on ref-cursor coming from the stored procedure define in the Package.
    Regards,
    Khan

    and compile my package, it complies without any error and warning.That doesn't mean anything in this case. You are getting a runtime error, not a compilation error. The error is coming when you execute your procedure.
    Did you test your modified procedure in sqlplus or SQL Developer?

  • ORA-24338: statement handle not executed   -- error in returning refcursor

    My packaged procedure has Ref cursor as out variable.
    Calling the packaged procedure from Cognos 8. while trying to access the packaged procedure , getting the below error.
    ORA-24338: statement handle not executed
    Please provide a solution...

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
    Confirm that the procedure works properly when called from sql*plus.
    For example here is some code that tests a package procedure I have in the SCOTT schema
    SET SERVEROUTPUT ON SIZE 1000000
    DECLARE
      l_cursor  test_refcursor_pkg.my_ref_cursor;
      l_ename   emp.ename%TYPE;
      l_empno   emp.empno%TYPE;
    BEGIN
      test_refcursor_pkg.test_proc (l_cursor);
      LOOP
        FETCH l_cursor
        INTO  l_empno, l_ename;
        EXIT WHEN l_cursor%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(l_ename || ' | ' || l_empno);
      END LOOP;
      CLOSE l_cursor;
    END;
    /

  • Oracle Error - statement handle not executed state

    Hello,
    A BCA scheduled job has failed and returned with the following error. Does anyone have an idea to fix this error.
    Connection or SQL sentence error: (DA0005): [Exception: DBD, ORA-24338: statement handle not executed State: N/A] The following data providers have not been successfully refreshed
    Thanks
    -Gopi

    Please provide more information on what Crystal Reports or Business Objects product you are using. The more details you can provide, the quicker the resolution...
    Ludek

  • Statement handle not executed error

    Hi,
    I have a package which have a statement as follows.
    OPEN p_out_provider_w_POSAccess FOR
                   SELECT DISTINCT claim.cert_no, claim.rec_code,
                                   prov.ghi_prov_num, prov.irs_number tax_id,
                                   prov.full_name, prov.lastname, prov.firstname
                              FROM hmo.hmo_medical_claim claim,
                                   ipd2.i_provider prov,
                                   ipd2.i_provider_top pt,
                                   ops_arw.phr_top top,
                                   ops_arw.provider_pin pin
                             WHERE claim.cert_no =hmo_conv_num_to_letter (p_in_cert_no)
                               AND claim.rec_code = p_in_rec_code
                               AND claim.ghi_prov_num = prov.ghi_prov_num
                               AND claim.ghi_prov_num = pt.ghi_prov_num
                               AND claim.ghi_prov_num = pin.ghi_prov_num
                               AND pt.top_code = top.top_code
                          ORDER BY prov.lastname, prov.firstname;                                
                                    when I execute the package ,I get
    dweb1:ops_arw> PRINT p_out_provider_w_POSAccess
    ERROR:
    ORA-24338: statement handle not executed
    SP2-0625: Error printing variable "p_out_provider_w_POSAccess"Thanks

    user11253970 wrote:
    No I am not closing it.Just now I noticed that when I input values which are in Database it returns the result without any failure.But when I try to input values which are not in database ,Instead of returning zero rows it gives the error message.Then your SP logic branches in such way that values which are not in the database bypass open cursor statement:
    SQL> create or replace
      2    procedure p1(p_cur in out sys_refcursor,p_ind number)
      3    is
      4    begin
      5        if p_ind = 1
      6          then
      7            open p_cur for select ename from emp where deptno = 10;
      8        end if;
      9  end;
    10  /
    Procedure created.
    SQL> exec p1(:p_cur,1)
    PL/SQL procedure successfully completed.
    SQL> print p_cur
    ENAME
    CLARK
    KING
    MILLER
    SQL> exec p1(:p_cur,0)
    PL/SQL procedure successfully completed.
    SQL> print p_cur
    ERROR:
    ORA-24338: statement handle not executed
    SP2-0625: Error printing variable "p_cur"
    SQL> SY.

  • Urgent: ORA-24338: statement handle not executed

    Hello,
    /*===================================================*/
    PL/SQL code:
    SQL> create or replace package p3 is
    2 type t_c is ref cursor;
    3 procedure p(p_c out t_c);
    4 end p3;
    5 /
    Package created.
    SQL> show errors;
    No errors.
    SQL>
    SQL>
    SQL> create or replace package body p3 is
    2
    3 procedure p(p_c out t_c)
    4 is
    5 v_c t_c;
    6 begin
    7 open v_c for
    8 select job_number
    9 from rep_adhoc_invoices
    10 where rownum<5;
    11 end p;
    12 end p3;
    13 /
    Package body created.
    SQL> show errors;
    No errors.
    /*===================================================*/
    C# code:
    OracleConnection dbConnection = null; /* see finalize{} */
    OracleCommand dbCommand = null;
    OracleDataAdapter dbAdapter = null;
    try
         dbConnection = new OracleConnection(GetConnectionString());
         dbConnection.Open();
         dbCommand = new OracleCommand();
         dbCommand.Connection = dbConnection;
         dbCommand.CommandText = "p3.p";                    dbCommand.CommandType = CommandType.StoredProcedure;
         dbCommand.Parameters.Add("p_c", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);
         dbAdapter = new OracleDataAdapter(dbCommand);
         System.Data.DataSet ds = new DataSet();
         dbAdapter.Fill(ds);
         return(ds);
    catch (Exception e)
         Console.WriteLine(e.Message);
    /*===================================================*/
    Problem:
    When code executes:
    dbAdapter.Fill(ds);
    I constantly get the ORA-24338.
    The same result if I try from console with "set autoprint on" (v_c is defined beforehand):
    SQL> execute p3.p(:v_c)
    PL/SQL procedure successfully completed.
    ERROR:
    ORA-24338: statement handle not executed
    It seems to me, that the problem is on the server.
    Does anyone know, WHAT is the problem?
    Thanks a lot beforehand!
    Edgar.

    In your procedure implementation (below), you forgot to assign the local variable v_c to the out parameter p_c before exiting the rountine. This means that the ref cursor parameter is never opened.
    The error you got occurs because when ODP.NET gets back the ref cursor it tries to fetch from it without checking whether it's open or not. If you look up the ORA-24338 error code in the documentation, it'll tell you as much. Typcially, when I get an error I don't understand, I head straight for the docs. They not only tell me what it means, but often suggest a solution.
    This behaviour of ODP must be for performance reasons, since doing the check everytime would be wasted most of the time. Still, it would have been nice if they'd emulated MSDAORA, which DOES check.
    3 procedure p(p_c out t_c)
    4 is
    5 v_c t_c;
    6 begin
    7 open v_c for
    8 select job_number
    9 from rep_adhoc_invoices
    10 where rownum<5;
    11 end p;
    12 end p3;
    13
    Frankly, I'm surprised you didn't get ORA-3113: end of communication channel. This is what happened to me when I exited a function without assigning the ref cursor. To solve it, I'd changed the declaration of the PL/SQL function and OracleCommand parameters to IN OUT instead of just OUT. THEN, I got ORA-24338. Anyway, watch out for these things as you progress.
    Happy coding.
    Clarence

  • Insert Statement Will Not Work if a user has

    I am using a MySQL database to process my Java Server Page form.
    Simply, I always try to see if I can process information, first, via the command line client, then thru JSP.
    At the command line client I type:
    I type insert into tablename (favorite_quote) VALUES
    ('Sleepin' in 'da house!');
    That insert throws an error. SImply said, because of the bunches of single quotes... Is there any advanced statement or insert statement to solve this?
    If I do this:
    INSERT INTO tablename (favorite_quote) VALUES
    ('Java');
    It adds the record perfectly normal...
    I am REALLY new to Java, so any help on this issue would be great!
    BTW: Part of my Java Server Pages has:
    String favorite_quote =request.getParameter("favorite_quote");
    "INSERT INTO tablename (favorite_quote) VALUES " +
    "('"+userid+"')";
    Obviously that works fine unless anybody adds a ' or " isn't or what's, etc.
    I'm loving Java, I just REALLY need some help on solving this issue.
    Thank you so much! Any help would BE **WONDERFUL**!

    String favorite_quote
    te =request.getParameter("favorite_quote");
    PreparedStatement ps =
    = connection.prepareStatement(""INSERT INTO tablename
    (favorite_quote) VALUES (?)");
    ps.setString(1, "Sleepin' in 'da house!");
    ps.execute();oops a small error
    PreparedStatement ps = connection.prepareStatement("INSERT INTO tablename (favorite_quote) VALUES (?)");

  • Insert statement is not working properly

    I've problem in inserting values in database.I'm able to retrieve data from a table, but I'm not able to store any values in a table.I've got no runtime error.In code, executeUpdate() statement is also returning 1(which shows successful execution).
    PROGRAM CODE:
    import java.io.*;
    import java.sql.*;
    public class test1
         public static void main(String args[])
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   Connection con=DriverManager.getConnection("jdbc:odbc:office");
                   Statement st=con.createStatement();
                   String query="insert into nam values('[email protected]')";          
                   int i=st.executeUpdate(query);
    System.out.println(i);
              catch(Exception e)
                   System.out.println(e);
    Eagerly Expecting a solution
    Thanks & Regards
    Venki

    Will not help, if he didn't change AutoCommit to false.
    An idea: Do you use Access?
    Then it might be this one again:
    http://forum.java.sun.com/thread.jsp?forum=48&thread=147704

  • Insert Statement is not working

    Hi all
    I am using MySql.
    I want to insert a string into DB which also has singlequotes and double quotes.
    I am able to insert single quotes but when i am inserting double quotes i'm getting sql exception.
    any example code is much appreciated.
    can anybody help?
    Advance thamks

    Bhanu,
    I gotta tell you that is about the dumbest post I have read on here in some time.
    It doesn't matter where the variable comes from... one you hard-coded in your source or user entered at run time.... the idea is the same.
    USE PREPARED STATEMENTS.
    The prepared statement AT RUN TIME will do what needs to be done with your value..
    It doesn't matter where it is coming from.
    I suppose you know all about design patterns eh? Yeah that's nice.
    Just maybe try the code sample out.. replacing the value with the one you get from the user. You will see it works.

  • Statement works as a straight insert statement but not in a procedure

    I can run the folloiwing statement as a straight insert
    INSERT INTO MYTEMP
    SELECT CASE WHEN line_num < 10 THEN NULL ELSE AVG( close) OVER (ORDER BY trade_date ROWS between 9 preceding and current row) END AVG_10
    FROM stocks_hold
    WHERE symbol = 'DIA';
    but when I try to compile it within a procedure I get the following error
    PL/SQL: ORA-00905: missing keyword
    The only difference is that I loop through a cursor and do the insert using a variable for symbol
    I'm done banging my head against the wall, any help would be appreciated.
    Thanks
    D

    Good point, newbie mistake
    Here is the entire procedure
    CREATE OR REPLACE PROCEDURE sp_doAll IS
    lc_SYMBOL VARCHAR2(50);
    CURSOR lCur IS
    SELECT DISTINCT SYMBOL
    FROM STOCKS_HOLD;
    lRec lCur%ROWTYPE;
    BEGIN
    DELETE
    FROM stocks;
    COMMIT;
    FOR lRec IN lCur LOOP
    lc_SYMBOL := lRec.SYMBOL;
    INSERT INTO STOCKS
    (symbol, trade_date, open, high, low, close, volume, LINE_NUM, avg_10, avg_20, avg_50, avg_100, avg_200)
    SELECT symbol, trade_date, open, high, low, close, volume, LINE_NUM,
    -- CASE WHEN line_num < 10 THEN NULL ELSE AVG( close) OVER (ORDER BY trade_date ROWS between 9 preceding and current row) END AVG_10,
    CASE WHEN line_num < 10 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 10 preceding) END avg_10,
    CASE WHEN line_num < 20 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 20 preceding) END avg_20,
    CASE WHEN line_num < 50 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 50 preceding) END avg_50,
    CASE WHEN line_num < 100 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 100 preceding) END avg_100,
    CASE WHEN line_num < 200 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 200 preceding) END avg_200
    FROM STOCKS_HOLD
    WHERE SYMBOL = lc_symbol
    ORDER BY TRADE_DATE;
    END LOOP;
    COMMIT;
    END sp_doAll;
    This compiles and runs, but, when I try the alternate way (that gives me the accurate results)
    Uncomment this statement:
    -- CASE WHEN line_num < 10 THEN NULL ELSE AVG( close) OVER (ORDER BY trade_date ROWS between 9 preceding and current row) END AVG_10,
    comment this statement:
    CASE WHEN line_num < 10 THEN NULL ELSE avg( close) OVER (ORDER BY trade_date ROWS 10 preceding) END avg_10,
    I still get the same error
    Thnx
    Dan

Maybe you are looking for

  • Unable to see Errors.

    Hi, I have an interface named 'Load_Interface' which loads data from source to target. After executing the interface, I am checking for Error by right clicking on target table (control ---> Error). I get the following error: ODI-20160: The table sche

  • Remove null values from query

    Hi All; Below is my query and the output and i need to remove null values from the output Any help regarding same is much appreciated Thanks ; WITH CTE AS select a.opportunityid,a.new_entrypoint_displayname,c.parentcustomerid,c.contactid,c.fullname,a

  • Order by problem

    hi all i have to make a report that has group fields. and i need to change order by of this query in runtime query must be ordered by each field that user select in runtime. if i use sql query for making this report and at the end of my sql statement

  • Disable field highlighting?

    Good Morning, Working on a form that will be distributed to a number of users.  The form utilizes a lot of scripts to highlight fields that require attention.  The form works/shows well when the preset "highlight fields" is turned off (currently done

  • SharePoint 2010 and Excel Calculation Services

    I'm curious what the hardware requirements are for Excel Calculation Services in Sharepoint 2010. I found an architecture document but it doesn't list out the specific requirements. architecture I understand that you can install all the services on o