Home » Developer & Programmer » Forms » Multi-record block not displaying items (oracle 10g)
Multi-record block not displaying items [message #543006] Sun, 12 February 2012 03:12 Go to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
hi experts, I want to ask what's wrong with my multi-record block.
When i click a node on my tree, it should display the records on it. For example, my root node is Sections, the parents are 1st sem and 2nd sem. In each sections in 1st sem, whenever i click a child node, it should display on display items. I have set its number of items displayed to 9. Since each sections have 9 subjects. The problem when i run it is that it displays many rows.
Re: Multi-record block not displaying items [message #543007 is a reply to message #543006] Sun, 12 February 2012 03:43 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
this is my code for trigger when tree node activated:


DECLARE
-- To store the tree
mytree ITEM;
-- To store the value of the node selected
-- value_of_mynode VARCHAR2(100);
-- To store the label of the node selected
label_of_mynode VARCHAR2(100);
BEGIN


-- Display message only when selecting the Tree
If (:System.trigger_node_selected = 'TRUE') then
-- Find out the tree
mytree := Find_Item('tree_block.tree8');
-- Get the value of the node clicked on.
-- value_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);
label_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_LABEL);
:main.txtsection := label_of_mynode;

first_record;
GO_ITEM('subject');
--IF label_of_mynode = 'LM11KA1' THEN
	SELECT Subj_Code, Day
	INTO :main.subject, :main.day1
	FROM SubjSec
	WHERE Section = label_of_mynode
	ORDER BY Subj_Code ASC;

END IF;
EXCEPTION
	WHEN TOO_MANY_ROWS THEN
	Message('Error');
		WHEN NO_DATA_FOUND THEN
	Message('Error');
END;
Re: Multi-record block not displaying items [message #543009 is a reply to message #543007] Sun, 12 February 2012 05:01 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
The problem when i run it is that it displays many rows.

Is it your interpretation of what happens? Did Oracle raise TOO-MANY-ROWS exception? I guess that it might, because SELECT statement - as you wrote it - is supposed to return a single record into variables you declared. If WHERE clause makes it return several records, it will fail. True, you are (kind of) handling it in EXCEPTION section, but that's in vain.

If the above is correct, what are your options? First of all, why do you want to select row-by-row? Couldn't you base your block on SUBJSEC table and simply execute query in it (set the WHERE condition with SET_BLOCK_PROPERTY(ONETIME_WHERE) (or DEFAULT_WHERE), or in PRE-QUERY trigger)?

If you insist on manual job, then you should do it in a (cursor FOR) loop which would return a single record. You should NEXT_RECORD - otherwise every new fetch would simply overwrite previous values in the first block record).
Re: Multi-record block not displaying items [message #543013 is a reply to message #543009] Sun, 12 February 2012 09:47 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
Sir, i want to select row-by-row because in each sections, there are many subjects, that's why i want it to appear in my text items. And another thing, can you give me some codes on how to do this onetime_where. Thanks for your kind reply.
Re: Multi-record block not displaying items [message #543014 is a reply to message #543013] Sun, 12 February 2012 09:48 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
this is my edited code

DECLARE
-- To store the tree
mytree ITEM;
-- To store the value of the node selected
-- value_of_mynode VARCHAR2(100);
-- To store the label of the node selected
label_of_mynode VARCHAR2(100);
BEGIN


-- Display message only when selecting the Tree
If (:System.trigger_node_selected = 'TRUE') then
-- Find out the tree
mytree := Find_Item('tree_block.tree8');
-- Get the value of the node clicked on.
-- value_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);
label_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_LABEL);
:main.txtsection := label_of_mynode;

	
	SET_BLOCK_PROPERTY('MAIN',ONETIME_WHERE,'subj_code='||:MAIN.subject);

--IF label_of_mynode = 'LM11KA1' THEN
	SELECT Subj_Code, Day
	INTO :main.subject, :main.day1
	FROM SubjSec
	WHERE Section = label_of_mynode
	ORDER BY Subj_Code ASC;

END IF;
EXCEPTION
	WHEN TOO_MANY_ROWS THEN
	Message('Error');
		WHEN NO_DATA_FOUND THEN
	Message('Error');
END;



