Home » Developer & Programmer » Forms » Problem in Cursor
Problem in Cursor [message #174992] Wed, 31 May 2006 06:17 Go to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member


Hii all

i have a button that when i press on it open a new view and perform that code


Quote:


DECLARE
CURSOR cDIS IS
SELECT GDACLXXXX.CODE CODE, GDACLXXXX.DAILY_DATE DAILY_DATE, SUM(GDACLDTXX.VALUE) VALUE

FROM GDACLXXXX, GDACLDTXX
WHERE GDACLXXXX.CODE = GDACLDTXX.GDACL_CODE
GROUP BY CODE, DAILY_DATE;

BEGIN

FOR vDIS IN cDIS LOOP
:DIS.CODE :=vDIS.CODE;
:DIS.DATE :=vDIS.DAILY_DATE;
:DIS.VALUE :=vDIS.VALUE;
NEXT_RECORD;
END LOOP;

SHOW_VIEW('STKITEMSTORES');



THE CANVAS 'STKITEMSTORES'
HOLD THE DATABLOCK 'DIS'
THAT CONTAIN THE ITEMS 'CODE','DAILY_DATE','VALUE'


THE RESULT OF THE CURSOR IS

Quote:


CODE DAILY_DAT VALUE
------- --------- ---------
1 01-JAN-06 110
2 01-FEB-06 20



BUT IN THE DISPLAYED CANVAS IT DISPLAYS ONLY THE SECOND ROW

how can i solve this ??

Thanks for everyone helped and helping me

Re: Problem in Cursor [message #175009 is a reply to message #174992] Wed, 31 May 2006 07:10 Go to previous messageGo to next message
jowahl
Messages: 82
Registered: May 2006
Member
maybe the function NEXT_RECORD does not work due to validation errors?

check out what the cursor really does, e.g. by inserting some messages:

BEGIN
FOR vDIS IN cDIS LOOP
MESSAGE('Begin filling data');PAUSE;
:DIS.CODE :=vDIS.CODE;
:DIS.DATE :=vDIS.DAILY_DATE;
:DIS.VALUE :=vDIS.VALUE;
MESSAGE('Skipping next record');PAUSE;
NEXT_RECORD;
END LOOP;
END;


Re: Problem in Cursor [message #175034 is a reply to message #174992] Wed, 31 May 2006 08:17 Go to previous messageGo to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

I still have the problem

it only displays one record as it overwrite on the first record
Re: Problem in Cursor [message #175036 is a reply to message #175034] Wed, 31 May 2006 08:27 Go to previous messageGo to next message
jowahl
Messages: 82
Registered: May 2006
Member
do you have any WHEN-VALIDATE-ITEM or WHEN-VALIDATE-RECORD triggers that cause NEXT_RECORD to fail?

maybe ther are required items which have no value?
Re: Problem in Cursor [message #175037 is a reply to message #174992] Wed, 31 May 2006 08:29 Go to previous messageGo to next message
Rehan Mirza
Messages: 67
Registered: July 2004
Location: Pakistan
Member

Just write go_Block('BlockName') before for loop

Best regards
R E H A N M I R Z A
Re: Problem in Cursor [message #175040 is a reply to message #174992] Wed, 31 May 2006 08:40 Go to previous messageGo to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

I wrote 'go_block'

so that the code become

Quote:



DECLARE
vDIALY_SUM NUMBER;
vCARD_SUM NUMBER;
vCURRECORD NUMBER;
CURSOR cDIS IS
SELECT GDACLXXXX.CODE CODE, GDACLXXXX.DAILY_DATE DAILY_DATE, SUM(GDACLDTXX.VALUE) VALUE

FROM GDACLXXXX, GDACLDTXX
WHERE GDACLXXXX.CODE = GDACLDTXX.GDACL_CODE
GROUP BY CODE, DAILY_DATE;


BEGIN

GO_BLOCK('DIS');


FOR vDIS IN cDIS LOOP

:DIS.CODE :=vDIS.CODE;
:DIS.DATE :=vDIS.DAILY_DATE;
:DIS.VALUE :=vDIS.VALUE;
next_record;
END LOOP;


SHOW_VIEW('STKITEMSTORES');
END;





i still have the same problem

[Updated on: Wed, 31 May 2006 08:40]

Report message to a moderator

Re: Problem in Cursor [message #175047 is a reply to message #174992] Wed, 31 May 2006 09:17 Go to previous messageGo to next message
jowahl
Messages: 82
Registered: May 2006
Member
if your view is not visible, you can not navigate there with GO_BLOCK. also NEXT_RECORD will fail, if your cursor is in the wrong block.

try to make the view visible an then load data from cursor.
Re: Problem in Cursor [message #175102 is a reply to message #174992] Wed, 31 May 2006 14:56 Go to previous messageGo to next message
Rehan Mirza
Messages: 67
Registered: July 2004
Location: Pakistan
Member

check yours block property single record???? and also see any message appear in status bar

please reply

Best regards
R E H A N M I R Z A
Re: Problem in Cursor [message #175109 is a reply to message #174992] Wed, 31 May 2006 15:31 Go to previous messageGo to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

the block property "single record" is set to "no"

does my code have something wrong
Re: Problem in Cursor [message #175126 is a reply to message #175109] Wed, 31 May 2006 19:18 Go to previous messageGo to next message
lomhanz
Messages: 18
Registered: May 2005
Location: Cebu, Philippines
Junior Member

hello emadbsb,

you forgot to include the "create_record;" procedure. place it before you assign values to your record.

thanks..lomhanz
Re: Problem in Cursor [message #175159 is a reply to message #174992] Thu, 01 June 2006 02:18 Go to previous messageGo to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

I attached the form


and this is the table creation and insertion script :
Quote:


CREATE TABLE GDACLDTXX (
GACCO_CODE NUMBER(5),
DUE_DATE DATE,
VALUE NUMBER(10,2)
);




THE INSERTION
Quote:


insert into GDACLDTXX
(GACCO_CODE,DUE_DATE,VALUE )
values
('1','10-MAY-2006','10');

insert into GDACLDTXX
(GACCO_CODE,DUE_DATE,VALUE )
values
('2','10-DEC-2006','20');


insert into GDACLDTXX
(GACCO_CODE,DUE_DATE,VALUE )
values
('3','20-DEC-2006','40');


insert into GDACLDTXX
(GACCO_CODE,DUE_DATE,VALUE )
values
('4','20-OCT-2006','50');



  • Attachment: PROBLEM.fmb
    (Size: 52.00KB, Downloaded 1006 times)
Re: Problem in Cursor [message #175163 is a reply to message #175159] Thu, 01 June 2006 02:37 Go to previous messageGo to next message
lomhanz
Messages: 18
Registered: May 2005
Location: Cebu, Philippines
Junior Member

hi,

set "insert_allowed property to Yes
also, enable the next_record procedure.

thanks..lomhanz
Re: Problem in Cursor [message #175164 is a reply to message #174992] Thu, 01 June 2006 02:37 Go to previous messageGo to next message
jowahl
Messages: 82
Registered: May 2006
Member
why didn't you post the error that occurs when pushing the button???

"... you can not create records here."

now the solution is simple: set the block property of DIS to "insert allowed = Y"

in your cursor you now can use both: NEXT_RECORD or CREATE_RECORD.

icon14.gif  Re: Problem in Cursor [message #175171 is a reply to message #174992] Thu, 01 June 2006 03:00 Go to previous message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

thanks for every one helped me in this problem


Previous Topic: Displaying some records with different attributes
Next Topic: Percentage
Goto Forum:
  


Current Time: Fri Sep 20 10:27:32 CDT 2024