Re: Function problem - Mailing list pgsql-novice

From Josh Berkus
Subject Re: Function problem
Date
Msg-id web-830646@davinci.ethosmedia.com
Whole thread Raw
In response to Function problem  ("Patrick Hatcher" <PHatcher@macys.com>)
List pgsql-novice
Partick,

> Ahhhhhhhh.  Thank you Josh.  I just learned something new.  I've been
>  doing
> it this way in MS SQL for years.

Different Procedural SQL implementation, different syntax.

Transact-SQL:
variable assignment:
SELECT @fig=col1, @mike=col2
FROM table1 WHERE col3 = 'a'
temp table creation:
SELECT col1, col2 INTO temp_1
FROM table1 WHRE col3 = 'a'

PL/pgSQL:
variable assignment:
SELECT col1, col2 INTO v_fig, v_mike
FROM table1 WHERE col3='a';
temp table creation
CREATE TEMPORARY TABLE temp_1 AS
SELECT col1, col2 FROM table1
WHERE col3='a';

BTW, in either language you want to minimize your creation of temporary
 tables in procedures -- they are much slower than variables or even
 very complex queries.

-Josh Berkus



pgsql-novice by date:

Previous
From: "Patrick Hatcher"
Date:
Subject: Re: Function problem
Next
From: Thorsten Haude
Date:
Subject: Re: create database, user