Received: from smtp013.mail.yahoo.com (smtp013.mail.yahoo.com [216.136.173.57]) by postgresql.org (Postfix) with SMTP id 757B74758EF for ; Tue, 19 Mar 2002 09:27:30 -0500 (EST) Received: from janwieck (AUTH login) at psc.progress.com (HELO saturn.janwieck.net) (janwieck@192.233.92.200) by smtp.mail.vip.sc5.yahoo.com with SMTP; 19 Mar 2002 14:27:33 -0000 Received: (from wieck@localhost) by saturn.janwieck.net (8.11.2/8.11.2) id g2JEPcL08516; Tue, 19 Mar 2002 09:25:38 -0500 From: Jan Wieck Message-Id: <200203191425.g2JEPcL08516@saturn.janwieck.net> Subject: Re: create function problem In-Reply-To: <20020319100343.28739.qmail@web14902.mail.yahoo.com> from "Kancha ." at "Mar 19, 2002 02:03:43 am" To: "Kancha ." Date: Tue, 19 Mar 2002 09:25:37 -0500 (EST) Cc: Matteo Beccati , pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200203/231 X-Sequence-Number: 7110 Kancha . wrote: > > > Hi, > > > > > create function usage(text) > > > returns numeric > > > as 'select ceil(sum(sessiontime)/60) from > > ath_online > > > where loginname=\'$1\' and startdate >= (select > > > startdate from cst_package where status=\'t\' and > > > cid=(select cid from cst_customer where > > > loginname=\'$1\'));' > > > language 'sql'; > > > > Try to replace \'$1\' with just $1 (i.e. loginname = > > $1). > > > > the argument is a string so it has to be enclosed in > quotes and \ is to escape the quote. replacing with > just $1 will give error like following: The argument is a string and $1 becomes a T_Param node of type "text" in your case, which is a perfectly valid string without the quotes. Don't get confused by the $ sign in the parameter name. $1 is treated like a variable name. Just try "exactly" what was suggested, including the whitespaces surrounding the = operator. Write loginname = $1 instead of loginname=$1 This does not only make the code more readable for humans. The parser likes it too. Jan > > Unable to identify an operator '=$' for types > 'varchar' and 'int4' > You will have to retype this query using an > explicit cast > > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Sports - live college hoops coverage > http://sports.yahoo.com/ > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com