MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delay of less than a second

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> CICS and Middleware
View previous topic :: View next topic  
Author Message
abhayasahoo
Beginner


Joined: 04 Dec 2002
Posts: 8
Topics: 6

PostPosted: Sun Dec 08, 2002 2:18 am    Post subject: Delay of less than a second Reply with quote

Hi,

The CICS Delay function does not support a DELAY INTERVAL of less than a second. I have a requirement in one of the application programs to put in a delay interval of 0.5 seconds. Can I do this using the CICS DELAY function ? Please let me know if I can do it by using any other function.

Regards,
Abhaya
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Sun Dec 08, 2002 3:34 am    Post subject: Reply with quote

abhayasahoo,


A delay of 0.5 secs?? I wonder what is the requirement for such tiny interval. Even if you are able to incorporate somehow(I can't think of any options) , how are you going to know ??. Half a second is much quicker than a blink of an eye. Do you really need such tiny interval??

Please explain your "need" for such tiny delay and may be someone can shed light on it

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
abhayasahoo
Beginner


Joined: 04 Dec 2002
Posts: 8
Topics: 6

PostPosted: Sun Dec 08, 2002 10:18 pm    Post subject: Reply with quote

Hi,

We are having a CICS-DB2 program where we try to fetch a record INSERTed by another application which happens simulataneously. But for some cases, there is a slight delay in putting the record. When you put a DELAY of 1 second, it is basically slowing down the application. When we don't put a DELAY, we get an SQLCODE +100 (Record not found).

Most of the time (more than 95 %), the application puts records at the right time. However, in some cases there is a slight delay (less than a second). Hence we put the DELAY of 1 second. Since it is an Interactive Voice Response (IVR) system, a DELAY of 1 second is significant. We would like to put a DELAY of say 0.2 or 0.3 seconds if CICS functions support that.

Thanks,
Abhaya
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Mon Dec 09, 2002 5:24 am    Post subject: Reply with quote

Let me get your question/problem:

1 What I understand is that while inserting a record, say RECORDA, in INSERT program, sometimes the insert command is taking time and if you do fetch RECORDA during that interval through your FETCH program then you are in trouble.

2 But if you fetch RECORDA after completion of insert command then you won't have problem.

3 So you will wan't to wait till insert command is over.

If answer to 1-3 are yes then -

In INSERT program - Enqueue RECORDA (which will vary for diffrent records) with NOQUEUE option before insert and DEQUEUE after insert. This will tell the CICS that RECORDA is being inserted.

In FETCH program - Enq RECORDA without NOQUEUE option before fetch and Deq after fetch. This will make FETCH program wait till insert is over.

This will be faster than fixed delay as it will delay only for required interval.

Kolusu: Why 5 sec?
I once neeed such small interval when we were trying to synchronize about 50 thousand transactions at one go. So every fraction of interval saved mattered a lot.
Back to top
View user's profile Send private message Send e-mail
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Dec 09, 2002 6:36 am    Post subject: Reply with quote

Hi Dibakar,
Can you please give me the syntax of doing a ENQ and DEQ on a record while inserting it or reading it to and from a DB2 database. Let us not consider CURSORS but singleton INSERT and SELECT statement.
Till now, I have only done ENQ on TSQs and TDQs.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Mon Dec 09, 2002 8:20 am    Post subject: Reply with quote

Manas,

As far as my understanding of ENQ goes, you don't ENQ a TSQ, TDQ etc but just a name. Now its upto you how to use this information in your program. So same syntax will work only that the name you would like to change, otherwise you will be passing false information. I don't know DB2 but I guess you will like to ENQ ws-record-identifier in both programs as follows

01 ws-current-record-name pic x(10).
01 ws-record-identifier.
05 ws-record-name pic x(10).
05 ws-table-name pic x(10) value 'table-name'.

MOVE ws-current-record-name TO ws-record-name
EXEC CICS ENQ
RESOURCE (ws-record-identifier)
LENGTH (20)
END-EXEC

Now it's upto you if you want to use NOSUSPEND and ENQBUSY or not.

PS: In earlier post I wrote NOQUEUE which should have been NOSUSPEND.
Back to top
View user's profile Send private message Send e-mail
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Mon Dec 09, 2002 9:28 am    Post subject: Reply with quote

Ok Dibakar,
Now I understand what you mean. But you can do ENQ on a resource and not on a WS record. Now, when the insert has not yet been done on the table, how can you ENQ it. The data is still present in the WS. How can you ENQ that?. Your approach suggests that before doing the insert, you ENQ the row in the table but before the insert there is no row that exists. How can you ENQ something which is not there in the tabe. You probably cannot ENQ something which is still there in the WS.
For the approach that you are suggesting, you have to do an ENQ on the whole table simply for the fact that you don't know where you are going to insert the new record. And to ENQ a whole table is not a good idea.

Please correct me if I am wrong.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Mike Tebb
Beginner


Joined: 02 Dec 2002
Posts: 20
Topics: 0
Location: Yorkshire, England

PostPosted: Mon Dec 09, 2002 10:43 am    Post subject: Reply with quote

I don't think you can delay for less than 1 second.

What about just attempting the read, and if a code 100 is returned then trying again (allow 1 re-read, 5 re-reads, or whatever you feel is necessary).
_________________
Cheers - Mike
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Tue Dec 10, 2002 1:57 am    Post subject: Reply with quote

Hi Manas,

You are getting idea of ENQ totally wrong. You can ENQ anything, whether it exist or not because ENQ command will only ENQ a name, not any corresponding physical file or anything. So the solution provided will still work even if you have the record or not. It is for programmer to interpret the ENQ information that something is being done to the record. ENQ command itself will not place any restriction on accesiing the table or record or TSQ etc. It will only reserve the name. So if some other program wants to directly access the record without using ENQ command then CICS will not prohibit it from doing so.

Try the solution suggested, it will work. I had similar doubts earlier but once you test it the concept will be clearer.

I think when CICS mannual talks about RESOURCE with ENQ command people get confused. But if you replace the word by SOMETHING it will be easier to understand.
Back to top
View user's profile Send private message Send e-mail
Manas Biswal
Intermediate


Joined: 29 Nov 2002
Posts: 382
Topics: 27
Location: Chennai, India

PostPosted: Tue Dec 10, 2002 3:05 am    Post subject: Reply with quote

Hi Dibakar,
Please excuse me for being persistent but I am still not able to comprehend how ENQ will work in this case. In one program you have a set of WS variables which contain the record to be inserted. Something like the following -
Code:

01  ws-record.
     05 ws-id    pic x(4) [Primary key]
     05 ws-name pic x(20)
     05 ws-tel-no pic x(10)

The above mentioned WS in one program contains the data for the record to be inserted. You code a SQL like the following to insert the data to a table
Code:

EXEC SQL
         INSERT INTO TABT1
          (ID,NAME,TELNO)
         VALUES
          (:ws-id,:ws-name,:ws-tel-no)
END-EXEC.

The above code will insert the record into the table.

Now, at the same time another program is trying to select the same record.
Code:

EXEC SQL
         SELECT ID,NAME,TELNO FROM TABT1
          INTO :ws-id-pgm2,:ws-name-pgm2,:ws-telno-pgm2
         WHERE ID=:ws-id-pgm2
END-EXEC.


Please note here that in the 2nd program the name of the WS variable that we are using in the WHERE clause is different from the name of the WS variable (ws-name) that was there in the first program which is inserting the record.(Although the data contained in both ws-id and ws-id-pgm2 is the same).

Now, how do you propose that we do the ENQ. In program 1, we need to a do a ENQ on the record before it is inserted into the table. And in Program 2 we again need to do a ENQ on a record which is not present in the table but in the WS of program 1.

Can you please provide me with the exact syntax of the ENQ/DEQ commands in this case considering the above mentioned WS and Table definitions.

Regards,
Manas
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Tue Dec 10, 2002 4:18 am    Post subject: Reply with quote

I guess the following syntax along with the comments will help.

Program 1

01 WS-RECORD.
05 WS-ID PIC X(4).
05 WS-TABLE PIC X(5) VALUE 'TABT1'.
* I am not putting name and tel as they might change, right!

PR-INSERT-PARA.

* Tell CICS, in a coded language, that something related to values in WS-RECORD is being done. So, other programs, take care accordingly!

EXEC CICS ENQ
RESOURCE (ws-record)
LENGTH (9)
END-EXEC

* Yes, you enqued a name, the value in ws-record, corresponding to a data which is not present yet. No problem, you passed the right information.

EXEC SQL INSERT
...
END-EXEC

EXEC CICS DEQ
RESOURCE (ws-record)
LENGTH (9)
END-EXEC

*OK guys, I am done, thanks for waiting, now please proceed.
* DEQ must be done otherwise your program2 might be in trouble

Program 2

01 WS-RECORD-PGM2.
05 WS-ID-PGM2 PIC X(4).
05 WS-TABLE-PGM2 PIC X(5) VALUE 'TABT1'.

* Variable name doesn't matter, its the value that is important

PR-SELECT-PARA.

EXEC CICS ENQ
RESOURCE (ws-record)
LENGTH (9)
END-EXEC

* If program 1 has started something with this record, your program2 will be waiting for it to finish.

* Again tell other programs that something is done with value in ws-record-pgm2

EXEC SQL SELECT
...
END-EXEC

EXEC CICS DEQ
RESOURCE (ws-record)
LENGTH (9)
END-EXEC

* DEQ must be done, why keep a wrong information.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> CICS and Middleware All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group