Subject unknown cursor error
Author Sudheer Palaparambil
Hi,

In the followng SP, the SQL statement on line 38

UPDATE account_heads SET ageing_id = :iAgID, ageing_balance = :dBaln
WHERE CURRENT OF cT1;

gives an 'unknown cursor error'

So I had to change it to

UPDATE account_heads SET ageing_id = :iAgID, ageing_balance = :dBaln
WHERE company_id = :dCID AND account_id = iAcCd;


to avoid the error. Is this a bug ?

Thank you.


Sudheer Palaparambil


1. CREATE PROCEDURE IR_AGEING_PROCESS(
2. DCID SMALLINT,
3. SFNYR CHAR(4))
4. AS
5. VARIABLE DECLARATIONS
6. BEGIN
7. SELECT dNextID FROM get_next_id( :dCID, '0000', 'AGEING_ID' ) INTO
:iAgID;
8. UPDATE param_1 SET ageing_process_id = :iAgID;
9.
10. FOR SELECT AO.account_id, AO.debit * -1, AO.credit
11. FROM ah_opening AO JOIN account_heads AH ON ( AO.company_id =
AH.company_id )
12. AND ( AO.account_id =
AH.id )
13. WHERE ( AO.company_id = :dCID ) AND ( AO.fin_year = :sFnYr )
14. AND ( AH.sub_schedule_id = 14 )
15. INTO :iAcCd, :dDebit, :dCredit AS CURSOR cT1
16. DO
17. BEGIN
18. ............
19. ............
20. ............
21. IF ( dBaln < 0.00 ) THEN BEGIN
22. FOR SELECT SL.nett
23. FROM sale SL
24. WHERE ( SL.company_id = :dCID ) AND ( SL.account_id =
iAcCd )
25. AND ( SL.s_type = 1 )
26. ORDER BY SL.entry_date DESC
27. INTO :dTran AS CURSOR cT2
28. DO
29. BEGIN
30. ............
31. ............
32. ............
33. UPDATE sale SET ageing_id = :iAgID, ageing_balance = :dABal
34. WHERE CURRENT OF cT2;
35. END
36. END
37. IF ( dBaln < 0.00 ) THEN
38. UPDATE account_heads SET ageing_id = :iAgID, ageing_balance =
:dBaln
39. WHERE CURRENT OF cT1;
40. END
41.END