Condition based execute_query [message #383068] |
Tue, 27 January 2009 03:04  |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Hi All !
I have created forms based on a table say form1,form2 and form3..
I retrieve records that is saved in form1 in form2 and form3 using
in order to avoid duplications..
Now my requirement is retrieve records in form3 based certain conditions..
I tried with the coding
Trigger:when button pressed Block : HODAL
Set_Block_Property('HODAL',DEFAULT_WHERE,'status like %Pending%');
execute_query;
and
Trigger:when button pressed Block : HODAL
Set_Block_Property('HODAL',DEFAULT_WHERE,'status=Pending Approval');
execute_query;
Both didnt work and gave me the error ..
FRM-40505: Oracle error: unable to perform query
Kindly help me to overcome this error..
Actually i need to check 2 conditions in the set_block_property for 2 variables which is of datatype varchar..
I tried searching for examples for this , but could not find .. If possible pls help with some examples for the same..
pls help!
Thanks and Regards,
varosh
|
|
|
|
|
Re: Condition based execute_query [message #383080 is a reply to message #383068] |
Tue, 27 January 2009 04:02   |
 |
Littlefoot
Messages: 21826 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Obviously, such a syntax is wrong.
When dealing with strings, you have to enclose them into single quotes. Quoting single quotes is a little bit more complicated task, as you'll have to double them.
Therefore, it would be better to write a query in SQL*Plus, make sure it works and then apply this solution in Forms.
This time, I'll help: correct syntax isSet_Block_Property('HODAL', DEFAULT_WHERE, 'status like ''%Pending%''');
Do the rest by yourself.
|
|
|
Re: Condition based execute_query [message #383101 is a reply to message #383080] |
Tue, 27 January 2009 04:35   |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Hi Sir !
Thanks for your reply..
Actually i was trying with
Set_Block_Property('HODAL', DEFAULT_WHERE, 'status like ''[B]'[/B]%Pending%[B]'[/B]''');
Now i got clear by the code u suggested..
Thanks and Regards,
varosh
|
|
|
Re: Condition based execute_query [message #383564 is a reply to message #383079] |
Thu, 29 January 2009 03:21   |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Hi sir !
I tried with the coding u suggested..
Trigger: when new block instance
if :global.employeeid='1111' then
[B]Set_Block_Property('HODAL', DEFAULT_WHERE,'employeeid=2 or employeeid=3 and status like ''Pending%''');[/B]
execute_query;
elsif :global.employeeid='2222' then
[B]Set_Block_Property('HODAL', DEFAULT_WHERE, 'employeeid=234 and status like ''Pending%''');[/B]
execute_query;
elsif :global.employeeid='3333' then
[B]Set_Block_Property('HODAL', DEFAULT_WHERE, 'employeeid=5 and status like ''Pending%''');[/B]
execute_query;
end if;
Initially i tried with 2 records with employeeid=2 and employeeid=3, whose status value'Pending Approval'..
It worked fine..
I have to change the status of employeeid=2 to Approved from Pending Approval and save the record in this block HODAL..
When i enter this block next time the record employeeid=2 with status=Approved is present, which should not happen..
Pls help to overcome this..
Thanks and Regards,
varosh
|
|
|
|
Re: Condition based execute_query [message #383589 is a reply to message #383564] |
Thu, 29 January 2009 04:12   |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Hi Sir !
Thanks for your reply..
I tried by giving
Trigger: when button pressed
clear_form(no_validate);
in a separate button..
But still the same thing happens..
Pls help to solve this
Thanks and Regards,
varosh
|
|
|
Re: Condition based execute_query [message #383594 is a reply to message #383564] |
Thu, 29 January 2009 04:24   |
 |
Littlefoot
Messages: 21826 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Try to rearrange triggers; instead of using the WHEN-NEW-BLOCK-INSTANCE, move code into the PRE-QUERY trigger - don't forget to remove EXECUTE-QUERY out of it!
-- PRE-QUERY trigger:
if :global.employeeid='1111' then
Set_Block_Property('HODAL', DEFAULT_WHERE,'employeeid=2 or employeeid=3 and status like ''Pending%''');
elsif :global.employeeid='2222' then
Set_Block_Property('HODAL', DEFAULT_WHERE, 'employeeid=234 and status like ''Pending%''');
elsif :global.employeeid='3333' then
Set_Block_Property('HODAL', DEFAULT_WHERE, 'employeeid=5 and status like ''Pending%''');
end if;
If it still doesn't work, you'll have to debug the form; check "global.employeeid" value (perhaps nothing is true so DEFAULT_WHERE is not set), check "employeeid" value, etc.
|
|
|
|
Re: Condition based execute_query [message #386182 is a reply to message #383607] |
Fri, 13 February 2009 00:54   |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Hi !
I resolved this issue using (),
Set_Block_Property('HODAL', default_where,'(employeeid=2 or employeeid=3) and status like ''Pending%''');
Now my issue is, i need to check two conditions for status for which i tried with the coding,
Set_Block_Property('HODAL', DEFAULT_WHERE,
'(employeeid=2 or employeeid=3) and (status like ''Pending%'' or status like ''Cancelled'')');
But this gave me the error
frm-40350 Query caused no records to be retrieved
Pls help to resolve the same !
Thanks and Regards
varosh [EDITED by DJM: split long line]
[Updated on: Sun, 15 February 2009 23:09] by Moderator Report message to a moderator
|
|
|
|
Re: Condition based execute_query [message #386200 is a reply to message #386197] |
Fri, 13 February 2009 02:06   |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Hi !
I tried in my database window with,
SELECT *
FROM empaply WHERE ( employeeid = 2
OR employeeid = 3)
AND ( status LIKE 'Pending%'
OR status LIKE 'Cancel%');
This is working !
In my case since i have created 2 forms based on single table i cant use select into statement to retrieve records since into clause tablename and from clause table name cant be the same right?
So i used execute_query, which i wanted to happen based the condition i gave in my coding ..
Thanks and Regards
varosh
|
|
|
Re: Condition based execute_query [message #386236 is a reply to message #383068] |
Fri, 13 February 2009 04:09   |
cookiemonster
Messages: 13972 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Presumably the form isn't executing the query you think it's executing.
I suggest you use
get_block_property(<block_name>, last_query);
To find out for sure what query the form is actually executing.
|
|
|
|