Reputation: 834
I'm trying to do the following:
through the C++ code create a tmp table with a key/value columns and values (sybase db)
create a sp in which I will do 'select * from #tmpTable'
call this sp from the C++ code.
But I'm faced with a problem: I can't create the such stored proc. There is an error, that table doesn't exist (and it is so true).
So, can I do it in the some other way, or are there any tricks?
My sp example:
create procedure my_sp
as
begin
if OBJECT_ID('#tmpTable') is not null
select key, value from '#tmpTable'
end
Upvotes: 0
Views: 171
Reputation: 316
You can create the temp as part of the same session when you compile the sp. This will allow sybase to compile your sp. You will need the tmp table definition for this. Try below -
use databasename
go
create table #tmpTable (key [keydatatype], value [valuedatatype], .....)
create procedure my_sp
as
begin
if OBJECT_ID('#tmpTable') is not null
select key, value from '#tmpTable'
end
Upvotes: 1