DB2 : SQL: Change in granularity for SCD type-2 table

I have a order table in SCD type-2 like below (Delivery Date in Order granularity and it create history when when delivery date changes) Order_Id Order_Status Order_Create_Dt Delivery_Dt Start_Date …

DB2 z/OS – Get the last 2 digits of year

SELECT SUBSTR(CAST(YEAR(SOMEDATE) AS VARCHAR(4)),2,2) AS “YY” FROM SOMESCHEMA.FOO; Gets me the following error: [Code: -104, SQL State: 42601] ILLEGAL SYMBOL “,2”. SOME …

Does DB2 implement multi-table indexes?

I’m afraid this functionality may not exist [yet]. I wanted to use an index that spans multiple tables in DB2. I know Oracle and SQL server implement them (with more or less options) and that …

Why is my query failing with SQLCODE = -420?

Can I get some help with this? I’ll copy the code as well as the error. I looked up the error code (DB2 SQL Error: SQLCODE=-420, SQLSTATE=22018, SQLERRMC=BOOLEAN) but I’m not understanding what …

Rows with multiple corresponding values in the same table

Suppose I have a table Name Wear Martin Hat Martin ? Martin Shirt Alfred Tee Alfred Jeans And I only want names of people whose Wear value is fully given, …

Issue with query in DB2 –Not able to find the cause

I was trying to execute the below query in Db2 and its giving me some error, which I am not able to identify the root cause.Could someone please help here. with test as( select * from ( …

Does PLSQL in DB2 support nested while statemnts?

I have a following query for DB2 database: BEGIN DECLARE NUMBER_OF_ROWS INT; DECLARE ITER_INDX_1 INT; DECLARE ITER_INDX_2 INT; SET ITER_INDX_1 = 0; SET …

Getting Exception With DB2 Auto Increment

I have created the following table: “CREATE TABLE ParsonCollection ” + “(id integer not null GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),” + “name …

DB2 query with multiple WITH AS cases not compiling

For some reason, I can’t get this query to perform as I’m getting an error: Token ( was not valid. Valid tokens: , FROM INTO. I’m running this in DB2 and I think this is occurring at either the very …

Create database user with DDL in DB2

I am trying to create a user using DDL in DB2. I tried this: CREATE USER ‘test_user’ IDENTIFIED BY ‘password’; and I got this error message: An unexpected token “‘test_user’ IDENTIFIED BY ‘…