pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Eckermann <jeckermann@verio.net>
To: 'Dado Feigenblatt' <dado@wildbrain.com>
To: Pgsql-Sql <pgsql-sql@postgresql.org>
Subject: RE: PLpgSQL
Date: Fri, 20 Jul 2001 16:25:29 -0500
Message-ID: <08CD1781F85AD4118E0800A0C9B8580B094B54@NEZU> (raw)

You will need to use "EXECUTE" to create the sequence.  The docs on pl/pgsql
cover it: basically, "EXECUTE string" will cause that string to be executed
as a SQL statement.

> -----Original Message-----
> From:	Dado Feigenblatt [SMTP:dado@wildbrain.com]
> Sent:	Friday, July 20, 2001 2:26 PM
> To:	Pgsql-Sql
> Subject:	PLpgSQL
> 
> 3 questions:
> 
> 1. Can I use CREATE SEQUENCE inside a function?
> 2. I can create this function but I can't get it to run:
> 
> CREATE FUNCTION new_proj_pts_seq(int4)
> RETURNS text
> AS 'DECLARE
>         proj_ID alias for $1;
>         seq_name TEXT;
>     BEGIN
>         seq_name := ''proj_pts_'' || proj_ID;
>         create sequence seq_name;
>     END;
>     RETURNS seq_name;'
> LANGUAGE 'plpgsql';
> 
> When I do
>     SELECT new_proj_pts_seq(9000);
> I get:
>     ERROR:  parser: parse error at or near "$1"
> 
> The same happens if I assign $1 to proj_ID (instead of aliasing), or 
> just use $1 in the string concatenation.
> I always get the same message.
> 
> Considering that all the above is possible/fixable...
> 
> 3. On the statement 'create sequence seq_name;', will  'seq_name' be 
> evaluated properly?
> 
> Thanks.
> 
> 
> -- 
> Dado Feigenblatt                                 Wild Brain, Inc.   
> Technical Director                               (415) 553-8000 x???
> dado@wildbrain.com                               San Francisco, CA.
> 
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster



view thread (23+ messages)  latest in thread

Message-ID: <08CD1781F85AD4118E0800A0C9B8580B094B54@NEZU>
Permalink:  ../08CD1781F85AD4118E0800A0C9B8580B094B54@NEZU/
Also on:    postgresql.org/message-id/08CD1781F85AD4118E0800A0C9B8580B094B54@NEZU

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jeckermann@verio.net, dado@wildbrain.com
  Subject: RE: PLpgSQL
  In-Reply-To: <08CD1781F85AD4118E0800A0C9B8580B094B54@NEZU>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox