Insert into with problems

Hy,
i have a little question. Try this:
create table strangetab (
id varchar2(20),
textfield varchar2(200)
CREATE OR REPLACE PROCEDURE writestrangetab
id VARCHAR2,
textfield varchar2 default null)
IS
pragma autonomous_transaction;
BEGIN
INSERT INTO strangetab
(id, textfield
) VALUES
(id, textfield
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(sqlerrm);
rollback;
END;
After table and procedure creation, try to run this script (simple insert into in autonompus_transaction):
set serveroutput on
declare
vstr varchar2(10000);
begin
for i in 1..2000
loop
vstr := vstr||'r';
end loop;
dbms_output.put_line('write a');
writestrangetab( 'idx' , 'a');
dbms_output.put_line('write big string');
writestrangetab( 'idx' , vstr);
dbms_output.put_line('write b');
writestrangetab('idx' , 'b');
end;
The script generate this output:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
write a
write big string
ORA-12899: value too large for column "STRANGETAB"."TEXTFIELD" (actual:
2000, maximum: 200)
write b
As i expect, the second write goes wrong but first and third no and it put string a and b into srangetable.
Now try to run this:
set serveroutput on
declare
vstr varchar2(10000);
begin
for i in 1..5000
loop
vstr := vstr||'r';
end loop;
dbms_output.put_line('write a');
writestrangetab( 'idx' , 'a');
dbms_output.put_line('write big string');
writestrangetab( 'idx' , vstr);
dbms_output.put_line('write b');
writestrangetab('idx' , 'b');
end;
The only difference from the previous is the vstr dimension: first 2000 now 5000.
In my db (10.2.0.4 on linux) the output of this, is:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
write a
write big string
ORA-01461: can bind a LONG value only for insert into a LONG column
write b
ORA-01001: invalid cursor
If i query the strangetable i am non able to find string b (Only string a was registered)!
As if that were not enough, If you try to insert others writestrangetab, anything after wath that produce the error will be stored!
It is normal?
By
Stefano

Tanks for your reply Jhon, but:
1) "The second run you are trying to pass 5000 characters to a varchar, which caused your error when trying to call your procedure"
Why you say "which caused". When i call a procedure can't pass more than 4000 Chars? I know that pl/sql varchar2 is up to 32000 Chars even in procedure calls!
2) "That is why your cursor because invalid"
Witch cursor? The strange thing is that there isn't any cursor in the autonomous procedure! The anly statement is an insert into!
The problem of the second miss in the second run is ok: that wont register the string. The main problem is the miss of the third in the seconf run.
Why it not register the third writestrangetab? In that case i pass only a 'b' char. Writestarngetab Is an autonomous transaction so i expect a miss if it fail, but the next, if ok, will be registerd. why not?
By
Stefano

