Latest versionsfixlist
11.1.0.7 FixList
10.5.0.9 FixList
10.1.0.6 FixList
9.8.0.5 FixList
9.7.0.11 FixList
9.5.0.10 FixList
9.1.0.12 FixList
Have problems? - contact us.
Register for free anmeldung-x26
Contact form kontakt-x26

DB2 - Problem description

Problem IC84358 Status: Closed

SQL0151N or SQL0206N MAY RESULT WHEN CREATING SQL PROCEDURE CONTAINING
TRUNCATE STATEMENT

product:
DB2 FOR LUW / DB2FORLUW / A10 - DB2
Problem description:
Various errors, such as SQL0151N and SQL0206N, may occur when 
creating a SQL procedure that contains a TRUNCATE statement. 
The following steps illustrate such a scenario: 
. 
1. Create a table and its alias. 
$ db2 "create table S1.T1 (C1 int)" 
$ db2 "create alias S2.T1 for table S1.T1" 
 
2. Create a SQL procedure with TRUNCATE statement. 
p1.sql 
------------------------------ 
CREATE OR REPLACE PROCEDURE P1() 
BEGIN 
TRUNCATE TABLE S2.T1 IMMEDIATE; 
INSERT INTO S2.T1 VALUES 1; 
END@ 
------------------------------ 
$ db2 -td@ -vf p1.sql 
SQL0151N  The column "C1" cannot be updated.  LINE NUMBER=4. 
SQLSTATE=42808 
 
p2.sql 
------------------------------ 
CREATE OR REPLACE PROCEDURE P2() 
BEGIN 
TRUNCATE TABLE S2.T1 IMMEDIATE; 
INSERT INTO S1.T1 VALUES 1; 
END@ 
------------------------------ 
$ db2 -td@ -vf p2.sql 
SQL0206N  "C1" is not valid in the context where it is used. 
LINE NUMBER=4. 
SQLSTATE=42703
Problem Summary:
**************************************************************** 
* USERS AFFECTED:                                              * 
* Users who use TRUNCATE statement in SQL procedures.          * 
**************************************************************** 
* PROBLEM DESCRIPTION:                                         * 
* See Error Description                                        * 
**************************************************************** 
* RECOMMENDATION:                                              * 
* Please upgrade to V10.1 FixPack 1 or later.                  * 
****************************************************************
Local Fix:
Replace the alias in the TRUNCATE statement with the base table 
OR 
Substitute the TRUNCATE statement with the DELETE statement
available fix packs:
DB2 Version 10.1 Fix Pack 1 for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 2 for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 3 for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 4 for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 3a for Linux, UNIX, and Windows
DB2 Version 10.1 Fix Pack 6 for Linux, UNIX, and Windows

Solution
This problem was first fixed in DB2 V10.1 FixPack 1.
Workaround
not known / see Local fix
Timestamps
Date  - problem reported    :
Date  - problem closed      :
Date  - last modified       :
13.06.2012
05.11.2012
05.11.2012
Problem solved at the following versions (IBM BugInfos)
Problem solved according to the fixlist(s) of the following version(s)
10.1.0.1 FixList
10.5.0.1 FixList