home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!news.gtech.com!caw
- From: caw@gtech.com (Christopher A. White)
- Subject: Stored Procedures and temp tables
- Message-ID: <1993Jan21.182032.23975@gtech.com>
- Keywords: lock
- Sender: news@gtech.com (USENET Administrator)
- Organization: GTECH Corporation, West Greenwich, RI
- References: <wolfgang.727637656@sfu.ca>
- Date: Thu, 21 Jan 1993 18:20:32 GMT
- Lines: 47
-
- [ I don't know if any of you have had a hard time figuring out
- how to do this, but we did for some reason, so I figured I post
- a copy of my internal note. If you didn't already know this,
- it can save you a lot of code and make things easier.]
-
- Here is a little programming tidbit: #temp tables created in a
- stored procedure are visible to stored procedures call by the
- creator. So, if procedure a creates #techs and then calls
- procedure b, b can use, access, update, etc. #techs.
-
- The problem we've always had is that the called procedure (b,
- in this example) could not be created. However, I have come
- up with a way to do so. It requires adding some code to the
- procedure creation script [our scripts have a section at the top
- that drops the procedure if it already exists, then the creation
- script itself. Since they are isql scripts, each section is
- terminated with a "go"].
-
- Since we know what proc b exepects to be in the temp table,
- we can put the temp table creation clauses in the section
- between the drop procedure and the create procedure, like this:
-
- If exists (select * from sysobjects ... etc
- drop procedure b
- go
-
- select * into #techs from techs where 1 = 2
- go
-
- create table #display as (disp_line char(80) )
- go
-
- create procedure b as
- .
- .
- .
- go
-
- The #temp tables must be the SAME in both procedures (a and b).
-
-
- Topher
- --
- Christopher A. White | Free Radical Programming
- caw@gtech.com | High combat Rock'n'Roll
- GTech Corporation, West Greenwich, RI | Software - Break the rules
- The opinions expressed are mine alone | and take no prisoners!
-