; elsif p_job= ' sales staff ' then v_sal:=p_salary*1.18; elsif p_job= ' manager ' then v_sal:=p_salary*1.19; ELSE v_sal:=p_salary; END IF; P_salary:=v_sal; --Assigning the adjusted result to the input/output parameter end calcraisedsalarywithtype;--procedure call is constrained by the formal parameter, violation of the constraint will trigger an exception declare v_sal number (8,2); --Salary variable V_job VARCHAR2 (10); --
statements to execute next.SQLCA is a data structure that is defined in an application with the exec SQL INCLUDE Sqlca.SQLCA has a variable sqlcode that stores the return code after each execution of the SQL statement.The application should test the value of Sqlcode after each execution of an SQL statement to understand the SQL statement execution and handle it accordingly.If
ThenDbms_output.put_line ('updated the'||Sql%RowCount||'article Records'); ElseDbms_output.put_line ('0 Records updated'); End if;
Commit;--Commit Statement
EndPR_TEST5; update operations for data --Match the relevant content by entering the number, and output the relevant content after the match is successful
Create or Replace procedurePr_test3 (V_BHinch varchar2, v_xxinchOutvarchar2) is
begin
--define input Output XINGM variable to V_XM and Bianh as variable v_bh, enter number, match BUMBM
# ' | | Partnum);When OTHERS ThenRaise_application_error ( -20000,errnum| | ERRMSG);END² Use the Exception keyword to declare a user-defined exception in the Declarations section of a PL/SQL block² Use PL/SQL command raise to detect user-defined exceptions²pl/sql can use the Raise_application_error procedure to return a user-defined number of errors and messages to the calling environment. All user-defined error messages must be between 20000 and-20999The ²pl/sql program can use when OTHERS exc
data. The original error number is [' | |Sqlcode | | '], the original error message is [' | | | sqlerrm | | '].');ReturnEnd
--Generate red stamping documents and review
--Generate primary tableBeginINSERT INTO DOC28BF(Docno,Optid,Ctyp,Shpid,Comid,Docdat,Invno,Isred,Iscover,VALID)Select P_reddocno, Optid, Ctyp, Shpid, Comid, Docdat, Invno, 1, 1, 0From DOC28BFwhere docno = P_docno;exceptionWhen others thenRollbackRaise_application_error (-20000,' In th
, execute1. Edit Exec.sqc file, save to: C:\Program Files\Microsoft SQL Server\mssql\binn DirectoryThe EXEC.SQC file is as follows:#include #include EXEC SQL BEGIN DECLARE section; /* Main variable description start */Char deptname[64];Char hsno[64];Char hsname[64];Char hssex[64];int hsage;int newage;Long SQLCODE;EXEC SQL END DECLARE section; /* Main variable description end */EXEC SQL INCLUDE Sqlca; /* Define the SQL Communication area *//***********
); EXCEPTION When No_data_found and then Dbms_output.put_line (' Incorrect employee number '); when Too_many_rows and then Dbms_output.put_line (' query can only return a single line '); When OTHERS then Dbms_output.put_line (' Error number: ' | | sqlcode| | ' Error description: ' | | SQLERRM); END; /*===========================================================| Benefit Benefits (Comm column) for employees with a query number of 7788.=========
PContext;Long sqlcode;//variable type and name can not be changedEXEC SQL END DECLARE section;If you add Threads=yes (in the makefile file) when Proc is compiled, you must first execute it in the PC fileENABLE Threads StatementsEXEC SQL ENABLE THREADS2.2 Initializing an embedded statement for OracleEXEC SQL CONTEXT ALLOCATE:p context;//allocates memory for PContextEXEC SQL CONTEXT use:p context;//using PContext2.3 Embedded SQL connected to OrcleEXEC
First, the conceptUser-defined exception errors are triggered by explicitly using the RAISE statement. When an exception error is thrown, the control moves to the exception block exception error section and executes the error-handling code.For handling this type of exception, the steps are as follows:
In the declaration section of the PL/SQL block, define the exception condition:
RAISE
In the exception handling section of the PL/SQL block, the exception is handled accordingly.
SQLCODE value is + 100 or the SQLSATE value is 02000. This exception usually occurs when SELECT does not return rows.
An error occurs when the SQLCODE value is negative due to the sqlexceptioin id.
The SQLWARNING flag causes a warning exception or an exception that causes a SQLCODE value other than 100.
If a not found or SQLWARNING exception is generated and
The db2 tutorial is: use shell to extract and update db2 data. The shell that is written for work needs to process the db2 database program. Use shell to extract and process db2 data.# SQL DefinitionSQL = "SELECT AAA, BBB, CCC FROM MYTBL1"# Execute SQLSDATA = 'db2 "$ SQL "'# Return Value JudgmentIf [$? -Ne 0]Then# Display error messages returned by db2Echo "$ SDATA"Exit 1Fi# Process the obtained data.Echo "$ SDATA" | sed-e'4,/^ $ /! D;/^ $/d' |While read AAA BBB CCCDoEcho "aaa is $ AAA, bbb is $
SQL BEGIN DECLARE SECTION;Char svrname [SQL _SVRNAME_MAX_LEN],/* Server name */Usrname [SQL _USRNAME_MAX_LEN],/* User name */Passwd [SQL _PASSWD_MAX_LEN],/* Passwd */Cnname [SQL _CNNAME_MAX_LEN];/* Connect name */Exec SQL END DECLARE SECTION; ... Exec SQL CONNECT TO: svrname AS: cnname USER: usrname USING: passwd;...}
V. error messageAfter each SQL statement is executed, the error code is stored in the global variable sqlca. sqlcode. You can use rget
content
Write_text (l_smtp_conn, p_htmlmsg_in );
-- Set lower HTML Boundary
Write_boundary (l_smtp_conn, true );
-- End mail msg
End_mail (l_smtp_conn );
-- End mail connection
End_session (l_smtp_conn );
Exception
When utl_smtp.transient_error or utl_smtp.permanent_error then
End_session (l_smtp_conn );
Err_raise_pkg.record_and_continue (
P_err_in => sqlcode,
P_msg_in => 'failed' to send mail due to error: '| sqlerrm );
When utl_smtp.invalid_op
only have BEFORE triggers
LOGON can only have AFTER triggers
LOGOFF can only have BEFORE triggers
SERVERERROR can only have an AFTER trigger
*/
-- After servererror trigger
/*
The following error will not be triggered
ORA-00600 oracle internal error
ORA-01034 oracle unavailable
No data found in ORA-01403
ORA-01422 returns multi-row data
ORA-01423
ORA-04030
-- Trigger will not fix errors
-- Built-in function to obtain exception information
Ora_server_error (index): error number returned. If no
, you can know whether the last fetch statement was successful. Generally, when the sqlcode value is 0, it indicates that everything is normal. 100 indicates that it has reached the end of the result set, and other values indicate that the operation is faulty, so that we can write the following code:Lb_continue = trueLl_total = 0Do While lb_continueFetch customercur-sorInto: ls_acct_no,: Ls_name,: Ll_balance;If sqlca.
Files
Add: C: \ Program Files \ Microsoft SQL Server \ devtools \ x86lib
And set as the first item
3. write programs, pre-compile, and finally compile and execute in VC ++
1. Edit the EXEC. sqc file and save it to the: C: \ Program Files \ Microsoft SQL Server \ MSSQL \ Binn directory.
The EXEC. sqc file is as follows:
// EXEC. cpp: Defines the entry point for the console application.//
# Include # Include
Exec SQL BEGIN DECLARE SECTION;/* main variable description start */Char deptna
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.