begin-end blocks in psql - Mailing list pgsql-general

From Gauthier, Dave
Subject begin-end blocks in psql
Date
Msg-id 0836165E8EE50F40A3DD8F0D87137267255FA6@azsmsx421.amr.corp.intel.com
Whole thread Raw
Responses Re: begin-end blocks in psql
List pgsql-general

How do you do a simple begin-end statement block inside of a psql session?

 

For Example, I want to...

 

-          begin

-             declare a variable x to be an integer.  Set it = 5

-             declare s to be a varchar(8).  Set it to “foo”

-             insert into mytable (theint,thestr) values (x.s);

-          end

 

I can do it in a formal declaration of a procedure, and then execute the procedure.  But is there a less formal way?

 

Thanks

-dave

 

 

 

pgsql-general by date:

Previous
From: "Adam Rich"
Date:
Subject: Re: MySQL to Postgres question
Next
From: "Adam Rich"
Date:
Subject: Re: 8.3.0 upgrade