The command that executes the script is already mentioned in the previous section and is no longer duplicated.
Sqlplus User/[email protected]:p ort/servicename @/path/sqltest.sql;
Sqltest's content and notes:
--This whenever indicates that after an error occurs, it is no longer executed and will try to roll backWhenever SQLERROREXITSql. SQLCODEROLLBACK--select ' OK ' from DUABBL;--select ' OK ' from Duiaaal;--Statement of output executionSetEcho on;--output execution results to a fileSpool/Tmp/Spool.txt;Select 'OK' fromdual;--create an empty, harmless stored procedureCreate or Replace procedureADISABLEDSP (TimeStamp Number, TableNamevarchar2) is begin if TimeStamp<0 Then --This condition can never be set and the input parameters are used timestampDbms_output.put_line ('We is going to operate on table' ||TableName);--the input parameters are used tablenameEnd if; End;--this/execution is required on the command line, indicating execution, otherwise, only newline/ Select 'OK' fromdual;Select 'OK' fromdzual;--Dual database is commonly used for testing purposesSelect 'OK' fromDual;spoolif;--This also must, otherwise, after the script execution completes, will hang in the Sqlplus command line, does not exitExit;
Look at a few SQL stored procedures, note that some display a row, some display the name, and some display content:
Select name from User_source where type= ' PROCEDURE ', select text from all_source where name = ' Pro_name ', select * from user _procedures;
The last trick, why in the script, will appear a/right slash it?????
usually in end; (note there is a semicolon) followed by a backslash/, that is, to execute a stored procedure, if there is no backslash, it is normal line break. This is typically used in command windows in Oracle.
Https://zhidao.baidu.com/question/560015241204373364.html
Some other tips on Oracle's sqlplus