What does the SQLCODE Function do
2012-02-25 15:17
337 查看
What does the SQLCODE Function do?
The SQLCODE function returns the error number associated with the most recently raised error exception. This function should only be used within the Exception Handling section of your code:EXCEPTION
WHEN exception_name1 THEN
[statements]
WHEN exception_name2 THEN
[statements]
WHEN exception_name_n THEN
[statements]
WHEN OTHERS THEN
[statements]
END [procedure_name];
You could use the SQLCODE function to raise an error as follows:
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END;
Or you could log the error to a table as follows:
EXCEPTION
WHEN OTHERS THEN
err_code := SQLCODE;
err_msg := substr(SQLERRM, 1, 200);
INSERT INTO audit_table (error_number, error_message)
VALUES (err_code, err_msg);
END;
相关文章推荐
- What does the PF function do in Primefaces
- Mongoose - What does the exec function do?
- What does the SQLERRM Function do
- what-is-the-bios-and-what-does-it-do
- What does the three dots in react do?
- A Function to Do All My SQL Statements Based On All The Others Comments
- Disaster Recovery: What to do when the SA account password is lost in SQL Server 2005
- What does this bit-manipulating function do?
- What Does __read_mostly In The Linux Kernel Do?
- 053-19 What recommendations does the SQL Access Advisor provide for optimizing SQL queries? (Choose
- What Does The HANDLECOLLISIONS Parameter Do? [ID 966207.1]
- What does ENABLE_BITCODE do in xcode 7?
- The 3-Minute Test: What do you know about SQL performance?
- [stackoverflow翻译] “yield” 关键字有什么用?what-does-the-yield-keyword-do
- What does the yield keyword do in Python?
- What does the CS_CLASSDC & CS_OWNDC class style do?
- 【随感】what do the Temple Run tells us
- 【原】SQL Server 2008 Designer Behavior Change: Saving Changes Not Permitted (I do not know why did the team deign this function )
- Self summary: What does typical CNN do and What is Soft-max?
- Error: The version of SQL Server in use does not support datatype 'datetime2'