X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A8AFC52802 for ; Thu, 19 May 2005 04:42:34 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39163-04 for ; Thu, 19 May 2005 07:42:26 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) by svr1.postgresql.org (Postfix) with ESMTP id C2C8952800 for ; Thu, 19 May 2005 04:42:24 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so619394wri for ; Thu, 19 May 2005 00:42:32 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=aI8NSj0XvR5HTsYWc1RCB3s3WYDltlGWRfQHPURg5jhzFTggCys+QBg/N5PDfRvtVVo7EIMUapS62VvoMQjyBLKDQZa7SeB5jvOqZKqYYutfHIVNrQNwkboOcca8zIJzfkgMTTx697G4QuXDAZDtz1BtJ4rRYwdx80PNsV7Bbu8= Received: by 10.54.41.42 with SMTP id o42mr217942wro; Thu, 19 May 2005 00:42:32 -0700 (PDT) Received: by 10.54.30.45 with HTTP; Thu, 19 May 2005 00:42:32 -0700 (PDT) Message-ID: <7104a7370505190042692d6649@mail.gmail.com> Date: Thu, 19 May 2005 10:42:32 +0300 From: Volkan YAZICI Reply-To: Volkan YAZICI To: bandeng Subject: Re: postgre variable Cc: pgsql-sql@postgresql.org In-Reply-To: <3817e22905051819111a04c2fe@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <3817e22905051819111a04c2fe@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.332 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/160 X-Sequence-Number: 21473 Hi, On 5/19/05, bandeng wrote: > i want to make dynamic sql query like this >=20 > select * from tb_cust where name=3D'erick' and age=3D'20' >=20 > to >=20 > select * from tb_cust $1 >=20 > i have tried but error comeup I think there's a confusion about the usage of parameters like $1, $2, ... etc. You cannot use parameters for a whole statement like "where name=3D'erick' and age=3D'20'" or "name=3D'erick'". It's only useful to point returned fields. Namely, above SQL query should be: SELECT * FROM tb_cust WHERE name =3D $1 AND age =3D $2; Plus beware it doesn't need quotes around parameter. Moreover, if you're using some PostgreSQL API, you don't need to escape data inserted by parameters. You may refer to documentation for further information. Regards.