Home » Developer & Programmer » Forms » viewing records from a tree issue (oracle 10g)
viewing records from a tree issue [message #545605] Thu, 01 March 2012 06:03 Go to next message
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 725 times)
Re: viewing records from a tree issue [message #545648 is a reply to message #545605] Thu, 01 March 2012 08:54 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
I just need it to bind immediately if click another data.
Re: viewing records from a tree issue [message #545650 is a reply to message #545648] Thu, 01 March 2012 09:00 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
I have no idea what you mean by that.
Re: viewing records from a tree issue [message #545651 is a reply to message #545650] Thu, 01 March 2012 09:17 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
if u see my screenshot, I click a particular subject it display twice, i wonder. and when i'd click another subject, the previous subjects disappears. i don't know how to display those subjects at the same time.
Re: viewing records from a tree issue [message #545652 is a reply to message #545651] Thu, 01 March 2012 09:25 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
If it displays twice it's almost certainly because the cursor returns the same subj_code twice.
Re: viewing records from a tree issue [message #545654 is a reply to message #545652] Thu, 01 March 2012 09:41 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
so how can i display many subjects at the same time? sorry i don't have any idea to do that
Re: viewing records from a tree issue [message #545656 is a reply to message #545654] Thu, 01 March 2012 09:44 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
By writing a query that selects many subjects maybe?
I don't really understand what you want to do here.
Re: viewing records from a tree issue [message #545657 is a reply to message #545656] Thu, 01 March 2012 09:51 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
http://i44.tinypic.com/10r0nkm.jpg
pls. see the picture. this is what i want to happen.


i want to display EACH subject when i click on it. But what happens is it displays the 1st subject and when i'd click for another the previous subjects disappears and the new subject replaces it.
Re: viewing records from a tree issue [message #545658 is a reply to message #545657] Thu, 01 March 2012 09:54 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
If you don't want to clear out previously selected data, why on earth have you got a clear_block in your code?!?!?
Re: viewing records from a tree issue [message #545659 is a reply to message #545658] Thu, 01 March 2012 09:57 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
i removed it, but still it clears out the previous data
Re: viewing records from a tree issue [message #545660 is a reply to message #545659] Thu, 01 March 2012 10:08 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Well that for loop is going to stick values in the record the cursor is currently in. Are you sure the cursor is in the right record?
Re: viewing records from a tree issue [message #545664 is a reply to message #545660] Thu, 01 March 2012 10:24 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
yup my cursor is in the right record Sad
Re: viewing records from a tree issue [message #545665 is a reply to message #545664] Thu, 01 March 2012 10:31 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
You checked this how?
Re: viewing records from a tree issue [message #545667 is a reply to message #545665] Thu, 01 March 2012 10:41 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
correct me if i'm wrong, i checked it in the query of the cursor. is that right?
Re: viewing records from a tree issue [message #545669 is a reply to message #545667] Thu, 01 March 2012 10:43 Go to previous messageGo to next message
cookiemonster
Messages: 13925
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 #545670 is a reply to message #545669] Thu, 01 March 2012 10:54 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
no i don't see the cursor, maybe due to display items
Re: viewing records from a tree issue [message #545671 is a reply to message #545670] Thu, 01 March 2012 10:55 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
Then use :system.cursor_record to work out where it is.
Re: viewing records from a tree issue [message #545672 is a reply to message #545671] Thu, 01 March 2012 10:58 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
where would i put :system.cursor_record in my code?
Re: viewing records from a tree issue [message #545673 is a reply to message #545672] Thu, 01 March 2012 11:00 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
After the go_block. Use a message to display the value.
Re: viewing records from a tree issue [message #545674 is a reply to message #545673] Thu, 01 March 2012 11:10 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
http://i43.tinypic.com/15y1ja.jpg

this is what happened. the it doubled everytime i click the last record
Re: viewing records from a tree issue [message #545675 is a reply to message #545674] Thu, 01 March 2012 11:17 Go to previous messageGo to next message
cookiemonster
Messages: 13925
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 messageGo to next message
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 1086 times)
Re: viewing records from a tree issue [message #545677 is a reply to message #545676] Thu, 01 March 2012 11:30 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
sorry, i don't know how to use messages
Re: viewing records from a tree issue [message #545684 is a reply to message #545677] Thu, 01 March 2012 12:10 Go to previous messageGo to next message
Littlefoot
Messages: 21813
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 messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
baliberde wrote on Thu, 01 March 2012 12:30
sorry, 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 #545697 is a reply to message #545694] Thu, 01 March 2012 13:48 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
thanks littlefoot. But i don't know what's wrong with the code. It still displays the record twice
Re: viewing records from a tree issue [message #545714 is a reply to message #545675] Thu, 01 March 2012 16:32 Go to previous messageGo to next message
cookiemonster
Messages: 13925
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 #545715 is a reply to message #545714] Thu, 01 March 2012 16:35 Go to previous messageGo to next message
cookiemonster
Messages: 13925
Registered: September 2008
Location: Rainy Manchester
Senior Member
And learn to use form builder help. It describes every single forms built-in with examples.
If I tell you to use something in forms and you don't know how - look it up
Re: viewing records from a tree issue [message #545716 is a reply to message #545715] Thu, 01 March 2012 18:47 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
have u solved your problem if not do first thing export your tables with data make it test.dmp and upload here

[Updated on: Thu, 01 March 2012 18:51]

Report message to a moderator

Re: viewing records from a tree issue [message #545717 is a reply to message #545716] Thu, 01 March 2012 19:11 Go to previous messageGo to next message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
i dont think .dmp u can upload here make test.dat but with few records otherwise if u want to send in my email this is my email:anzishmughal@hotmail.com send your tables with few records


thanks

[Updated on: Thu, 01 March 2012 19:14]

Report message to a moderator

Re: viewing records from a tree issue [message #545743 is a reply to message #545717] Fri, 02 March 2012 03:04 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
thanks, I will try to upload my tables later. Thanks for helping me, I'm really stuck with this problem.
Re: viewing records from a tree issue [message #545746 is a reply to message #545743] Fri, 02 March 2012 03:29 Go to previous messageGo to next message
cookiemonster
Messages: 13925
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 messageGo to next message
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

these are the data inside hie table:
http://i40.tinypic.com/2u93j47.jpg
  • Attachment: LM.fmb
    (Size: 104.00KB, Downloaded 1073 times)
Re: viewing records from a tree issue [message #545823 is a reply to message #545822] Fri, 02 March 2012 10:36 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
i have already attached my new form.
Re: viewing records from a tree issue [message #545833 is a reply to message #545823] Fri, 02 March 2012 11:31 Go to previous messageGo to next message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
this is my .dmp file pls check. thanks

db.rar

[Updated on: Fri, 02 March 2012 11:34]

Report message to a moderator

Re: viewing records from a tree issue [message #545847 is a reply to message #545833] Fri, 02 March 2012 12:48 Go to previous messageGo to next message
cookiemonster
Messages: 13925
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 messageGo to next message
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

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

Re: viewing records from a tree issue [message #545900 is a reply to message #545858] Sat, 03 March 2012 07:18 Go to previous message
baliberde
Messages: 201
Registered: January 2012
Location: outer space
Senior Member
I have another question but am gonna post it as another topic.
Previous Topic: how to get visual attribute name into a varible?
Next Topic: delete a record in a cursor
Goto Forum:
  


Current Time: Sat Jul 06 00:00:32 CDT 2024