It’s not another lame question as the topic suggests ;). So here’s my query:
CREATE TEMP TABLE temp_tab WITH (OIDS) ON COMMIT DROP AS SELECT 22 AS num, 'smth' AS something_else;
SELECT * FROM temp_tab;
What I’m trying to accomplish is to insert into this temporary table more than one value at a time, like this:
CREATE TEMP TABLE temp_tab WITH (OIDS) ON COMMIT DROP AS SELECT (22, 23, 24) AS num, ('smth', 'wqer', 'asdf') AS something_else;
The reason why I’m not inserting the data into an ordinary table rather than temp is because I want to use my db to calculate distances between geographical points (postgis), and I have a lot of data – doing this (plus sorting) would be too exhaustive for php and I don’t need to store this data – I just want to make some calculations and return the set to my code.
You can also use a
VALUEScommand as per http://www.postgresql.org/docs/9.0/interactive/sql-createtableas.html, so*note: I haven’t tried the query, so there may be a typo in there, but you should get the idea.