Oracle PL/SQL

Source: Internet
Author: User


In Oracle PL/SQL, writing a Stored Procedure for null operations, although we write a Stored Procedure (Stored Procedure) to complete some specific functions. However, in some cases, the functions implemented by the existing storage functions may no longer be needed or we intend to use other methods to implement them, at this time, in order to minimize the changes to the existing system (to minimize the impact on the existing system), we cannot delete this stored procedure, but we need to modify this stored procedure to make it short, that is, no substantive functions are implemented. However, Oracle requires the code of the stored procedure body when compiling the stored procedure: 1. All parameters declared by the stored procedure must be used in the Stored Procedure body; 2. All declared or computed variable values in the stored procedure must be used in this process. Therefore, to implement null operations on stored procedures, we cannot comment out all the code in the original Stored Procedure body, because the Annotated Code cannot be compiled at all. Www.2cto.com that is to say, we need some special processing to implement null operations on the stored procedure: write the code of the stored procedure body as an if statement, and the conditions of this statement will never be true, in addition, this statement uses all the variables defined in the stored procedure. In this way, the stored procedure can be compiled without any substantive functions. For example, in the following stored procedure, assume that timeStamp represents the number of seconds from the current system time to January 1, January 1, 1970 (therefore, this value will always be a positive number, not a negative number ). Www.2cto.com create or replace procedure ADisabledSP (timeStamp number, tableName varchar2) isbegin -- this condition can never be true, and the input parameter timeStampif timeStamp <0 then -- the input parameter tableNamedbms_output.put_line ('We are going to operate on table' | tableName); end ifend www.2cto.com is used, by specifying the "timeStamp <0" condition in the if statement, the code in the entire if statement can never be executed, so as to achieve the purpose of null operations. In addition, The Condition Clause in the if statement and all variables defined in this stored procedure are used in the statement body to ensure that the compilation can pass.
Source http://blog.viscenthuang.info/
 

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.