pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Miguel González <iafmgc@unileon.es>
To: Haller Christoph <ch@rodos.fzk.de>
Cc: PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: Creating a boolean function
Date: Wed, 19 Sep 2001 20:55:49 +0200
Message-ID: <000901c1413c$b29fe0f0$1301a8c0@uimagen> (raw)

by the way you know how to create the following sql function?

I need to return a boolean saying if an object is onloan.

the loan table is as follows:

loans
-----
code_loan
code_user
typetable


i want to check these three fields, the first two fields (the code ones) are
integer and the last a string.

I tried

create function check_loan (text,int,int)
returns bool
as
'select CAST(typetable AS text) from loans where typetable=$1 and
code_user=$2 and code_loan=$3;'
language 'sql';


But I got that the parser cannot identify the =$ operator and requires me to
do the proper casting.

How can I do it? Sorry for the questions, but I am new at creating functions
and I have to hand in this project tomorrow.

Many thanks

Miguel








view thread (5+ messages)  latest in thread

Message-ID: <000901c1413c$b29fe0f0$1301a8c0@uimagen>
Permalink:  ../000901c1413c$b29fe0f0$1301a8c0@uimagen/
Also on:    postgresql.org/message-id/000901c1413c$b29fe0f0$1301a8c0@uimagen

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: iafmgc@unileon.es, ch@rodos.fzk.de
  Subject: Re: Creating a boolean function
  In-Reply-To: <000901c1413c$b29fe0f0$1301a8c0@uimagen>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox