Captain Classmate's original address: https://www.cnblogs.com/teamleader/archive/2007/05/31/765943.html
Captain Classmate's original description:
Sometimes we need to execute multiple SQL statements at once, and the SQL used to update them is spelled out according to the actual code.
The solution is to put SQL into this form:
Begin
Update TB_VG Set seq = 1, vessel_id = ' Jin14 ', Vessel_type = ' track ' where batch_number = ' 20837 ' and train_id = ' 0233086 ' ;
Update TB_VG Set seq = 2, vessel_id = ' Jin14 ', Vessel_type = ' track ' where batch_number = ' 20992 ' and train_id = ' 0233110 ' ;
End
Summarized as follows:
Begins with a begin, ends with an end (the semicolon cannot be saved after end), and each SQL statement in the middle is separated by a semicolon;
In the actual code, it is found that even if there is an error, replace the line break in the SQL statement with a space.
A more secure coding method is:
1, in the normal way to write SQL, according to the needs of reading and writing, there will definitely be a newline character in the middle
2. Replace before execution: strSQL = strsql.replace ("\r\n", ""). Replace (' \ n ', ');
If you do not use this method, the possible exceptions are:
Ora-00933:sql command does not end correctly (if SQL does not end with a semicolon)
ORA-00911: Invalid characters (if no begin and end are added)
ORA-06550: line x, section XXX: PLS-00103: The appearance of the symbol "End-of-file" in the need for one of the following: ... (If End does not follow; semicolon)
ORA-06550: line x, section XXX: PLS-00103: The sign appears "" In the need for one of the following: ... (There are line breaks between statements)
Here's what I added:
(See the Red one in the Replace parameter?) , less this can't, @ captain, you have killed a lot of people ah ^_^!
(learn) How to execute multiple SQL statements at once in Oracle