From: | Elieser Leão <elieser(at)nho(dot)com(dot)br> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Verifying data type |
Date: | 2004-08-16 21:16:12 |
Message-ID: | 4121241C.6000300@nho.com.br |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello guys,
I have a function like this
CREATE OR REPLACE FUNCTION "public"."f_tipo_campo" (varchar) RETURNS
numeric AS
'declare
p_valor ALIAS FOR $1;
v_resultado varchar;
begin
v_resultado := 1;
<> return v_resultado;
<>end;
<><>' LANGUAGE 'plpgsql'
<>
<>
I need to verify if the data in p_valor is just number or it is a string.
What is the best way to do this?
Here is the original function in Oracle PL/SQL
create or replace function f_tipo_campo (p_valor varchar) return number is
v_resultado number;
v_number number;
begin
begin
select p_valor
into v_number from dual;
v_resultado := 0;
exception
when others then
v_resultado := 1;
end;
return v_resultado;
end;
/
show err
--
Elieser Leão
Sorry for my bad english...
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-08-16 23:30:55 | Re: Verifying data type |
Previous Message | Peter Eisentraut | 2004-08-16 20:41:54 | Re: any chance SQL ASSERTIONS will be implemented? |