Home > database >  What a great god help to see if any of the code has a problem!!!!!!
What a great god help to see if any of the code has a problem!!!!!!

Time:09-21

 declare 
- the type definition
Cursor c_job
Is
The select invclasscode, invclassname from bd_invcl where forinvname='1';
- define a cursor variable v_cinfo c_emp % ROWTYPE, the type of cursor c_emp a row in the data type
C_row c_job % rowtype;
The begin
For c_row c_job in loop
Dbms_output. Put_line (' select * from bd_invcl where invclasscode like ' ' '| | c_row. Invclasscode | |' % '");

The BEGIN
The execute immediate 'select * from bd_invcl where invclasscode like' ' '| | c_row. Invclasscode | |' % '"';
commit;
END;

end loop;
end;


Bms_output. Put_line can the normal output

The execute immediate this execution, nor an error

CodePudding user response:

The problem is what results you want, want to let his output? Want to print the query results list?
If you want to check the results, you can switch to view the results such as insert,

CodePudding user response:

In PLSQL:
Select to have into clause, or this is a cursor,

CodePudding user response:

Dbms_output output string, so you can write directly select * from...
The execute immediate this is to perform dynamic SQL, not directly write the select * from... , but only to a select * into * * * the from...

This dynamic SQL sentence you want to do? Look not to understand completely, want to return a result set?
Behind don't need to COMMIT, SELECT and also did not update the data,

CodePudding user response:

reference yaiger reply: 3/f
dbms_output output string, so you can write directly select * from...
The execute immediate this is to perform dynamic SQL, not directly write the select * from... , but only to a select * into * * * the from...

This dynamic SQL sentence you want to do? Look not to understand completely, want to return a result set?
Behind don't need to COMMIT, SELECT and also did not update the data,


Before I try to use the MSSQL directly execute can result,
Just in the oracle, still not familiar with

CodePudding user response:

1. You must define two variables to receive output value:
The select invclasscode, invclassname from bd_invcl where forinvname='1'
2. You must define a cursor
Select * from bd_invcl where invclasscode like,,,
  • Related