dbTalk Databases Forums  

Too many temporary tables ????

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss Too many temporary tables ???? in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
at
 
Posts: n/a

Default Too many temporary tables ???? - 09-10-2009 , 03:38 AM






I have a stored procedure which uses a cursor. When running this
procedure I get an error message after some time saying that there are
too many temporary tables on the connection. Since I do not create any
temp table I do not understand what this means!

Here the code:

LTER PROCEDURE "DBA"."sp_ONCE_updateOnwerChange"()
begin
declare cur cursor for select DBA.Verkauf.VbIdNr,
DBA.Verkauf.VbWiederZuDat as Zulassungsdatum,
DBA.Fahrzeuge.FzIdNr, row_number()
over (order by fzidnr asc, vbidnr asc) "nummer"
from DBA.Verkauf key join DBA.Fahrzeuge
order by Fahrzeuge.fzidnr asc,Verkauf.vbidnr
asc;
declare @vbidnr integer;
declare @zulassungsdatum date;
declare @fzidnr integer;
declare @nummer integer;

declare @prev_vbidnr integer;
declare @prev_fzid integer;
declare @prev_nummer integer;

set @prev_fzid = 1;
set @prev_nummer = 1;

open cur;
lp: LOOP
fetch next cur into @vbidnr, @zulassungsdatum, @fzidnr, @nummer;
if SQLCODE <> 0 then leave lp end if;
if @fzidnr = @prev_fzid and @nummer <> @prev_nummer then
update verkauf set Halterwechsel =
dateadd(day,-1,@zulassungsdatum), IdFolgeverkauf = @vbidnr where vbidnr
= @prev_vbidnr;
end if;
set @prev_vbidnr = @vbidnr;
set @prev_nummer = @nummer;
set @prev_fzid = @fzidnr;
end LOOP;
close cur;
end


Can anybode help me with this??

many thanks

Tom

Reply With Quote
  #2  
Old   
Reg Domaratzki [Sybase iAnywhere]
 
Posts: n/a

Default Re: Too many temporary tables ???? - 09-10-2009 , 07:54 AM






at wrote:
Quote:
I have a stored procedure which uses a cursor. When running this
procedure I get an error message after some time saying that there are
too many temporary tables on the connection. Since I do not create any
temp table I do not understand what this means!

Can anybode help me with this??

What version and build number of SQL Anywhere are you using?
Do you have any statement level triggers or row level triggers on the
verkauf table?

--
Reg Domaratzki, Sybase iAnywhere Solutions
Please reply only to the newsgroup

Documentation : Exercise your WRITE @DocCommentXchange: DCX.sybase.com
SQL Anywhere Patches and EBFs : http://downloads.sybase.com/swd/base.do
-> Choose SQL Anywhere
-> Optionally set filter to "Display ALL platforms IN ALL MONTHS"

Reply With Quote
  #3  
Old   
at
 
Posts: n/a

Default Re: Too many temporary tables ???? - 09-10-2009 , 04:31 PM



I use the latest available version 11.0.1 2299.

There were no triggers on the verkaufs table.

I had four materialized view, one of them a immediate mv. All of them
hold references to the verkaufs table. When I deleted them, the error
disapeared!

Do MV cause such kind of problems?

Tom


Reg Domaratzki [Sybase iAnywhere] schrieb:
Quote:
at wrote:
I have a stored procedure which uses a cursor. When running this
procedure I get an error message after some time saying that there are
too many temporary tables on the connection. Since I do not create any
temp table I do not understand what this means!

Can anybode help me with this??


What version and build number of SQL Anywhere are you using?
Do you have any statement level triggers or row level triggers on the
verkauf table?

Reply With Quote
  #4  
Old   
Bruce Hay
 
Posts: n/a

Default Re: Too many temporary tables ???? - 09-11-2009 , 09:40 AM



The IMMEDIATE REFRESH materialized view is likely causing this behavior; it will
consume 2 temporary table id's each time a statement updates a table referenced
by the view.

Committing more frequently will avoid the problem. If you are able to re-form
the procedure so that it executes as a single statement rather than a loop, that
would also avoid the problem as well as improving the performance of the procedure.

SQL Anywhere Developer Community:
http://www.sybase.com/developer/libr...ere-techcorner


SQL Anywhere Blog Center: http://www.sybase.com/sqlanyblogs




at wrote:
Quote:
I use the latest available version 11.0.1 2299.

There were no triggers on the verkaufs table.

I had four materialized view, one of them a immediate mv. All of them
hold references to the verkaufs table. When I deleted them, the error
disapeared!

Do MV cause such kind of problems?

Tom


Reg Domaratzki [Sybase iAnywhere] schrieb:
at wrote:
I have a stored procedure which uses a cursor. When running this
procedure I get an error message after some time saying that there
are too many temporary tables on the connection. Since I do not
create any temp table I do not understand what this means!

Can anybode help me with this??


What version and build number of SQL Anywhere are you using?
Do you have any statement level triggers or row level triggers on the
verkauf table?

Reply With Quote
  #5  
Old   
at
 
Posts: n/a

Default Re: Too many temporary tables ???? - 09-12-2009 , 04:29 AM



Thanks for your hints! Immediate Refresh mat views are tricky anyway. I
had to remove them because of massive performance drawbacks when
updating large numbers of records. One need to consider very carefully
when and when not to use materialized views.

Tom

Bruce Hay schrieb:
Quote:
The IMMEDIATE REFRESH materialized view is likely causing this behavior;
it will consume 2 temporary table id's each time a statement updates a
table referenced by the view.

Committing more frequently will avoid the problem. If you are able to
re-form the procedure so that it executes as a single statement rather
than a loop, that would also avoid the problem as well as improving the
performance of the procedure.

SQL Anywhere Developer Community:
http://www.sybase.com/developer/libr...ere-techcorner


SQL Anywhere Blog Center: http://www.sybase.com/sqlanyblogs




at wrote:
I use the latest available version 11.0.1 2299.

There were no triggers on the verkaufs table.

I had four materialized view, one of them a immediate mv. All of them
hold references to the verkaufs table. When I deleted them, the error
disapeared!

Do MV cause such kind of problems?

Tom


Reg Domaratzki [Sybase iAnywhere] schrieb:
at wrote:
I have a stored procedure which uses a cursor. When running this
procedure I get an error message after some time saying that there
are too many temporary tables on the connection. Since I do not
create any temp table I do not understand what this means!

Can anybode help me with this??


What version and build number of SQL Anywhere are you using?
Do you have any statement level triggers or row level triggers on the
verkauf table?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.