Quantcast
Channel: SCN: Message List - SAP Adaptive Server Enterprise (SAP ASE) for Custom Applications
Viewing all articles
Browse latest Browse all 3587

Multiple same-named temporary tables in nested stored procedures

$
0
0

Hi!

 

I am on ASE 15.0.3. Suppose I have three stored procedures, A, B, and C.

 

Procedure A creates a temporary table called #temp. Then it calls procedure B.

 

Procedure B also creates a temporary table called #temp, and doesn't know or care about the one that had been created by A. (So far, so good, I understand how ASE might logically keep the scope of the two tables separate.) Then B calls procedure C.

 

Now, procedure C tries to access the pre-existing table named #temp. Here's where I can't predict what will happen, because there are two tables named #temp that could be within C's scope. Does it:

 

1. Crash out with a runtime error?

2. Choose to access the #temp that was created first?

3. Choose to access the #temp that was created last?

4. Choose one or the other but in an unpredictable way?

 

I think I would like it to do #3. It is the one "closest in scope" to the reference. I believe ASE keeps track of the "nesting level" of the temporary table, but does it utilize that information in order to judge "closeness" of scope?

 

Thanks.

- John.


Viewing all articles
Browse latest Browse all 3587

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>