problem with pl/pgsql function unknown parameters - Mailing list pgsql-novice

From Jules Alberts
Subject problem with pl/pgsql function unknown parameters
Date
Msg-id 20030211093936.C14911CB1B1@koshin.dsl.systemec.nl
Whole thread Raw
List 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!

pgsql-novice by date:

Previous
From: greg@turnstep.com
Date:
Subject: Re: Characters To be Escaped in Perl
Next
From: greg@turnstep.com
Date:
Subject: Re: