Home » Developer & Programmer » Forms » Make Field protected against update (Oracle Forms 6i)
Make Field protected against update [message #505167] Fri, 29 April 2011 13:24 Go to next message
praveenkumar2408
Messages: 5
Registered: April 2011
Junior Member
Dear Experts,
I am new into Oracle Forms 6i and am in the process of learning. I have attached a POST-TEXT-ITEM Trigger below. What i am required to do is to protect a field 'COUR_CODE' from update when the SHIP_METHOD='R'. can any one of you help me with this below code on how to incorporate thsi change.

if :system.record_status = 'INSERT' then
declare
vcour_code ACCOUNTS.cour_code%type := NULL;
vcourier_account_no ACCOUNTS.courier_account_no%type := NULL;
canvas_name varchar2(30);
begin
select cour_code,courier_account_no
into vcour_code,vcourier_account_no
from accounts acct
where acct.no = :orde.acco_no;
if vcour_code is not null then
hide_view('CG$TAB_1');
:cg$ctrl.cg$stack_control := 'CG$TAB_2';
show_view('CG$TAB_2');
soft_messages('I',FALSE,'Customer''s courier preference is '||vcour_code|| ', Account: '||nvl(vcourier_account_no,'N/A'));

else
hide_view('CG$TAB_2');
:cg$ctrl.cg$stack_control := 'CG$TAB_1';
show_view('CG$TAB_1');
end if;
if :orde.shipping_method = 'R'
then next_item;
end if;
end;
end if;

Regards
Praveen.R
Re: Make Field protected against update [message #505170 is a reply to message #505167] Fri, 29 April 2011 14:28 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
First of all, welcome to the OraFAQ Forum!

In order to modify item's properties, you should use SET_ITEM_PROPERTY built-in. Check its syntax in Forms Online Help System.

If it is not too much to ask, take a look at the Forum Guide, or - at least - how to format your code so that your code would be easier to read.
Re: Make Field protected against update [message #505173 is a reply to message #505170] Fri, 29 April 2011 14:51 Go to previous messageGo to next message
praveenkumar2408
Messages: 5
Registered: April 2011
Junior Member
Thanks..
if :system.record_status  = 'INSERT' then
		declare
			vcour_code               ACCOUNTS.cour_code%type := NULL;
		  vcourier_account_no      ACCOUNTS.courier_account_no%type := NULL;
		  canvas_name varchar2(30);
		begin
			select cour_code,courier_account_no
			into vcour_code,vcourier_account_no
			from accounts acct
			where acct.no = :orde.acco_no;
			if 	vcour_code is not null then
				  hide_view('CG$TAB_1');
					:cg$ctrl.cg$stack_control := 'CG$TAB_2';
		 			show_view('CG$TAB_2');
		 			soft_messages('I',FALSE,'Customer''s courier preference is '||vcour_code|| ', Account: '||nvl(vcourier_account_no,'N/A'));
	
			else 
			  		hide_view('CG$TAB_2');
			  		:cg$ctrl.cg$stack_control := 'CG$TAB_1';
						show_view('CG$TAB_1');
			end if;	
			if :orde.shipping_method = 'R'
				then set_item_property('ORDE.COUR_CODE', NAVIGABLE, PROPERTY_TRUE);
						 set_item_property('ORDE.COUR_CODE', INSERT_ALLOWED, PROPERTY_TRUE);
						 SET_ITEM_PROPERTY('ORDE.COUR_CODE', UPDATE_ALLOWED, PROPERTY_FALSE);
						 SET_ITEM_PROPERTY('ORDE.COUR_CODE', REQUIRED, PROPERTY_FALSE);
						 
				end if; 
		end;
end if;		
As you had adviced i tried the above SET_ITEM_PROPERTY built in. However still not working. Still i could see the 'LIST OF VALUES' when the CURSOR is at the field COURIER CODE.
Have i made any mistakes?
Regards
Praveen.R
Re: Make Field protected against update [message #505180 is a reply to message #505173] Fri, 29 April 2011 16:43 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You said that you "see list of values". Can you select a value from the list and update this item? I guess not.

If you want to disable "List of Values" too, you'll have to do that in your code as well (because it won't "disappear" just because you'd want it to, right?).
Re: Make Field protected against update [message #505363 is a reply to message #505180] Mon, 02 May 2011 11:55 Go to previous messageGo to next message
praveenkumar2408
Messages: 5
Registered: April 2011
Junior Member
To answer the first question:

YES, i can select the LOV and update this item. I am trying to disable this. For example when I have the Cursor on this item and try to select the LOV, i should not be able to do it, instead should say "Field is protected against update"

Regards
Praveen
Re: Make Field protected against update [message #505381 is a reply to message #505363] Mon, 02 May 2011 13:29 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As I said:
-- key-listval trigger
if certain_condition_is_met then
   message('Field is protected against update');
   raise form_trigger_failure;
end if;
Re: Make Field protected against update [message #523878 is a reply to message #505381] Tue, 20 September 2011 20:07 Go to previous messageGo to next message
mas2011
Messages: 11
Registered: September 2011
Location: Malaysia
Junior Member

what about protecting forms from 'DELETE'? permission only to administrator of the system only.
Re: Make Field protected against update [message #523886 is a reply to message #523878] Wed, 21 September 2011 00:06 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If you can distinguish administrators from other stuff, in WHEN-NEW-FORM-INSTANCE trigger use SET_BLOCK_PROPERTY for all blocks you want, and set its DELETE_ALLOWED property to FALSE (it specifies whether the operator of the application is allowed to delete records in the given block).
Re: Make Field protected against update [message #523905 is a reply to message #523886] Wed, 21 September 2011 01:27 Go to previous messageGo to next message
mas2011
Messages: 11
Registered: September 2011
Location: Malaysia
Junior Member

ok...i found it..thanks a lot.
it set 'NO Delete' to the whole forms and to every user.

what if i want to set the 'Delete' permission only to 1 user?
Re: Make Field protected against update [message #523907 is a reply to message #523905] Wed, 21 September 2011 01:35 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As I said, "if you can distinguish administrators from other stuff". You'll probably have to have another table that would contain username and its privileges, and then query that table in WHEN-NEW-FORM-INSTANCE trigger and set block properties accordingly to what you find in that table.

If you don't have it, I have no idea how you could know who is who.
Re: Make Field protected against update [message #523927 is a reply to message #523907] Wed, 21 September 2011 02:55 Go to previous messageGo to next message
mas2011
Messages: 11
Registered: September 2011
Location: Malaysia
Junior Member

thanks...you help a lot...Smile
Re: Make Field protected against update [message #523937 is a reply to message #523927] Wed, 21 September 2011 03:57 Go to previous message
Baranor
Messages: 83
Registered: September 2011
Location: Netherlands
Member
Well, one could hardcode the username into the check, but that would be a bit... iffy.
Previous Topic: pre-text-item
Next Topic: Menu-bar not displayed correctly
Goto Forum:
  


Current Time: Mon Sep 16 17:39:17 CDT 2024