Now V7R1 - Default parameter values are supported for both SQL and external stored procedures
Page 1 of 1
Now V7R1 - Default parameter values are supported for both SQL and external stored procedures
With the delivery of Technology Refresh #5 for the IBM i 7.1 release, We can now have flexibility to minimize coding changes when deploying new versions of stored procedures. New default value support for parameters enables this flexibility. Default parameter values are supported for both SQL and external stored procedures. IBM plans to enable default parameter values for user-defined functions (UDFs) in a future release of the IBM i operating system.
This new ability to declare default parameter values enables developers to selectively choose which programs have to be modified to accommodate the new input parameters for a stored procedure. Deploying your upgraded stored procedures will go much faster when you can reduce the number of invoking programs that have to be changed.
Let's assume that the Generate_Claim stored procedure in Figure 1 was upgraded with two new parameters that allow the invoker to specify the department to process a claim and override the claim date.
CREATE OR REPLACE PROCEDURE Generate_Claim
(IN policyID CHAR(10),
IN claimDept CHAR(3) DEFAULT('45H'),
IN claimDate DATE DEFAULT CURRENT DATE)
LANGUAGE SQL
BEGIN
/* Logic goes here */
END;
Once the upgraded version of the Generate_Claim procedure is deployed, existing programs will continue to work with the following SQL Call statement:
CALL Generate_Claim('AB12345678')
For this type of invocation, the stored procedure will use the default values of 45H and the current date during execution of the stored procedure.
If an invoker wanted to override the claim department, but not the claim date, the developer could use one of the following SQL Call statements to override the claims department while still using the default claim date value.
CALL Generate_Claim('AB12345678', '50A')
CALL Generate_Claim('AB12345678', '50A', DEFAULT)
This new support also makes it possible to override the claim date and still have the default value used for the claim department. This is done using the named parameter syntax shown in the following CALL statement. With named parameters, default values are used for any parameter that's not specified in the stored procedure invocation—in this example, that means the default value is used for the claim department input parameter.
CALL Generate_Claim('AB12345678', claimDate=>'10/12/2012')
This new ability to declare default parameter values enables developers to selectively choose which programs have to be modified to accommodate the new input parameters for a stored procedure. Deploying your upgraded stored procedures will go much faster when you can reduce the number of invoking programs that have to be changed.
Let's assume that the Generate_Claim stored procedure in Figure 1 was upgraded with two new parameters that allow the invoker to specify the department to process a claim and override the claim date.
CREATE OR REPLACE PROCEDURE Generate_Claim
(IN policyID CHAR(10),
IN claimDept CHAR(3) DEFAULT('45H'),
IN claimDate DATE DEFAULT CURRENT DATE)
LANGUAGE SQL
BEGIN
/* Logic goes here */
END;
Once the upgraded version of the Generate_Claim procedure is deployed, existing programs will continue to work with the following SQL Call statement:
CALL Generate_Claim('AB12345678')
For this type of invocation, the stored procedure will use the default values of 45H and the current date during execution of the stored procedure.
If an invoker wanted to override the claim department, but not the claim date, the developer could use one of the following SQL Call statements to override the claims department while still using the default claim date value.
CALL Generate_Claim('AB12345678', '50A')
CALL Generate_Claim('AB12345678', '50A', DEFAULT)
This new support also makes it possible to override the claim date and still have the default value used for the claim department. This is done using the named parameter syntax shown in the following CALL statement. With named parameters, default values are used for any parameter that's not specified in the stored procedure invocation—in this example, that means the default value is used for the claim department input parameter.
CALL Generate_Claim('AB12345678', claimDate=>'10/12/2012')
Similar topics
» How to create and Use SQL Stored Procedures?
» Where are the Condition names and values stored within the model?
» Define execute external function?
» What are the default functions crated for REF and CPT file?
» Multiple events supported in a single SQL trigger
» Where are the Condition names and values stored within the model?
» Define execute external function?
» What are the default functions crated for REF and CPT file?
» Multiple events supported in a single SQL trigger
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|