Received: from isidoro2.unileon.es (isidoro2.unileon.es [193.146.96.2]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8JIxwe26643 for ; Wed, 19 Sep 2001 14:59:59 -0400 (EDT) (envelope-from iafmgc@unileon.es) Received: from intergraph (n104111.unileon.es [193.146.104.111]) by isidoro2.unileon.es (8.9.3/8.9.1) with SMTP id UAA12687; Wed, 19 Sep 2001 20:59:56 +0200 (MET DST) Message-ID: <000901c1413c$b29fe0f0$1301a8c0@uimagen> From: =?iso-8859-1?Q?Miguel_Gonz=E1lez?= To: "Haller Christoph" Cc: "PostgreSQL SQL" Subject: Creating a boolean function Date: Wed, 19 Sep 2001 20:55:49 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200109/154 X-Sequence-Number: 4832 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