DB2 programming skills (5)

Source: Internet
Author: User

The db2 tutorial is: DB2 programming skills (5 ). 1.16 Stored Procedure fence and unfence
The stored procedure of fence enables a new address space separately, while the stored procedure of unfence uses the same address space as the process that calls it.
In general, the fence stored procedure is safer.
But sometimes some special requirements, such as the caller's pid, will be unable to get the fence stored procedure, but only unfence can get.

1.17 SP error handling usage
If you call other SP with return values, including the result set, temporary table, and output parameter type,
DB2 automatically sends out a SQLWarning. In our original processing
Will be inserted into the log, so that multiple warning messages with SQLCODE = 0 will appear at the end.
Solution:
Define a flag variable, such as DECLARE V_STATUS integer default 0,
After call spname, SET V_STATUS = 1,
DECLARE CONTINUE HANDLER FOR SQLWARNING
BEGIN
IF V_STATUS <> 1 THEN
-- Warning processing and log insertion
SET V_STATUS = 0;
End if;
END;
1.18 import usage
Db2 import from gh1.out of DEL messages err.txt insert into db2inst1. tb_dbf_match_ha

Add schma

1.19 use of values
If there are multiple set statements to pay the value for the variable, it is best to use the values statement and rewrite it into a sentence. This improves the efficiency.

However, you must note that values cannot pay a null value to a variable.
Values (null) into out_return_code;
This statement will report an error.


1.20 specify the isolation level for the select statement
Select * from tb_head_stock_balance with ur

1.21 what is the difference between atomic and not atomic?
Atomic is to specify this part of the program block as a whole. If any of the statements fails, the entire program block is not done, including the statements that have been successfully executed in the atomic block, it is somewhat similar to transaction.


2 DB2 programming performance considerations
2.1 big data table Import
It should be because load does not write logs.
It is better than select.


<

Related Article

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.