Getting error SQLCODE = -805, ERROR: DBRM OR PACKAGE NAME Not found - db2

Getting error SQLCODE = -805, ERROR: DBRM OR PACKAGE NAME DALLAS9..DSNTIAUL.184FA79814E1838D NOT FOUND IN PLAN COBDBSTR.REASON 01.
//DBULOAD JOB CLASS=A,MSGCLASS=A,NOTIFY=&SYSUID,MSGLEVEL=(1,1),
// PRTY=15,REGION=4M
//*
//JOBLIB DD DSN=DSN910.DB9G.SDSNEXIT,DISP=SHR
// DD DSN=DSN910.SDSNLOAD,DISP=SHR
//UNLOAD EXEC PGM=IKJEFT01,DYNAMNBR=50
//SYSIN DD *
SELECT * FROM SYSIBM.SYSTABLES ;
/*
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DB9G)
RUN PROGRAM(DSNTIAUL) -
PLAN(DSNTIAUL) -
LIB('DSN910.DB9G.RUNLIB.LOAD') -
PARMS('SQL')
END
/*
//SYSREC00 DD DSN=RAHUL.TABLE.UNLOAD,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//*** TABLE STRUCTURE
//SYSPUNCH DD DSN=RAHUL.TABLE.SYSPUNCH,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//*
I am running Db2 unload JCL and getting the above error. As per above error it is asking me to bind again. No idea where is DSNTIAUL dbrm module.
Getting same error again and again. It is a utility. My JCL completes with a 0012 error code . Please help guys.

You are running into DB2 Sql Error Code -805.
-805 PACKAGE NAME location-name.collection-id.dbrm-name.consistency-token NOT FOUND IN PLAN plan-name. REASON reason-code
Where
location-name : DALLAS9
collection-id : NULL
dbrm-name : DSNTIAUL
consistency-token: 184FA79814E1838D
reason-code : 01
plan-name : COBDBSTR
Which means The package name was not found because there is no package list for the plan.
Verify it with query
SELECT LOCATION, COLLID, NAME
FROM SYSIBM.SYSPACKLIST
WHERE PLANNAME = 'COBDBSTR';
Contact DB2 admins asking them to add the PKLIST option with the appropriate package list entry to the REBIND subcommand and rebind the application plan that is identified by name COBDBSTR

Got the correct plan from DB2ADM (DB2 administrator).

Related

Easytrieve Plus and Db2 - Read a file as input to matching against Db2 table

I am running a batch job that reads in a file in with a list of templates. I am trying to find an example since the one I was provided will not work. I have tried to find any example of reading in a file via EZTPA00. The JCL is correct, but I keep getting an error. Here's the basic code followed by the error I'm getting:
LIST ON
PARM SSID('DB2G')
FILE INFILE1 VB (133 6233)
IP-REC 01 133 A
TEMPLATE 01 015 A
FILE OUFILE1 FB (100 1000)
OP-REC 01 100 A
COMMUN_TRANS_ID 01 040 A
COMMUN_TEMPLATE_NO 42 015 A
DEFINE H-CNT W 13 N
SQL DECLARE C1 CURSOR FOR +
SELECT TRANSACTION, TEMPLATE +
FROM DB2.TEMPLATE_TABLE WHERE +
TEMPLATE = INFILE1:TEMPLATE
FETCH FROM INFILE1
IF EOF INFILE1
DISPLAY 'TEMPLATE ' TEMPLATE ' NOT RETURNED'
STOP
END-IF
CLOSE INFILE1
* INPUT SETUP
JOB INPUT(INFILE1) +
START 010-INIT +
FINISH 999-END
* START THE SQL
SQL OPEN C1
DO WHILE SQLCODE NE +100
SQL FETCH C1 +
INTO :WS-TMPLT, :WS-COMMID
IF SQLCODE NE 0
DISPLAY 'PF : ERROR : SQLCODE : ' SQLCODE
STOP
END-IF
13 SQL DECLARE C1 CURSOR FOR +
SELECT COMMUN_TRANS_ID, COMMUN_TEMPLATE_NO +
FROM VMUSIU.E_COMM_DLVY WHERE +
COMMUN_TEMPLATE_NO = INFILE1:TEMPLATE
13 *******B204 SQL - SQL ERROR, SQLCODE IS -104
13 *******B204 SQL - DSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL "?". SOME SYMBOLS THAT MIGHT BE LEGAL
13 *******B204 SQL - ARE: AND * AT OR SELECTIVITY YEAR YEARS MONTH MONTHS DAY DAYS HOUR
13 *******B204 SQL - DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODE
I have no idea what the "?" is. I tried using a fetch for infile1 but it said it was invalid. Everything I try gives me the same answer. I even tried using ws variables, but it still failed. Does someone have something that allows you to match db2 table info against a file?

Redshift failing on column named "MM"

I get this error on a column named mm in Redshift:
select sum(mm) mm from foo;
ERROR: syntax error at or near "mm"
LINE 1: select sum(mm) mm from foo;
^
I do not get the same error if I alias the column to something else like select sum(mm) mm2 ...
what's special about mm? It is not on the list of reserved words.
Use AS:
SELECT
sum(mm) AS mm
FROM foo

PostgreSQL Cursor Re-open error in GnuCOBOL

I am trying to move from Oracle to PostgreSQL on GnuCOBOL. I have a piece of code which uses cursors and need opening a cursor multiple times. However when trying to open the cursor again I get the error ERROR: cursor "fetchtbl_c1" already exists
IDENTIFICATION DIVISION.
PROGRAM-ID. FETCHTBL.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 D-SOC-REC.
05 D-SOC-NO-1 PIC X(3).
05 FILLER PIC X.
05 D-SOC-NO-2 PIC X(3).
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 USERNAME PIC X(30) VALUE SPACE.
01 SOC-REC-VARS.
05 SOC-NO-1 PIC X(3).
05 SOC-NO-2 PIC X(3).
EXEC SQL END DECLARE SECTION END-EXEC.
EXEC SQL INCLUDE SQLCA END-EXEC.
PROCEDURE DIVISION.
MAIN-RTN.
MOVE SPACE TO USERNAME.
EXEC SQL
CONNECT :USERNAME
END-EXEC.
IF SQLCODE NOT = ZERO DISPLAY "ERROR CONNECTING".
* DECLARE CURSOR
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT SOC_NO_1, SOC_NO_2
FROM INSP
ORDER BY SOC_NO_1
END-EXEC.
EXEC SQL
OPEN C1
END-EXEC.
IF SQLCODE = ZERO DISPLAY "OPEN SUCCESSFUL"
ELSE DISPLAY "OPEN FAILED".
* FETCH
EXEC SQL
FETCH C1 INTO :SOC-NO-1,:SOC-NO-2
END-EXEC.
IF SQLCODE = ZERO DISPLAY "FETCH SUCCESSFUL"
ELSE DISPLAY "FETCH FAILED".
PERFORM UNTIL SQLCODE NOT = ZERO
MOVE SOC-NO-1 TO D-SOC-NO-1
MOVE SOC-NO-2 TO D-SOC-NO-2
DISPLAY D-SOC-REC
EXEC SQL
FETCH C1 INTO :SOC-NO-1,:SOC-NO-2
END-EXEC
END-PERFORM.
* CLOSE CURSOR
EXEC SQL
CLOSE C1
END-EXEC.
IF SQLCODE = ZERO DISPLAY "CLOSE SUCCESSFUL"
ELSE DISPLAY "CLOSE FAILED".
* OPEN AGAIN
EXEC SQL
OPEN C1
END-EXEC.
IF SQLCODE = ZERO DISPLAY "REOPEN SUCCESSFUL"
ELSE DISPLAY "REOPEN FAILED " SQLERRMC.
* COMMIT
EXEC SQL
COMMIT WORK
END-EXEC.
* DISCONNECT
EXEC SQL
DISCONNECT ALL
END-EXEC.
* END
STOP RUN.
Pre-compiled the code using ocesql and compiled using cobc -x
Postgres Output
OPEN SUCCESSFUL
FETCH SUCCESSFUL
003 001
005 001
CLOSE SUCCESSFUL
REOPEN FAILED ERROR: cursor "fetchtbl_c1" already exists
The above code works perfectly fine (except for connection part) in Oracle.
Oracle output
OPEN SUCCESSFUL
FETCH SUCCESSFUL
003 001
CLOSE SUCCESSFUL
REOPEN SUCCESSFUL
I have tried searching on the internet but without any luck. Anybody can help me with this?
I am using PostgreSQL version 10.3 and GnuCOBOL version 2.2.0.
There seemed to be an issue with ocesql pre-compiler. I have put a fix in ocdb.c in function OCDBSetResultStatus to return a successful code in case there is not result resource (which happens for open cursor case).
This might not be entirely correct but after spending a few hours testing I see this working fine.
Code changes:
int
OCDBSetResultStatus(int id, struct sqlca_t *st){
struct s_conn *p_conn;
int retval;
p_conn = look_up_conn_lists(id);
if(p_conn == NULL){
//return OCDB_RES_FATAL_ERROR;
return RESULT_ERROR;
}
if(p_conn->resaddr == OCDB_RES_DEFAULT_ADDRESS){
// 結果リソースが無いため成功で返す
// Ankit: uncommented since there is no result resource,
// (true in case of open cursor)
return OCDB_RES_COMMAND_OK;
//return RESULT_ERROR;
}
#ifdef PGSQL_MODE_ON
retval = OCDB_PGSetResultStatus(p_conn->resaddr,st);
#endif
return retval;
}
Let me know if anybody faces any issues because of this change.

SQLSTATE 7003 while unloading table in JCL

I have a JCL with the following format
Proc Library
//JS020 EXEC PGM=IKJEFT01,
// DYNAMNBR=20
//*
//EXTRACT DD DSN=PATH.EXTRACT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(1,10),RELEASE)
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSPUNCH DD SYSOUT=*
//*
//SYSTSIN DD DSN=PATH.CONTROL_CARD_LIB(CARD1), DISP=SHR
//SYSREC00 DD DSN=TABLEA.UNLOAD.FILE,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,LRECL=80
//SYSIN DD DSN=PATH.CONTROL_CARD_LIB(CARD2), DISP=SHR
----->>
PATH.CONTROL_CARD_LIB
CARD1
DSN SYSTEM(XXXX)
RUN PROGRAM(DSNTIAUL) PLAN(DSNTIAUL) PARM('SQL')
CARD2
Select * from TABLE
where condition1
and condition2
and condition3
When I submit my job I am always getting SQLSTATE = 7003 and SQLCODE = -518. I tried looking in the web and got the following description
The statement identified in the EXECUTE statement is a select-statement, or is not in a prepared state.
Can someone tell me what I miss? Many thanks.
I think it could simply be you are missing a semi-colon ( ; ) to terminate your sql statement.
As James mentions, your SELECT statement in CARD2 is missing a semicolon. When you specify PARM('SQL'), it indicates that your input data set contains one or more complete SQL statements, each of which ends with a semicolon.
If you do not specify the SQL parameter, your input data set must contain one or more single-line statements (without a semicolon) that use the following syntax:
table or view name [WHERE conditions] [ORDER BY columns]
Each input statement must be a valid SQL SELECT statement with the clause SELECT * FROM omitted and with no ending semicolon.
Please refer to this for more details => http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2.doc.apsg%2Frntiaul.htm

Problems using REXX to access both Teradata output and DB2 output

I have a REXX job that needs to read from both Teradata (using BTEQ) and DB2. At present, I can get it to either read from Teradata or DB2, but not both. When I try to read from both, the Teradata one (which runs first) works fine but the DB2 read gives an error of RC(1) upon attempting to open the cursor.
Code to read from Teradata (by and large copied from http://www.teradataforum.com/teradata/20040928_131203.htm):
ADDRESS TSO "DELETE BLAH.TEMP"
"ALLOC FI(SYSPRINT) DA(BLAH.TEMP) NEW CATALOG SP(10 10) TR RELEASE",
"UNIT(SYSDA) RECFM(F B A) LRECL(133) BLKSIZE(0) REUSE"
"ATTRIB FBATTR LRECL(220)"
"ALLOC F(SYSIN) UNIT(VIO) TRACKS SPACE(10,10) USING(FBATTR)"
/* Set up BTEQ script */
QUEUE ".RUN FILE=LOGON"
QUEUE "SELECT COLUMN1 FROM TABLE1;"
/* Run BTEQ script */
"EXECIO * DISKW SYSIN (FINIS"
"CALL 'SYS3.TDP.APPLOAD(BTQMAIN)'"; bteq_rc = rc
"FREE FI(SYSPRINT SYSIN)"
/* Read and parse BTEQ output */
"EXECIO * DISKR SYSPRINT (STEM BTEQOUT. FINIS"
DO I = 1 to BTEQOUT.0
...
END
Code to read from DB2:
ADDRESS TSO "SUBCOM DSNREXX"
IF RC THEN rcDB2 = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT " subsys
sqlQuery = "SELECT COLUMN2 FROM TABLE2;"
ADDRESS DSNREXX "EXECSQL DECLARE C001 CURSOR FOR S001"
IF SQLCODE <> 0 THEN DO
SAY 'DECLARE C001 SQLCODE = ' SQLCODE
EXIT 12
END
ADDRESS DSNREXX "EXECSQL PREPARE S001 FROM :sqlQuery"
IF SQLCODE <> 0 THEN DO
SAY 'PREPARE S001 SQLCODE = ' SQLCODE SQLERROR
EXIT 12
END
ADDRESS DSNREXX "EXECSQL OPEN C001"
IF SQLCODE <> 0 THEN DO
SAY 'OPEN C001 SQLCODE = ' SQLCODE
EXIT 12
END
ADDRESS DSNREXX "EXECSQL FETCH C001 INTO :col2"
IF SQLCODE <> 0 THEN DO
SAY 'FETCH C001 SQLCODE = ' SQLCODE
EXIT 12
END
I suspect that this has something to do with my use of SYSPRINT and SYSIN. Anyone know how I can get this to work?
Thanks.
Edit
The question as stated was actually wrong. Apologies for not correcting this earlier.
What I had really done was have this:
ADDRESS TSO "SUBCOM DSNREXX"
IF RC THEN rcDB2 = RXSUBCOM('ADD','DSNREXX','DSNREXX')
ADDRESS DSNREXX "CONNECT " subsys
...followed by a small read from DB2, then followed by the code to read from Teradata, followed by more code to read from DB2. When this was changed to reading from Teradata first before having anything to do with DB2 at all, it worked.
I don't think this has anything to do with SYSPRINT or SYSIN.
I think you are getting TSO RC = 1, not SQLCODE = 1 (because there is no SQLCODE of 1.
1 is a warning, -1 is an error. You can look this up in the DB2 Application Programming
and SQL Guide
Turn on TRACE R and run it.
There are variables (shown below) that display info about the error/warning.
22 *-* ADDRESS DSNREXX "EXECSQL OPEN C1"
>>> "EXECSQL OPEN C1"
+++ RC(1) +++
23 *-* IF SQLCODE <> 0
28 *-* SAY 'SQLSTATE='sqlstate', SQLERRMC='sqlerrmc', SQLERRP='sqlerrp
SQLSTATE=00000, SQLERRMC=, SQLERRP=DSN
29 - SAY 'SQLERRD='sqlerrd.1', 'sqlerrd.2', 'sqlerrd.3', 'sqlerrd.4',',
sqlerrd.5', 'sqlerrd.6
SQLERRD=0, 0, 0, -1, 0, 0
32 - SAY 'SQLWARN='sqlwarn.0', 'sqlwarn.1', 'sqlwarn.2', 'sqlwarn.3',',
sqlwarn.4', 'sqlwarn.5', 'sqlwarn.6', 'sqlwarn.7',',
sqlwarn.8', 'sqlwarn.9', 'sqlwarn.10
SQLWARN= , N, , , , 2, , , , ,
For example, it could be that when both are used together, there is not enough memory.