Home » Developer & Programmer » Forms » Regarding form
Regarding form [message #161804] Tue, 07 March 2006 05:13 Go to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Hi ,
I am designing a DISPLAY FORM.
The form is as follows.
               Product_type
                 X
                 Y
Product    Excellent    Good    Poor  N/A
  X1           2          2       3     1
  X2           1          2       1     2
  Y1           3          1       2     0
  Y2           2          2       2     2
When I select the Product_type as X, both the products X1 and X2 get selected. Similarly when I select Y both Y1 and Y2 get populated.
I already wrote the code for it.

I created a Entry form where I can rate products as excellent, good, poor or N/A. The Entry form is as follows:
People_name                    Product_type
  Alex                           X
  John                           Y
  Tom
  Jay
      
Product       Rate
X1         .Excellent  .Good   .Poor  .N/A
X2         .Excellent  .Good   .Poor  .N/A
Y1         .Excellent  .Good   .Poor  .N/A
Y2         .Excellent  .Good   .Poor  .N/A
Now in my Display form, When I select product_type as X, X1 and X2 are getting populated.
Now my query is as follows:
In the display form,
1)I should be able to see how many people rated excellent , good, poor, N/A regarding product X1. Likewise for X2,Y1,and Y2.
2)Also I want to see the names of people who rated excellent, good, poor and N/A . Can I do this using alert?
I wrote the logic.
select count(people.people_name) from people, ratings, products
where products.product='X1' and ratings.rating='Excellent';
Please tell me how to achieve this task.
People table has People_name, Ratings table has ratings and products table has product.
Kindly help me.
Thanks & Regards,

[Updated on: Tue, 07 March 2006 17:52] by Moderator

Report message to a moderator

Re: Regarding form [message #161806 is a reply to message #161804] Tue, 07 March 2006 05:14 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
What trigger should I use to accomplish the task??
How should I write code in trigger.?
Re: Regarding form [message #162030 is a reply to message #161806] Wed, 08 March 2006 04:55 Go to previous messageGo to next message
samidc
Messages: 35
Registered: February 2006
Member
You can use Post_query Trigger.
Re: Regarding form [message #162033 is a reply to message #161804] Wed, 08 March 2006 05:11 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Hi,
My requirement has slightly changed.
In the Display form, when I select the product_type as X , we see that both X1 an X2 are populated. Similarly the ratings ie Excellent,Good and poor should show me how many people have voted against them in the back end.This is somewhat like a report.Only for viewing how many people have voted for each product.
How can I achieve this task?
Re: Regarding form [message #162150 is a reply to message #162033] Thu, 09 March 2006 00:06 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
For each count run a separate 'select' and populate a non-database item with the result. You need to do this only once so I suggest using the When-New-Block or the Post-Query trigger on a blcok based on 'dual'.

David
Re: Regarding form [message #162441 is a reply to message #162150] Fri, 10 March 2006 04:18 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Hi,
This is the code that I have written in the when_new_block instance of CSKILLS .
DECLARE
	EMP_ID NUMBER;
	BEGIN
set_block_property('cskills',default_where,'skill_type_id in (select skill_type_id from pskills where skill_type=:CONTROL.SPRIMARY)');

select count(emp_id) into :CSKILLS.EXCELLENT  from entries where rating_id=1 and 
 skill_id=(select skill_id from cskills where skill=:CSKILLS.SKILL);
   
 select count(emp_id) into :CSKILLS.GOOD from entries where rating_id=2 and 
 skill_id=(select skill_id from cskills where skill=:CSKILLS.SKILL);
  
 select count(emp_id) into :CSKILLS.POOR from entries where rating_id=3 and 
 skill_id=(select skill_id from cskills where skill=:CSKILLS.SKILL); 
END;
My query doesn't work.Kindly help

[Updated on: Mon, 13 March 2006 00:44] by Moderator

Report message to a moderator

Re: Regarding form [message #162678 is a reply to message #162441] Mon, 13 March 2006 00:45 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay - reformatted the code looks like this.
DECLARE
   EMP_ID   NUMBER;
BEGIN
   set_block_property
         ('cskills',
          default_where,
          'skill_type_id in (select skill_type_id from pskills where skill_type=:CONTROL.SPRIMARY)');

   select count (emp_id)
     into :CSKILLS.EXCELLENT
     from entries
    where rating_id = 1
      and skill_id = (select skill_id
                        from cskills
                       where skill = :CSKILLS.SKILL);

   select count (emp_id)
     into :CSKILLS.GOOD
     from entries
    where rating_id = 2
      and skill_id = (select skill_id
                        from cskills
                       where skill = :CSKILLS.SKILL);

   select count (emp_id)
     into :CSKILLS.POOR
     from entries
    where rating_id = 3
      and skill_id = (select skill_id
                        from cskills
                       where skill = :CSKILLS.SKILL);
END;
David
Re: Regarding form [message #162681 is a reply to message #162678] Mon, 13 March 2006 00:51 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Why are you setting the default_where in the When_New_Block_Instance trigger? Put it in the 'cskills' block's 'default where' property and leave it there.

By the way, add some logic to handle a NULL ':CONTROL.SPRIMARY', use the following code in your where clause.
select skill_type_id
  from pskills
 where skill_type = nvl(:CONTROL.SPRIMARY,skill_type)
How many rows do you have displayed in the 'cskills' block? I believe you need to put these counts into a post_query as you are basing your counting 'select' statements on a value that you have not yet retrieved (:CSKILLS.SKILL).

David
Re: Regarding form [message #162740 is a reply to message #162681] Mon, 13 March 2006 06:59 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Sir,
My form is working ....ie I am able to view the number of people against each rating.

Primaryskill
Oracle
Java

Skill Excellent Good Poor
SQL 1 2 1
PLSQL

Only when I highlight PLSQL , I can see the ratings of PLSQL ...but in the same row as in SQL. What could be the reason for this error?? The values returned are correct...but the values should be displayed against the respective skill. That is not happening.

There is one more doubt.
When I click on "Oracle", I can see SQL and PLSQL. Similarly for Java, I can see J2ee and Servlet.
I want to have something like "All" ,which will diaplay all skills.
In the When_list_changed of Primaryskills, I wrote :
go_block('cskills');
Execute_query;

And in the prequery of cskills, I wrote:
set_block_property('cskills',default_where,'skill_type_id in (select skill_type_id from pskills where skill_type=:CONTROL.SPRIMARY)');

What additions can I make to my code?
I tried writing this but it did not work.

if not :control.sprimary='All' then
set_block_property('cskills',default_where,'skill_type_id in (select skill_type_id from pskills where skill_type=:CONTROL.SPRIMARY)');
else
-----

Kindly help me.

[Updated on: Tue, 14 March 2006 00:14] by Moderator

Report message to a moderator

Re: Regarding form [message #162889 is a reply to message #162740] Tue, 14 March 2006 00:16 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Try
begin
   if not :control.sprimary = 'All' then
      set_block_property
         ('cskills',
          default_where,
          'skill_type_id in (select skill_type_id from pskills where skill_type=:CONTROL.SPRIMARY)');
   else
      set_block_property ('cskills', default_where, null);
   end if;
end;

David

[Updated on: Tue, 14 March 2006 00:18]

Report message to a moderator

Re: Regarding form [message #162944 is a reply to message #162889] Tue, 14 March 2006 04:39 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Sir,
Thank you so much. It is working!!!
I made a small change.
In set_block_property ('cskills', default_where, null);
It gave me a error so I changed null to ' ' .It is working perfectly now.
Thank you so much for your guidance and help.
Sir, Please guide me in my other query too....The values returned are correct but they are be displayed against the respective skill ..they are displayed in the same row as in SQL..
Please guide me.

Re: Regarding form [message #163075 is a reply to message #162944] Tue, 14 March 2006 20:55 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Sorry ... use "set_block_property ('cskills', default_where, to_char(null));"

I don't understand what results you are receiving. Please attach an 8-bit screen dump to your next post.

David
Re: Regarding form [message #163146 is a reply to message #163075] Wed, 15 March 2006 01:58 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Sir,
I uploaded a snapshot of my screen.
As I said earlier, the code is working fine...but the result for 2nd, 3rd or 4th row is also getting retrieved in the 1st row. I need to just highlight on the skill ..the result will be seen only in the first row and not the respective rows of the skill.
Thank you.
Re: Regarding form [message #163148 is a reply to message #161804] Wed, 15 March 2006 02:08 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Sir,
I uploaded a snapshot of my screen.
As I said earlier, the code is working fine...but the result for 2nd, 3rd or 4th row is also getting retrieved in the 1st row. I need to just highlight on the skill ..the result will be seen only in the first row and not the respective rows of the skill.
Thank you
  • Attachment: Doc1.doc
    (Size: 77.50KB, Downloaded 1370 times)
Re: Regarding form [message #163281 is a reply to message #163148] Wed, 15 March 2006 23:16 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
You need to populate the Excellent, Good, and Poor fields in the Post-Query trigger. Where are you populating them currently?

The Excellent, Good, and Poor must be non-database fields in the SAME block as the 'Skill' that is being displayed.

David
Re: Regarding form [message #163330 is a reply to message #163281] Thu, 16 March 2006 04:39 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Sir,
I moved the three items(excellent, good and poor) to cskills block.I tried to populate using post-query trigger(on cskills block)...but my secondary skills are also not getting displayed now. In the console I am getting a message that I should enter something into the skill. If I enter each skill name and press Tab key, I am able to view the ratings. How can I proceed now?
Re: Regarding form [message #163480 is a reply to message #163330] Thu, 16 March 2006 21:01 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay ... let's go back a bit and summarise what is in the form.
1) How many blocks do your have?
2) What are their names?
3) Which is the master and which the detail?
4) Do you have a 'relations' defined between the blocks?
5) Which block has the Post-Query trigger?

David
Re: Regarding form [message #163851 is a reply to message #163480] Mon, 20 March 2006 06:31 Go to previous messageGo to next message
orafan2003
Messages: 122
Registered: February 2006
Senior Member
Sir,
I am sending you the complete details of both the forms. Kindly suggest me a solution to both the forms.
Thank u,
Re: Regarding form [message #166371 is a reply to message #163851] Thu, 06 April 2006 00:51 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Orafan,

Sorry that it has been so long since I got back to you on your question. How have you progressed with it?

I have created your tables and loaded the data. I assume that the zero values in the 'rating_id' of the 'entries' table are actually 'null' values. This is because there is no zero in the 'ratings' table and there is a foreign key relationship between the 'rating_id' on 'entries' and 'rating_id' on 'ratings'.

Would you please consider attaching the current version of your forms so that I can look at them.

David
Previous Topic: launching a form from web in debug mode
Next Topic: Could not reserve record (2 tries) keep trying ?
Goto Forum:
  


Current Time: Fri Sep 20 06:26:38 CDT 2024