View previous topic :: View next topic |
Author |
Message |
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Fri Dec 20, 2002 4:47 am Post subject: Scrollable Cursors |
|
|
Hi,
I am planning to write a small sample application with scrollable cursors - something which I have not done before. I was going through the DB2 v7 application programming guide. The CURSOR Declaration and the FETCH seem simple enough but I need to know whether the TEMP table that is required for the scrollable cursors to perform has been created by the SYSADMIN or not. Can anyone please tell me whether there is any way to check that. I can of course talk to the system people but if there is some way to check whether the TEMP table exists, then I can quickly start off with my application.
Regards,
Manas |
|
Back to top |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Fri Dec 20, 2002 5:40 am Post subject: |
|
|
Hi Ravi,
I am sorry but I was not able to get it. What I had asked is how to check whether there is a temporary table already defined that can be used for Scrollable cursors. That table has to be defined by SYSADMIN and not by an application programmer. What you are telling me is perhaps how to declare a temporary table for some other purpose and not for scrollable cursors. To use Scrollable cursors, we don't have to do anything else but to change the CURSOR declaration and FETCH a little. We don't have to define a temporary table and insert rows into that ourselves.
Can you please go through my question once again.
Regards,
Manas |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Fri Dec 20, 2002 6:14 am Post subject: |
|
|
Manas,
You can query the SYSIBM.SYSTABLES catalog table if the Global temporary table( designated by type 'G') existed.
ex:
Code: |
SELECT *
FROM SYSIBM.SYSTABLES
WHERE NAME LIKE 'TEMP%'
AND TYPE = 'G'
;
|
Hope this helps...
cheers
kolusu |
|
Back to top |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Fri Dec 20, 2002 6:52 am Post subject: |
|
|
Thanx Kolusu,
When I ran the query, I got two tables but they were in a different database from the one that I am using. That means that perhaps there is no such table defined in my database. I think I will have to contact the support.
Regards,
Manas |
|
Back to top |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Fri Dec 20, 2002 8:17 am Post subject: |
|
|
Hi Kolusu,
I have some other doubts in Scrollable cursors. Basically, I need to implement a paging logic using scrollable cursors in a CICS-DB2 Application. Basically, the program displays 100 records(say) 10 at a time on to the screen. The program is pseudoconversational. So, if the user wants to scroll forward to the next page, the cursor has to be opened again and the next 10 records have to be read from the table and displayed. I have done this using -
1) TSQS ONLY
2) GREATER THAN/LESS THAN WHERE clause on the primary key in the cursor. There will be basically two cursors - one for forward scrolling and one for backward scrolling.
Hope I could make my requirements clear.
Now, I want to do the same thing using Scrollable cursors.
Code: |
EXEC SQL FETCH ABSOLUTE +5 C1 INTO :HVDEPTNO, :DEPTNAME, :MGRNO;
|
Now, in this Scrollable cursor FETCH statement, I have to make the +5(Absolute row position) variable if I have to use this for paging. Is it possible to assign a host variable in place of +5 in the above fetch query?
If not, then can you please tell me some alternate method of paging using scrollable cursors.
Thanks in anticipation.
Regards,
Manas |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Sun Dec 22, 2002 2:20 am Post subject: |
|
|
Hi Kolusu,
The link is fine but that actually does not solve my problem. I am coding a CICS-DB2 program in pseudoconversational mode. In the beginning, I am selecting 10 records from a DB2 table and displaying it on a map. After the SEND MAP the task ends and the cursor state is lost. Now, when the user presses PF8(say), I want to retrieve the next 10 records from the table. This will continue for both forward and backward scrolling. Now, the FETCH query for scrollable cursors will be something like the following :-
Code: |
EXEC SQL FETCH ABSOLUTE +5 C1 INTO :HVDEPTNO, :DEPTNAME, :MGRNO;
|
Now, to implement my requirement in pseudoconversation, I have to make the +5 variable. It has to be something like
Code: |
EXEC SQL FETCH ABSOLUTE :counter C1 INTO :HVDEPTNO, :DEPTNAME, :MGRNO;
|
On every pass through the program I should be able to populate the host variable counter so that I can directly go that record and start retrieving frrom that point onwards. I hope I am able to make myself clear. Now,my question is whether this is possible(Using a Host variable :counter). If not, then what else can be done.
The link that you had provided will work fine for conversational programs but I am coding it the pseudoconversational way.
Regards,
Manas |
|
Back to top |
|
|
hari_uss Beginner
Joined: 19 Dec 2002 Posts: 78 Topics: 6 Location: Trivandrum, India
|
Posted: Wed Dec 25, 2002 3:37 am Post subject: |
|
|
Manas,
You can have a host variable along with ABSOLUTE. That is,
Code: |
EXEC SQL FETCH ABSOLUTE :counter C1 INTO :HVDEPTNO, :DEPTNAME, :MGRNO;
|
is valid. Datatype for 'counter' should be INTEGER or DECIMAL(n,0) where 18 is the maximum value possible for 'n'.
For more information, have a look at this link.
Scrollable Cursors
Note the subtopic 'Fetching from a Scrollable Cursor' in it.
-----
Hari. |
|
Back to top |
|
|
Manas Biswal Intermediate
Joined: 29 Nov 2002 Posts: 382 Topics: 27 Location: Chennai, India
|
Posted: Wed Dec 25, 2002 11:56 pm Post subject: |
|
|
Thanks a ton hari for providing the link. I had searched the v7 Application Programming guide but it was nowhere mentioned that I could use a host variable after ABSOLUTE. And my requirements need a host variable there.
Thanks Again.
Regards,
Manas |
|
Back to top |
|
|
|
|