Similar Messages

  • Insert into with variables

    Hi!
    I've a procedure with a insert into phrase.
    For example:
    INSERT INTO type (NAME) values(A_CHA);
    type is not a table name it is a variable and name is not a column name it is also a variable.
    Can i make a insert into with variables?
    How is the right syntax?
    Thank's for help!
    Nicole

    Hi!
    I've found a way to do this:
    sql_statement:= 'INSERT INTO' || type_table || '('||NAME|| ',CABLE_NUM,FACILITY_NUM) values( '||A_CHA||','||CABLE_N||','||FAC_N||')';
    EXECUTE IMMEDIATE sql_statement;
    But when i execute my procedure i get the error:
    Keyword INTO is missing!
    Please help
    Nicole

  • INSERT INTO with SELECT invalid column name error

    I have a problem where I wish to update a table with only records that have changed or insert into a table with only new records. The Source table is queried using OPENQUERY as we have no staging db for this.
    I have the following code (adapted from a working example):
    INSERT INTO dbo.Contact
    SELECT contactID, lastUpdatedDateTime
    FROM
    MERGE INTO dbo.Contact AS DT
    USING (SELECT * FROM OPENQUERY(LINKED_SERVER,'SELECT contactID, lastUpdatedDateTime FROM Contact')) AS DS
    ON (DT.ContactID = DS.ContactID)
    WHEN NOT MATCHED THEN
    INSERT VALUES (DS.contactID, DS.lastUpdatedDateTime)
    WHEN MATCHED AND (DT.lastUpdatedDateTime <> DS.lastUpdatedDateTime) THEN
    UPDATE SET DT.contactID = DS.contactID, DT.lastUpdatedDateTime = DS.lastUpdatedDateTime
    OUTPUT $Action Action_Out
    AS MERGE_OUT
    WHERE MERGE_OUT.Action_Out = 'UPDATE';
    GO
    When I run this query I am getting the following errors referring to the columns in the SELECT:
    Msg 207, Level 16, State 1, Line 2
    Invalid column name 'contactID'.
    Msg 207, Level 16, State 1, Line 2
    Invalid column name 'lastUpdatedDateTime'.
    Am I missing something obvious as I can't quite work out why? The Target and source definitely exist with the specified columns present in both...

    Hello,
    The issue is because you are not outputting those values from the inner merge statement. All you are currently outputting is the action, so the error is correct as those columns do not exist.
    Change your output portion to be:
    OUTPUT inserted.contactID, inserted.lastUpdatedDateTime, $Action Action_Out
    Then it should work.
    Sean Gallardy | Blog | Microsoft Certified Master

  • INSERT INTO with SELECT CASE

    Hi all,
    I've this problem: insert into Table_A some values from Table_B... with one derivated/calculated filed.
    Example
    INSERT INTO Table_A (id_part, vendtype, origin, proven, desc)
    SELECT id_p, vendt, origin, proven, <calculate/derivated_field_desc>
    FROM Table_BThe rules for calculate the field desc inserted on Table_A are 1. IF vendt='V' AND origin='N' AND proven!='04' THEN ---> desc='TRANSFER'
    2. IF vendt='M' AND origin='N' AND proven!='04' THEN ---> desc='IMPORTED'
    3. IF proven='04' THEN ---> desc='BAD'So what I use in <calculate/derivated_field_desc> on my INSERT INTO statement??
    Can I use a SELECT CASE WHEN... or only DECODE is a right solution?
    Edited by: trebbia on 15-nov-2010 12.51

    Ok,
    I prefer use select case when... because trasform my rules in DECODE statement is more difficult
    So I write: INSERT INTO Table_A (id_part, vendtype, origin, proven, desc)
    SELECT id_p, vendt, origin, proven, SELECT CASE WHEN vendt='V' AND origin='N' AND proven!='04' THEN 'TRANSFER'
                                                    WHEN vendt='M' AND origin='N' AND proven!='04' THEN 'IMPORTED'
                                                    WHEN proven='04 THEN 'BAD'
                                                    END
    FROM Table_BObtain this error:
    40/56 PL/SQL: ORA-00936: missing expression
    33/1 PL/SQL: SQL Statement ignored
    PS: I use '<' '>' and not '!=' in my code... here not prompted correctly '<''>'
    Edited by: trebbia on 15-nov-2010 13.04
    Edited by: trebbia on 15-nov-2010 13.06

  • INSERT INTO  with Button

    Hi everyone.
    I'm working on my project for the faculty and I have one question.
    I want to insert comment into the table for comments.
    What should I do?
    Should I create Item or Page button.
    I now that i have to create a PL/SQL Page process.
    The comment table has ID column.
    How to make the process PL/SQL ( with INSERT INTO ) assign correct ID for the ID Column.
    Thanks in advance.

    Hi
    Please can you change your username so that we know who we're talking to.
    Also, can you pop an example on apex.oracle.com for me to have a look at.
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • Merge update insert into with exception

    I m opening a new thread for the same question i had posted earlier....
    create Table test(
    col1 varchar2(200),
    col2 varchar2(200),
    col3 varchar2(200),
    id varchar2(200),
    job_id varchar2(10)
    create Table test1(
    col1 varchar2(200),
    col2 varchar2(200),
    col3 varchar2(200),
    id varchar2(200),
    job_id varchar2(10)
    create Table test2(
    col1 varchar2(200),
    col2 varchar2(200),
    col3 varchar2(200),
    id varchar2(200),
    job_id varchar2(10)
    create Table err_tbl(
    col1 varchar2(200),
    col2 varchar2(200),
    col3 varchar2(200),
    id varchar2(200),
    job_id varchar2(10)
    ===============================================================
    merge into test t
    using (select distinct col1, col2, col3,id, job_id
    from test1
    where job_id = curr_job_id -- cur_job_id is variable which is declared in the procedure to sysdate
    union
    select distinct col1, col2, col3,id, job_id
    from test2
    where job_id = curr_job_id --cur_job_id is variable which is declared in the procedure to sysdate
    ) ss
    on (t.id = ss.id
    AND t.job_id = ss.job_id)
    when matched then update
    set t.col1 = ss.col1,
    t.col2 = ss.col2,
    t.col3 = ss.col3
    when not matched then insert into
    ( t.col1,
    t.col2,
    t.col3,
    t.id,
    t.job_id
    )Values
    ( ss.col1,
    ss.col2,
    ss.col3,
    ss.id,
    ss.jobid,
    exception
    when others then
    insert into err_tbl (
    col1,
    col2,
    col3,
    id,
    job_id )
    values ( ss.col1,
    ss.col2,
    ss.col3,
    ss.id,
    ss.jobid,
    Above, all i m trying to do is Updating or inserting into TEST table, and if there is any Duplicate records or any bad records then making use of exception i m INSERTING into ERR_TBL
    i get error with the merge insert update code ....
    The error i get is --- "ss.col1" column is not allowed here
    Any idea guys ????
    Hey one more quick question ....Can we use exception in merge insert update block ???

    user642297 wrote:
    I m opening a new thread for the same question i had posted earlier....
    Any idea guys ????
    Hey one more quick question ....Can we use exception in merge insert update block ???Did you learn nothing nothing from [Your other thread|http://forums.oracle.com/forums/thread.jspa?messageID=3810396&#3810396]
    (Maybe that's why you never bothered to close it)
    It looks like you did learn something, since you ended up saying
    Thanks alex...i think i got the answer.....so i cannot use exception handler in merge statement...
    Thank you so much!!!What beats me is that yu post the exact same question again, when you already got the answer
    ?:|
    Peter

  • UPDATE/INSERT INTO with Connection with access DB

    Hello,
    I am trouble getting the update statement working when connecting to my database. The "Select" statement works fine but i am using:
    result2= stmt2.executeUpdate("INSERT INTO Table1 VALUEs('1', '1')");
    and i get the error incompatiable types...found int but expected java.sql.resultset
    I am not sure what i am doing wrong. Can anyone help?

    since you're using Access, be sure to close both your Statement and the Connection you used after your INSERT/UPDATE. It's well known that changes won't show up in Access unless you do.
    %

  • Large insert into tables, problems with rollback

    I have applications that inserts or updates a large number of records. After each insert or update a commit is issued, it would release rollback area. But after some time running, i receive an error message about no space in rollback area. How can i force a write into disk to release rollback area ?
    Thanks.

    Sounds like your still running out of space in your rollback segment with your transaction being too big - as Oracle should always write the rollback segment to disk upon commit. What might help is to specify a rollback segment you want to use for the transaction or use the 'no logging' option - though this means you can't rollback - and if anything bad happens you can end up with an unhappy database. My suggestion would be to create a much larger rollback segment and pin the statement to that rollback segment, you can even switch the rollback segment on and off again just for this transaction.
    Hope that helps

  • Strange result from insert into...select query

    Hello guys,
    I need your preciuos help for a question maybe simple, but that I can't explain by myself!
    I have a query of "insert into...select" that, as I have explained in the title, returns a strange result. In facts, If I execute ONLY the SELECT statement the query returns the expected result (so 2 rows); instead If I execute the entire statement, that is the "insert into...select", the query returns 0 rows inserted!!
    Following an example of the query:
    INSERT
    INTO TITOLI_ORI
    COD_TITOLO_RICCONS ,
    D_ESTRAZIONE ,
    COD_SOCIETA ,
    COD_PIANO_CONTABILE ,
    COD_CONTO_CONTABILE ,
    COD_RUBRICATO_STATISTICO_1 ,
    COD_NDG ,
    NUM_ESEGUITO ,
    CUR_IMPORTO_RICCONS ,
    CUR_IMPORTO_BICO ,
    FLG_MODIFICATO ,
    CUR_NON_ASSEGNATO ,
    FLG_QUOTATO ,
    COD_CATEG ,
    TIP_COPERTURA ,
    TIPTAS_TITOLO
    SELECT NEWID,
    '28-feb-2111',
    COD_SOCIETA,
    COD_PIANO_CONTABILE,
    COD_CONTO_CONTABILE,
    COD_RUBRICATO_STATISTICO_1,
    COD_NDG,
    NUM_ESEGUITO,
    CUR_VAL_IMPEGNI,
    'ABC' as CUR_IMPORTO_BICO,
    0 as FLG_MODIFICATO,
    NULL as CUR_NON_ASSEGNATO,
    FLG_QUOTATO,
    COD_CATEG,
    TIP_COPERTURA,
    TIP_TASSO
    FROM
    (SELECT S.COD_SOC AS COD_SOCIETA,
    S.TIP_PIANO_CNTB AS COD_PIANO_CONTABILE,
    S.COD_CONTO_CNTB AS COD_CONTO_CONTABILE,
    S.COD_RUBR_STAT AS COD_RUBRICATO_STATISTICO_1,
    TRC.COD_RAGGR_IAS AS COD_RAGGRUPPAMENTO_IAS,
    TRC.COD_NDG AS COD_NDG,
    TRC.COD_ESEG AS NUM_ESEGUITO,
    CAST((TRC.IMP_PLUS_MINUS_VAL/TRC.IMP_CAMB) AS FLOAT) AS CUR_VAL_IMPEGNI,
    TRC.TIP_QUOTAZ AS FLG_QUOTATO,
    TRC.COD_CAT_TIT AS COD_CATEG,
    TIP_COP AS TIP_COPERTURA,
    T.TIP_TASSO AS TIP_TASSO
    FROM S_SLD_CNTB S
    INNER JOIN
    (SELECT DISTINCT COD_SOC,
    TIP_PIANO_CNTB,
    COD_CONTO_CNTB,
    COD_RUBR_STAT ,
    COD_INTER_TIT AS COD_INTER
    FROM S_COLLEG_CONTO_CNTB_TIT
    WHERE COD_SOC = 'ME'
    ) CCC
    ON S.COD_SOC = CCC.COD_SOC
    AND S.TIP_PIANO_CNTB = CCC.TIP_PIANO_CNTB
    AND S.COD_CONTO_CNTB = CCC.COD_CONTO_CNTB
    AND S.COD_RUBR_STAT = CCC.COD_RUBR_STAT
    INNER JOIN S_TIT_RICCONS TRC
    ON CCC.COD_INTER = TRC.COD_INTER_TIT
    AND CCC.COD_SOC = TRC.COD_SOC
    AND TRC.COD_RAGGR_IAS = RTRIM('VALUE1 ')
    AND TRC.COD_RAGGR_IAS NOT IN ('VALUE2')
    AND TRC.DES_TIP_SLD_TIT_RICCONS IN ('VALUE3')
    AND TRC.DES_MOV_TIT = RTRIM('VALUE4 ')
    AND TRC.COD_CAT_TIT = RTRIM('VALUE4 ')
    AND TRC.COD_INTER_TIT = RTRIM('VALUE5')
    AND '28-feb-2011' = TRC.DAT_RIF
    LEFT JOIN S_TIT T
    ON T.COD_INTER_TIT = TRC.COD_INTER_TIT
    AND T.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = T.DAT_RIF
    INNER JOIN S_ANAG_SOGG AG
    ON TRC.COD_NDG = AG.COD_NDG
    AND AG.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = AG.DAT_RIF
    WHERE S.DAT_RIF = '28-feb-2011'
    AND (S.FLG_ANULL_BICO = 0
    OR S.FLG_ANULL_BICO IS NULL)
    AND S.COD_SOC = 'V6'
    AND LENGTH(RTRIM(S.COD_CONTO_CNTB)) = 10
    AND S.TIP_PIANO_CNTB = 'V7'
    AND TRC.IMP_PLUS_MINUS_VAL < 0
    AND SUBSTR(S.COD_CONTO_CNTB,1,7) IN (RTRIM('VALUE8 '))
    Thanks a lot

    Right, I have executed this steps:
    - I have changed the query with the select count(*)
    - Changed the insert into with the select count(*)
    - Executed the insert into
    These are the result:
    SQL> select count(*) from TITOLI_ORI2;
    COUNT(*)
    1
    BUT:
    SQL> select * from TITOLI_ORI2;
    A
    0
    The insert into that I've modified is this:
    INSERT INTO bsc.TITOLI_ORI2
    select count(*)
    FROM
    (SELECT bsc.NEWID,
    TO_DATE('28-feb-2111','DD-MON-YYYY') as data,
    COD_SOCIETA,
    COD_PIANO_CONTABILE,
    COD_CONTO_CONTABILE,
    COD_RUBRICATO_STATISTICO_1,
    COD_NDG,
    NUM_ESEGUITO,
    CUR_VAL_IMPEGNI,
    'ABC' AS CUR_IMPORTO_BICO,
    0 AS FLG_MODIFICATO,
    NULL CUR_NON_ASSEGNATO,
    FLG_QUOTATO,
    COD_CATEG,
    TIP_COPERTURA,
    TIP_TASSO
    FROM
    (SELECT S.COD_SOC AS COD_SOCIETA,
    S.TIP_PIANO_CNTB AS COD_PIANO_CONTABILE,
    S.COD_CONTO_CNTB AS COD_CONTO_CONTABILE,
    S.COD_RUBR_STAT AS COD_RUBRICATO_STATISTICO_1,
    TRC.COD_RAGGR_IAS AS COD_RAGGRUPPAMENTO_IAS,
    TRC.COD_NDG AS COD_NDG,
    TRC.COD_ESEG AS NUM_ESEGUITO,
    CAST((TRC.IMP_PLUS_MINUS_VAL/TRC.IMP_CAMB) AS FLOAT) AS CUR_VAL_IMPEGNI,
    TRC.TIP_QUOTAZ AS FLG_QUOTATO,
    TRC.COD_CAT_TIT AS COD_CATEG,
    TIP_COP AS TIP_COPERTURA,
    T.TIP_TASSO AS TIP_TASSO
    FROM bsc.S_SLD_CNTB S
    INNER JOIN
    (SELECT DISTINCT COD_SOC,
    TIP_PIANO_CNTB,
    COD_CONTO_CNTB,
    COD_RUBR_STAT ,
    COD_INTER_TIT AS COD_INTER
    FROM bsc.S_COLLEG_CONTO_CNTB_TIT
    WHERE COD_SOC = 'ME'
    ) CCC
    ON S.COD_SOC = CCC.COD_SOC
    AND S.TIP_PIANO_CNTB = CCC.TIP_PIANO_CNTB
    AND S.COD_CONTO_CNTB = CCC.COD_CONTO_CNTB
    AND S.COD_RUBR_STAT = CCC.COD_RUBR_STAT
    INNER JOIN bsc.S_TIT_RICCONS TRC
    ON CCC.COD_INTER = TRC.COD_INTER_TIT
    AND CCC.COD_SOC = TRC.COD_SOC
    AND TRC.COD_RAGGR_IAS = RTRIM('HFT ')
    AND TRC.COD_RAGGR_IAS NOT IN ('GPO')
    AND TRC.DES_TIP_SLD_TIT_RICCONS IN ('DISPONIBILI')
    AND TRC.DES_MOV_TIT = RTRIM('CONSEGNARE ')
    AND TRC.COD_CAT_TIT = RTRIM('OBBLIGAZIONE ')
    AND TRC.COD_INTER_TIT = RTRIM('334058')
    AND '28-feb-2011' = TRC.DAT_RIF
    LEFT JOIN bsc.S_TIT T
    ON T.COD_INTER_TIT = TRC.COD_INTER_TIT
    AND T.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = T.DAT_RIF
    INNER JOIN bsc.S_ANAG_SOGG AG
    ON TRC.COD_NDG = AG.COD_NDG
    AND AG.COD_SOC = TRC.COD_SOC
    AND '28-feb-2011' = AG.DAT_RIF
    WHERE S.DAT_RIF = '28-feb-2011'
    AND (S.FLG_ANULL_BICO = 0
    OR S.FLG_ANULL_BICO IS NULL)
    AND S.COD_SOC = 'ME'
    AND LENGTH(RTRIM(S.COD_CONTO_CNTB)) = 10
    AND S.TIP_PIANO_CNTB = 'IS'
    AND TRC.IMP_PLUS_MINUS_VAL < 0
    AND SUBSTR(S.COD_CONTO_CNTB,1,7) IN (RTRIM('P044C11 '))
    Another time the strange result returns!!
    And I've created the table TITOLI_ORI2 as create table TITOLI_ORI2 (a number); to contain the number result of the query.

  • How to INSERT INTO a specific row?

    I have a form with a calendar at the top, below it is a list of items each with a check box.
    Here is a wonderful visual of it -
    Calendar
    Checkbox | Col | Col | Col
    Checkbox | Col | Col | Col
    Checkbox | Col | Col | Col
    I want it so you select the date and it gets passed into the database in the same row as the one (definitely one, multiple is better) that has been checked by the user.
    I was trying an INSERT INTO with a WHERE statement but apparently you can't do that. So if I can use a WHERE with INSERT INTO, how can I identify which row to insert the info?
    Currently it is passing the dates but it creates a new row.
    I didn't think posting the code is neccisary for this question but if anyone wants to see it let me know and I will post it.
    THANKS!

    Ah, ok, I will try UPDATE.
    Right now my form looks like this...
    <cfform name="requestform" role="form"action="resources/requestform.cfm" method="post"  width="375" height="350" >
        <label for="startdate">Start Date:</label>
          <label for="enddate">Finish Date:</label>
        <cfcalendar name="selectedDate" 
            selectedDate="#Form.selectdate#"
            startRange="#Form.startdate#"
            endRange="#Form.enddate#" 
            mask="mmm dd, yyyy" 
            dayNames="SU,MO,TU,WE,TH,FR,SA"
            firstDayOfWeek="1"
            monthNames="JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC"
            style="rollOverColor:##FF0000"
            width="200" height="150">
                <cfinput type="dateField" name="startdate" label="Start Date" width="100" value="#Form.startdate#">
                <cfinput type="dateField" name="enddate" label="End Date" width="100" value="#Form.enddate#">
        </div>
    <cfinclude
        template = "resources/query.cfm">
        <span class="label label-default">Equipment List</span>
        <table class="table table-bordered table-striped">
            <tr>
                <td><b>Select</b></td>   
                <td><b>Name</b></td>
                <td><b>Description</b></td>
                <td><b>Status</b></td>
            </tr>
        <cfloop query = "equiplist">
            <cfoutput>
            <tr>
                <td>
                    <cfinput name="status" type="checkbox" value="#serial#">Select:</cfinput>
                    <cfinput name="serial"type="text"style="display:none" value="#serial#">
                </td>   
                <td>#name#</td>
                <td>#descrip#</td>
                <td>#status#</td>
            </tr>
            </cfoutput>
    </cfloop>
    </table>
          <cfinput class="btn btn-default" type="Submit" value="Submit" name="addsubmit"></cfinput>
    </cfform>
    And the action page looks like this...
    <cfquery
            name = "requestform"
            dataSource = "db_cie">
            UPDATE equip
            SET STATUS="Out",
            WHERE serial='#status#'
    </cfquery>
    <cflocation
        url = "../request.cfm">
    But I am getting an error "invalid.user.table.column, table.column, or table specification. But the error message shows the SQL output and it looks correct...UPDATE equip SET STATUS="Out" WHERE serial="325255"... it IS getting the serial number variable passed from the form. ...No update though. Is my action form written wrong?

  • How do I insert cells using INSERT INTO & SET? (Excel oledb)

    Updating a cell works:
        oledbConnect = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\__\\test.xls;Extended Properties='Excel 12.0 Xml;HDR=NO;'");
        oledbConnect.Open();
        oledbCmd.Connection = oledbConnect;
        string stSheetName = "Sheet2";
        string sql;
        sql = "UPDATE [" + stSheetName + "$A1:B1] SET F1=1";
        oledbCmd.CommandText = sql;
        oledbCmd.ExecuteNonQuery();
    Inserting a cell does not:
        sql = "INSERT INTO [" + stSheetName + "$A2:B2] SET F1=2'";
        oledbCmd.CommandText = sql;
        oledbCmd.ExecuteNonQuery();
    I understand that inserting will add a new row ... but this doesn't work either.
        sql = "INSERT INTO [" + stSheetName + "$] SET F1=3";
        oledbCmd.CommandText = sql;
        oledbCmd.ExecuteNonQuery();
    bhs67

    Hi hbs67,
    No, we can't use Insert into with Set, it's the basic syntax in SQL statement. Give the worksheet a header row, then use Insert into or Update syntax with the field name.
    Check more information in this kb article:
    https://support.microsoft.com/en-us/kb/316934?wa=wsignin1.0
    If you have Office application installed on your machine, you could also automate the Excel files with Excel PIA:
    How to automate Microsoft Excel from Microsoft Visual C#.NET
    It's easy to insert or update cell values with the cell address.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • A problem with inserting into DB hebrew strings

    Hi,
    I am working with a 8.1.7 DB version, and use thin driver.
    I have my DB Charest configured to iso 8859P8 (which is visual Hebrew)
    I have no problem in making a connection and retrieving strings, using SELECT * FROM ..
    and then use the ResultSet.getString(String columnName) method .
    I also have no problem in inserting the Hebrew characters , and retrieving them back ( I represent them in a servlet ),
    The only problem I do have, is when I try to insert into DB a row in the following manner
    INSERT into table_name values( Hebrew_String_value1, Hebrew_String_value2, Hebrew_String_value3, Hebrew_String_value4)
    the insertion works fine , but somehow the insertion misplaces the strings order and actually the insertion is in opposite order :
    Hebrew_String_value4, Hebrew_String_value3, Hebrew_String_value2, Hebrew_String_value1.
    If I use the same insert with English Strings , there is no problem.
    does any one have the solution how I insert the strings in the right order ?
    one solution I have is to insert only one column and then update the table for each column , but then , instead of one execute() action , I have to make ,
    1 execute() + 9 executeUpdate() for a 10 column table

    Can you try specify the column order in your INSERT statement, i.e.
    INSERT INTO mytable( column1_name,
                         column2_name,
                         column3_name,
                         column4_name )
                 VALUES( column1_string,
                         column2_string,
                         column3_string,
                         column4_string)My wild guess, though I can't understand why at the moment, is that there may be a problem because Hebrew is read from right to left, that may be causing a problem.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Weird problem w. mysql 4.0 when inserting  into a table with auto_incremet

    Since I upgraded my mysql database from 3.23 to 4.0.1
    the following code does not work anymore:
    I get this error msg:
    <b>"Invalid argument value: Duplicate entry '2147483647' for key 1"</b>
    <code>
    package mysql4test;
    import java.sql.*;
    class test {
    public test() {
    public static void main(String[] args) {
    Connection connection = null;
    Statement st = null;
    try {
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    connection = DriverManager.getConnection
    ("jdbc:mysql://192.168.0.4/x?user=x&password=");
    st = connection.createStatement();
    for (int i=1;i<10;i++)
    String insert = "insert into x (b) values('hello');";
    System.out.println(insert);
    st.executeUpdate(insert);
    } catch (Exception ex) { System.err.println(ex.getMessage());}
    </code>
    The table definition of table x is the following:
    create table x(a int(11) primary key auto_increment, b varchar(10));
    What makes the thing even more mysterious is, that doing the same thing as this programm does manually on an mysql client does not produces any error message.
    insert into x (b) values('hello'); works fine on the mysql client deliverd with the server.

    Hi eggsurplus!
    Yes, I succeeded in different ways to solve the problem. changing the table was one of it. but the problem is that i can't simply change all tables (there are a lot) as the are used in other programms.
    The simplest solution that i figured out so far was changing the insert from
    insert into x (b) values('hello')
    to
    insert into x (a,b) values("+i+",'hello')"
    But this solution is still not satisfactory as in more complex programs you can't just use the i variable of the for loop, but you have to add a new variable that increments on every insert.
    This still means changing a lot of code that i wrote for mysql 3.x.
    Besides, i tried also another jdbc driver and it still didn't work.
    The same bug was reported in a PHP forum, but without solution

  • Problem with using INSERT INTO script

    Hi guys,
    I was trying to duplicate a table with the following script:
    CREATE TABLE TAB3(
    KEYATTR     NUMBER(3)     NOT NULL,
    BODY1     CHAR(1000)     NOT NULL,
    BODY2      CHAR(1000)     NOT NULL,
    BODY3     CHAR(1000)     NOT NULL,
         CONSTRAINT TAB3_PKEY PRIMARY KEY(KEYATTR) )
    INSERT INTO TAB3
         SELECT      *           
         FROM system.table3
         ORDER BY DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) DESC, KEYATTR DESC
    However, when I execute the script, I keep getting a 'missing right parenthesis' error. Any idea what went wrong?

    You don't need braces.
    Just
    INSERT INTO TAB3
    SELECT *
    FROM system.table3
    ORDER BY DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) DESC, KEYATTR DESCshould work.

  • Sequence and INSERT ALL INTO with parallelism problem

    I want to use the INSERT ALL INTO style of multiple-inserts (with 10gR2) to normalize a wide table into a skinny table. The large table has a few fk columns and 100 numeric columns. I want to insert them into another table as 100 rows in a single SQL pass.
    CREATE TABLE WIDE_SOURCE(
    FKEY_1 INTEGER,
    FKEY_2 INTEGER,
    FKEY_3 INTEGER,
    AMT001 INTEGER,
    AMT002 INTEGER,
    AMT100 INTEGER);
    CREATE TABLE SKINNY_DEST(
    PKEY INTEGER NOT NULL,
    FKEY_1 INTEGER,
    FKEY_2 INTEGER,
    FKEY_3 INTEGER,
    AMT INTEGER,
    CONSTRAINT PK_SKINNY_DEST PRIMARY KEY(PKEY)
    CREATE SEQUENCE KEY_GEN MINVALUE 1 INCREMENT BY 100 START WITH 1;
    INSERT ALL
    INTO SKINNY_DEST VALUES(KEY_GEN.NEXTVAL+001, FKEY_1, FKEY_2, FKEY_3, AMT001)
    INTO SKINNY_DEST VALUES(KEY_GEN.NEXTVAL+002, FKEY_1, FKEY_2, FKEY_3, AMT002)
    INTO SKINNY_DEST VALUES(KEY_GEN.NEXTVAL+003, FKEY_1, FKEY_2, FKEY_3, AMT003)
    INTO SKINNY_DEST VALUES(KEY_GEN.NEXTVAL+100, FKEY_1, FKEY_2, FKEY_3, AMT100)
    SELECT * FROM WIDE_SOURCE;
    With this query, each row in WIDE_SOURCE will generate 100 rows in SKINNY_DEST. I know that works. Unfortunately, it appears that the sequence isn't working the way I thought it should- with multiple nodes and parallel insert, there's some overlap in the generated key.
    Is there a better way? I've considered 100 separate sequences, but that just seems plain silly. Am I trying to have my cake (the parallelism) and eat it too (by disregarding limitations of Oracle's sequence construct)?

    Have not tested this on a RAC, but it seems to work fine - as expected without any overlaps. (version 10.2.0.1.0)
    SQL> create sequence seq_id start with 1 increment by 10 nomaxvalue nocycle;
    Sequence created.
    SQL> create table skinny ( id number, fk_key1 number );
    Table created.
    SQL> create table wide( fk_key1 number, name varchar2(32) ) parallel( degree 2 );
    Table created.
    SQL> insert into wide select object_id, object_name from all_objects where rownum < 100000;
    51853 rows created.
    SQL> commit;
    Commit complete.
    SQL> exec DBMS_STATS.Gather_Table_Stats( USER, 'WIDE' );
    PL/SQL procedure successfully completed.
    SQL> alter session enable parallel dml;
    Session altered.
    SQL> set autotrace on
    SQL> insert all
    2 into skinny values( seq_id.nextval+0, fk_key1 )
    3 into skinny values( seq_id.nextval+1, fk_key1 )
    4 into skinny values( seq_id.nextval+2, fk_key1 )
    5 into skinny values( seq_id.nextval+3, fk_key1 )
    6 into skinny values( seq_id.nextval+4, fk_key1 )
    7 into skinny values( seq_id.nextval+5, fk_key1 )
    8 into skinny values( seq_id.nextval+6, fk_key1 )
    9 into skinny values( seq_id.nextval+7, fk_key1 )
    10 into skinny values( seq_id.nextval+8, fk_key1 )
    11 into skinny values( seq_id.nextval+9, fk_key1 )
    12 select
    13 /*+ FULL(o) PARALLEL(w,2) */
    14 fk_key1
    15 from wide w
    16 /
    518530 rows created.
    Execution Plan
    Plan hash value: 1585486391
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
    | 0 | INSERT STATEMENT | | 51853 | 253K| 37 (14)| 00:00:01 | | | |
    | 1 | MULTI-TABLE INSERT | | | | | | | | |
    | 2 | INTO | SKINNY | | | | | | | |
    | 3 | INTO | SKINNY | | | | | | | |
    | 4 | INTO | SKINNY | | | | | | | |
    | 5 | INTO | SKINNY | | | | | | | |
    | 6 | INTO | SKINNY | | | | | | | |
    | 7 | INTO | SKINNY | | | | | | | |
    | 8 | INTO | SKINNY | | | | | | | |
    | 9 | INTO | SKINNY | | | | | | | |
    | 10 | INTO | SKINNY | | | | | | | |
    | 11 | INTO | SKINNY | | | | | | | |
    | 12 | SEQUENCE | SEQ_ID | | | | | | | |
    | 13 | PX COORDINATOR | | | | | | | | |
    | 14 | PX SEND QC (RANDOM)| :TQ10000 | 51853 | 253K| 37 (14)| 00:00:01 | Q1,00 | P->S | QC (RAND) |
    | 15 | PX BLOCK ITERATOR | | 51853 | 253K| 37 (14)| 00:00:01 | Q1,00 | PCWC | |
    | 16 | TABLE ACCESS FULL| WIDE | 51853 | 253K| 37 (14)| 00:00:01 | Q1,00 | PCWP | |
    Statistics
    37168 recursive calls
    26542 db block gets
    7610 consistent gets
    0 physical reads
    12696752 redo size
    498 bytes sent via SQL*Net to client
    1084 bytes received via SQL*Net from client
    6 SQL*Net roundtrips to/from client
    3 sorts (memory)
    0 sorts (disk)
    518530 rows processed
    SQL> set autotrace off
    SQL> commit;
    Commit complete.
    SQL> select
    2 id, count(*)
    3 from skinny
    4 group by id
    5 having count(*) > 1
    6 /
    no rows selected
    SQL>
    I checked the PQ V$ views and PQ slaves were used.

Maybe you are looking for

  • How to stop a DIA process ?

    hi all, In SM50, there is one DIA has been running for long hours. I have tried deleting it from SM50 --> Process --> Cancel Without Core. I also tried to delete its session from SM04. But all failed. any suggestion ? regards, kent

  • Add tempfile and has erorrs?

    Hi all, I get the following errors and I add tempfile: SQL> alter tablespace temp add tempfile '/u01/uat/uatdata/temp02.dbf' size 500M 2 ; alter tablespace temp add tempfile '/u01/uat/uatdata/temp02.dbf' size 500M ERROR at line 1: ORA-01119: error in

  • WS-X6704-10GE at line rate ?

    Hi.. Any idea if the 4 port 10GE card WS-X6704-10GE runs at line rate for each port ? Can we get approx 40Gbps throughput out of this card ? Eng Wee

  • 07 not allowed in by log in.

    Hi, When I go to log in with my mobile number,[which begins with 07, I receive this message, the number should begin with 07, how can I get by this problem please? Thanks. 

  • Somthing is running in the background

    The blue circle constantly flickers - telling me there is something running in hte back ground. this causes the computer to be slow and videos and graphics are very slow to open - if at all.