X-Original-To: pgsql-sql@postgresql.org Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 69E7B4758E6 for ; Thu, 13 Mar 2003 01:05:30 -0500 (EST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id CC548D610; Wed, 12 Mar 2003 22:05:29 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id C20F05C04; Wed, 12 Mar 2003 22:05:29 -0800 (PST) Date: Wed, 12 Mar 2003 22:05:29 -0800 (PST) From: Stephan Szabo To: vincent Cc: Subject: Re: Function calling error in postgreSQL 7.3.1 In-Reply-To: Message-ID: <20030312220435.F61658-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200303/326 X-Sequence-Number: 12365 On Thu, 13 Mar 2003, vincent wrote: > Hi all, > > I'm trying to create a function that take in 2 varchar string and return a > string. > The function was created successfully, but when i issued the following > command via pgadmin II, > it give me the following error: > > select * from sc_company.dbseq('sc_company', 'COMPANY'); > > ERROR: Namespace "in_schname" does not exist > > > CREATE FUNCTION sc_company.dbseq(text, text) RETURNS varchar AS ' > DECLARE > in_schname ALIAS FOR $1; > in_seqname ALIAS FOR $2; > retval VARCHAR := 0; > BEGIN > SELECT SEQ_VAL INTO retval FROM in_schname.DB_SEQ WHERE SEQ_NAME = > in_seqname; That is not going to use the argument in the FROM. If you want to do something like that you're probably going to need to look into using EXECUTE.