Skip to content

Tag: db2-400

Converting decimal to Date

I have a column with dates formatted as decimals, for example: 20,210,830. I want to convert this number to date format as 08/30/2021 I have tried to use convert and the database shoots me an error that convert is not a valid function. Cast seems to work but, only returns a null value every time. This stateme…

DB2 SELECT from UPDATE Options

I am currently trying to do an However, the version of DB2 I have does not appear to support this Is there any alternative to this in DB2 that could be return a desired result? Where in one query we can Update and Return the result? EDIT – The Select statement is supposed to return the values that are t…

Column or global variable not found db2

I have a issue with DB2. I have two libraries with the same structure database. The only one difference is the data. When i try this sql request for the first library, it’s work but when i try with the other library, i have this error. I check the CLIENT and EMPLOYE tables and they have the column with …

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 referen…

How to sort columns values in sql db2-400?

I have 10 columns with similar information, and I would like to sort them asc when greater than 0. For instance, from this: A1 A2 A3 A4 A5 A6 A7 A8 A9 A0 00 01 00 09 08 05 00 02 06 03 To this: A1 A2 A3 A4 A5 A6 A7 A8 A9 A0 01 02 03 05 06

How to create generated columns in DB2/400

I wanna create a virtual column which concatenates two columns to 1. My attempt was: This should work according to the docs. ( https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzpdf.pdf?view=kc ) (page 851). Has anyone an idea how to get this done? Thanks in advance. edit: I doublechecked it. T…

SQL query grouping by range

Hi have a table A with the following data: I’d like to have the following result: My DB is DB2/400. I have tried with ROW_NUMBER partitioning, subqueries but I can’t figure out how to solve this. Answer I understand this as a gaps-and-island problem, where you want to group together adjacent rows …

Character with Bit/hex confusion in DB2

This works: SELECT TASKT_ID FROM DATA . TASKT WHERE TASK_WEB_IDENTIFIER = CAST ( HEXTORAW ( ‘0213725501A421D384233E5001’ ) AS CHAR ( 26 ) ) ; Since that work I put it into the procedure: BEGIN …