DB2

IBM DB2 is a family of relational database server products developed by IBM that have been extended to support object-relational features and non-relational structures like JSON and XML. There are three main products in the DB2 family: DB2 for Linux, UNIX and Windows (informally known as DB2 LUW), DB2 for z/OS (mainframe), and DB2 for i (formerly OS/400), plus a version for IBM's Virtual Storage Extended (VSE) operating system.

Share tech news, updates, or what's on your mind.

Sign up to Post

How can I save the results for REORGCHK_IX_STATS to a table in TOAD.  This is on DB2 10.5 for Windows.

CALL SYSPROC.REORGCHK_IX_STATS('S', 'SCHEMA1')

Thank you!
0
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

My background is as a MS SQL Server DBA, very new to DB2.

I have a report query that I have in a file and I want to analyse it using db2advis.  I run this

C:\Windows\system32>db2advis -d depsvcs -n MainSchema -i c:\db2advis\sqlfile.in -t  5

And I get this.

execution started at timestamp 2017-07-26-10.55.06.475000
Error.  Could not open this input file [c:\db2advis\sqlfile.in]

Error.  No valid statements were found in this input file or in the
workload table.


In windows I set the security to the db2advis folder to full control by everyone.  Same for the sqlfile.in file.

So how do I get db2advis to actually open and use the file?

Thank you!
0
Hi Experts,

I try to check a value in a SQL where clause, but get the error: CPD4374

On the  Where xxxx in() of the next statement

Exec SQL Select * from my file
Where Field1 = :Parm1
  and Field2 = in(:Parm2)

Field2 is numeric(15,0)
Parm2 is Character(128) and contains  '12,13,45,16,32  '

What is missing?
0
Environment:
IIS:8.0
.net4.5
windows server 2012
11.PNG 22.PNG
My website sometime will show this error in the web server .

A process serving application pool 'XXX' suffered a fatal communication error with the Windows Process Activation Service. The process id was '6052'. The data field contains the error number.

please help.
0
Thanks for reading.

I have an SQL database with a linked DB2 server. My client software interfaces with SQL.

The DB2 server contains a parts table, which contains pricing and availability information.

I read a linked view from the DB2 server which is presented as a SQL view at the SQL end. It takes a few seconds to come over in its entirety, which isn't a problem unless I want to run some heavy interrogation on it. Which, I do.

Realistically this information shouldn't be more than 10 minutes behind. So, I thought a trigger might be the answer. I have a table I update every 5 minutes for a completely separate reason. I thought I could attach a trigger to this table to drop/insert a temp parts table, and then merge the information to a locally held table.

I've not got as far as the merge yet, just the first bit! Here is the trigger:

USE MyDB
GO

CREATE TRIGGER dbo.UpdateParts
ON dbo.T1
AFTER UPDATE  
  
AS

IF OBJECT_ID('dbo.TempParts', 'U') IS NOT NULL
DROP TABLE TempParts

SELECT     DB2PartsView.*
INTO            TempParts
FROM         DB2PartsView

GO

Open in new window


I can create the trigger fine, and if I run the SQL outside of the trigger the table is created successfully.

However, when I fire the trigger, I get the error:

"The row value(s) updated or deleted either do not make the row unique or they alter multiple rows"

I understand that triggers have hidden 'Inserted' and 'Deleted' tables, and that perhaps this might be something to do with it.

Is a trigger the right thing to use?

Thanks!

John.
0
We have problem with the application run DB2ResultSet.Read(). sometime will get EROR [24000] [IBM] CLI0115E  Invalid cursor state. SQLSTATE=24000.

Database : DB2 for Linux, UNIX and Windows V10.5
Client: Windows 7 64bit

Method:
public int EventGetEvSegmentCnt(string SegmentID, string strEvntGroup)
        {
            int strGroupCnt = 0;
            string strSQL = string.Empty;
            DB2ResultSet objRs;
            if (string.IsNullOrEmpty(SegmentID) || string.IsNullOrEmpty(strEvntGroup))
            {
                strGroupCnt = 0;
            }
            else
            {
                strSQL = " SELECT COUNT(EVNT_CODE) AS EVNT_GROUP_COUNT FROM E_SEGMENT_EVENT WHERE C_SEGMENT_ID = " + SegmentID + " AND EVNT_GROUP = " + strEvntGroup;
                Common.DatabaseHelper helper = new Common.DatabaseHelper();
                objRs = helper.ExecuteResultSet(strSQL);
                if (objRs.Read())
                {
                    strGroupCnt = 0;
                }
                else
                {
                    strGroupCnt = int.Parse(objRs["EVNT_GROUP_COUNT"].ToString());
                }
            }
            return strGroupCnt;

        }

