Re: plpgsql syntax error

From: Ondrej Ivanič <ondrej(dot)ivanic(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: plpgsql syntax error
Date: 2011-10-10 11:14:14
Message-ID: CAM6mieKs4q1NuG8Qz1V+yRrZO6vFUqGHEo7Bdw72hj0Pxt-Vnw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

On 10 October 2011 21:35, József Kurucz <jozsef(dot)kurucz(at)invitel(dot)hu> wrote:
> ERROR:  syntax error at or near "$1"
> LINE 1: create table  $1  ( )
>                      ^
> QUERY:  create table  $1  ( )
> CONTEXT:  SQL statement in PL/PgSQL function "check_table" near line 22

I think you have to use "execute":

execute 'create table ' || tblname || ' ()';

http://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

--
Ondrej Ivanic
(ondrej(dot)ivanic(at)gmail(dot)com)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sarma Chavali 2011-10-10 11:57:42 Help on PostgreSQL
Previous Message Albe Laurenz 2011-10-10 10:50:14 Re: [GENERAL] how to save a bytea value into a file?