About the ORA-01002 read violation order, endloop carried out the loop value, but when JDBC calls the stored procedure, only need to return a result set (cursor) on the line, then
About the ORA-01002 read violation order, the end loop carries out the loop value, but when JDBC calls the stored procedure, only need to return a result set (cursor) on the line, then
Today, the following error occurs when you run your own JDBC to call the stored procedure:
ORA-01002 read violation order
Most of the suggestions provided on the Internet are to set Automatic SQL submission to false: cn. setAutoCommit (false );
But this is not where my error is located. I did not set it when I finally solved it.
My stored procedure is as follows:
Create or replace procedure tag (outs out sys_refcursor) is
Allout sys_refcursor;
Id varchar2 (16 );
Mid varchar2 (16 );
Tty varchar2 (16 );
Cty varchar2 (16 );
Tid varchar2 (16 );
Tna varchar2 (16 );
Tva varchar2 (16 );
Tsi varchar2 (16 );
Tti varchar2 (16 );
Pid varchar2 (16 );
Nex varchar2 (16 );
Gra char (4 );
Begin
Open allout for select id, module_id, tag_type, control_type, tag_id, tag_name, tag_value, tag_size, tag_title, parent_id, next, grade
Into id, mid, tty, cty, tid, tna, tva, tsi, tti, pid, nex, gra from t_tag;
-- Loop
-- Fetch allout into id, mid, tty, cty, tid, tna, tva, tsi, tti, pid, nex, gra;
-- Exit when allout % notfound;
-- Dbms_output.put_line (allout % rowcount | ''| id |'' | mid | ''| tty |'' | cty | ''| tid | ''| tna |'' | tva | ''| tsi |'' | tti | ''| pid |'' | nex | ''| gra );
-- End loop;
Outs: = allout;
End tag;
JDBC is as follows:
Cn = DBFactory. getconn ();
// Cn. setAutoCommit (false );
// System. out. println ("create Declaration ");
Cst = cn. prepareCall ("{call tag (?)} ");
System. out. println ("Execute SQL ");
Cst. registerOutParameter (1, Oracle. jdbc. OracleTypes. CURSOR );
Cst.exe cute ();
System. out. println ("execute successful ");
Rs = (ResultSet) cst. getObject (1 );
System. out. println (rs );
While (rs. next ()){
}
My error lies in the usage
Loop
Fetch
The end loop carries out the cyclic value, but when calling the stored procedure in JDBC, you only need to return a result set (cursor). In this case, the error "read violation order" is reported, solution: Remove loop .... end loop code.
For more information about Oracle, see the Oracle topic page? Tid = 12