Link to home
Start Free TrialLog in
Avatar of blossompark
blossomparkFlag for Ireland

asked on

SELECT INTO Temp table in DB2

Hi,
I'm new to db2  but in sql server you can use a SELECT INTO clause to put the results of a query into a local table which you can then in turn query..
is there an equivalent in db2?
thanks
ASKER CERTIFIED SOLUTION
Avatar of Member_2_2484401
Member_2_2484401
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of blossompark

ASKER

Hi daveslash,
thanks for your input..
the following code works fine;
select distinct  GROUP,
TICKET_ID
 from Table

but when i run it as
declare global temporary table deleteme as (
select distinct  GROUP,
TICKET_ID
 from Table
)with data;
select * from deleteme;

i get an error
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
deleteme is just the name of the temp table...
what i am trying to do is ;
1.run a query against  a db2 database
2. put the results of that query into a local table
3. Run queries against that local table that will further filter the data...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
by local table I mean a temp table....the source  table is located on  remote server ... i want to query the remote server and the result set that is returned by this query to the remote server i want to put into a temp table and then run queries against this temp table
a temp table in RAM is what i mean, i do not have write access to the database so i want to create a temp table in ram and query against it
i am using SQL Profiler in Eclipse to connect to the database
this is not possible is it? i need a db application to create the temp table and store it somewhere?
there is a "WITH" clause I think i can use
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi  daveslash and momi_sabag<br /><br />The WITH function does what I need<br /><br />WITH RAW_DATA (Group,TicketID) as<br />(<br />select distinct  GROUP,<br />TICKET_ID<br /> from Table<br />)<br />SELECT * FROM RAW_DATA