Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to check string as a data or number

592815Feb 15 2009 — edited Feb 17 2009
Hi Experts,

I read a string from text files. However, client can not keep source data fromat. That means there are a comma (,) if it is not data.
However, we get source data as

POS,SAL,500159,54.5501,-163.248100,65,017,20090209,05
POS,SAL,500166,20090208,080207

from 2 th position, miss 4 data column(3,4,5,6) . the last data is data and time.
in sencond line it should be as
POS,SAL,500166, , , , , 20090208,080207.
my procedure abrot it when I sign a LATITUDE
l_cnt number;
l_cntend number;
vn_LATITUDE NUMBER(9,6) default 0;
vn_LONGITUDE NUMBER(9,6) default 0;
vd_DADATE DATE;
vNewLine varchar2(200);

l_cnt := l_cntend +1;
DBMS_OUTPUT.PUT_LINE('lt-- l_cnt --'|| l_cnt );

l_cntend := instr(vNewLine, ',',(l_cnt +1) );

vn_LATITUDE :=substr(trim(vNewLine), l_cnt, (l_cntend - l_cnt));

the data time assign syntax as
vd_DADATE :=to_date(to_char(substr(trim(vNewLine), (l_cnt +1), (l_cntend - (l_cnt +1)))), 'yyyymmdd');

Do we have a way to check string is a data or number by SQL so that we can use two procedure to handle 2 data format?

Thanks
Jim
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 17 2009
Added on Feb 15 2009
5 comments
608 views