viewing records from a tree issue [message #545605] |
Thu, 01 March 2012 06:03 ![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 |
|
|
hello, i've got problem when viewing my records from a tree.
When i click a data from a tree it displays 2 times. and when i try to click another data my previous data was gone.
my screenshot is attached
this is my code:
DECLARE
mytree ITEM;
label_of_mynode VARCHAR2(100);
label_of_myParent VARCHAR2(100);
CURSOR subj_cur IS
SELECT s.subj_code, ss.day, ss.starttime, ss.endtime
FROM subjects s, subjsec ss
WHERE s.subj_Code = ss.subj_code
AND s.subj_Code = label_of_mynode
ORDER BY s.subj_code ASC;
BEGIN
IF (:System.trigger_node_selected = 'TRUE') then
-- Find out the tree
mytree := Find_Item('tree.tree');
-- 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);
label_of_myParent := Ftree.Get_Tree_Node_Property(mytree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_LABEL);
END IF;
GO_BLOCK('MAIN');
CLEAR_BLOCK;
FOR subj_rec IN subj_cur
LOOP
:main.txtsection := label_of_mynode;
:main.subject := subj_rec.subj_code;
NEXT_RECORD;
END LOOP;
END;
-
Attachment: lm66a.JPG
(Size: 40.73KB, Downloaded 764 times)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: viewing records from a tree issue [message #545669 is a reply to message #545667] |
Thu, 01 March 2012 10:43 ![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 |
|
|
I'm talking about the screen cursor. The one that appears in items when you click on them.
The one that moves when you do a next_record.
Are you sure it's in the correct record after the go_block?
|
|
|
|
|
|
|
|
Re: viewing records from a tree issue [message #545675 is a reply to message #545674] |
Thu, 01 March 2012 11:17 ![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 |
|
|
?
I ask you to put a message in to display the cursor record and you come back to say it's doing something different?
I have no idea what you've done there.
As I've told you before, you need to learn to debug your code.
Use messages to check what record the cursor is in.
Use messages to check what values the query is returning.
Work out what's going on.
Then if you still can't fix the problem, supply all that information to use and we'll see what we can do.
I can't debug it for you.
|
|
|
Re: viewing records from a tree issue [message #545676 is a reply to message #545675] |
Thu, 01 March 2012 11:28 ![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 |
|
|
pls check my .fmb file.
and i changed my code:
DECLARE
mytree ITEM;
label_of_mynode VARCHAR2(100);
label_of_myParent VARCHAR2(100);
pos NUMBER;
CURSOR subj_cur IS
SELECT s.subj_code, ss.day, ss.starttime, ss.endtime
FROM subjects s, subjsec ss
WHERE s.subj_Code = ss.subj_code
AND s.subj_Code = label_of_mynode
ORDER BY s.subj_code ASC;
BEGIN
IF (:System.trigger_node_selected = 'TRUE') then
-- Find out the tree
mytree := Find_Item('tree.tree');
-- 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);
END IF;
GO_BLOCK('MAIN');
pos := :system.cursor_record;
FOR subj_rec IN subj_cur
LOOP
:main.txtsection := label_of_mynode;
:main.subject := subj_rec.subj_code;
NEXT_RECORD;
END LOOP;
-
Attachment: MOD_LMa.fmb
(Size: 292.00KB, Downloaded 1159 times)
|
|
|
|
Re: viewing records from a tree issue [message #545684 is a reply to message #545677] |
Thu, 01 March 2012 12:10 ![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 |
|
|
Like this:
declare
l_x varchar2(1);
begin
message('Step 1');
select 'x' into l_x from dual;
message('Step 2');
for cur_r in (select dname from dept) loop
message('Step 3 - FOR loop - DNAME = ' || cur_r.dname);
end loop;
message('Step 4 - out of loop');
end;
[Updated on: Thu, 01 March 2012 12:11] Report message to a moderator
|
|
|
Re: viewing records from a tree issue [message #545694 is a reply to message #545677] |
Thu, 01 March 2012 13:13 ![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) |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
baliberde wrote on Thu, 01 March 2012 12:30sorry, i don't know how to use messages
Then you need to start with reading the documentation before you start to try to code. Plus you could use a good book on beginner analysis/debugging techniques.
|
|
|
|
Re: viewing records from a tree issue [message #545714 is a reply to message #545675] |
Thu, 01 March 2012 16:32 ![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 |
|
|
cookiemonster wrote on Thu, 01 March 2012 17:17?
As I've told you before, you need to learn to debug your code.
Use messages to check what record the cursor is in.
Use messages to check what values the query is returning.
Work out what's going on.
Then if you still can't fix the problem, supply all that information to use and we'll see what we can do.
I can't debug it for you.
We really can't debug it for you.
We don't have your tables or your data or your form.
We can't run this.
So you have to.
You need to collect as much information as possible about what it is doing and give that information to us.
I've already told you two things to check. Have you checked them?
|
|
|
|
|
|
|
Re: viewing records from a tree issue [message #545746 is a reply to message #545743] |
Fri, 02 March 2012 03:29 ![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 |
|
|
Maybe if you gathered the information we told you to gather and then posted it here so we could see, we could help you become unstuck.
What's the point of posting here if you're not going to do what we ask?
|
|
|
Re: viewing records from a tree issue [message #545822 is a reply to message #545746] |
Fri, 02 March 2012 10:35 ![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 |
|
|
yes cookie i put messages on my code,
pls. do check it:
in when-button-pressed trigger:
DECLARE
mytree ITEM;
label_of_mynode VARCHAR2(100);
label_of_myParent VARCHAR2(100);
pos NUMBER;
CURSOR subj_cur IS
SELECT s.subj_code, ss.day, ss.starttime, ss.endtime
FROM subjects s, subjsec ss
WHERE s.subj_Code = ss.subj_code
AND s.subj_Code = label_of_mynode
ORDER BY s.subj_code ASC;
BEGIN
IF (:System.trigger_node_selected = 'TRUE') then
-- Find out the tree
mytree := Find_Item('tree.tree');
-- 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);
END IF;
GO_BLOCK('MAIN');
message('FOR loop');
FOR subj_rec IN subj_cur
LOOP
message('FOR loop - subj_code = ' || subj_rec.subj_code);
-- :main.txtsection := label_of_mynode;
:main.subject := subj_rec.subj_code;
Message('Position of cursor');
pos := :system.cursor_record;
NEXT_RECORD;
END LOOP;
message('Step 4 - out of loop');
END;
this is the structure of my table:
![http://i39.tinypic.com/2r2tzb5.jpg](http://i39.tinypic.com/2r2tzb5.jpg)
these are the data inside hie table:
![http://i40.tinypic.com/2u93j47.jpg](http://i40.tinypic.com/2u93j47.jpg)
-
Attachment: LM.fmb
(Size: 104.00KB, Downloaded 1124 times)
|
|
|
|
|
Re: viewing records from a tree issue [message #545847 is a reply to message #545833] |
Fri, 02 March 2012 12: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) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
FOR subj_rec IN subj_cur
LOOP
message('FOR loop - subj_code = ' || subj_rec.subj_code);
-- :main.txtsection := label_of_mynode;
:main.subject := subj_rec.subj_code;
Message('Position of cursor');
pos := :system.cursor_record;
NEXT_RECORD;
END LOOP;
message('Step 4 - out of loop');
You've got a loop. In the loop you have a message that says 'Position of cursor'.
After the message you assign :system.cursor_record to a variable.
You then do nothing with the variable. What's the point of that?
How does that allow you to check that the cursor is in the correct record?
This:
Message('Position of cursor');
pos := :system.cursor_record;
should simply be:
Message('Position of cursor '||:system.cursor_record);
That would tell you something useful.
Next
Where does the hie table fit into this? There's been no mention of it so far. The posted code references subjects and subjsec.
If you're getting duplicates in the block it's probably the cursor query in the code is returning that data, so:
a) we need to know what data is in those two tables
b) you've got a message that shows what the query cursor is returning - care to share what it says?
Finally - don't post dump files. A simple create table statement and some insert statements for the data are always preferable. A test case in other words.
|
|
|
Re: viewing records from a tree issue [message #545858 is a reply to message #545847] |
Fri, 02 March 2012 14:12 ![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 |
|
|
wow it works like a charm! It only now displays one record at a time! I also changed my cursor query, since I joined two tables, it displayed both its records.
For the Hie table, it's the table for my tree.
Pls. see my screenshot:
![http://i39.tinypic.com/za0jl.jpg](http://i39.tinypic.com/za0jl.jpg)
and my final code is:
DECLARE
mytree ITEM;
label_of_mynode VARCHAR2(100);
CURSOR subj_cur IS
SELECT subj_code
FROM subjects
WHERE subj_Code = label_of_mynode
-- AND ss.subj_Code = label_of_mynode
ORDER BY subj_code ASC;
BEGIN
IF (:System.trigger_node_selected = 'TRUE') then
-- Find out the tree
mytree := Find_Item('tree.tree');
-- 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);
END IF;
GO_BLOCK('MAIN');
message('FOR loop');
FOR subj_rec IN subj_cur
LOOP
message('FOR loop - subj_code = ' || subj_rec.subj_code);
-- :main.txtsection := label_of_mynode;
:main.subject := subj_rec.subj_code;
Message('Position of cursor ' || :system.cursor_record);
NEXT_RECORD;
END LOOP;
message('Step 4 - out of loop');
END;
[Updated on: Fri, 02 March 2012 14:16] Report message to a moderator
|
|
|
|