0

I am trying to insert a data from another table using below query

cmd_write = new OracleCommand(@"insert into table1 (f_id, f_name, s_id, r_id,
       t_date, t_type, sys_entry_date, parent_sys_id, sys_f_source)
      select 
          f_id, f_name, s_id, r_id,
          t_date, 1, sysdate, sys_id, sys_file_source 
      from table2 
      where sys_id = :sy_id 
      returning sys_id
        into :sys_get_id ", ora_con);

cmd_write.Parameters.Add(new OracleParameter("sy_id", sys_id));

OracleParameter sys_get_id = new OracleParameter("sys_get_id", OracleDbType.Int64);
sys_get_id.Direction = ParameterDirection.Output;
cmd_write.Parameters.Add(sys_get_id);
cmd_write.CommandTimeout = 0;

cmd_write.ExecuteNonQuery();

I get this error:

ORA-00911: invalid character

9
  • returning into is a pl/sql construct while you have just a simple sql statement if I do understand what this extract of C# code means. please take a look also here. Do you need so see the number of the rows affected? Isn't the ExecuteNonQuery method returning that already? Commented May 15, 2020 at 14:48
  • @micklesh iam moving some record to table1(interface) table not all files from table2. Commented May 15, 2020 at 15:24
  • @Sachu you are inserting multiple records here n trying to return one sys_id, that's the issue, u can get no of records u have inserted Commented May 15, 2020 at 15:33
  • @MuhammedNigil this is inisde another loop..The condition is sys_id = :sy_id so only record will enter at a time Commented May 15, 2020 at 15:55
  • try this - place ....:sy_id returning sys_id into :sys_get_id all on a same line Commented May 16, 2020 at 1:38

1 Answer 1

1

It looks like this is not possible. I tried this

create table A (c1 varchar(10) null);

declare 
   x varchar2(10);
   TYPE myType IS TABLE OF A.c1%TYPE INDEX BY BINARY_INTEGER;
   vData myType;
begin
   insert into A select dummy from dual returning c1 bulk collect into vData;
   -- null;
end;
/

To no avail. Then I found this

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.