problem with pl/pgsql function unknown parameters

From: "Jules Alberts" <jules(dot)alberts(at)arbodienst-limburg(dot)nl>
To: pgsql-novice(at)postgresql(dot)org
Subject: problem with pl/pgsql function unknown parameters
Date: 2003-02-11 09:39:04
Message-ID: 20030211093936.C14911CB1B1@koshin.dsl.systemec.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello everybody,

I'm building a function that will import data into a postgresql db
(7.2.4). Now i have run into this problem: in my import module I do a
lot of checks to see if a value is empty or null. I want to solve this
with a function, something like this:

drop function is_empty();
create function is_not_empty() returns boolean as '
declare
begin
if $1 = NULL or $1 = '''' then
return true;
else
return false;
end if;
end; '
language 'plpgsql';

select is_empty();
true
select is_empty('');
true
select is_empty('Blah');
false

This won't work, pl wants to know at compile time which function
parameters there will be. Another problem is when I don't know the
datatype of the parameter or how many parameters there will be at
compile time.

Can anybody point me in the right direction? Thanks!

A more general matter. I have some finding answers to questions like
these in the material I have here (the pg documentation & website,
Bruce Momjians book, the PHP and Postgresql book, online books,
Google). Is there a book or website that will give in depth explanation
on pl/pgsql? TIA!

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message greg 2003-02-11 17:50:05 Re:
Previous Message greg 2003-02-11 02:54:53 Re: Characters To be Escaped in Perl