Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id CCA1D64FCC4 for ; Wed, 10 Sep 2008 22:35:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 71110-04 for ; Wed, 10 Sep 2008 22:35:16 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.236]) by postgresql.org (Postfix) with ESMTP id 19D9E64FD2F for ; Wed, 10 Sep 2008 22:35:15 -0300 (ADT) Received: by rv-out-0506.google.com with SMTP id b25so143330rvf.43 for ; Wed, 10 Sep 2008 18:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=sKiZo2Uh4B2rYfkgLljYQryJUFeY2QmpKAyuFS/6Q0s=; b=W48SjH5GTow1N4Pd9A84TmbCLFCZKGBQJBFze0H3oyIBQ14/U4Ij1SjuUc7u7g/PIY Hh+ZH31qlxodP6DnFoyqhwwr4gH9wxOoyEXW/IKRW48gcCj2XB6xWNPjO6GXlgw4NjOb n9z9YtfO9RRjoeIweQtZoab0JW6cx25CIUmTs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=Y5s6i3JR3O9YmKMZsvP+vcqCS71s+wWAqF690nVob/zukkMLbG46PrN/vdSn9To184 nIvXqmG6BXNbt/FDTIOaPcBvMfWrUw5EVc9nRamMcPlgqKFHz9QP7cyU/I7xpCRCzQFk 6DvyXjU/VHm5CUL1G9nveHpmoEZ53l4UuCtI0= Received: by 10.140.164.6 with SMTP id m6mr1310576rve.208.1221096914015; Wed, 10 Sep 2008 18:35:14 -0700 (PDT) Received: by 10.141.74.11 with HTTP; Wed, 10 Sep 2008 18:35:13 -0700 (PDT) Message-ID: Date: Wed, 10 Sep 2008 19:35:13 -0600 From: "Scott Marlowe" To: davyd Subject: Re: dynamic SQL Cc: pgsql-admin@postgresql.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/85 X-Sequence-Number: 30178 On Wed, Sep 10, 2008 at 9:45 AM, davyd wrote: > Hi list, > I need to create a sql where the name of a tabla is on a variable.. > > vbuffer varchar; > > SELECT buffer > INTO vbuffer > FROM rutas r, unidades u > WHERE r.codigo_ruta = u.codigo_ruta AND > u.codigo_uni = 'B15_AFF666'; > > > SELECT within(the_geom,(SELECT geomunion(the_geom) from var vbuffer)) as > inside You'll need to do it by building the query as a string in a plpgsql function and then execute it.