Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Index on temp table

Status
Not open for further replies.

iamsonali

Programmer
Feb 19, 2002
2
IN
I am really new to Sybase and this has me stumped.

I created a SP and within it, instead of creating a cursor directly, I first created a temporary table like -

create table #tempTrans
(
RecId integer not null,
SeqNo smallint not null,
CustAmount numeric(18,5) null,
CustQuantity numeric(18,5) null
)

Then I select data into the table and declare a cursor on it-

declare trans_cursor cursor for
select RecId, SeqNo, CustAmount, CustQuantity
from #tempTrans

Now, when I execute this SP, I get an error saying - The optimizer could not find a unique index which it could use to scan table '#tempTrans' for cursor 'trans_cursor.

Do temporary tables require indexes? The table that fills the data into the temp table does have 4 indexes on it.

Pls. help!
 
Hi,
If there is any primary key for the temporary table, specify it.

like this

create table #tempTrans
(
RecId integer not null primary key,
SeqNo smallint not null,
CustAmount numeric(18,5) null,
CustQuantity numeric(18,5) null
)

while using cursors it is suggested to delcare primary key or explicitly declare unique index on temporary table

Gopal
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top