If i'm missing something here, pls kindly guide me through. thanks
Re: Multi-record block not displaying items [message #543019 is a reply to message #543014] Sun, 12 February 2012 10:56 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
I want to fetch all records(subjects) of the section that is clicked.
Re: Multi-record block not displaying items [message #543022 is a reply to message #543019] Sun, 12 February 2012 11:22 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
SET_BLOCK_PROPERTY is described in Forms' Help.

There's nothing I'd like to add to my previous message.
Re: Multi-record block not displaying items [message #543023 is a reply to message #543022] Sun, 12 February 2012 11:27 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
okay i have read it.

this is my new code

     DECLARE
     	mytree ITEM;
     	label_of_mynode VARCHAR2(100);

	 /* Explicit declaration of a cursor */

  				
    CURSOR subjtyp_cur IS 
    SELECT subj_code, day 
    FROM subjsec 
    WHERE section = label_of_mynode;
  					
		
     BEGIN
     	
     
     	If (:System.trigger_node_selected = 'TRUE') then
-- Find out the tree
mytree := Find_Item('tree_block.tree8');
-- Get the value of the node clicked on.
-- value_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);
label_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_LABEL);
:main.txtsection := label_of_mynode;
     	
     	end if;
     	
     	
        /* Check to see if cursor is already open. If not, open it. */
        IF NOT subjtyp_cur%ISOPEN
       THEN
          OPEN subjtyp_cur;
      END IF;

      /* Fetch row from cursor directly into an Oracle Forms item */
      
      FETCH subjtyp_cur INTO :main.subject, :main.day1;


       /* Close the cursor */
       CLOSE subjtyp_cur;
   END;



but my problem is, it won't display multiple records, only single record.
Re: Multi-record block not displaying items [message #543026 is a reply to message #543023] Sun, 12 February 2012 11:58 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Which one?
Re: Multi-record block not displaying items [message #543029 is a reply to message #543026] Sun, 12 February 2012 12:11 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
this is the screenshot of my form
http://i40.tinypic.com/ip0a40.jpg

when i click a specific node, it should display all its records, I tried cursor, but it still didn't work.
Re: Multi-record block not displaying items [message #543030 is a reply to message #543029] Sun, 12 February 2012 12:12 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
it only displays one record.
Re: Multi-record block not displaying items [message #543037 is a reply to message #543009] Sun, 12 February 2012 14:26 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
You could try actually doing what Littlefoot said:

Littlefoot wrote on Sun, 12 February 2012 11:01
Couldn't you base your block on SUBJSEC table and simply execute query in it (set the WHERE condition with SET_BLOCK_PROPERTY(ONETIME_WHERE) (or DEFAULT_WHERE), or in PRE-QUERY trigger)?

If you insist on manual job, then you should do it in a (cursor FOR) loop which would return a single record. You should use NEXT_RECORD - otherwise every new fetch would simply overwrite previous values in the first block record).
Re: Multi-record block not displaying items [message #543210 is a reply to message #543037] Mon, 13 February 2012 08:15 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
hi cookiemonster, i tried the cursor FOR, but i got an error, record must be entered or deleted first.


check my code
DECLARE
	mytree ITEM;
  label_of_mynode VARCHAR2(100);
  subject varchar2(100);
  day varchar2(100);
  
   CURSOR subj_cur IS
      SELECT subj_code, day
        FROM subjsec WHERE section = label_of_mynode;
				subj_rec subj_cur%ROWTYPE;

BEGIN
	     	IF (:System.trigger_node_selected = 'TRUE') then
					-- Find out the tree
					mytree := Find_Item('tree_block.tree8');
					-- Get the value of the node clicked on.
					-- value_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);
					label_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_LABEL);
  				:main.txtsection := label_of_mynode;     	
     	END IF;
	

FOR subj_rec IN subj_cur
LOOP

	:main.subject := subj_rec.subj_code;
  :main.day1 := subj_rec.day;
  NEXT_RECORD;
 

END LOOP;

END;

[Updated on: Mon, 13 February 2012 08:18]

Report message to a moderator

Re: Multi-record block not displaying items [message #543211 is a reply to message #543210] Mon, 13 February 2012 08:24 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Use messages to pinpoint which line of code raises the error. Also post the FRM number of the error so we can look it up.
Re: Multi-record block not displaying items [message #543212 is a reply to message #543211] Mon, 13 February 2012 08:25 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
And delete the declaration of subj_rec, it isn't used.
Re: Multi-record block not displaying items [message #543213 is a reply to message #543211] Mon, 13 February 2012 08:40 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
FRM-40102 - record must be entered or deleted first.

why is it not displaying my 9 records?
Re: Multi-record block not displaying items [message #543214 is a reply to message #543211] Mon, 13 February 2012 08:43 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
cookiemonster wrote on Mon, 13 February 2012 14:24
Use messages to pinpoint which line of code raises the error.

Re: Multi-record block not displaying items [message #543215 is a reply to message #543214] Mon, 13 February 2012 08:52 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
You could also try looking up the error message yourself, it might help your understanding.
Also might be an idea to do clear_block at the start. and go_block so the cursor is in the block main (which I suspect is the problem).
Re: Multi-record block not displaying items [message #543216 is a reply to message #543214] Mon, 13 February 2012 08:53 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
correct this if i'm wrong.
EXCEPTION
	WHEN NO_DATA_FOUND THEN
	Message('Error');
END;
Re: Multi-record block not displaying items [message #543217 is a reply to message #543216] Mon, 13 February 2012 08:56 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
No idea what you think that's going to do.
You would put a message between each line of existing code. Then you see what messages you get before the error occurs.
Then you know which line is the problem.
Having looked the error up I know it'll be next_Record that causes it. I suspect it's because the cursor is in the wrong block.
Re: Multi-record block not displaying items [message #543218 is a reply to message #543217] Mon, 13 February 2012 09:01 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
this code i'm doing is in the tree_block trigger when_tree_node_activated.
Re: Multi-record block not displaying items [message #543219 is a reply to message #543218] Mon, 13 February 2012 09:02 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
yah the error is in the next_record. should i put the code in the button so it'd be in the correct block?
Re: Multi-record block not displaying items [message #543220 is a reply to message #543219] Mon, 13 February 2012 09:03 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
yes
Re: Multi-record block not displaying items [message #543221 is a reply to message #543220] Mon, 13 February 2012 09:06 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
wow it works! Thanks cookiemonster. But another problem, when i click another node, it overrides the previous one. what should i do with this?
Re: Multi-record block not displaying items [message #543222 is a reply to message #543221] Mon, 13 February 2012 09:10 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
What do you expect it to do?


EDIT: missing you

[Updated on: Mon, 13 February 2012 09:13]

Report message to a moderator

Re: Multi-record block not displaying items [message #543223 is a reply to message #543222] Mon, 13 February 2012 09:15 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
Since, in each of my sections,, it don't have the same number of records. In my LM11KA1 section, it has 9 subjects(records), and when i click another section, LM32FC3, it only has 5 records. It did override the previous one, but the remaining 4 records still remain. What i want is to clear those records for new section.
Re: Multi-record block not displaying items [message #543224 is a reply to message #543215] Mon, 13 February 2012 09:17 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
cookiemonster wrote on Mon, 13 February 2012 14:52

Also might be an idea to do clear_block at the start.


You need to stop ignoring parts of what people tell you.
Re: Multi-record block not displaying items [message #543225 is a reply to message #543224] Mon, 13 February 2012 09:23 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
Sorry cookiemonster, I have just read your reply. I will try that soon. Thank you for being patient with me.
Re: Multi-record block not displaying items [message #543226 is a reply to message #543225] Mon, 13 February 2012 09:30 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
This is my working code:

DECLARE
	mytree ITEM;
  label_of_mynode VARCHAR2(100);
  subject varchar2(100);
  day varchar2(100);
  
   CURSOR subj_cur IS
      SELECT subj_code, day
        FROM subjsec WHERE section = label_of_mynode;
		--		subj_rec subj_cur%ROWTYPE;

BEGIN
	     	IF (:System.trigger_node_selected = 'TRUE') then
					-- Find out the tree
					mytree := Find_Item('tree_block.tree8');
					-- Get the value of the node clicked on.
					-- value_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);
					label_of_mynode := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_LABEL);
  				:main.txtsection := label_of_mynode;     	
     	END IF;
	

FOR subj_rec IN subj_cur
LOOP
--	FETCH subj_cur INTO :main.subject, :main.day1;
	:main.subject := subj_rec.subj_code;
  :main.day1 := subj_rec.day;
	NEXT_RECORD;
  --SET_BLOCK_PROPERTY('MAIN', ONETIME_WHERE, 'subj_code = ' || :MAIN.subject);
END LOOP;

CLEAR_RECORD;


:SYSTEM.MESSAGE_LEVEL := '5';
UP;
IF NOT FORM_SUCCESS THEN
	Message('');
END IF;
:SYSTEM.SUPPRESS_WORKING := 'TRUE';
END;


thanks to you cookiemonster and littlefoot Smile ^^ God bless.
Re: Multi-record block not displaying items [message #543227 is a reply to message #543226] Mon, 13 February 2012 09:37 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
That works? There's no clear_block, and I don't see the point of the clear_record or the up.
Re: Multi-record block not displaying items [message #543228 is a reply to message #543227] Mon, 13 February 2012 09:44 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
yup, it still works cookie. The message code i put here is just what i saw on google.
Re: Multi-record block not displaying items [message #543229 is a reply to message #543228] Mon, 13 February 2012 09:50 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you say so, I see no way of it working without the clear_block.
Re: Multi-record block not displaying items [message #543230 is a reply to message #543229] Mon, 13 February 2012 09:55 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
when i changed it to clear_block and omitted up, my records didn't appear. so i reverted it to the code i posted.
Re: Multi-record block not displaying items [message #543235 is a reply to message #543230] Mon, 13 February 2012 10:16 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
clear_block would need to go before the for loop not after.
How else are you going to get rid of the previous set of records when you select a new value in the tree?
Re: Multi-record block not displaying items [message #543239 is a reply to message #543235] Mon, 13 February 2012 10:43 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
Yes I put it before the loop. ^^
Re: Multi-record block not displaying items [message #543240 is a reply to message #543239] Mon, 13 February 2012 10:47 Go to previous message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
In fact the "working" code doesn't even contain the go_block needed to fix the FRM-40102
Previous Topic: CLOB Insertion and Updation
Next Topic: Cycle Reference in Oracle Form's Attached Libraries (merged 2)
Goto Forum:
  


Current Time: Thu Sep 12 23:30:33 CDT 2024