0

I am trying to insert records into a table using insert....select...stmt in a oracle stored procedure. How do find the number of records inserted using SQLERRD?

recIn number;
Insert into t1 ....Select.....;
recIn := SQLCA.SQLERRD(3);
....
....
PLS-00201: identifier 'SQLCA.SQLERRD' must be declared

is the error message thrown. How do you declare SQLCA.SQLERRD?

using Oracle 9.2

bcs     
user1064227
  • 47
  • 2
  • 7

1 Answers1

2

Are you using PL/SQL? Or are you using Pro*C/C++? SQLCA.SQLERRD would be defined in Pro*C/C++, it would not be defined in PL/SQL. Since you didn't tag the question for Pro*C, I'm guessing that you're just using PL/SQL.

In PL/SQL, you simply reference SQL%ROWCOUNT after running a SQL statement to get the row count. Something like

DECLARE
  l_num_rows INTEGER;
BEGIN
  INSERT INTO t1( <<list of columns>> )
    SELECT <<list of columns>>
      FROM <<some tables>>
     WHERE <<some predicates>>
  l_num_rows := sql%rowcount;
  dbms_output.put_line( 'The statement inserted ' || l_num_rows || ' rows.';
END;
Justin Cave
  • 227,342
  • 24
  • 367
  • 384