Multi-record block not displaying items [message #543006] |
Sun, 12 February 2012 03:12 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/9d3a737834daa8c057331fef1633aed5?s=64&d=mm&r=g) |
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 #543009 is a reply to message #543007] |
Sun, 12 February 2012 05:01 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 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 #543014 is a reply to message #543013] |
Sun, 12 February 2012 09:48 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/9d3a737834daa8c057331fef1633aed5?s=64&d=mm&r=g) |
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 #543023 is a reply to message #543022] |
Sun, 12 February 2012 11:27 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/9d3a737834daa8c057331fef1633aed5?s=64&d=mm&r=g) |
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 #543037 is a reply to message #543009] |
Sun, 12 February 2012 14:26 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You could try actually doing what Littlefoot said:
Littlefoot wrote on Sun, 12 February 2012 11:01Couldn'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 message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/9d3a737834daa8c057331fef1633aed5?s=64&d=mm&r=g) |
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 #543215 is a reply to message #543214] |
Mon, 13 February 2012 08:52 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 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 #543217 is a reply to message #543216] |
Mon, 13 February 2012 08:56 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|