What are the operational skills of DB2 programming?

Source: Internet
Author: User

The following articles mainly describe the operational skills of DB2 programming. If you are interested in the operational skills of DB2 database programming, you can click and view the following articles, the following is a detailed description of the main content of the article. I hope you will have a better understanding of it after browsing.

DB2 programming skills 1. Do not use the TAB key after creating a stored procedure

 
 
  1. create procedure 

You can only use spaces, but not tab keys, otherwise the compilation will fail. Remember, remember.

DB2 programming skills 2. Using temporary tables

Note that temporary tables can only be created on user tempory tables space. If the database only has system tempory table space, temporary tables cannot be created.

In addition, the temporary tables of DB2 are not the same as those of sybase and oracle. The temporary tables of DB2 are valid in a session. Therefore, if the program has multiple threads, it is better not to use temporary tables, which is difficult to control.

It is best to add the with replace option when creating a temporary table so that the drop temporary table is not displayed, if you do not add this option when creating a temporary table and the temporary table has been created in this session and has not been dropped, an error occurs.

DB2 programming skills 3. Getting the specified first few records from the data table

 
 
  1. select * from tb_market_code fetch first 1 rows only 

However, the following method is not allowed.

 
 
  1. select market_code into v_market_code  
  2. from tb_market_code fetch first 1 rows only;  

Select the field of the first record to a variable in the following way

 
 
  1. declare v_market_code char(1);  
  2. declare cursor1 cursor for select market_code from tb_market_code  
  3. fetch first 1 rows only for update;  
  4. open cursor1;  
  5. fetch cursor1 into v_market_code;  
  6. close cursor1;  

The above content is an introduction to the DB2 programming skills. I hope you will have some gains.

The above content is a description of the DB2 programming skills, hoping to help you in this regard.

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.