Error Message:
[Information]      System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> IBM.Data.DB2.DB2Exception (0x80004005): ERROR [24000] [IBM] CLI0115E  Invalid cursor state. SQLSTATE=24000
   at …
0
Microsoft provides a development SQL server that can run on your laptop or PC for developers to work against. I can put a Northwind database on such for example, and devise queries against it. I am looking for similar tools that I can do so for these database formats, if there is such an animal...

DB2
Oracle
SAP
AS400
0
"OF DEL MODIFIED BY COLDEL,REPLACE" works fine and was able to load the records into the database
modified the same to
"OF DEL MODIFIED BY COLDEL'0x7c'REPLACE" as my original file is pipe delimited, now I'm getting below error for the same input file which worked for the "," delimited ( just did replace all for "," with "|") and there are no other ,

SQL3125W  The character data in row "F0-1" and column "1" was truncated
because the data is longer than the target database column.
0
I have the need to get a BOM with all components , currently using Tc. CK86 , but this doesn't give enough information, so I want to do this by SQL, I come from oracle background and dont know how could I get this done in DB2 R/3, I do not have access to query builder or quickview , but i do have read access via SQL, I'm currently trying to figure out a way of getting this info using tables :

MAST Material to BOM Link
STKO BOM Header
STPO BOM item

Does any of you  have a solution for this?

In Oracle I did something like the following:
SELECT DISTINCT LEVEL
	,sys_connect_by_path(msil.segment1, ' @ ') AS "BOM TREE"
	,msi.segment1
	,lpad(' ', LEVEL, '') || msil.segment1 Cod_Component
	,msil.item_type
	,msil.description Desc_Component
	,BIC.component_quantity
	,msiL.primary_unit_of_measure
FROM mtl_system_items msi
	,bom_bill_of_materials bom
	,BOM_INVENTORY_COMPONENTS BIC
	,MTL_SYSTEM_ITEMS MSIL
WHERE msi.organization_id = 332
	AND BOM.ASSEMBLY_ITEM_ID = MSI.INVENTORY_ITEM_ID
	AND BOM.ORGANIZATION_ID = MSI.ORGANIZATION_id
	AND bom.bill_sequence_id = bic.bill_sequence_id
	AND nvl(bic.disable_date, sysdate) >= SYSDATE
	AND BIC.component_ITEM_ID = MSIL.INVENTORY_ITEM_ID
	AND Bom.ORGANIZATION_ID = MSIL.ORGANIZATION_ID
	AND msil.inventory_item_status_code = 'Active'
	AND msi.inventory_item_status_code = 'Active' connect BY prior bic.component_item_id = bom.assembly_item_id
	START
                  WITH msi.segment1 = trim(:parte)
        ORDER BY 2

Open in new window

0
Hi All,

I could be going about this completely wrong; however, I'm working with a field that is originally a number; however, I need to use the Like command in a where clause to isolate certain results.  To further compound this, I need to use the left command to have the where clause only look at the first 5 characters.  

Here is what I have so far:

CAST(MBRLOG.MLCHDT AS VARCHAR(7)) LIKE(LEFT(Date_Table.EligMstrConvert, 5))

Open in new window


I don't always use sql with db2 so I might be slightly off on my logic, but any help or suggestions here would be greatly appreciated.

-Anthony
0
Announcing the Most Valuable Experts of 2016
LVL 6
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

I need to combine address fields(addr_1, addr_2, City, St_cd, zip) into new Mail_Address field where most of the time the addr_2 contains null using DB2

In sql server I can do
rtrim(ltrim(a.addr_1)) + ' ' + rtrim(ltrim(isnull(a.addr_2,''))) + ', '  + rtrim(ltrim(a.City)) + ', ' + rtrim(ltrim(a. St_cd)) + ', ' + rtrim(ltrim(a.zip))
but unable to use in DB2.

I've tried a.addr_1 || '' '' || a.addr_2 || '', '' ||  a.City || '', '' ||  a.St_cd  || '', '' || a.zip  which only return a value in the new field if all fields are not null

I've also tried
Coalesce(a.addr_1,'') || '' '' || Coalesce(a.addr_2,'') . This only returned what was in a.addr_1 even if a.addr_2 wasn't null and I couldn't add the city, st_cd or zip to the coalesce
0
I had this question after viewing Number of Weeks in a particular month.

