MS-SQL to PostgreSQL

Started by Craig Brydenover 21 years ago3 messagesgeneral
Jump to latest
#1Craig Bryden
brydencraig@hotmail.com

Hi

Below is a snippet of MS-SQL code. Please can someone translate this to
plpgsql for me.

**************************************************************
DECLARE @MaxVal int, @MinVal int

SELECT @MaxVal = MAX(Value), @MinVal = MIN(Value)
FROM ABC
**************************************************************

The variables would then be used for purther processing.
I know that the variables would be declared like

*******************************************
DECLARE
MaxVal int;
MinVal int;
BEGIN
???
END;
*******************************************

I am not sure of the query part and in particular the assignment of the
values to the variables

Thank you
Craig

_________________________________________________________________
Research SA schools and varsities on MSN Search. http://search.msn.co.za

#2Michael Fuhr
mike@fuhr.org
In reply to: Craig Bryden (#1)
Re: MS-SQL to PostgreSQL

On Fri, Jan 07, 2005 at 10:00:47PM +0200, Craig Bryden wrote:

I am not sure of the query part and in particular the assignment of the
values to the variables

See SELECT INTO in the PL/pgSQL documentation.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

#3dbalinglung
alam_surya@highpointoffice.com
In reply to: Craig Bryden (#1)
Re: MS-SQL to PostgreSQL

Hi Craig....

try with this....

Declare v_maxval integer; v_minval integer;
Begin
Select max(value),min(value) into v_maxval,v_minval from ABC;
............
............
............
end;

or see SELECT INTO from postgresql documentation

regards,

Alam Surya

----- Original Message -----
From: "Craig Bryden" <brydencraig@hotmail.com>
Subject: [GENERAL] MS-SQL to PostgreSQL

Show quoted text

Hi

Below is a snippet of MS-SQL code. Please can someone translate this to
plpgsql for me.

**************************************************************
DECLARE @MaxVal int, @MinVal int

SELECT @MaxVal = MAX(Value), @MinVal = MIN(Value)
FROM ABC
**************************************************************

The variables would then be used for purther processing.
I know that the variables would be declared like

*******************************************
DECLARE
MaxVal int;
MinVal int;
BEGIN
???
END;
*******************************************

I am not sure of the query part and in particular the assignment of the
values to the variables

Thank you
Craig