Considerations for using the IBM DB2 database

Source: Internet
Author: User
Tags command line commit constant db2 ibm db2 ibm db2 database rtrim

1. After installing the DB2 database, you can use the command line or graphical interface to operate, if your database server is not on this computer, you need to be in the "Client Configuration Helper" in the configuration of a client connection.

2. In the control center can not be deleted or modified data, can only write SQL statements to implement and quest provided by the tool, although it can increase the data, but cannot use the copy, Paste and tab, you must input, and then click on the mouse to switch the existing data appears to be able to edit the changes in the cell, but the actual can not commit, Oh, or honest write update statements, as to delete data, is not write DELETE statement. However, you can use PB as a cell to edit the data, the corresponding disadvantage is to edit the data button and delete the table button is too close, all wrong to delete the table button, PB but without prompting the table to delete, faint

The 3.DB2 view cannot be used directly with the order BY statement and must be written like this:

Selectxfrom (select A,b,c from table1 order by a) as tab

Note: The premise of this writing is that you have already patched

4. Problems with stored procedures:

DB2 provides LTrim functions and RTRIM functions, but does not provide the trim function, if you want to remove characters at both ends of the space, sorry, you must use the LTrim (RTrim ()) way to invoke the INSERT statement can not be used to assign values, The value must be assigned to a variable to call other stored procedures should not be used as a constant parameter, the value of the constant must be assigned to a variable, and then take this variable as a parameter

SELECT * FROM table fetch the ' N rows only ' statement not available in stored procedure

5. Dynamic SQL can be used in stored procedures, but cannot be used in functions, Kao

6. When a commit or rollback is encountered, the cursor is automatically closed, so it is necessary to use the individual commit carefully.

Proc Builder is always in the debugging of low memory, the screen spent. When a breakpoint is debugged, pausing for a slightly longer period of time will prompt a time-out.

7. Development issues:

When you take a date by using the date variable +1 MONTHS OR Date variable-1 MONTHS, such as when the date variable value is 2004-02-29, the date variable +1 MONTHS is assigned to another

An error occurs when a date variable. The corresponding SQLState is 01506 (DB2 01506): the date or timestamp values are adjusted to correct the invalid dates for arithmetic operations.

If you want to get only the next January, the alternative is to get the first day of the month of the current date as the benchmark +1 MONTHS OR-1 MONTHS

8. Assign values to variables cannot be used with select. Into.. method instead of using Set v= (SELECT ...) The way, the specific examples are as follows:

drop function SXFM.ISORDERSUBMITDATE;
create FUNCTION SXFM.ISORDERSUBMITDATE(IN_ROW_ID DECIMAL(16,0))
RETURNS DATE
LANGUAGE SQL
BEGIN ATOMIC
DECLARE V_SUBMIT_DATE DATE;
DECLARE V_SELL_ID DECIMAL(16, 0);
DECLARE V_BUY_ID DECIMAL(16, 0);
set V_SELL_ID = (select COALESCE(RECEIVE_ID,-1) FROM IS_ORDER where ROW_ID=IN_ROW_ID);
set V_BUY_ID = (select COALESCE(PAY_ID,-1) FROM IS_ORDER where ROW_ID=IN_ROW_ID);
set V_SUBMIT_DATE = (select DATE(MAX(A.SUBMIT_DATE)) FROM AM_AUDIT_QUEUE A,SM_USER B,SM_USER C
where A.TABLE_CODE=’IS_ORDER’ AND A.TABLE_ROW_ID=IN_ROW_ID
AND A.AUDIT_EMP_ID=C.ROW_ID AND C.BRANCH_ID=V_BUY_ID  --审核方为付款方
AND A.SUBMIT_EMP_ID=B.ROW_ID AND B.BRANCH_ID=V_SELL_ID); --提交方为收款方
RETURN V_SUBMIT_DATE;
END;
#SYNC 10;

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.