This works great for Saturday but I my week starts on Monday (day 1).  How do I change this so that I can pick a different day, example, Monday (first day) or Sunday (last day) of the week.
Thank you!
0
We have prod environment and development environment  for DB2 .

1> we are thinking of proposing have a nick schema in dev pointing to prod .
in this case we will need to make sure only specific user id will have access to these nick schema .
is it possible to do that ?

2> if we fire select on  nick schemas< with ur > ; Is it sure that we will not lock  not lock the database tables .

3> Is there any way of controlling database load on the prod databases when queries are fired by nick schema ?
0
Greetings!

As I make my transition from working on "DB2 for I" to "DB2 for z/OS", I'm finding subtle differences that are tripping me up.

For example, I copied the following simple stored procedure from a website:

CREATE PROCEDURE MYSCHEMA.UPDATE_SALARY_1 (
  IN EMPLOYEE_NUMBER CHAR(10),
  IN RATE NUMERIC(6,2))
LANGUAGE SQL
MODIFIES SQL DATA
  UPDATE MYSCHEMA.EMP
     SET SALARY = SALARY * RATE
   WHERE EMPNO = EMPLOYEE_NUMBER

Open in new window


But, when creating the procedure, it throws the following error:

WLM ENVIRONMENT NAME MUST BE SPECIFIED

I googled that error, and it was recommended that I add "DISABLE DEBUG MODE":

CREATE PROCEDURE MYSCHEMA.UPDATE_SALARY_1 (
  IN EMPLOYEE_NUMBER CHAR(10),
  IN RATE NUMERIC(6,2))
LANGUAGE SQL
MODIFIES SQL DATA
DISABLE DEBUG MODE
  UPDATE MYSCHEMA.EMP
     SET SALARY = SALARY * RATE
   WHERE EMPNO = EMPLOYEE_NUMBER

Open in new window


But, it now throws these errors:

REBIND AUTHORIZATION ERROR USING MYSCHEMA AUTHORITY PACKAGE =
LOCDBT1.MYSCHEMA.UPDATE_SALARY_1.(V1) PRIVILEGE = BIND.      

What am I doing wrong?

Thanks for your help!
DaveSlash
0
I had this question after viewing iSeries DB2 SQL - Request user input.

I also have similar requirement and code also follows:-

Sub ChangeQueryVariables()
DIM ssql AS String, NUM AS Interger       
Dim qd as dao.QueryDef,db as dao.Database

Set db=CurrentDb()
Set qd=db.QuerDefs("BM")

NUM=Inputbox()

ssql=select ABAN8,ABALPH from ascrpdta.F0101 where ABAN8=&NUM"
qd.SQL=ssql
Do cmd.OpenQuery "BM"x
End sub

And error is

