Insert statement between ver. 10.2.0.1 and 10.2.0.5

Last week I helped user to clone a schema from Oracle ver. 10.2.0.1 to 10.2.0.5.
They reported to me that one of the SQL query doesn't work anymore in newer version of Oracle.
The statement seems like following:
insert into TABLE_01 T
(col1,col2,col3,col4)
values
('A','B','C',SELECT NVL(ROUND(SUM(OTH.AMT), 0), 0) OTB_AMT
FROM OTM_PLAN_APR_HDR OTH
WHERE OTH.CODE= T.COL03
AND OTH.TERRITORY = T.COL02
AND OTH.SEASON = T.COL01));
In 10.2.0.1, it worked fine.
In 10.2.0.5, it got error:
ORA-00904: "T"."COL01": invalid identifier
Anyone know that, is it the problem due to version, or due to setting?
Thanks a lot!
Regards,
Michael

I have tried to create testing tables;
create table tab_a (
text1 varchar2(30)
create table tab_b (
text2 varchar2(30)
insert into tab_a values ('a');
insert into tab_a values ('b');
insert into tab_b values ('b');
commit;
insert into tab_b b
(text2)
values
((select text1 from tab_a a where
a.text1 = b.text2))
It works in ver 10.0.2.1 but doesn't work in 10.0.2.5

Similar Messages

  • Use of the "updlock" hint with update and insert statements

    I have inherited some stored procedures and am trying to figure out why the developers decided to use the "updlock" hint on many of the update and insert statements. I have looked around everywhere and have found only one explanation of why "update...with
    (updlock)" can be useful, namely when a table has no clustered index:
    http://www.sqlnotes.info/2012/10/10/update-with-updlock/ I have found nothing yet that mentions why "insert into...with (updlock)" might be used. I understand why the hint
    might be useful on select statements in some cases, but if all of the tables have clustered indexes, is there any good reason to use it on update and insert statements?
    Thanks,
    Ron
    Ron Rice

    This form of deadlock error can occur on a table which has a clustered index.
    If you are doing updates on a table which has a clustered index and that table also has a nonclustered index and the nonclustered index is used to find the row to update you can see this type of deadlock.  For example create a table with a clustered
    primary key index and a nonclustered index by running
    Create Table Foo(PK int primary key identity, OtherKey varchar(10), OtherData int);
    go
    Insert Foo Default Values;
    go 10000
    Update Foo Set OtherKey = 'C' + Cast(PK As varchar(10))
    Create Unique Index FooIdx On Foo(OtherKey);
    That creates a table with 10000 rows, a clustered index and a nonclustered index.  Then run
    Begin Transaction
    Update Foo Set OtherData = 1 Where OtherKey = 'C5'
    That will use the FooIdx index to find the row that needs to be updated.  It will get a U lock on the index row in the FooIdx index, then an X lock on the row in the clustered index, update that row, then free the U lock on FooIdx, but keep the X lock
    on the row in the clustered index.  (There is other locking going on, but to simplify things, I'm only showing the locks that lead to the deadlock).
    Then in another window, run
    Begin Transaction
    Update Foo Set OtherData = 2 Where OtherKey = 'C5'
    This will get a U lock on the index row in the FooIdx index, then try to get an X lock on the row in the clustered index.  But that row is already exclusively locked, so this second window will wait holding a U lock on FooIdx row and is waiting for
    an X lock on the clustered index row.
    Now go back to the first window and run
    Update Foo Set OtherData = 3 Where OtherKey = 'C5'
    This will once again try to get the U lock on the FooIdx row, but it is blocked by the U lock the second window holds.  Of course the second window is blocked by the X lock on the clustered index row and you have a deadlock.
    All that said, I certainly do not routinely code my updates with UPDLOCK.  I try to design databases and write code so that deadlocks will be rare without holding excessive locks.  The more locks you hold and the longer you hold them, the more
    blocking you will get and the slower your system will run.  So I write code that if a deadlock exception occurs, it is properly handled.  Then if too many deadlocks occur, that is the time to go back to the code to see what changes are needed to
    decrease the number of deadlocks (one way to do that may be to get locks earlier and/or hold them longer. 
    But I wouldn't worry much about this form of deadlock.  It is, in my experience, vary rare.  I don't recall ever seeing it in a production environment.
    Tom

  • Many child cursors on an insert statement

    Oracle: 10.2.0.5
    Cursor_sharing = exact
    I understand how you get many child cursors with cursor sharing set to exact. However, this is an insert statement. It has a plan_hash_value = 0 and there are not any explain plans in v$sql_plan.
    They all have the parsing_schema_name = 'GWYDB'
    This is not an issue with multiple copies of the same table in different schemas since the statement has <owner>.<table name>
    this is a 1 line insert statement.
    insert into schema.mytablue values (:b1.:b2,:b3);

    Guess2 wrote:
    Oracle: 10.2.0.5
    Cursor_sharing = exact
    I understand how you get many child cursors with cursor sharing set to exact. However, this is an insert statement. It has a plan_hash_value = 0 and there are not any explain plans in v$sql_plan.
    They all have the parsing_schema_name = 'GWYDB'
    This is not an issue with multiple copies of the same table in different schemas since the statement has <owner>.<table name>
    this is a 1 line insert statement.
    insert into schema.mytablue values (:b1.:b2,:b3);Oracle ERROR indicates something need to change.
    post SQL & error code and message that needs to be fixed.

  • How to use the structure on my insert statement.

    I have a function and returning a structure:
    <CFSET stLoc_and_AttIDs=StructNew(1)>
    <CFSET
    stLoc_and_AttIDs["LocID"]="#getLocID.LocationID#">
    <CFSET
    stLoc_and_AttIDs["AttID"]="#getLocID.AttachmentID#">
    I call this function like this:
    <CFSET LocAndAttIDs= MyFunction(LocName)>
    I'm having difficulty in refering to the values of this
    structure in my insert statement:
    I'm doing it this way and got error, I'm sure I didn't do it
    right, please help.
    Insert Into MyTable (Column1, Column2, Column3, .....)
    VALUES (#LocAndAttIDs.stLoc_and_AttIDs["LocID"]="#,
    #LocAndAttIDs.stLoc_and_AttIDs["AttID"], 23)

    is that the actual code? if so, it looks like your # aren't
    matched up properly. for example, i count 3. there should be an
    even number :)
    you don't seem to have a closing # after the 2nd variable,
    and the closing # for the first variable seems to be a little....
    late. it should be after the closing bracket ( ] ), since that's
    where the variable name ends.

  • RE: insert statement runs twice in place of once Randomly

    Hi
    I am using a simple nsert statement .The insert statement picks a variable
    from the form and inserts it into the database
    I have no loops in the page
    the code is :
    <cfif isdefined("Form.Category")>
    <cfquery name="InsertCat" datasource="ShoppingCart">
    Insert Into ShoppingMstCategory(Category)
    Values '#Form.Category#')
    </cfquery>
    </cfif>
    The insert runs twice on its own.
    Though if I use Query analyser to insert the statement only inserts once.
    am I missing something. I am using CF 10

    ColdFusion is behaving exactly as it should. When the form is submitted, the variables form.category and form.categoryEdit are both defined. In other words, isdefined("Form.Category") and isdefined("Form.CategoryEdit") are both true. Hence, the if-block as well as the else-block will run.

  • Re: insert statement runs twice in place of once

    I am using a insert statement.The insert statement picks a variable
    from the form and inserts it into the database
    I have no loops in the page the code is :
    <cfif isdefined("Form.Category")>
    <cfquery name="InsertCat" datasource="ShoppingCart">
    Insert Into ShoppingMstCategory(Category)
    Values('#Form.Category#')
    </cfquery>
    </cfif>
    The insert runs twice on its own.
    Though if I use Query analyser to insert the statement only inserts once.
    am I missing something. I am using CF10.
    Here's the whole page.
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>cat update</title>
    </head>
    <body>
    <cfif isdefined("Form.Category")>
    <cfquery name="InsertCat" datasource="ShoppingCart">
    Insert Into ShoppingMstCategory(Category)
    Values('#Form.Category#')
    </cfquery>
    <cfelse>
    <cfif isdefined("Form.CategoryEdit")>
    <cfquery datasource="Shoppingcart">
    UPDATE ShoppingMstCategory
    SET
    [Category] = '#Form.Category#'
    WHERE CategoryID = #Form.EditId#
    </cfquery>
    </cfif>
    </cfif>
    </body>
    </html>

    ColdFusion is behaving exactly as it should. When the form is submitted, the variables form.category and form.categoryEdit are both defined. In other words, isdefined("Form.Category") and isdefined("Form.CategoryEdit") are both true. Hence, the if-block as well as the else-block will run.

  • Slow performance on Insert Statement

    Hi All,
    I realize my question is going to be very general....what I am looking for is someone to look at my insert statement below and pick out any inefficiencies or potential improvement points. I'm doing an insert into a very large table already but my insert statement is taking an extremely long time and I've had to cancel it a few times. Table A in the "From" clause has about 500 million records while Table B has about 350 million records. Table C is just a small reference table that I link to to pull a description column for a code. I have all the necessary indexes on the tables, specifically on the columns in the join clauses. I'm using an insert with append hint and the table is set to NOLOGGING. I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.5.0. If anyone has options on how to improve performance it would be much appreciated. Here's the Insert Statement below:
    insert /*+append */ into crg_edc_prevalence_raw
    select
    A.CRG_INPUT_REC_FISCAL_YR as fiscal_year,
    A.CRG_INPUT_REC_IDENTIFIER as phn,
    is_date(substr(a.crg_input_rec,13,8),'yyyymmdd') as date_of_encounter,
    decode(A.CRG_INPUT_REC_SRC,'CPIRUDBA.AHS_IP_DOCTOR_DX','Inpatient','Outpatient') as inpatient_outpatient_flag,
    ltrim(rtrim(substr(a.crg_input_rec,2,7))) as diag_cd,
    B.EDC_EPC as edc_CD,
    c.EDC_DESCRIPTION as edc_desc,
    C.EDC_AGG_CD,
    c.EDC_AGG_DESC as edc_agg_desc,
    a.crg_input_rec as m_record,
    ltrim(rtrim(substr(a.crg_input_rec,9,1))) as medical_cd_type,
    A.CRG_INPUT_REC_SEQ as sequence_number,
    A.CRG_METHOD_DIMR_1,
    A.CRG_METHOD_DIMR_2,
    A.CRG_METHOD_AHW_3
    from CRG_INPUT_FINAL_MASTER a,
         CRG_OUTPUT_R_RECORD_FINAL b,
        (SELECT EDC_CD,EDC_DESCRIPTION,EDC_AGG_CD,EDC_AGG_DESC FROM CRG_DIAG_EDC_REF GROUP BY EDC_CD,EDC_DESCRIPTION,EDC_AGG_CD,EDC_AGG_DESC) c
    where  A.CRG_INPUT_REC_SEQ = B.CRG_OUTPUT_R_REC_SEQ_MLINK
       and A.CRG_INPUT_REC_FISCAL_YR = B.FYE;
       and B.EDC_EPC = c.edc_cd(+)
       and A.CRG_INPUT_REC_SHORT_DESC = 'DIAGNOSIS'
       and b.fye = '201112';Thanks,
    Ed

    Try predicate pushing if that might substantially reduce the number of rows (maybe not both as shown here)
    insert /*+ append */
      into crg_edc_prevalence_raw
    select a.crg_input_rec_fiscal_yr as fiscal_year,
           a.crg_input_rec_identifier as phn,
           is_date(substr(a.crg_input_rec,13,8),'yyyymmdd') as date_of_encounter,
           a.inpatient_outpatient_flag,
           a.diag_cd,
           b.edc_epc as edc_cd,
           c.edc_description as edc_desc,
           c.edc_agg_cd,
           c.edc_agg_desc as edc_agg_desc,
           a.m_record,
           a.medical_cd_type,
           a.sequence_number,
           a.crg_method_dimr_1,
           a.crg_method_dimr_2,
           a.crg_method_ahw_3
      from (select crg_input_rec_seq,
                   crg_input_rec_fiscal_yr,
                   crg_input_rec_identifier,
                   substr(crg_input_rec,13,8) as maybe_date_of_encounter,
                   case crg_input_rec_src when 'CPIRUDBA.AHS_IP_DOCTOR_DX'
                                          then 'Inpatient'
                                          else 'Outpatient'
                   end as inpatient_outpatient_flag,
                   trim(substr(crg_input_rec,2,7)) as diag_cd,
                   crg_input_rec as m_record,
                   trim(substr(crg_input_rec,9,1)) as medical_cd_type,
                   crg_input_rec_seq as sequence_number,
                   crg_method_dimr_1,
                   crg_method_dimr_2,
                   crg_method_ahw_3
              from crg_input_final_master
             where crg_input_rec_short_desc = 'DIAGNOSIS'
           ) a,
           (select crg_output_r_rec_seq_mlink,
                   fye,
                   edc_epc,
              from crg_output_r_record_final
             where fye = '201112'
           ) b,
           (select edc_cd,
                   edc_description,
                   edc_agg_cd,
                   edc_agg_desc
              from crg_diag_edc_ref
             group by edc_cd,edc_description,edc_agg_cd,edc_agg_desc
           ) c
    where a.crg_input_rec_seq = b.crg_output_r_rec_seq_mlink
       and a.crg_input_rec_fiscal_yr = b.fye;
       and b.edc_epc = c.edc_cd(+)Regards
    Etbin
    Edited by: Etbin on 5.6.2013 19:15
    Oops! Should have checked before posting.

  • Relation between record in a form and insert statement written in button

    hi all,
    i am using Forms [32 Bit] Version 6.0.8.24.1 (Production).
    i have a master detail form with relation
    A is master of B, B is master of C and a button which resides on control block(other than A,B,C).
    so i will insert a one record into the block 'A' and i will press button which will insert particular record into particular table.
    so when i try to move to next record('A' block) it is asking for database change. when i give 'yes' everything is ok. but when i give 'no'(w.r.t that record) and moves to next record and inserts the record and insert record throguh button also, at this time user press 'yes' then the first record is not saving but what ever i have inserted through the insert statement is not rolling back.
    How can i control insert statement with the respect to datablock change in the block.
    The block 'C' data is going to the other table through insert statement the block 'C' i am posting. So due to 'post' the block is not getting cleared so insert statement is also firing.
    In other words i want to unpost the posted data when user press 'no' in the database message.
    I know there is nothing to do with the forms message. But is its possible to control when user press 'no' then the insert statement should not gets saved into the table.
    Please help.
    Thanks..
    Edited by: GD on Jun 27, 2011 5:38 AM

    First off, you need to understand how Oracle Forms interacts with an Oracle database. Forms natively handles all DML transactions for you. Meaning, if you have a Forms data block based on a database table, Forms will generate all the necessary DML to handle any changes that occur in that block. You do not need to write your own DML statements in code.
    so i will insert a one record into the block 'A' and i will press button which will insert particular record into particular table.Is Block "A" based on a table? How are you inserting the record into the table? If you are writting your own DML to insert the record this would explain why you are being prompted to save when you change records. As I mentioned, if your block is based on a table, Forms will know if you change a value within the block.
    How can i control insert statement with the respect to datablock change in the block.If your blocks are based on tables, let Forms handle the DML! don't do it yourself.
    In other words i want to unpost the posted data when user press 'no' in the database messageIf your block is based on a table, when you are prompted to save changes - answering 'NO' will automatically clear the current record of the data block (in essence - rollback the change).
    Craig...

  • Exception handling for all the insert statements in the proc

    CREATE PROCEDURE TEST (
    @IncrStartDate DATE
    ,@IncrEndDate DATE
    ,@SourceRowCount INT OUTPUT
    ,@TargetRowCount INT OUTPUT
    ,@ErrorNumber INT OUTPUT
    ,@ErrorMessage VARCHAR(4000) OUTPUT
    ,@InsertCase INT --INSERT CASE INPUT
    WITH
    EXEC AS CALLER AS
    BEGIN --Main Begin
    SET NOCOUNT ON
    BEGIN TRY
    DECLARE @SuccessNumber INT = 0
    ,@SuccessMessage VARCHAR(100) = 'SUCCESS'
    ,@BenchMarkLoadFlag CHAR(1)
    ,@BenchmarkFlow INT
    ,@MonthYearStart DATE
    ,@MonthYearEnd DATE
    ,@StartDate DATE
    ,@EndDate DATE
    /* Setting the default values of output parameters to 0.*/
    SET @SourceRowCount = 0
    SET @TargetRowCount = 0
    /*Setting the Start and end date for looping */
    SET @MonthYearStart = @IncrStartDate;
    SET @MonthYearEnd = @IncrEndDate;
    /* Setting the @InsertCase will ensure case wise insertion as this sp will load data in different tables
    @InsertCase =0 means data will be inserted in the target TAB1
    @InsertCase =1 means data will be inserted in the target TAB2
    @InsertCase =2 means data will be inserted in the target TAB3
    @InsertCase =3 means data will be inserted in the target TAB4
    @InsertCase =4 means data will be inserted in the target TAB5
    @InsertCase =5 means data will be inserted in the target TAB6
    if @InsertCase =0
    WHILE (@MonthYearStart <= @MonthYearEnd)
    BEGIN
    SET @StartDate = @MonthYearStart;
    SET @EndDate = @MonthYearEnd;
    /* Delete from target where date range given from input parameter*/
    DELETE FROM TAB1
    WHERE [MONTH] BETWEEN MONTH(@StartDate) AND MONTH(@EndDate)
    AND [YEAR] BETWEEN year(@StartDate) and year(@EndDate)
    /*Insert data in target-TAB1 */
    BEGIN TRANSACTION
    INSERT INTO TAB1
    A,B,C
    SELECT
    A,BC
    FROM XYZ
    COMMIT TRANSACTION
    SET @MonthYearStart = DATEADD(MONTH, 1, @MonthYearStart)
    SELECT @TargetRowCount = @TargetRowCount + @@ROWCOUNT;
    END -- End of whileloop
    END TRY
    BEGIN CATCH
    IF @@TRANCOUNT>0
    ROLLBACK TRANSACTION
    SELECT @ErrorNumber = ERROR_NUMBER() ,@ErrorMessage = ERROR_MESSAGE();
    END CATCH
    END--End of Main Begin
    I have the above proc inserting data based on parameters  where in @InsertCase  is used for case wise execution.
     I have written the whole proc with exception handling using try catch block.
    I have just added one insert statement here for 1 case  now I need to add further insert  cases
    INSERT INTO TAB4
                    A,B,C
    SELECT
                                    A,BC
    FROM XYZ
    INSERT INTO TAB3
                    A,B,C
    SELECT
                                    A,BC
    FROM XYZ
    INSERT INTO TAB2
                    A,B,C
    SELECT
                                    A,BC
    FROM XYZ
    I will be using following to insert further insert statements 
    if @InsertCase =1 
    I just needed to know where will be my next insert statement should be fitting int his code so that i cover exception handling for all the code
    Mudassar

    Hi Erland & Mudassar, I have attempted to recreate Mudassar's original problem..here is my TABLE script;
    USE [MSDNTSQL]
    GO
    /****** Object: Table [dbo].[TAB1] Script Date: 2/5/2014 7:47:48 AM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[TAB1](
    [COL1] [nvarchar](1) NULL,
    [COL2] [nvarchar](1) NULL,
    [COL3] [nvarchar](1) NULL,
    [START_MONTH] [int] NULL,
    [END_MONTH] [int] NULL,
    [START_YEAR] [int] NULL,
    [END_YEAR] [int] NULL
    ) ON [PRIMARY]
    GO
    Then here is a CREATE script for the SPROC..;
    USE [MSDNTSQL]
    GO
    /****** Object: StoredProcedure [dbo].[TryCatchTransactions1] Script Date: 2/5/2014 7:51:33 AM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[TryCatchTransactions1] (
    @IncrStartDate DATE
    ,@IncrEndDate DATE
    ,@SourceRowCount INT OUTPUT
    ,@TargetRowCount INT OUTPUT
    ,@ErrorNumber INT OUTPUT
    ,@ErrorMessage VARCHAR(4000) OUTPUT
    ,@InsertCase INT --INSERT CASE INPUT
    WITH
    EXEC AS CALLER AS
    BEGIN --Main Begin
    SET NOCOUNT ON
    BEGIN TRY
    DECLARE @SuccessNumber INT = 0
    ,@SuccessMessage VARCHAR(100) = 'SUCCESS'
    ,@BenchMarkLoadFlag CHAR(1)
    ,@BenchmarkFlow INT
    ,@MonthYearStart DATE
    ,@MonthYearEnd DATE
    ,@StartDate DATE
    ,@EndDate DATE
    /* Setting the default values of output parameters to 0.*/
    SET @SourceRowCount = 0
    SET @TargetRowCount = 0
    /*Setting the Start and end date for looping */
    SET @MonthYearStart = @IncrStartDate;
    SET @MonthYearEnd = @IncrEndDate;
    /* Setting the @InsertCase will ensure case wise insertion as this sp will load data in different tables
    @InsertCase =0 means data will be inserted in the target TAB1
    @InsertCase =1 means data will be inserted in the target TAB2
    @InsertCase =2 means data will be inserted in the target TAB3
    @InsertCase =3 means data will be inserted in the target TAB4
    @InsertCase =4 means data will be inserted in the target TAB5
    @InsertCase =5 means data will be inserted in the target TAB6
    IF @InsertCase =0
    WHILE (@MonthYearStart <= @MonthYearEnd)
    BEGIN
    SET @StartDate = @MonthYearStart;
    SET @EndDate = @MonthYearEnd;
    /* Delete from target where date range given from input parameter*/
    DELETE FROM TAB1
    WHERE START_MONTH BETWEEN MONTH(@StartDate) AND MONTH(@EndDate)
    AND START_YEAR BETWEEN year(@StartDate) and YEAR(@EndDate)
    /*Insert data in target-TAB1 */
    BEGIN TRANSACTION
    INSERT INTO TAB1 (COL1,COL2,COL3)
    VALUES ('Z','X','Y')
    SELECT COL1, COL2, COL3
    FROM TAB1
    COMMIT TRANSACTION
    SET @MonthYearStart = DATEADD(MONTH, 1, @MonthYearStart)
    SELECT @TargetRowCount = @TargetRowCount + @@ROWCOUNT;
    END -- End of whileloop
    END TRY
    BEGIN CATCH
    IF @@TRANCOUNT > 0
    ROLLBACK TRANSACTION
    SELECT @ErrorNumber = ERROR_NUMBER() ,@ErrorMessage = ERROR_MESSAGE();
    END CATCH
    PRINT @SUCCESSMESSAGE
    END--End of Main Begin
    GO
    I am just trying to help --danny rosales
    UML, then code

  • Using sqlerrm in insert statement in 10g

    Hi,
    I do not have 10g to test the following snippet, which tries to use sqlerrm in an insert statement:
    -- start testcase
    drop table tbl;
    drop table err;
    create table tbl (x number);
    create table err (a number, b varchar2(4000));
    declare
      n_tmp   tbl.x%type;
    begin
      select x into n_tmp from tbl;
    exception
      when others then
        -- the line below works in 9i
        -- dbms_output.put_line('Sqlerrm: '||sqlerrm);
        -- but the insert statement doesn't work in 9i, how about 10g ?
        insert into err(a,b) values (1,sqlerrm);
        commit;
    end;
    declare
      n_tmp   tbl.x%type;
    begin
      select x into n_tmp from tbl;
    exception
      when others then
        -- the line below works in 9i
        -- dbms_output.put_line('Sqlerrm: '||sqlerrm);
        -- the insert statement works in 9iR2 but the error message is
        -- not the one sought, how about 10g ?
        insert into err(a,b) values (1,sys.standard.sqlerrm);
        commit;
    end;
    /Can someone test it on any release/edition of 10g please ?
    The tests on 9iR2 below behave predictably:
    SQL>
    SQL> @ver
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE    9.2.0.8.0       Production
    TNS for Solaris: Version 9.2.0.8.0 - Production
    NLSRTL Version 9.2.0.8.0 - Production
    SQL>
    SQL>
    SQL> -- start testcase
    SQL> drop table tbl;
    Table dropped.
    SQL> drop table err;
    Table dropped.
    SQL>
    SQL> create table tbl (x number);
    Table created.
    SQL> create table err (a number, b varchar2(4000));
    Table created.
    SQL>
    SQL> declare
      2    n_tmp   tbl.x%type;
      3  begin
      4    select x into n_tmp from tbl;
      5  exception
      6    when others then
      7      -- the line below works in 9i
      8      -- dbms_output.put_line('Sqlerrm: '||sqlerrm);
      9      -- but the insert statement doesn't work in 9i, how about 10g ?
    10      insert into err(a,b) values (1,sqlerrm);
    11      commit;
    12  end;
    13  /
        insert into err(a,b) values (1,sqlerrm);
    ERROR at line 10:
    ORA-06550: line 10, column 36:
    PL/SQL: ORA-00984: column not allowed here
    ORA-06550: line 10, column 5:
    PL/SQL: SQL Statement ignored
    SQL>
    SQL> --
    SQL> declare
      2    n_tmp   tbl.x%type;
      3  begin
      4    select x into n_tmp from tbl;
      5  exception
      6    when others then
      7      -- the line below works in 9i
      8      -- dbms_output.put_line('Sqlerrm: '||sqlerrm);
      9      -- the insert statement works in 9iR2 but the error message is
    10      -- not the one sought, how about 10g ?
    11      insert into err(a,b) values (1,sys.standard.sqlerrm);
    12      commit;
    13  end;
    14  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from err;
             A B
             1 ORA-0000: normal, successful completion
    SQL>
    SQL>The behavior of the second pl/sql block was mentioned by Nicolas:
    Re: INSERT INTO ..VALUES (SQLERRM, SQLCODE, SYSDATE) doesn't work?
    Is there any change in 10g ?
    Thanks in advance,
    pratz
    (Sorry, the hyperlink is getting modified automatically; remove the backslash ("\") immediately before the ampersand ("&") character.)
    Message was edited by:
    pratz

    Same in 10.2.0.3.0
    SQL*Plus: Release 10.1.0.4.2 - Production on Thu Jan 24 11:55:53 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> drop table tbl;
    Table dropped.
    SQL>
    SQL> drop table err;
    Table dropped.
    SQL> 
    SQL> create table tbl (x number);
    Table created.
    SQL>
    SQL> create table err (a number, b varchar2(4000));
    Table created.
    SQL> declare 
      2  n_tmp   tbl.x%type;
      3  begin  select x into n_tmp from tbl;
      4  exception  when others then  
      5  -- the line below works in 9i    
      6  --dbms_output.put_line('Sqlerrm: '||sqlerrm);   
      7  -- but the insert statement doesn't work in 9i, how about 10g ?   
      8  insert into err(a,b) values (1,sqlerrm);   
      9  commit;
    10  end;
    11  /
    insert into err(a,b) values (1,sqlerrm);
    ERROR at line 8:
    ORA-06550: line 8, column 32:
    PL/SQL: ORA-00984: column not allowed here
    ORA-06550: line 8, column 1:
    PL/SQL: SQL Statement ignored
    SQL>  declare 
      2   n_tmp   tbl.x%type;
      3   begin 
      4   select x into n_tmp from tbl;
      5   exception  when others then   
      6   -- the line below works in 9i    
      7   --dbms_output.put_line('Sqlerrm: '||sqlerrm);   
      8   -- the insert statement works in 9iR2 but the error message is    -- not the one sought, how a
    bout 10g ?    i
      9   insert into err(a,b) values (1,sys.standard.sqlerrm);   
    10   commit;
    11   end;
    12   /
    PL/SQL procedure successfully completed.
    SQL> select * from err;
             A
    B
             1
    ORA-0000: normal, successful completion
    SQL>

  • Using 1million insert statement to create a table

    Dear Expert;
    Lets say someone sent you about 2 million insert statements and you want to use them to insert into a table or create a new table...How do you go about doing so...
    because I tried just highlighting all the insert statement and executing them, however that didnt work in pl/sql developer, it was crashing everytime I did so
    The other way might be to create a loop for them and inserting about 10,000 at a time...but is there a faster way to do it...
    All help is appreciated it..

    user13328581 wrote:
    Dear Expert;
    Lets say someone sent you about 2 million insert statements and you want to use them to insert into a table or create a new table...How do you go about doing so...
    because I tried just highlighting all the insert statement and executing them, however that didnt work in pl/sql developer, it was crashing everytime I did soDo it in SQL*PLUS. It can handle such large files.
    And let it run at night so that other users are not influenced that much by your session.
    You might want to add very few commits somewhere in between. However in case something breaks you then need to know which insert was still executed and which one one.

  • Plsql insert statement.  urgent help needed

    Hi all oracle gurus
    I am trying to insert a value which is difference between two dates, for that reason i am doing (" rec_jag_promos.end_date -rec_jag_promos.start_date") inside my insert statement.
    but it is not working. my plsql code is running but not giving me any o/p.
    Here what i am trying to do is i want to insert DAYS value into my table which is between start date and end date.
    ........its not working . please guide me or correct me.
    Below is part of my querry ........
    Thanks
    -- migrate data
    FOR rec_jag_promos IN cur_jag_promos
    LOOP
    v_jag_count := v_jag_count + 1;
    BEGIN
    v_wots_hot_id := rec_jag_promos.promotion_id;
    -- this call will throw and exception 0 or many regions found
    v_region_id := get_region_id( rec_jag_promos.promotion_id, rec_jag_promos.region_display_type );
    INSERT INTO wotif_promo.WOTS_HOT
    ( id, country_code,
    start_date, end_date,inventory_source_id,hotel_id,
    rate_plan_code,region_id,blurb, modified_username,
    version,DAYS_ACTIVE )
    VALUES
    ( v_wots_hot_id, rec_jag_promos.country_code,
    rec_jag_promos.start_date, rec_jag_promos.end_date,v_inv_source_id,rec_jag_promos.hotel_id,
    rec_jag_promos.rate_plan_code, v_region_id, rec_jag_promos.blurb, rec_jag_promos.modified_username,
    1, rec_jag_promos.end_date-rec_jag_promos.start_date);
    v_wots_hot_inserts := v_wots_hot_inserts + 1;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT Insert Error on wots_hot_id : ' || rec_jag_promos.wots_hot_id );
    DBMS_OUTPUT.PUT_LINE( SQLCODE || ' ' || SQLERRM );
    v_wots_hot_errs := v_wots_hot_errs + 1;
    END;

    I am trying to insert a value which is difference between two dates, for that reason i am doing (" rec_jag_promos.end_date -rec_jag_promos.start_date") inside my insert statement.
    ........its not working . please guide me or correct me.
    Below is my file ........
    Thanks
    DECLARE
    -- cursors
    CURSOR cur_inventory_source IS
    select id
    from wotif_common.inventory_source
    where SHORT_DESCRIPTION = 'wotif';
    CURSOR cur_jag_promos IS
    select wh.id as wots_hot_id, p.id as promotion_id, cty.iso_countrycode as country_code,
    wh.blurb, dm.propid as hotel_id,
    p.startdts as START_DATE, p.expirydts as END_DATE,
    wa.username as modified_username, rt.roomtypecode as rate_plan_code,
    dm.dealdate as hot_date, dm.advertisedrate as price,
    wh.REGIONDISPLAYTYPE as region_display_type
    from wotif_web.PROM_wots_hot wh
    join wotif_web.PROMOTION p on wh.promotionid=p.id
    join wotif_web.country cty on p.countrycode=cty.countrycode
    join wotif_web.deal_master dm on wh.dealid=dm.dealid
    join wotif_web.prop_master_room_type rt on rt.proproomtypeid=dm.proproomtypeid
    join wotif_web.wotif_administrator wa on p.adminid = wa.administratorid
    where p.expirydts < trunc(sysdate) ---> TRUNC(sysdate)
    order by wh.id;
    -- variables
    v_debug BOOLEAN := FALSE;
    v_nls_length_semantics VARCHAR2(255);
    v_jag_count INTEGER := 0;
    v_inv_source_id WOTIF_COMMON.INVENTORY_SOURCE.ID%TYPE;
    v_wots_hot_id WOTIF_PROMO.WOTS_ON.ID%TYPE;
    v_wots_hot_day_id WOTIF_PROMO.WOTS_ON_DAY.ID%TYPE;
    v_wots_hot_inserts INTEGER := 0;
    v_wots_hot_day_inserts INTEGER := 0;
    v_wots_hot_errs INTEGER := 0;
    v_wots_hot_rate_plan_errs INTEGER := 0;
    v_wots_hot_day_errs INTEGER := 0;
    v_region_id wotif_promo.WOTS_HOT.region_id%TYPE;
    -- variables
    FUNCTION get_region_id
    p_promotion_id IN wotif_web.PROMOTION.id%TYPE,
    p_region_type_enum IN wotif_web.PROM_WOTS_HOT.regiondisplaytype%TYPE
    ) RETURN NUMBER
    IS
    CURSOR cur_sub_region
    p_promotion_id IN wotif_web.PROMOTION.id%TYPE,
    p_region_type IN wotif_web.PROPERTY_REGION.region_type%TYPE
    ) IS
    select reg.region_id as REGION_ID
    from wotif_web.PROM_WOTS_HOT wh
    join wotif_web.PROPERTY_REGION reg on wh.propid = reg.prop_id
    where wh.promotionid = p_promotion_id
    and reg.region_type = p_region_type;
    CURSOR cur_region
    p_promotion_id IN wotif_web.PROMOTION.id%TYPE,
    p_region_type IN wotif_web.PROPERTY_REGION.region_type%TYPE
    ) IS
    select NVL(reg.parent_id, reg.id) as REGION_ID
    from wotif_web.PROM_WOTS_HOT wh
    join wotif_web.PROPERTY_REGION prop_reg on wh.propid = prop_reg.prop_id
    join wotif_web.region reg on prop_reg.region_id = reg.id
    where wh.promotionid = p_promotion_id
    and prop_reg.region_type = p_region_type;
    v_region_id wotif_web.PROPERTY_REGION.region_id%TYPE;
    BEGIN
    -- if region A
    IF p_region_type_enum = 0
    THEN
    OPEN cur_region( p_promotion_id, 'A' );
    FETCH cur_region INTO v_region_id;
    CLOSE cur_region;
    END IF;
    -- if region B
    IF p_region_type_enum = 2
    THEN
    OPEN cur_region( p_promotion_id, 'B' );
    FETCH cur_region INTO v_region_id;
    CLOSE cur_region;
    END IF;
    -- if sub_region A
    IF p_region_type_enum = 1
    THEN
    OPEN cur_sub_region( p_promotion_id, 'A' );
    FETCH cur_sub_region INTO v_region_id;
    CLOSE cur_sub_region;
    END IF;
    -- if sub_region B
    IF p_region_type_enum = 3
    THEN
    OPEN cur_sub_region( p_promotion_id, 'B' );
    FETCH cur_sub_region INTO v_region_id;
    CLOSE cur_sub_region;
    END IF;
    RETURN v_region_id;
    END get_region_id;
    -- main block
    BEGIN -- outer block
    -- initialise
    DBMS_OUTPUT.enable( 1000000 );
    -- validate
    EXECUTE IMMEDIATE 'alter session set NLS_LENGTH_SEMANTICS = ''CHAR''';
    SELECT VALUE
    INTO v_nls_length_semantics
    FROM NLS_SESSION_PARAMETERS
    WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS';
    DBMS_OUTPUT.put_line('nls length semantics: ' || v_nls_length_semantics);
    IF v_nls_length_semantics 'CHAR' THEN
    RAISE_APPLICATION_ERROR( -20005, 'PROMO_MIGRATION ERROR: NLS_LENGTH_SEMANTICS set incorrectly');
    END IF;
    OPEN cur_inventory_source;
    FETCH cur_inventory_source INTO v_inv_source_id;
    CLOSE cur_inventory_source;
    DBMS_OUTPUT.put_line('v_inv_source_id: ' || v_inv_source_id);
    IF v_inv_source_id IS NULL THEN
    RAISE_APPLICATION_ERROR( -20005, 'PROMO_MIGRATION ERROR: v_inv_source_id not set');
    END IF;
    -- migrate data
    FOR rec_jag_promos IN cur_jag_promos
    LOOP
    v_jag_count := v_jag_count + 1;
    BEGIN
    v_wots_hot_id := rec_jag_promos.promotion_id;
    -- this call will throw and exception 0 or many regions found
    v_region_id := get_region_id( rec_jag_promos.promotion_id, rec_jag_promos.region_display_type );
    INSERT INTO wotif_promo.WOTS_HOT
    ( id, country_code,
    start_date, end_date,inventory_source_id,hotel_id,
    rate_plan_code,region_id,blurb, modified_username,
    version,DAYS_ACTIVE )
    VALUES
    ( v_wots_hot_id, rec_jag_promos.country_code,
    rec_jag_promos.start_date, rec_jag_promos.end_date,v_inv_source_id,rec_jag_promos.hotel_id,
    rec_jag_promos.rate_plan_code, v_region_id, rec_jag_promos.blurb, rec_jag_promos.modified_username,
    *1, rec_jag_promos.end_date -rec_jag_promos.start_date);*
    v_wots_hot_inserts := v_wots_hot_inserts + 1;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT Insert Error on wots_hot_id : ' || rec_jag_promos.wots_hot_id );
    DBMS_OUTPUT.PUT_LINE( SQLCODE || ' ' || SQLERRM );
    v_wots_hot_errs := v_wots_hot_errs + 1;
    END;
    -- insert single mandatory wots_hot_day
    BEGIN
    v_wots_hot_day_id := wotif_promo.wots_hot_day_seq.nextval;
    INSERT INTO wotif_promo.wots_hot_day
    ( id, wots_hot_id, hot_date, price )
    VALUES
    ( v_wots_hot_day_id, v_wots_hot_id, rec_jag_promos.hot_date, rec_jag_promos.price );
    v_wots_hot_day_inserts := v_wots_hot_day_inserts + 1;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT DAYS Insert Error on wots_hot_id : ' || rec_jag_promos.wots_hot_id );
    DBMS_OUTPUT.PUT_LINE( SQLCODE || ' ' || SQLERRM );
    v_wots_hot_day_errs := v_wots_hot_day_errs + 1;
    END;
    END LOOP; -- wots_hot loop
    DBMS_OUTPUT.PUT_LINE( 'Jaguar wots hot count ' || NVL( v_jag_count,0) );
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT' );
    DBMS_OUTPUT.PUT_LINE( 'inserts ' || NVL( v_wots_hot_inserts,0) );
    DBMS_OUTPUT.PUT_LINE( 'errors ' || NVL( v_wots_hot_errs,0) );
    DBMS_OUTPUT.PUT_LINE( ' ' );
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT_DAY' );
    DBMS_OUTPUT.PUT_LINE( 'inserts ' || NVL( v_wots_hot_day_inserts,0) );
    DBMS_OUTPUT.PUT_LINE( 'errors ' || NVL( v_wots_hot_day_errs,0) );
    DBMS_OUTPUT.PUT_LINE( ' ' );
    END; --outer block
    commit;
    select count(*) from wotif_promo.wots_hot;
    select count(*) from wotif_promo.wots_hot_day;
    select * from wotif_promo.wots_hot_day;
    --commit;
    --rollback;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.

    I have been looking at my code for hours now and cant figure out what is wrong. The error has kept popping up even when i thought i had fixed everything. maybe a second set of eyes could help me out here. If you could help me out it would be much appreciated.
    USE [ConorsSetKits]
    GO
    CREATE TABLE Customers (
    CustomerID Int NOT NULL IDENTITY(1000,1),
    LastName NChar(30) NOT NULL,
    FirstName NChar(30) NOT NULL,
    Address NChar(50) NOT NULL,
    City NChar(30) NOT NULL,
    State NChar(2) NOT NULL,
    Zip Numeric(5) NOT NULL,
    Email NVarChar(50) NOT NULL,
    DateOfBirth Numeric (4) NOT NULL,
    CONSTRAINT CustomersPK PRIMARY KEY(CustomerID),
    CONSTRAINT ValidZip
    CHECK ( [Zip] LIKE '[0-9][0-9][0-9][0-9][0-9]' ),
    CONSTRAINT ValidState
    CHECK( LEN([State]) = 2),
    CONSTRAINT DateOfBirth
    CHECK ([DateOfBirth] BETWEEN '1920-01-01' AND getdate() - 5844));
    CREATE TABLE Sets (
    SetID Int NOT NULL IDENTITY(1000,1) Primary Key,
    SetName NChar(20) NOT NULL,
    SetType NChar (20) NOT NULL,
    Price Numeric (20) NOT NULL,
    Quantity Numeric (50) NOT NULL,
    CONSTRAINT SetTypeCheck
    CHECK (SetType IN ('Planes','Tanks','Robots','Cars','Helicopters','Boats','Trains','Motorcycles','Jets')),
    CONSTRAINT ValidQuantity 
    CHECK (Quantity >= 0)
    CREATE TABLE Orders (
    OrderID Int NOT NULL IDENTITY(1000,1),
    CustomerID Int NOT NULL,
    OrderDate Date NOT NULL,
    CONSTRAINT CAIntPK PRIMARY KEY(OrderID, CustomerID),
    SET IDENTITY_INSERT dbo.CUSTOMER OFF
    SET IDENTITY_INSERT dbo.Sets OFF
    SET IDENTITY_INSERT dbo.Orders OFF
    SET IDENTITY_INSERT dbo.CUSTOMER ON
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1000, 'Janes', 'Jeffrey', '123 W. Elm St', 'Renton', 'WA', '98055',
    '[email protected]',1985);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1001, 'Smith', 'David', '813 Tumbleweed Lane', 'Loveland', 'CO', '81201', 
    '[email protected]',1992);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1015, 'Twilight', 'Tiffany', '88 1st Avenue', 'Langley', 'WA', '98260',
    '[email protected]',1972);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1033, 'Smathers', 'Fred', '10899 88th Ave', 'Bainbridge Island', 'WA', '98110',
    '[email protected]',1980);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1034, 'Frederickson', 'Mary Beth', '25 South Lafayette', 'Denver', 'CO', '80201',
    '[email protected]',1970);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1036, 'Warning', 'Selma', '205 Burnaby', 'Vancouver', 'BC', '80201',
    '[email protected]',1981);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1037, 'Wu', 'Susan', '105 Locust Ave', 'Atlanta', 'GA', '30322',
    '404', '653-3465', '[email protected]',1971);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1040, 'Gray', 'Donald','55 Bodega Ave', 'Bodega Bay', 'CA', '94923',
    '[email protected]',1985);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1041, 'Johnson', 'Lynda', '117 C Street', 'Washington', 'DC', '20003',
    '[email protected]',1969);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1051, 'Wilkens', 'Chris', '87 Highland Drive', 'Olympia', 'WA', '98508',
    '[email protected]',1994); 
    SET IDENTITY_INSERT dbo.CUSTOMER OFF
    SET IDENTITY_INSERT dbo.Sets ON
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1000, 'MysterySet1','Planes',$29.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1001, 'MysterySet2','Planes',$19.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1002, 'MysterySet4','Tanks',$39.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1003, 'MysterySet3','Robots',$19.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1004, 'MysterySet5','Cars',$29.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1005, 'MysterySet6','Boats',$29.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1006, 'MysterySet7','Trains',$39.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1007, 'MysterySet8','Motorcycles',$9.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1008, 'MysterySet9','Helicopters',$29.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1009, 'MysterySet10','Jets',$29.99,10);
    SET IDENTITY_INSERT dbo.Sets OFF
    SET IDENTITY_INSERT dbo.Orders ON
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1000, '2012-12-12');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1000, '2013-12-30');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1005, '2013-08-30');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1004, '2013-12-30');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1004, '2013-08-31');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1004, '2014-03-25');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1002, '2012-11-14');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1001, '2012-11-14');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1001, '2013-01-05');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1006, '2012-06-22');
    SET IDENTITY_INSERT dbo.Orders OFF

    Price Numeric (20) NOT NULL,
    I do not think you understand this datatype?  Go look at the values you are attempting to insert into this column.  For example, "$29.99".  After the insert, what value is actually stored in that column? 
    DateOfBirth Numeric (4) NOT NULL,
    No. Just No.  Either change the column name to faithfully represent what values you intend to store (and apply the appropriate constraints) or change the datatype and the values that you intend to store to match the column name.  And the constraint
    that you do have:
     CONSTRAINT DateOfBirth
     CHECK ([DateOfBirth] BETWEEN '1920-01-01' AND getdate() - 5844));
    is both logically suspect and syntactically wrong. First, the upper boundary will be computed as 1999-04-29 15:50:21.670.  But, of course, your column is a whole number of no more than 4 digits.  The same issue applies to your lower boundary. 
    A simple select statement will show you those errors
    select cast('1920-01-01' as numeric(4)), getdate() - 5844, cast(getdate() - 5844 as numeric(4));
    An insert statement fails with the same error.  Because, of course, your boundary values must actually be converted to numeric(4) in order to compare them against the value contained in the column.   Generally, you can convert from
    string to numeric - IF the content of the string actually contains a value that is numeric and can be converted into the specific type needed.  Not so in this case.  Is this 16 year period (5844 days) significant for some reason?  You should
    document it here in your DDL with a comment, because it is unlikely to be documented (and kept current) anywhere else. 
    And lastly, your script has:
    SET IDENTITY_INSERT dbo.CUSTOMER OFF
    That is not the name of your table, and therefore that statement also fails.  The table name you used is plural. 

  • SQL*Loader-930: Error parsing insert statement for column

    we upload data on daily basis in application throug apps user and these table are invloved
    1. DEV_RA_INTERFACE_LINES_ALL(owner is a apps)
    2.RA_INTERFACE_LINES_ALL(owner is a AR)
    we do steps
    1 delete record from DEV_RA_INTERFACE_LINES_ALL table
    2 delete record from      RA_INTERFACE_LINES_ALL table
    3 load data using sql loader with apps user
    4 insert in RA_INTERFACE_LINES_ALL table
    we want to change user i mean these step do dataupload user not apps
    we give the proper rights to dataupload like select,delete and insert rights on these table to dataupload user but when i going to load data throug sql loader we receive error
    SQL*Loader-930: Error parsing insert statement for column APPS.DEV_RA_INTERFACE_
    LINES_ALL.ORIG_SYSTEM_BILL_ADDRESS_ID.
    ORA-00904: "F_ORIG_SYSTEM_BILL_ADDR_REF": invalid identifier
    and if i insert data through apps then done.

    make sure that u have no speces left
    between lines.
    give the path of control file path correctly.

  • Record Group In Insert Statement

    Hi All,
    I am using Oracle 9i Ver 2 & Developer 6i on Windows platform. I want to ask, can we pass a Form's Record Group object to a select statement as a whole. I mean something like this,
    Suppose emp_rg is a Forms RecordGroup which has all the columns of scott.emp table & it contains 10 rows. So, can I write like this:
    INSERT INTO emp VALUES(emp_rg);
    Or anything like this, if this is wrong.
    Or, I need to create a PL/SQL record object & then I can pass. Pls clarify.
    Thanks in Advance,
    Inderjeet Singh

    Yes I often have trouble deciding whether to use a record group or a pl/sql table. They both have their own advantages in different situations. Manipulating record groups programatically requires rather more cumbersome syntax, but they do come with some handy built-ins (such as populate_group), and they also integrate with LOVs, Trees etc.
    If you want the pl/sql table to be available throughout the form you will need to declare it in a package spec.
    Even with a pl/sql table, you will need to write code to feed it into your insert statement. I reckon a global temporary table might allow the most straightforward syntax.

Maybe you are looking for