Home » Developer & Programmer » Forms » leading zero in STD code or MOBILE NO.
leading zero in STD code or MOBILE NO. [message #87430] Mon, 03 January 2005 20:17 Go to next message
shish mate
Messages: 49
Registered: February 2004
Member
i want to insert a STD code (number field). which normaly have leading zero.

in form i'm inseting data with leading zero but when i
query form it does not show me leading zero. how to insert leading zero in number field. dont tell me to use lpad or somthig like that coz oracle is allowing me to insert record with leading zero but it's not showing me what i've inserted.

(if i use varhar2 datatype then user can enter charater instade of numbers is there any way to avoide this...)

try this for more details

insert into scott.emp (EMPNO,DEPTNO,sal) values (13,10,0251);

select empno,sal from scott.emp where empno = 13 ;

plz. it's urgent
ASHish
Re: leading zero in STD code or MOBILE NO. [message #87431 is a reply to message #87430] Mon, 03 January 2005 22:26 Go to previous message
Himanshu
Messages: 457
Registered: December 2001
Senior Member
Ashish,
You need to use Varchar2 type feild only.

In order to restrict entry of other characters apart from Numbers add following validation on your feild in the form e.g on when-validate-item:

Declare
a number:=0;
Begin
select to_number(:blk.feild_name) into a from dual;
exeception
when others then
message('E: Please enter numeric 0-9 only.',no_acknowledge);
raise form_trigger_failure;
end;

When user enters say 00123A into this feild then the when-validate-item will raise an error when you try to convert this into a number using TO_NUMBER function.

If he enters 0000123 then simply this is coverted into 123 & no error will be raised.

HTH
Regards
Himanshu
Previous Topic: Reports errors REP-4201 REP-4220
Next Topic: Oracle Form Partial Commit
Goto Forum:
  


Current Time: Thu Sep 19 10:14:57 CDT 2024