View previous topic :: View next topic
|
Author |
Message |
darakhshan
New User
Joined: 03 Mar 2008 Posts: 32 Location: India
|
|
|
|
Hi All
I have a program where there are quite a few cursors and in some places before an operation, i need to check the existance of that row.
for doing that, i have used the following select query:
SELECT 1
INTO :WS-COUNT
FROM SYSIBM.SYSDUMMY1
WHERE EXISTS
(SELECT 1
FROM abcd B
WHERE
B.col1 = :col1
AND B.col2 = :col2
and then i am checking for this variable WS-COUNT..
however, looks like using sysibm.sysdummy1 leads to random scan that is affecting the performance. Can anyone suggest me an alternative?? |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
If you want to chk the existence of a row then a normal select query on your base table shud be sufficient right ??? if return sqlcode is 100 , it means the row is not present ... |
|
Back to top |
|
|
darakhshan
New User
Joined: 03 Mar 2008 Posts: 32 Location: India
|
|
|
|
that is not getting compiled.. it says 'into' clause required. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Just do a normal select ...
Code: |
SELECT col1
INTO ws-col
FROM abcd B
WHERE
B.col1 = :col1
AND B.col2 = :col2
Evaluate sqlcode
when 0
when -811
row exists ..
when 100
no row
|
|
|
Back to top |
|
|
|