From: Kenneth Marshall <ktm@rice.edu>
To: Steven Dahlin <pgdb.sldahlin@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: running scripts like oracle sqlplus
Date: Mon, 21 Jun 2010 13:52:06 -0500
Message-ID: <20100621185206.GB23529@aart.is.rice.edu> (raw)
In-Reply-To: <AANLkTilYiUlT16ijWW8KoUm76MCpC-bvYzJIHxEJFYCt@mail.gmail.com>
References: <AANLkTilYiUlT16ijWW8KoUm76MCpC-bvYzJIHxEJFYCt@mail.gmail.com>
On Fri, Jun 18, 2010 at 04:24:18PM -0600, Steven Dahlin wrote:
> I have been trying to figure out how I can run a pgsql script like I can run
> a plsql script with oracle's sqlplus. Here is a sample script file for what
> I want to run:
>
> declare
> sysuserid integer := 0;
> hwcustid integer := 0;
> begin
>
> select nextval( 'user_seq' ) into sysuserid;
> select nextval( 'customer_seq' ) into hwcustid;
>
> insert into user
> (
> user_id,
> customer_id,
> create_user,
> update_user
> )
> values
> (
> sysuserid,
> hwcustid,
> sysuserid,
> sysuserid
> );
>
> insert into customer
> (
> customer_id,
> create_user,
> update_user
> )
> values
> (
> hwcustid,
> sysuserid,
> sysuserid
> );
>
> commit;
>
> end;
>
> I try to run the script in psql and thru pgadmin and cannot seem to make
> them work. I do not want to turn it into a function. I just want it to
> execute the block in a fashion similar to Oracle'sqlplus running
> @scriptfile.sql.
>
> Thanks
I think you will need to wait for version 9.0 and anonymous functions
using DO.
Cheers,
Ken
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: ktm@rice.edu, pgdb.sldahlin@gmail.com
Subject: Re: running scripts like oracle sqlplus
In-Reply-To: <20100621185206.GB23529@aart.is.rice.edu>
* 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