Home » Developer & Programmer » Forms » Compilation error
Compilation error [message #478689] Tue, 12 October 2010 01:14 Go to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

I create a simple form....where i display a record 10.
On that form i create a two button i.e. view, add

When i pressed view button i want to show data on form

so i create a trigger on view button
Code is this :

DECLARE
CURSOR C1 IS
SELECT NO,NAME,FLG FROM TEST0;

BEGIN
OPEN C1;
LOOP
FETCH C1 INTO CUR1 ;
EXIT WHEN C1%NOTFOUND;
TEST0.NO = CUR1.NO ;
TEST0.NAME = CUR1.NAME ;
TEST0.FLG = CUR1.FLG ;
END LOOP;

CLOSE C1;
END;

My data block name is test0...
but when i complinig i get a error
which is
encountered symol '=' when one of the expecting following

I didnt get where i mistake
please help me
Re: Compilation error [message #478690 is a reply to message #478689] Tue, 12 October 2010 01:21 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

Dear Swapnil,

Use ':='for assignments,instead of '='.
DECLARE
   CURSOR c1
   IS
      SELECT NO, NAME, flg
        FROM test0;
BEGIN
   OPEN c1;

   LOOP
      FETCH c1
       INTO cur1;

      EXIT WHEN c1%NOTFOUND;
      test0.NO := cur1.NO;
      test0.NAME := cur1.NAME;
      test0.flg := cur1.flg;
   END LOOP;

   CLOSE c1;
END;


Regards
Deepak
Re: Compilation error [message #478691 is a reply to message #478690] Tue, 12 October 2010 01:24 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

deepak,

i did that..it now showing
identifier cur1 must be defined....
Re: Compilation error [message #478692 is a reply to message #478691] Tue, 12 October 2010 01:27 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

Dear swapnil,

You didn't declared 'cur1'. Do it in declaration section
Regards
Deepak
Re: Compilation error [message #478693 is a reply to message #478692] Tue, 12 October 2010 01:28 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

but i declred c1 as cursor..
and i fetch all rows from c1 to cur1..

is it necessary to declared cur1 ..
if yes why???
Re: Compilation error [message #478695 is a reply to message #478693] Tue, 12 October 2010 01:34 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

Check the code below
DECLARE
   CURSOR c1
   IS
      SELECT NO, NAME, flg
        FROM test0;
		cur1 c1%rowtype
		
BEGIN
   OPEN c1;

   LOOP
      FETCH c1
       INTO cur1;

      EXIT WHEN c1%NOTFOUND;
      test0.NO := cur1.NO;
      test0.NAME := cur1.NAME;
      test0.flg := cur1.flg;
   END LOOP;

   CLOSE c1;
END;


here
cur1 c1%rowtype
cur1 is cursor variable, a record of type cursor. You must declare a record of cursor type. otherwise use cursor for loop
DECLARE
   CURSOR c1
   IS
      SELECT NO, NAME, flg
        FROM test0;
BEGIN
   FOR cur1 IN c1
   LOOP
      test0.NO := cur1.NO;
      test0.NAME := cur1.NAME;
      test0.flg := cur1.flg;
   END LOOP;

   CLOSE c1;
END;


This may be more help full to you http://plsql-tutorial.com/plsql-explicit-cursors.htm

Regards
Deepak

[Updated on: Tue, 12 October 2010 01:35]

Report message to a moderator

Re: Compilation error [message #478701 is a reply to message #478695] Tue, 12 October 2010 02:12 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

Thanks man...but i want another help

as i mentioned earlier..no. of displayed record is 10 on that datblock...in my database total 5 rows i inserted earlier....

but in my form shows only last record....i want to shows all reocrd in form..

what is the problem ???
Re: Compilation error [message #478702 is a reply to message #478701] Tue, 12 October 2010 02:15 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

Use NEXT_RECORD after assignment.
DECLARE
   CURSOR c1
   IS
      SELECT NO, NAME, flg
        FROM test0;
BEGIN
   FOR cur1 IN c1
   LOOP
      test0.NO := cur1.NO;
      test0.NAME := cur1.NAME;
      test0.flg := cur1.flg;
      NEXT_RECORD;
   END LOOP;

   CLOSE c1;
END;


Regards
Deepak
Re: Compilation error [message #478703 is a reply to message #478702] Tue, 12 October 2010 02:20 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

I apply same code..as you given me ..
but it shows me message...record must be entered or delete first..

still only one record display
Re: Compilation error [message #478704 is a reply to message #478703] Tue, 12 October 2010 02:23 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

Please don't apply the same code. I don't know where(in which trigger) you are writing the code.
Re: Compilation error [message #478705 is a reply to message #478703] Tue, 12 October 2010 02:23 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

hey deepak,

I send you my .fmb file...
  • Attachment: MODULE1.fmb
    (Size: 48.00KB, Downloaded 954 times)
Re: Compilation error [message #478708 is a reply to message #478705] Tue, 12 October 2010 02:30 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

Try this and give me feedback
DECLARE
   CURSOR c1
   IS
      SELECT NO, NAME, flg
        FROM test0;
BEGIN
   GO_BLOCK ('test0');
   FIRST_RECORD;

   FOR cur1 IN c1
   LOOP
      test0.NO := cur1.NO;
      test0.NAME := cur1.NAME;
      test0.flg := cur1.flg;
      NEXT_RECORD;
   END LOOP;

   FIRST_RECORD;

   CLOSE c1;
END;


Regards
Deepak
Re: Compilation error [message #478709 is a reply to message #478708] Tue, 12 October 2010 02:36 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

And please use ':' data block name ':test0.NO'
Re: Compilation error [message #478710 is a reply to message #478708] Tue, 12 October 2010 02:36 Go to previous messageGo to next message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

but may i know why u use first_record before close cursor .....eaxct intention of that keyword..

Thanks
Re: Compilation error [message #478711 is a reply to message #478709] Tue, 12 October 2010 02:37 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

and in your case there is no need of this code, you just press the execute query button in menu bar
Re: Compilation error [message #478712 is a reply to message #478711] Tue, 12 October 2010 02:45 Go to previous messageGo to next message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

The cursor will be at last record, i used FIRST_RECORD just to move the cursor to first record. No other intentions
Re: Compilation error [message #478720 is a reply to message #478712] Tue, 12 October 2010 03:42 Go to previous message
swapnil_naik
Messages: 269
Registered: December 2009
Location: Mumbai
Senior Member

Thanks you deepak for your help..

[Updated on: Tue, 12 October 2010 03:44]

Report message to a moderator

Previous Topic: loop not working properly
Next Topic: PDE-PLI011 ERROR
Goto Forum:
  


Current Time: Thu Sep 19 12:20:34 CDT 2024