From: Elieser Leão <elieser@nho.com.br>
To: pgsql-sql@postgresql.org
Subject: Verifying data type
Date: Mon, 16 Aug 2004 18:16:12 -0300
Message-ID: <4121241C.6000300@nho.com.br> (raw)
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...
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: elieser@nho.com.br
Subject: Re: Verifying data type
In-Reply-To: <4121241C.6000300@nho.com.br>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox