Home » Developer & Programmer » Forms » How can i validate input number into a Field of type char in oracle form?
How can i validate input number into a Field of type char in oracle form? [message #168810] Sun, 23 April 2006 03:04 Go to next message
qewani
Messages: 51
Registered: December 2005
Location: uaq
Member
hi.....
can any one help me.....please...!!!?!!
How can i validate input number into a Field of type char in oracle form?
Re: How can i validate input number into a Field of type char in oracle form? [message #168856 is a reply to message #168810] Sun, 23 April 2006 19:49 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Try something like this:
function iznumeric (
   field_value   in   varchar2 := name_in ('system.cursor_value') )
   return boolean is
begin
   if rtrim (field_value, '0123456789') is null then
      return (true);
   else
      return (false);
   end if;
end;

David
Re: How can i validate input number into a Field of type char in oracle form? [message #169891 is a reply to message #168856] Sun, 30 April 2006 02:32 Go to previous messageGo to next message
qewani
Messages: 51
Registered: December 2005
Location: uaq
Member
djmartin wrote on Sun, 23 April 2006 19:49

Try something like this:
function iznumeric (
   field_value   in   varchar2 := name_in ('system.cursor_value') )
   return boolean is
begin
   if rtrim (field_value, '0123456789') is null then
      return (true);
   else
      return (false);
   end if;
end;

David

where do i had to put this code?
please help?!
Re: How can i validate input number into a Field of type char in oracle form? [message #169956 is a reply to message #169891] Mon, 01 May 2006 00:28 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
It is a function. You put it in the area of the form that holds functions, that is, the 'program units' area. You then create a When-Validate-Item trigger on the field in question and apply the function to it.

David
Re: How can i validate input number into a Field of type char in oracle form? [message #173252 is a reply to message #168810] Sun, 21 May 2006 01:14 Go to previous messageGo to next message
qewani
Messages: 51
Registered: December 2005
Location: uaq
Member
i dont know that much about functions, but i have treid putting a when validate item trigger on the customer name here is my code
begin  if to_number(:CUST_TBL.CUST_NAME) = 0 then null; 
	
end if;  
message('The entry cannot be numeric');
  raise form_trigger_failure; exception  when value_error then 
  message('The entry cannot be numeric');
  
  end;


but still when the input is character + number like this 20John it accept it.
i want to not accept any numerics entry even if it comes with characters.
Re: How can i validate input number into a Field of type char in oracle form? [message #173262 is a reply to message #168810] Sun, 21 May 2006 03:38 Go to previous messageGo to next message
saadatahmad
Messages: 452
Registered: March 2005
Location: Germany/Paderborn
Senior Member

ok,
so here is the code for your When-Validate-Item trigger on CUST_NAME.

DECLARE
	v_number_found VARCHAR2(1);
BEGIN
SELECT SUBSTR(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE
  (:CUST_TBL.CUST_NAME, 0,'F_O_U_N_D'),
			1,'F_O_U_N_D'),
			2,'F_O_U_N_D'),
			3,'F_O_U_N_D'),
			4,'F_O_U_N_D'),
			5,'F_O_U_N_D'),
			6,'F_O_U_N_D'),
			7,'F_O_U_N_D'),
			8,'F_O_U_N_D'),
			9,'F_O_U_N_D'),
			'F_O_U_N_D', 1), -1,1)
	INTO v_number_found
	FROM dual;
	IF v_number_found <> '1' THEN
		MESSAGE('Name is Valid');
	ELSE
		MESSAGE('No number can come in the Customer Name');
	RAISE FORM_TRIGGER_FAILURE;
	END IF;
END;


Write this code and enter an Alpha Numeric name, it'll not allow. Write a name only in Alphabets and it'll allow.

Note: This is the idea not the complete solution. If you enter the name like, it'll work only for the names entered in teh format ALPHA01234 etc....It'll not work for the names like GDGF234HGCH or 12345JDGJF.
I think you should do the remaining work yourself.

regards

[Updated on: Sun, 21 May 2006 03:57]

Report message to a moderator

Re: How can i validate input number into a Field of type char in oracle form? [message #173339 is a reply to message #173262] Sun, 21 May 2006 23:24 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Try this:
begin
   if rtrim (upper (:CUST_TBL.CUST_NAME), ' ABCDEFGHIJKLMNOPQRSTUVWXYZ') is not null then
      message ('The entry is not all alphabetic');
      raise form_trigger_failure;
   end if;
end;

David
icon10.gif  Re: How can i validate input number into a Field of type char in oracle form? [message #173357 is a reply to message #168810] Mon, 22 May 2006 01:42 Go to previous messageGo to next message
qewani
Messages: 51
Registered: December 2005
Location: uaq
Member
thanks David,
the code which you gave me is working.

thanks again.
^__^
Re: How can i validate input number into a Field of type char in oracle form? [message #232324 is a reply to message #168856] Fri, 20 April 2007 02:38 Go to previous messageGo to next message
habib.khan
Messages: 20
Registered: March 2007
Location: Islamabad
Junior Member
Thanis David,
Thanks to send function for checking number.But problem is that how to call this function.I put this function into program unit area and i want to call this in 'when_validate_item'.how can i call this function.
Thanks again.
habib khan

[Updated on: Fri, 20 April 2007 02:39]

Report message to a moderator

Re: How can i validate input number into a Field of type char in oracle form? [message #232334 is a reply to message #168810] Fri, 20 April 2007 03:32 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

If iznumeric(:field_str) Then
--str has numbers
Else
--str is all alphabetic
End If;

Function calling is basic in programming isn't it? Razz

Re: How can i validate input number into a Field of type char in oracle form? [message #232400 is a reply to message #173339] Fri, 20 April 2007 07:03 Go to previous messageGo to next message
habib.khan
Messages: 20
Registered: March 2007
Location: Islamabad
Junior Member
Thanks a lot David,
Your code is now working fine.
Thanks again.
habib khan.
Re: How can i validate input number into a Field of type char in oracle form? [message #232656 is a reply to message #232400] Sun, 22 April 2007 21:00 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
It was 'wency' who answered your question, not me.

David
Re: How can i validate input number into a Field of type char in oracle form? [message #239358 is a reply to message #173339] Tue, 22 May 2007 02:22 Go to previous message
mustaf_82
Messages: 20
Registered: May 2007
Location: UAE
Junior Member
Try this code and put it on When-Validate-Item trigger for that field:

declare
chk_str varchar2(2);
len_str number(10);

begin
if :customer_name is not null then
len_str:=length(:customer_name);

for a in 1.. len_str loop
chk_str:=substr(:customer_name,a,1);
if ascii(chk_str) not in
(65,66,67,68,69,70.....91) OR
ascii(chk_str) not in (97,98,99,100....122) then
message('Numbers are not allowed');
message('Numbers are not allowed');
raise form_trigger_failure;
end if;
end loop;
end if;
end;

[Updated on: Tue, 22 May 2007 02:27]

Report message to a moderator

Previous Topic: NEED Answer for This Question!
Next Topic: How to restrict entering alphabet into text box
Goto Forum:
  


Current Time: Thu Apr 25 17:59:21 CDT 2024