|
|
|
|
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 |
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 |
|
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 #239358 is a reply to message #173339] |
Tue, 22 May 2007 02:22 |
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
|
|
|