Home » Developer & Programmer » Forms » how to use decode for a column of a datablock (oracle 10g)
how to use decode for a column of a datablock [message #591327] Fri, 26 July 2013 07:00 Go to next message
oraclehi
Messages: 41
Registered: July 2012
Location: India
Member
hello

i want to decode a column(aan_status) of a datablock based on table. the column have value in the form of 0 and 1, and i want to display this value as yes(0) or no(1) on my oracle form. how can i do this and where should i put my code???

i tried this by code:
set_block_property('aan_occupant_vu', DEFAULT_WHERE, qry1);
	go_block('aan_occupant_vu');
	clear_block(no_validate);
	SYNCHRONIZE;
	execute_query;



if :AAN_OCCUPANT_VU.aan_status= '0' then
	 =:AAN_OCCUPANT_VU.aan_status:;
else	 
	 :AAN_OCCUPANT_VU.aan_status:='NO';
end if;	




but if else part of my code is not working, as i got the data still in 0 and 1 format, not in 'YES' or 'NO' format.

Thanks.
Re: how to use decode for a column of a datablock [message #591328 is a reply to message #591327] Fri, 26 July 2013 07:02 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Make the item a list item.
Re: how to use decode for a column of a datablock [message #591329 is a reply to message #591328] Fri, 26 July 2013 07:07 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Or radio button. Or checkbox. Or modify code as
:aan_occupant_vu.aan_status := case when :aan_occupant_vu.aan_status = '0' then 'Yes'
                                    else 'No'
                               end;
Re: how to use decode for a column of a datablock [message #591336 is a reply to message #591329] Fri, 26 July 2013 08:06 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
That code would be a bad idea - it modifies a datablock item, so oracle will try and save those changes to the DB.
If you want to use a text item you need to use a different one to the database item to display the value.
Re: how to use decode for a column of a datablock [message #591447 is a reply to message #591336] Mon, 29 July 2013 00:34 Go to previous messageGo to next message
oraclehi
Messages: 41
Registered: July 2012
Location: India
Member
:aan_occupant_vu.aan_status := case when :aan_occupant_vu.aan_status = '0' then 'Yes'
else 'No'
end;


where should i add this code if i'm retriving data through execute_query.
set_block_property('aan_occupant_vu', DEFAULT_WHERE, qry1);
go_block('aan_occupant_vu');
clear_block(no_validate);
SYNCHRONIZE;
execute_query;
Re: how to use decode for a column of a datablock [message #591451 is a reply to message #591447] Mon, 29 July 2013 01:05 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That would be a POST-QUERY trigger.

But, as Cookiemonster suggested, that might cause problems later because Forms will think that item's value has changed.
Re: how to use decode for a column of a datablock [message #591466 is a reply to message #591451] Mon, 29 July 2013 03:22 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
There's no might about it. It will cause problems.
Use a list item, or check box, or radio group.
Re: how to use decode for a column of a datablock [message #591718 is a reply to message #591466] Wed, 31 July 2013 04:19 Go to previous message
oraclehi
Messages: 41
Registered: July 2012
Location: India
Member
Thanks, i used check box for this and this solved my problem.
Previous Topic: Weblogic 10.3.5 with oracle forms and reports 11.1.2.1.0
Next Topic: listitem populates but not accepting the value
Goto Forum:
  


Current Time: Thu Apr 25 22:20:39 CDT 2024