View previous topic :: View next topic
|
Author |
Message |
antonrino.b
New User
Joined: 10 Jan 2006 Posts: 76 Location: Germany
|
|
|
|
Hi,
I have a JCL to run a COBOL program which inserts a row into table tableA. While inserting, it populates the column Entry-id of the table with the JOBID.
After running the JCL, I have to submit the following query to check whether the row has been inserted.
Select * from tableA where Entry-id=<JOBID>.
I want to include this query submission in the JCL itself. For which I need the JOBID of the jcl being submitted. Is it possible to get that?
Thanks,
Antu |
|
Back to top |
|
|
narasimha_devi Warnings : 1 New User
Joined: 10 Mar 2005 Posts: 26
|
|
|
|
Hi,
OPTION 1:
You can pass Job-ID thru SYSIN.
//sysin dd *
job-id
This you can accept in your cobol program.
OPTION 2:
you can pass JOB-ID as data
//ddjobid dd *
job-id
In your cobol program allocate a file assigning to "ddjobid".
Read the file once to get the job-id.
Thanks
Devi |
|
Back to top |
|
|
antonrino.b
New User
Joined: 10 Jan 2006 Posts: 76 Location: Germany
|
|
|
|
JOBID is assigned only at the time of JCL submission. My COBOL program already picks up the JOBID and uses it while inserting into table.
I need that for my inline SPUFI query, which I want to add next to my COBOL program run step.
Hope I am clear about my requirement.
Thanks,
Antu |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Why doesn't your COBOL program get this information automatically? |
|
Back to top |
|
|
antonrino.b
New User
Joined: 10 Jan 2006 Posts: 76 Location: Germany
|
|
|
|
No, My COBOL program automatically gets this information.
I need the jobid for executing the query as inline in JCL after the completion of cobol program.
Code: |
//cobrun job-acc-info
****
//steplib dd dsn=my.pgm.lib
step1 exec pgm=pgmname
.
.
.
****
//step2 exec dsn=my.db.load
.
.
//systsin dd *
Select * from tableA where Entry-id=<JOBID> <--- here i need the jobid |
|
|
Back to top |
|
|
narasimha_devi Warnings : 1 New User
Joined: 10 Mar 2005 Posts: 26
|
|
|
|
Hi,
If this table is inserted by only one JOB then we can get job-id using subquery.
//systsin dd *
Select * from tableA where Entry-id= (select JOBID from tableA fetch FIRST ROW ONLY)
If your table is inserted/updated with only one JOB then it picks the JOBID from first row and then assign the JOBID to Entry-Id in where clause.
Try this.. |
|
Back to top |
|
|
antonrino.b
New User
Joined: 10 Jan 2006 Posts: 76 Location: Germany
|
|
|
|
No devi, it is updated by many programs simultaneously.. |
|
Back to top |
|
|
narasimha_devi Warnings : 1 New User
Joined: 10 Mar 2005 Posts: 26
|
|
|
|
Hi,
If it is updated with multiple Jobs then what you want to check in your sql query?
if you want to check whether rows are inserted or not then why dont you add the sql query in the same Job where you are executing the cobol program to insert rows. |
|
Back to top |
|
|
antonrino.b
New User
Joined: 10 Jan 2006 Posts: 76 Location: Germany
|
|
|
|
That is my requirement. I want to add the sql query in the same job.
I was trying to get the JOBID of the job being submitted, in the same job itself to execute the query.
Anyway, I will try running the query with "fetch first one row". But are you sure, that it will return the most recent row? |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Here is my solution: Insert additional step between the COBOL and your SELECT.
In this step, put a REXX exec that gets the jobid and generate the SYSTSIN for the next step. You can use temporary file with DISP=(NEW,PASS) in the REXX setp, and DISP=(OLD,DELETE,DELETE) in the next step.
To get jobid from REXX, you may try the following code:
Code: |
/* REXX */
/* Get jobid: CURRENT_TCB->JSCB->SSIB */
numeric digits 24 ; TRACE I
cvtptr=storage(10,4) /*CVT*/
psatcb=storage(d2x(c2d(cvtptr)),4)
currtcb=storage(d2x(c2d(psatcb)),4)
tcbjscb=storage(d2x(c2d(currtcb)+x2d(B4)),4)
jscbssib=storage(d2x(c2d(tcbjscb)+x2d(13c)),4)
ssibjbid=storage(d2x(c2d(jscbssib)+x2d(c)),8)
say 'jobid='ssibjbid
return 0 |
Enjoy.
O. |
|
Back to top |
|
|
narasimha_devi Warnings : 1 New User
Joined: 10 Mar 2005 Posts: 26
|
|
|
|
Hi,
If you are adding SQL query in the same job then you can use the job-id which is passed to cobol.
Otherwise job-id which is defined in jobcard.
Fetch first row only will retrieve the first row from the table not the latest one.
In ur table if you have current date or current time stamp then you can get latest row from the table using max(timstamp/date column) in subquery.
Thanks
Devi |
|
Back to top |
|
|
|