function returning NULL?

Started by Sandro Dentellaalmost 25 years ago2 messagesdocs
Jump to latest
#1Sandro Dentella
sandro.dentella@tin.it

I'm trying to create a function that should return a date, and occasionally
NULL value. I can't see how to do that. I'm using pl/tcl.

CREATE FUNCTION "start" (text,text) RETURNS date AS '
regsub ^. $1 "$2" job
spi_exec "select start_date from jobs where job_code = ''$job''" {
if {[info exist start_date]} {
return $start_date
}
}
# return "2/2/2222" HERE I want NULL
return "2/2/2222"
'LANGUAGE 'pltcl';

That is to say I'd like to have a function that returns a date but under
some circumstancies it leave it blanck.

TIA
sandro
*:-)

--
Sandro Dentella *:-)
e-mail: sandro@ermit.it sandro.dentella@mi.infn.it

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Sandro Dentella (#1)
Re: [INTERFACES] function returning NULL?

Sandro Dentella <sandro.dentella@tin.it> writes:

I'm trying to create a function that should return a date, and occasionally
NULL value. I can't see how to do that. I'm using pl/tcl.

You need the "return_null" command, which is new in 7.1 --- before that
there was no way to do it in pltcl.

"return_null" seems to be missing from the documentation :-(. No wonder
you couldn't find it.

regards, tom lane