Solved

Populate a Temporary Table

Posted on 2006-06-22
4
1,397 Views
Last Modified: 2008-02-01
Hi,
 iam new to Sybase.
 I have a stored procedure,which returns a data set.I'd like to dump the results of this stored procedure,into a temporary table.
  How can i do that?
Thanks.
0
Comment
Question by:pvsbandi
  • 2
  • 2
4 Comments
 

Author Comment

by:pvsbandi
Comment Utility
Hello!!...nobody to clear my doubt?
0
 
LVL 24

Accepted Solution

by:
Joe Woodhouse earned 500 total points
Comment Utility
Which Sybase product and version? There are three major Sybase databases.

The easiest way, and this will work in all Sybase products, is simply to redirect the result sets of all queries in the procedure into a temp table. (ie. turn all SELECTs into INSERT... SELECTs)

If you do this, you will want to create the temp table in the parent calling environment first.

If you are using ASE of at least 11.5 or above, you could also create a proxy table mapped to the stored procedure, so that issuing a SELECT on the proxt table executes the procedure and displays its result set. It would then be trivial to put this into a temp table.

This second method is complicated so I'll hold off until you confirm the first method isn't sufficient.

Good luck!
0
 

Author Comment

by:pvsbandi
Comment Utility
Hi,
 Thanks for the reply..iam on ASE 12.5.
  As you said,the first method asks for a structure of a table to be created first,in order to
  populate the data from the stored proc.
  Can you tel me another way,which will simply dump the data returned by the
  stored proc into a temporary table on the fly,without having to create the table.
Thanks1
 
0
 
LVL 24

Expert Comment

by:Joe Woodhouse
Comment Utility
Any temp table that you create in the stored proc does not exist outside the scope of that proc. When the proc finishes executing, then the table is gone.

You could go with my first suggestion and have the first result set in the proc do a SELECT INTO, and all subsequent SELECTs do an INSERT... SELECT. You can use a "persistent" table in tempdb, which unlike #temp tables *will* be visible when the proc is finished...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now