Skip to content
Advertisement

Tag: db2

Update in DB2 using where exists instead of join

I’m trying to perform an update in DB2, which I started out trying with an inner join, but DB2 won’t allow that. I altered it to use a ‘where exists’ clause but now it’s telling me that main_discount in my set clause is not found (I’m assuming because it isn’t referenced until the later where exists How can I make

Having weird exception using MAX(CASE WHEN) in query: DB2.iSeries.iDB2DCFunctionErrorException: ‘An unexpected exception occurred

I have the following query to put some data from rows in columns: But when I try to run it in the following code: I get this exception: “IBM.Data.DB2.iSeries.iDB2DCFunctionErrorException: ‘An unexpected exception occurred. Type: System.AccessViolationException, Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt..'” I have other queries that work just

Apply column filter on summed columns in DB2

I have the following DB2 table: COLUMN_NAME DATA_TYPE TYPE_NAME COLUMN_SIZE COLUMN_TEXT DMPROD -2 CHAR () FOR BIT DATA 35 Product Code DMPTYP -2 CHAR () FOR BIT DATA 1 Period Type DMTYPE -2 CHAR () FOR BIT DATA 6 Type of Data DMVL01 3 DECIMAL 17 Value Period 1 DMVL02 3 DECIMAL 17 Value Period 2 DMVL03 3 DECIMAL 17

Selecting substring with different starting location

(I’m not sure if I’m using the correct title… please let me know if you think it should be changed to something else) Hi, I’m trying to select substring with different starting location. I have a table like this, Req: I’m trying to get a table like this: After googling around, I found CHARINDEX() might be a solution. So I

dynamic pivot SQL Query in DB2

I have table like below in DB2 where all these 3 columns are VARCHAR data type I need a dynamic PIVOT query which should select values for ABC_COL1 and ABC_COL2 in row format when FILE_NM filter is used as ABC.TXT The same query should select the values for XYZ_COL1, XYZ_COL2 and XYZ_COL3 in row format when FILE_NM filter is used

Using subquery with update SQL

I have Table 1 : EMP as below Table 2: EMP1 ID is the Key and is common in both the files. I want an Update SQL to update the amount field of Table 1 using Amount field of table 2, which gives the result as below. Result: Answer One method is a correlated subquery: You can check if the

Advertisement