Skip site navigation (1) Skip section navigation (2)

Re: Function call

From: "Nico Callewaert" <callewaert(dot)nico(at)telenet(dot)be>
To: "Andreas Kretschmer" <akretschmer(at)spamfence(dot)net>,<pgsql-novice(at)postgresql(dot)org>
Subject: Re: Function call
Date: 2009-01-24 14:29:31
Message-ID: A5F785E639474B96B9F2975DDC8CE8AB@etsinformatics.local (view raw or flat)
Thread:
Lists: pgsql-novice
> Nico Callewaert <callewaert(dot)nico(at)telenet(dot)be> schrieb:
>
>> Hi again,
>>
>> I tried your solution, but it gives me still the same error message.  But
>> there is a dotted line under the funcion name, like the error is pointing 
>> to
>> the function name.  Is that the correct way to execute a function, using
>> SELECT ?
>
> Sorry, you should also cast the 1 to smallint:
>
> test=# CREATE OR REPLACE FUNCTION upd_afdeling(update_type text, in_afd_id 
> smallint, in_afd_omschrijving text, in_date_changed timestamp without time 
> zone) RETURNS integer AS $BODY$ BEGIN return 1; END; $BODY$ LANGUAGE 
> plpgsql VOLATILE COST 100;
> CREATE FUNCTION
> Zeit: 0,607 ms
> test=*# select upd_afdeling('I'::text, 1::smallint, 'afdeling 1'::text, 
> current_timestamp::timestamp);
> upd_afdeling
> --------------
>            1


Hello again,

This is working ! Thanks...
Is it better to use varchar as parameter, or just "text" ?  The colmuns I'm 
updating through this function are varchars.
I'm still surprised about 1 thing : it seems PostgreSQL is not checking for 
existing tables or columns.

Like this :         UPDATE tbl_table_last_change
            SET last_user = current_user,

Table tbl_table_last_change doesn't exist yet, but still postgreSQL is 
acception the function definition...
So, I guess, there is no early checking on tables/fields ?

Thanks for your help, for sure I would never find the solution, I had no 
idea about the casting...

Best regards, Nico



In response to

Responses

pgsql-novice by date

Next:From: Andreas KretschmerDate: 2009-01-24 15:38:48
Subject: Re: Function call
Previous:From: Andreas KretschmerDate: 2009-01-24 14:13:50
Subject: Re: Function call

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group