u/Iguanas_Everywhere

▲ 7 r/IBMi

1928 and 2063...

I had always assumed that Century indicators in CYMD dates were as simple as "0 = 1900s and 1 = 2000s." However, I just learned that a QCENTURY value of 0 indicates 1928-1999, and 1 indicates 2000-2063. I'm sure there's a fascinating explanation for this, but I can't find what it is. Anyone have some insights to share to satiate my curiosity? Is there a storage issue at play, a la Y2K issues, but obviously different somehow?

reddit.com
u/Iguanas_Everywhere — 18 days ago
▲ 8 r/SQL

VARCHAR vs CAST AS varchar

I'm converting a decimal value to a VARCHAR on a DB2 system. I'm finding one syntactical version works, and another doesn't. I'm coming up short when trying to explain to myself why.

SELECT VARCHAR(My_Field)
FROM My_Table

works!

SELECT CAST(My_Field AS VARCHAR)
FROM My_Table

doesn't work--"Attributes not valid" error.

Weirdly:

SELECT CAST(My_Field AS CHAR)
FROM My_Table

works.

What am I not understanding? Many thanks!

reddit.com
u/Iguanas_Everywhere — 26 days ago
▲ 4 r/IBMi

CL initial values and DMPCLPGM

I've realized that if I look at a dump from a CL program by using a DMPCLPGM command in the code, the variables that are declared and initialized (given a VALUE when declared) won't show up in the dump. If I "do something" with the variable, whether a CHGVAR or pass it as a PARM to another program, then they do show up in the dump properly. Strangely, this seems to be the case regardless of where the DMPCLPGM command is in my code (i.e. before or after the "do something with the variable" command).

I'm guessing there's an order of operations happening under the hood, like a variable doesn't really occupy memory until it's used in a command, and that DMPCLPGM runs after a program ends or something. But I haven't been able to track down any documentation to satisfy my curiosity on the subject. Can anyone shed some light? Many thanks!

reddit.com
u/Iguanas_Everywhere — 1 month ago