Questions tagged [db2-luw]
DB2 for Linux, UNIX and Windows
837
questions
0
votes
0
answers
20
views
Db2 Nested Query Error SQLCODE=-206, SQLSTATE=42703
WITH EXECUTIONDATES AS (
SELECT MONTHNAME(UBEXECUTIONDT) AS MONTHNAME,UBEXECUTIONDT FROM WASADMIN.UBTB_CLOSEOFFHIST
),CALCULATED_INT AS (
SELECT ED.UBEXECUTIONDT AS "EXECUTION DATE",IH....
0
votes
0
answers
25
views
Db2 package specification
I've created the following DB2 package specification based on the documentation from IBM.
https://www.ibm.com/docs/en/db2/9.7?topic=plsql-creating-package-specifications
CREATE PACKAGE ...
0
votes
1
answer
33
views
DB2 function timing out with a deadlock or timeout error in query
I have created the following DB2 function below:
CREATE FUNCTION CLAIMS.get_gross_amount
(payment_option varchar(30),fy date, released date, grossamt int, taxamt int)
RETURNS INT
LANGUAGE SQL
...
-1
votes
1
answer
30
views
ROW_NUM() OR DNSE_RANK() Which one should be used and how should I use it?
I have below table and would like to get the result in ROW_NUM Column.
I tried this but don't get what I need.
DENSE_RANK() OVER (PARTITION BY ID, DATE, SURG?, CODE ORDER BY ID)
0
votes
0
answers
36
views
SQL / stored procedure - detect when changes happen within a list of specified values
I need to create a report that returns customer accounts whose account type have changed to or from this list of account_types:
('CAM', 'CAMADP', 'CAMHD', 'CAMHDADP', 'DIST', 'DISTADP', 'GAM', 'GAMADP'...
0
votes
2
answers
29
views
AUTONOMOUS_TRANSACTION in DB2 Luw
I have an application migrated from oracle to db2. There is a package defined where some of the procedures are using pragma autonomous transaction to maintain some logs.
The package got compiled ...
0
votes
1
answer
30
views
Can DB2REMOTE be used to point a file from another server?
Using the script below, I was able to load the data to the table with local files.
db2 load from SOME/LOCAL/File.txt of asc modified by reclen=123 method L \(1 11, 12 14\) REPLACE INTO schema....
0
votes
0
answers
39
views
DB2 - Select count(*) not working properly on subquery
Here follows 2 querys that should bring the same result, but unfortunately thats not the case. They have just 1 different line:
1.
Result = 403
SELECT count(*)
FROM (SELECT CONSULTORA.ID CONSULTORA_ID,...
-2
votes
2
answers
33
views
DB2 - extended_row_sz pros and cons
Can you help me understand the pros and cons of using extended_row_sz parameter in DB2 settings level?
Is that something can we set for a specific tablespace only?
Without extended_row_sz setting ...
0
votes
1
answer
32
views
After successful db2 restore, some tables might have incomplete data loaded?
Two weeks ago, I took db backup(db2 luw - 5tb) and restored it to new server. However three days ago, developer claimed that one of his table data was incompletely restored.
The earliest full backup ...
0
votes
1
answer
21
views
Does DB2 Luw support CHAR semantic?
Oracle supports Byte and Char Semantic when creating table
Create table test(n varchar2(10 byte);
Create table test(n varchar2(10 char);
Does DB2 Luw support the second create statement with char ...
0
votes
1
answer
36
views
Repeat the value from left table if date from right table falls between start date and end date
I would like to join my two tables on [Group] and [YearMonth] Dates. Where [YRMO_NB] from Table 2 falls between [ENR_START] AND [ENR_END] from Table 1 then repeat the value of column [PHASE] for each ...
0
votes
0
answers
28
views
Defining a constructor function of user defined type (object) DB2
I have read that if we create a user defined type with parameters in DB2, DB2 automatically creates a function of this type without the parameters, Which is not the case in ORACLE.
I have checked the ...
0
votes
1
answer
30
views
Convert Floating point value to percentage in Db2 SQL Query
I want to convert floating point values to percentage values from the below DB2 SQL query.
db2 "select STANDBY_SPOOL_PERCENT from table(MON_GET_HADR(NULL))"
The output of the above query is....
0
votes
0
answers
46
views
SAP / DB2 for LUW 11.1 Finding out process that is creating high number of TLOG entries
I have problem with replicating data from DB2 LUW (that is DB for SAP ECC app).
Replication procedure utilize DB2 low level API DB2 Log Reader.
https://www.ibm.com/docs/en/db2/11.1?topic=apis-...
1
vote
1
answer
59
views
Using User defined types in DB2
I am migrating my database from ORACLE to DB2, While doing the migrations I have come across a
situation related to User defined types. As I have been working with DB2 recently, I have been through ...
0
votes
0
answers
62
views
SQL0007N invalid character with sqlalchemy in jupyter-notebook
%%sql
Select Per_capita_Income, Community_Area_Name
from CENSUS_DATA
Where Per_Capita_Income < 11000;
ibm_db_sa://ztl80401:***@125f9f61-9715-46f9-9399-c8177b21803b.c1ogj3sd0tgtu0lqde00.databases....
0
votes
1
answer
33
views
Two CLOB values need to append in DB2
Set ls_total=ls_concat1 || ls_cocat2;
Getting "is too long" error came
Note:ls_concat1,ls_cocat2,ls_total are CLOB datatypes
0
votes
1
answer
56
views
setClientProgramName in DataSource
In tomcat9 there is a setting in context.xml:
<Resource name="jdbc/db2xx" auth="Container"
type="javax.sql.DataSource" driverClassName="com....
0
votes
2
answers
188
views
How to get list of Db2 users from user groups?
On Db2 v11.1 Linux I can get the list of groups a user belongs to:
db2 "SELECT * FROM TABLE (SYSPROC.AUTH_LIST_GROUPS_FOR_AUTHID('MYUSER'))"
How to get vice-versa, list of users that ...
0
votes
1
answer
183
views
User does not have authority/permission despite being db2 dba admin user
On Db2 v11.1 Enterprise Edition on Linux/x86-64 I checked authorities for my current connected user:
select
granteetype,
dbadmauth,
securityadmauth,
dataaccessauth,
accessctrlauth
from ...
0
votes
2
answers
324
views
Db2 rollforward "to end of backup" vs. "to end of logs"?
On Db2 Enterpise Server Edition v11.1 single patitioned database on Linux/Intel using LOGARCHMETH1 I executed backup and restore commands:
db2 "backup database mydb online to /path/to/backup ...
0
votes
1
answer
177
views
creating sql function implemented in java via flyway
I'm trying to create a function like:
--#SET TERMINATOR @
CREATE OR REPLACE FUNCTION NYA.QUINT_2_UINT( I VARCHAR(11))
RETURNS INTEGER
RETURNS NULL ON NULL INPUT
FENCED THREADSAFE
DETERMINISTIC
...
-1
votes
1
answer
80
views
DB2 Update cursor issue
Whats wrong with the below cursor. It works well with oracle, but with db2 gives error
"The FOR UPDATE clause is not allowed because the table specified by the cursor cannot be modified.. SQLCODE=...
0
votes
1
answer
48
views
DB2 LUW MERGE using same table to update a different row
My table data looks like this
My poorly attempted SQL is this...
MERGE INTO PRINT target
USING
(
select ID,PDF_FILE
from PRINT
where date(PRINTED) = '2022-01-06'
and ...
0
votes
2
answers
190
views
SQL0601N The name of the object to be created is identical to the existing name "DJANGO_MIGRATIONS" of type "TABLE"
I want the django to connect to db2 as another user (a DBADM) instead of db2inst1, the schema is XXX. but after running python manage.py migrate, it failed after creating tables DJANGO_MIGRATIONS and ...
0
votes
0
answers
154
views
DBVisualizer ERRORCODE=-4214, SQLSTATE=28000 Password expired
Connecting to DB2 LUW 11.5 database (running on docker)
since a few days I got the following:
An error occurred while establishing the connection:
ERRORCODE=-4214, SQLSTATE=28000 Password expired
the ...
0
votes
1
answer
36
views
Why can my function not use same keywords on DB2 LUW?
I have following function on IBM i DB2 and want to use it on DB2 LUW (Linux). The error I receive is "Multiple or conflicting keywords involving the "FENCED" clause are present.. ...
-1
votes
1
answer
67
views
Db2 Database info wiped out after VM Restart in Azure
I have done the Db2 11.1 installation on Linux 8.1 VM in Azure.
However, every time we STOP & START the VM in Azure, all the Databases, Schemas & Tables are disappearing.
NOTE : I have made an ...
0
votes
1
answer
40
views
SQL0526N when referencing a DGTT (Declared global temporary table) in a FUNCTION
I would like to return content from a pre-created DGTT as a result-set for a table function.
But when I reference it, I get SQL SQL0526N / SQLSTATE 42995 error.
I can't see why. Documentation says ...
0
votes
1
answer
69
views
How to get db2 query output in the following form?
I have a DB2 LUW database, I need the query output in the following form. Each row in from the query output should be in a single line as follows. Thanks in advance for youe help.
Example:-
Table - ...
-1
votes
1
answer
59
views
Unable to create tables in DB2 11.1 installed on Linux VM
I am trying to create a 'employee' table in DB2 11.1.4.6.
However getting -bash: syntax error near unexpected token `('
Installed Db2 11.1 on Linux. Also created 'professional' schema.
Below is the ...
0
votes
1
answer
52
views
SQL0628N with MODIFIES SQL DATA when creating a table function
I am trying to encapsulate the functionality from this sample code here, inside a Table-Function.
I can run the sample alone without any problem.
But when I create a table function, just with a ...
0
votes
2
answers
79
views
Relacing a word in an db2 sql file causes DSNC105I : End of file reached while reading the command error
I have a dynamic sql file in which name of TBCREATOR changes as given in a parameter.
I use a simple python script to change the TBCREATOR=<variable here> and write the result to an output sql ...
0
votes
0
answers
111
views
How to get last accessed date of a table and the user who accessed the table in db2 LUW
I have a db2 LUW database, i'm able to get last accessed date using last_used column from syscat.tables, i also need the user name or id who is trying to access thsi table. Is there any system table ...
0
votes
1
answer
60
views
Count between two dates for each row
I need to count [SALES] for last 12 months per each row of [selected YearMonth]. For example, if 202110 is selected, I know between 202110 and 202011 I had one sale and [HAD SALES] in front of 202110 ...
0
votes
2
answers
57
views
IBM DB2 PIVOT A TABLE FULL OF DATES
I have this table in DB2:
DATE
----------
09/11/2021
06/10/2021
28/11/2021
17/11/2021
11/10/2021
24/11/2021
07/11/2021
30/11/2021
I want to count how many times a date appeared in the table and ...
0
votes
0
answers
61
views
Db2 error during enlarge of a column which is in the primary key
I'm using Db2 11.5.4000.1449 on window 10.
I have the table THETABLE with those columns:
THEKEY CHAR(30) NOT NULL
THEDATA CHAR(30)
Primary key: THEKEY
I try to enlarge the primary key column using ...
0
votes
1
answer
385
views
Executing db2 commands from bash script giving errors?
I am a noob in running db2 commands in the unix environment, so I have been trying to connect to a db2 instance from a bash script. However I get errors here is what my script looks like:
#!/bin/bash
...
-1
votes
2
answers
90
views
SQL Help - Detect Changes Within Specified List of Values
I need to create a report that returns customer accounts whose account type have changed to or from this list of account_types:
('CAM','CAMADP','CAMHD','CAMHDADP','DIST','DISTADP','GAM','GAMADP','LAM',...
0
votes
1
answer
127
views
Django 3.2 Project with DB2 (IBM_DB driver)
Currently, I am working in developing a web application with Python 3.8.10, Django 3.2 and IBM_DB_DJANGO 1.5.0.0.
When I am trying the first step to move from sqlite3 to DB2, I type the command:
...
0
votes
0
answers
77
views
MD5 Hash of a table
I'm not finding anything in the manual or SO that quite matches my need.
Scenario - moving DB2 data to another DBMS - high volume both in terms of number tables and amount of data. It is critical ...
0
votes
2
answers
120
views
calling sqlj.install_jar from jdbc?
I have a python snippet that I try to port to java. The aim is Gradle but I could not get that to work, so I figured I would start with plain JDBC. The python code looks like this:
import argparse
...
0
votes
1
answer
59
views
DB2 Convert Each Column to a Row based on ID
Not sure where to start with this, I've read about pivot/lateral but don't fully understand their use cases so I'm not sure if they apply here. They don't appear to be in my version of DB2 regardless.
...
0
votes
0
answers
170
views
Steps to relocate the primary hadr database to a new server?
Currently we have several databases with a HADR configuration where the primary databases are on a Linux Server "A", with the standby all on Linux Server "B". DB2 version is 9.7.
...
1
vote
1
answer
97
views
How to upgrade Java (to at least 8.0.6.25 ) in IBM DB2 v11.1
I am trying to upgrade Java (to atleast 8.0.6.25 ) in IBM DB2 v11.1.
It's currently bundled but I don't know if the Java setup can separatly be upgraded in any way.
0
votes
1
answer
61
views
Error in connecting to Database in DB2 using python
When I tried to connect the DB2 database through the following python code
python version : 3.6
ibm_db version : ibm_db-2.0.9
DB2_version : 11.5
import configparser
import ibm_db_dbi
config = ...
0
votes
1
answer
47
views
On Db2 v11.1, how do we get or setup the notification for DBA team if there is any hang or slowness situation in offshift working hours?
On Db2 v11.1, how do we get or setup the notification for DBA team if there is any hang or slowness situation in off shift working hours?
1
vote
2
answers
137
views
Select sum based on value of other column
I have a table with values like
ID | CODE | QUANTITY
====================
1 | 2 | 20
2 | 2 | 40
3 | 5 | 10
4 | 6 | 15
5 | 5 | 20
6 | 6 | 50
7 | 6 | 10
8 | 7 | 20
9 | 8 ...
0
votes
1
answer
109
views
Error while using "Export" command in python code
I used the below python code to export the table data from my local server to the required folder in DB2
import os
import ibm_db_dbi
conn = ibm_db_dbi.connect('sandy','USER','qwerty')
cursor = conn....