Thread: declare variable in postgresql

declare variable in postgresql

From
Jignesh Ramavat
Date:
Hello,

need help,

Declare @TypeTransactionID As int";

Select @TypeTransactionID=ID from TypeTransaction Where TypeTransactionCode = 'TxnBackupInc' ";

these is in sqlserver. If i want to do same in postgresql then ???

--
Thanks & Regards,
Jignesh Ramavat
Software Engineer

Re: declare variable in postgresql

From
Pavel Stehule
Date:
Hello

2011/6/24 Jignesh Ramavat <ramavat.jignesh@gmail.com>:
> Hello,
>
> need help,
>
> Declare @TypeTransactionID As int";
>
> Select @TypeTransactionID=ID from TypeTransaction Where TypeTransactionCode
> = 'TxnBackupInc' ";
>
> these is in sqlserver. If i want to do same in postgresql then ???
>

you can't do it - PostgreSQL does not support session variables

Regards

Pavel Stehule

> --
> Thanks & Regards,
> Jignesh Ramavat
> Software Engineer
>

Re: declare variable in postgresql

From
Merlin Moncure
Date:
On Fri, Jun 24, 2011 at 3:41 AM, Jignesh Ramavat
<ramavat.jignesh@gmail.com> wrote:
> Hello,
>
> need help,
>
> Declare @TypeTransactionID As int";
>
> Select @TypeTransactionID=ID from TypeTransaction Where TypeTransactionCode
> = 'TxnBackupInc' ";
>
> these is in sqlserver. If i want to do same in postgresql then ???

http://www.postgresql.org/docs/9.0/static/plpgsql.html
http://www.postgresql.org/docs/9.0/static/plpgsql-declarations.html#PLPGSQL-DECLARATION-PARAMETERS

merlin

Re: declare variable in postgresql

From
Brar Piening
Date:
On Fri, 24 Jun 2011 10:16:52 -0500, Merlin Moncure
<mmoncure@gmail.com> wrote:
> http://www.postgresql.org/docs/9.0/static/plpgsql.html
> http://www.postgresql.org/docs/9.0/static/plpgsql-declarations.html#PLPGSQL-DECLARATION-PARAMETERS

Plus http://www.postgresql.org/docs/current/static/sql-do.html

if want it the non procedural TSQL way...

Regards,

Brar