ERROR: [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0104 -
Token SUB was not valid. Valid tokens: ( CL END GET SET CALL DROP
FREE HOLD LOCK OPEN WITH ALTER BEGIN. Error Code: -104

Query = Sub ChangeQueryVariables()
DIM ssql AS String, NUM AS Interger       
Dim qd as dao.QueryDef,db as dao.Database

Set db=CurrentDb()
Set qd=db.QuerDefs("BM")

NUM=Inputbox()

ssql=select ABAN8,ABALPH from ascrpdta.F0101 where ABAN8=10000
qd.SQL=ssql
Do cmd.OpenQuery "BM"x
End sub

Please suggest

Regards
Suresh
0
Hello. I imported a txt file as a table into QMF and a couple of my columns are displaying as 4.43300000000000E+001, etc.. How can I convert/format these to standard numbers in my query?

Thanks in advance,

James
0
How do I find out to see if there is any open transaction in DB2 database ? in sql server we used to use DBCC OPENTRAN. I am using toad for db2

Many Thanks
0
Hi,

Can we have CDC data mirroring between 2 different version servers.
Example a table is in V5R3 and we create the same table in V7R2 and we would like to have the data replicated from V5R3 to V7R2.

Is this possible. Do you see any issues.

Thanks
Chaitu
0
Hi,

I'm working in the DATA WAREHOUSE PROJECT, Does anyone have the industry best practices on how to build a  TEST cases.

Such as Tools, Technique, the methodology used?
0
Microsoft Certification Exam 74-409
LVL 1
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Greetings, experts!

After almost 25 years of working primarily on DB2 for the midrange (AS/400, IBM i), I now have a new job where I need to quickly come up to speed on DB2 for the mainframe (z/OS). Fortunately, the system catalogs in the SYSIBM schema look to be almost the same, so I’ve been able to glean some information about the database-layout from there. But, I keep thinking, “There HAS TO be a better way!”

For example, on DB2 for i, there’s a fat-client GUI application (called “System i Navigator”) where I can easily view and modify table-structure (including column-definition and indexes) and even run SQL queries. I’ve asked around at the new job, but nobody seems to know of a similar application for DB2 on z/OS.

Can anyone point me in the right direction?

Thanks!
DaveSlash
0
Hello,

We have an index corruption Issue at (HADR environment ) founded into db2diag of primary caused crash , this corruption occurred on primary. I've decided to

1-takeover on standby as no page corruption there and deactivated primary to avoid this corruption moved to standby
2-backup (new primary ) and drop db on old primary
3-restore on old primary (standby) , then working successfully

but doesn't know what the root cause of this page corruption I faced this issue twice during 40 days. My suspect is maybe index not building at true bases, even db2support hadn't got particularity more details they said maybe application code

Is there any way to ensure an index is working fine or not?
As my understanding, there are many flavors of index-related corruption problems, for instance:

Unique index contains duplicates with different RID(s) or same RID(s)
Multiple index entries pointing to the same RID
Index key is out of place (wrong index key order)
Row exists, but index keys do not exist in any or some of the indexes
Index entry pointing to an empty data slot or unused data slot or RID is invalid
Incorrect previous or next index page pointers, incorrect high key or other corruptions on index pages

And if this happens again, is there any different method unless backup and restore?

I found This maybe can be a solution could you  please give me your thoughts  can i do this as a solution ???

REORG the corrupted indexes or mark the index as bad by …
0
I have access database that runs 3 business rules and updates a final table in access.  The logic is in the module rule mod.   I need to loop through 1 million row tables in access and perform procedure logic against the record set.  I am thinking before the database gets to big I should process this information on Teradata platform.  Somehow convert this access module in a stored procedure if that is possible. Or there might be another way through subqueries to get the final outcome.

Sample Database
Customer      Product      Orderdate
11111      VIP      01/01/2017
11111      PLANE      01/16/2017
11111      HOTEL      02/05/2017
22222      VIP      01/01/2017
22222      PLANE      02/28/2017
33333      VIP      01/01/2017
33333      VIP      01/06/2017
33333      HOTEL      01/17/2017
44444      VIP      01/01/2017
55555      VIP      01/01/2017
55555      VIP      02/15/2017
66666      VIP      01/01/2015
66666      VIP      01/28/2017
66666      PLANE      01/29/2017
66666      OTHER      02/01/2017


Business Rule 1 - The first product that has to be ordered is the VIP PRODUCT by customer.
If the VIP PRODUCT is not ordered all rules fail.
Business Rule 2 - If VIP PRODUCT was ordered where there any orders placed within 30 days of the first order for each customer.

Final Output - should look like this:
CustomerID      CustomerName      OrderRuleTest      ProductRuleTest      OrderDateTest      OrderDateFlag
11111      Customer A      PASS   …
0
Experts -

HI,
Using a standard SQL query editor ( like TOAD) , how can I count the total number of tables in a DB2 Database, and also return the count of rows in each table.  

The Database is connected via ODBC connection called an DB2ODBC, the Database name is DB2DB.

Thanks
0
Hi,

  How can i disconnect sessions ( idle or active ) from a DB2 database after some period of time.

  I would like to know how to do it for idle and for active connections.

  The problem is that for some reason the application is not disconnecting the sessions from the database and i would like to be able to disconnect sessions after some period of time.     I will like to find out a way to do it for idle and for active sessions.  Like two different ways for each type of sessions state.

  What i am doing now to solve this problem is rebooting the computer to release all those sessions connections.

 Regards,

   Joe Echavarria
0
I need suggestion around tools that can be used to convert sql, procedures from Oracle DB to IBM DB2 database.
Thanks in advance
0

DB2

IBM DB2 is a family of relational database server products developed by IBM that have been extended to support object-relational features and non-relational structures like JSON and XML. There are three main products in the DB2 family: DB2 for Linux, UNIX and Windows (informally known as DB2 LUW), DB2 for z/OS (mainframe), and DB2 for i (formerly OS/400), plus a version for IBM's Virtual Storage Extended (VSE) operating system.