Re: Help: PL/SQL String?
Date: 1995/11/20
Message-ID: <48pvql$d4b_at_alpine.valleynet.com>#1/1
sl6gs_at_cc.usu.edu wrote:
>Hi everyone:
> I have trouble in shorting a string. say, how
>to change '333.00001' to '333.xx'
>or change '333.10000' to '333.100'
>in C language, I can access string
>by str[i], but how to access individual
>value in str(varchar2) in PL/SQL like C
>does?
> Any suggestion?
> Sorry for bad english
> thank you.
>Wei Jiang
use the substr and instr functions
x:='333.100000'; p:=instr(x,'.') -- find decimal point y:=substr(x.1,p+2) -- truncate to 2 decimal places
this is strictly a string based solution
this also would work
declare
a varchar2(10) := '33.1350001';
b number(10,2);
begin
b:=a;
end;
this will incur rounding however. the string based method merely truncates.
Jared Still, Oracle DBA
RxNet, Division of Value Health
"All opinions are mine, not my employers"
jared_at_valleynet.com
Received on Mon Nov 20 1995 - 00:00:00 CET