12,969 questions
0
votes
0
answers
35
views
SELECT dynamic FROM statement [closed]
I want to look over all tables which have specific columns like OUTLET and OUTLET2.
And then I want to look if the columns has any match with any value like 'xyz'. But the value can be changed.
I am ...
0
votes
1
answer
72
views
Issue trying to use the ALTER TABLE DROP COLUMN
I am trying to drop a column from a table. I am getting an error
Illegal symbol ""
and I don't really understand it. The only space I see is the extra line. I updated it to put it on one ...
0
votes
0
answers
50
views
DB2 CLP command via subprocess.run sometimes returns empty output and sometimes SQL1024N: A database connection does not exist
I'm running a DB2 stored procedure from Python using subprocess.run.
The command works perfectly when I run it directly in my shell:
db2 'CALL GET_DBSIZE_INFO(?, ?, ?, 0);' | awk -F': *' '/Parameter ...
2
votes
1
answer
131
views
SQL: Calculating percentage of time spent in a country
I have this table in SQL:
CREATE TABLE myt (
name VARCHAR(20),
country VARCHAR(20),
date_arrived DATE,
date_left DATE
);
INSERT INTO myt (name, country, date_arrived, date_left) ...
-1
votes
1
answer
86
views
For multiple records in first column with distinct value in second column
I have a SQL statement which works fine for a single value of columnD, but when I need data for multiple columnD values, it's not returning any data.
This is the working SQL statement:
Select max(...
Advice
0
votes
3
replies
62
views
How to use Read Stability in db2 interactive SQL
I'm experimenting with DB2 isolation levels. I've installed DB2 12.1.1 for Linux on Ubuntu 22.04 and created a user & instance. Now I'd like to open two sessions and step-by-step type SQL commands,...
-3
votes
2
answers
187
views
Using SQL to keep track of changes occurring in a table?
I start with this table in SQL on day=0 (e.g. 2025-10-29):
CREATE TABLE TABLE_0 (
NAME VARCHAR(20),
VAR1 INT,
VAR2 INT
);
INSERT INTO TABLE_0 (NAME, VAR1, VAR2) VALUES
('RED', 1, 2),
('...
2
votes
2
answers
155
views
Is there a SQL equivalent of the R setdiff() function?
I have two tables:
CREATE TABLE t1 (
NAME1 VARCHAR(20),
date DATE
);
INSERT INTO t1 (NAME1, date) VALUES
('RED', '2020-01-05'),
('BLUE', '2020-03-15'),
('GREEN', '2020-06-20'),
('YELLOW', '...
1
vote
1
answer
204
views
IIDR CDC Kafka Custom KCOP disable schema auto register
we are trying to replicate Db2 changes from z/OS to Confluent Kafka.
Everything works out fine for the production of simple JSON records in Kafka.
As our policies for Kafka Topics and Schemas are ...
0
votes
0
answers
60
views
How do I / example of adding source info in IBM MQ Header (possible MQRFH2/usr) from DB2 stored procedure
We have a stored procedure in DB2 written in an external sproc (possibly some mainframe language, possibly C++) that creates an XML structure and puts it on a queue.
I know we can add a correlation id,...
3
votes
1
answer
147
views
Why does Pandas not recognise my sqlalchemy connection engine?
I'm trying to connect to an IBM DB2 database from Python. I'm using Python 3.12.10, SQLAlchemy 1.4.54, and Pandas 2.3.2. This is what my code looks like:
import os
import sqlalchemy
import pandas as ...
-1
votes
3
answers
137
views
Count 3 different set of dates from two columns
I have a query with a result like this example:
Column_1
Column_2
Column_3
Text
9/1/2025
9/15/2025
Text
9/1/2025
9/15/2025
Text
9/1/2025
9/30/2025
Text
9/1/2025
9/30/2025
I want to create a nested ...
2
votes
4
answers
133
views
Multiply a Row by a Multiplier of a Column
I have a query that output a dataset that looks like this in DB2:
ID
Amount
Multiplier
001
1000
0
002
2000
0
003
3000
3
004
4000
2
I'd like to add a nested query with this condition: When Multiplier ...
0
votes
0
answers
79
views
How to downgrade the IBM driver to match the license
my previous license version is 1.6.0, and connected to the IBM db2. However I accidentally upgrade the driver version, now is 4.34.3 which is the latest version, I can't get the newest license, is ...
1
vote
1
answer
96
views
SQL JSON_OBJECT in RPGLE Character conversion is not defined
I try to make a JSON_OBJECT in my SQLRPGLE Program. But even the simplest doesnt work:
**FREE
ctl-opt dftactgrp(*no) actgrp(*caller);
dcl-s PAYLOAD varchar(1000);
EXEC SQL
SELECT CAST(
...