View previous topic :: View next topic
|
Author |
Message |
NahuelTori
New User
Joined: 29 Sep 2008 Posts: 9 Location: Argentina
|
|
|
|
Hello, I have a problem:
I've got a cursor in my program. I open it, fetch some rows, and then I close it. When I open it again, the first fetch give me an SQLCODE 100.
Why this happened? I thought the cursor would return the same rows again...
An important thing: before I open the cursor for the second time, the table used is UPDATED. I tried with a COMMIT before the 2nd OPEN, but doesn't work.
Any help is gratefull...
Bye!!
PD: Sorry for my english, I'm from Argentina. |
|
Back to top |
|
|
Suresh Ponnusamy
Active User
Joined: 22 Feb 2008 Posts: 107 Location: New York
|
|
|
|
Hi
Please provide Declare Cursor, Open, fetch and Update statements. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Check the fields in your WHERE statement.
They probably have different values than during the 1st OPEN. |
|
Back to top |
|
|
NahuelTori
New User
Joined: 29 Sep 2008 Posts: 9 Location: Argentina
|
|
|
|
The cursor is a simple one, like
Code: |
EXEC SQL
DECLARE cursor_name CURSOR FOR
SELECT variable 1,
variable 2,
etc...
FROM table
WHERE BANCO = :BANCO AND
PROD = :PROD AND
SUBPROD = :SUBPROD AND
TIPO = :TIPO AND
CCC = :CCC AND
OPERAC = :OPERAC AND
TAREA = :TAREA AND
CUOTA <> 0
ORDER BY CUOTA ASC, SECUENCIA DESC
END-EXEC.
|
I have checked the fields from the Where statement before both OPENs, and they have the same values.
saludos, |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
An important thing: before I open the cursor for the second time, the table used is UPDATED.
|
any chance that any of the following columns where updated?
BANCO
PROD
SUBPROD
CCC
OPERAC
TAREA
CUOTA |
|
Back to top |
|
|
NahuelTori
New User
Joined: 29 Sep 2008 Posts: 9 Location: Argentina
|
|
|
|
Anyone of that columns where updated... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Nahuel,
Reason I asked: these are columns in your WHERE clause.
If any were UPDATEd,
then the results of the second cursor are not surprising.
the rows were a part of the first cursor.
change any of these columns
and then the second cursor will not find them,
because they nolonger contain the same values
that you used in your host variables of the WHERE clause. |
|
Back to top |
|
|
NahuelTori
New User
Joined: 29 Sep 2008 Posts: 9 Location: Argentina
|
|
|
|
Dick, I've misunderstood what I typed, my apologize.
I mean that none of the columns where updated. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
NahuelTori,
Are the values of the host variables in the WHERE condn. the same before each OPEN. Try DISPLAY ing these values. |
|
Back to top |
|
|
NahuelTori
New User
Joined: 29 Sep 2008 Posts: 9 Location: Argentina
|
|
|
|
Arun, yes they are the same.
I've DISPLAYed it and checked. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
NahuelTori,
Are you sure that you're the only person playing around with this table. |
|
Back to top |
|
|
NahuelTori
New User
Joined: 29 Sep 2008 Posts: 9 Location: Argentina
|
|
|
|
Yes, during the execution, no one modifies the table except me. |
|
Back to top |
|
|
NahuelTori
New User
Joined: 29 Sep 2008 Posts: 9 Location: Argentina
|
|
|
|
Well, I've solved it creating another cursor with the same code, but different name. This time it worked.
I think the problem was that the table has being taken, but I didn't realize where.
Thank you everyone for your help!! |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
NahuelTori,
Did you mean that the problem got solved just by changing the cursor name on second open. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
the reason we can not solve these problems is because we don't understand this heavy tech language:
Quote: |
... table has being taken, but I didn't realize where |
Changing the name on the cursor should make no difference.
Now that you have two (2) cursor declarations, 2 cursor opens , 2 cursor fetches, and 2 closes - that have the same where clause??
sorry, your solution to this 'problem' does not make any sense to me. |
|
Back to top |
|
|
NahuelTori
New User
Joined: 29 Sep 2008 Posts: 9 Location: Argentina
|
|
|
|
Quote: |
we don't understand this heavy tech language |
I apologize again for my english, I'm still learning...
Yes, I have 2 cursor declarations, 2 cursor opens, etc, etc, with 2 paragraphs each, that have the same WHERE clause.
Also does not make any sense to me, if I find the reason promise I tell you. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you mentioned before that your language skills were lacking
and I apologize to you for my comment - about the tech lang.
But, as you, I don't understand the solution. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Yes, I too am surprised by the "solution".
Do you fetch all the rows returned by the 1st cursor ?
Do you always receive SQLCODE = 100 in the 2nd cursor ?
The fields in the WHERE are not the same ones as the FETCH INTO ? |
|
Back to top |
|
|
|