Re: help with TCL function

From: ljb <lbayuk(at)mindspring(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: help with TCL function
Date: 2003-09-11 00:45:54
Message-ID: bjogk1$30b0$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

jules(dot)alberts(at)arbodienst-limburg(dot)nl wrote:
> Op 10 Sep 2003 (15:27), schreef Jules Alberts <jules(dot)alberts(at)arbodienst-limburg(dot)nl>:
>> Hello everybody,
>>
>> Someone helped me earlier with this TCL trigger function:
>>
>> create or replace function tlow() returns trigger as '
>> set NEW($1) [string tolower $NEW($1)]
>> return [array get NEW]'
>> language 'pltcl';
>>
>> I use it to force lowercase of values inserted in the db. There is one
>> problem though, if the parameter is absent, the function will give an
>> error message. I would like it to rather check for null before tolower
>> is applicated. In semicode:
>>
>> if ($1 <> NULL) {
>> set NEW($1) [string tolower $NEW($1)]
>> }
>> return [array get NEW]'
>>
>> but I have no idea how to do this in TCL. Can somebody please tell me?
>> Thanks a lot!
>
> I found argisnull, but I can't run it, apparently it cannot be used in
> triggers :-( Does anybody know a solutions for this problem? Thanks!

I think you're missing something. When you use a Tcl function as a trigger,
any arguments (like $1) are explicitly supplied in the CREATE TRIGGER
command. You either define the trigger to call the function with a
constant argument or not; there is no issue of NULL here or an optional
argument. Show us your CREATE TRIGGER command.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hosoo 2003-09-11 01:04:51
Previous Message Marc G. Fournier 2003-09-11 00:38:55 Re: Release date