Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Error in Temporal Table (#)

6 posts in General Discussion Last posting was on 2011-10-23 13:31:55.0Z
RGS Posted on 2011-10-21 15:59:36.0Z
Sender: 6beb.4ea1914f.1804289383@sybase.com
From: RGS
Newsgroups: sybase.public.ase.general
Subject: Error in Temporal Table (#)
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4ea196e8.6d61.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 21 Oct 2011 08:59:36 -0700
X-Trace: forums-1-dub 1319212776 10.22.241.41 (21 Oct 2011 08:59:36 -0700)
X-Original-Trace: 21 Oct 2011 08:59:36 -0700, 10.22.241.41
Lines: 30
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30632
Article PK: 73522

Hi!

First I am using ASE 15.5

I have a chain of stored procedures:

sp1 call sp2

sp1:

1) create a temporal table #accounts

sp2:

1) insert values into #accounts
2) create a cursor from #accounts
3) inside a cursor, execute SELECT's on #accounts

When I execute sp1, the next message appears:

"Table #accounts doesn't exists"

This error appears in step 3 of the sp2 program, e.d. when
the program try to execute SELECT's inside the cursor.
Before, there are not errors, ASE can find the temporal
table

Why it happens?

Thanks!


"Mark A. Parsons" <iron_horse Posted on 2011-10-21 16:27:00.0Z
From: "Mark A. Parsons" <iron_horse@no_spamola.compuserve.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Error in Temporal Table (#)
References: <4ea196e8.6d61.1681692777@sybase.com>
In-Reply-To: <4ea196e8.6d61.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4ea19d54$1@forums-1-dub>
Date: 21 Oct 2011 09:27:00 -0700
X-Trace: forums-1-dub 1319214420 10.22.241.152 (21 Oct 2011 09:27:00 -0700)
X-Original-Trace: 21 Oct 2011 09:27:00 -0700, vip152.sybase.com
Lines: 34
X-Authenticated-User: TeamSybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30633
Article PK: 73523

It's not apparent (to me) what you're (technically) doing in step 3, so I'd suggest you post a small test case that
reproduces the issue.

On 10/21/2011 11:59, RGS wrote:
> Hi!
>
> First I am using ASE 15.5
>
> I have a chain of stored procedures:
>
> sp1 call sp2
>
> sp1:
>
> 1) create a temporal table #accounts
>
> sp2:
>
> 1) insert values into #accounts
> 2) create a cursor from #accounts
> 3) inside a cursor, execute SELECT's on #accounts
>
> When I execute sp1, the next message appears:
>
> "Table #accounts doesn't exists"
>
> This error appears in step 3 of the sp2 program, e.d. when
> the program try to execute SELECT's inside the cursor.
> Before, there are not errors, ASE can find the temporal
> table
>
> Why it happens?
>
> Thanks!


RGS Posted on 2011-10-21 16:49:16.0Z
Sender: 6beb.4ea1914f.1804289383@sybase.com
From: RGS
Newsgroups: sybase.public.ase.general
Subject: Re: Error in Temporal Table (#)
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4ea1a28c.70b4.1681692777@sybase.com>
References: <4ea19d54$1@forums-1-dub>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 21 Oct 2011 09:49:16 -0700
X-Trace: forums-1-dub 1319215756 10.22.241.41 (21 Oct 2011 09:49:16 -0700)
X-Original-Trace: 21 Oct 2011 09:49:16 -0700, 10.22.241.41
Lines: 236
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30634
Article PK: 73526

Next, I copy a portion of sp2
The last sentence is the SELECT sentence that generate the
error "Temporaly table doesn't exist"

Can I upload files to this site?

Thanks!!!


-- HMarroquin 05/07/2011

insert into #tmp_trnmon

select tm_cta_banco, tm_fecha, tm_fecha_efec,
tm_fecha_ult_mov,

tm_tipo_tran, tm_signo, tm_valor,
tm_saldo_disponible,

tm_causa, tm_hora, 'N'

from ah_tran_monet

where tm_cta_banco = @i_cta_banco



select @w_cont = count(1) from #tmp_trnmon

print '@w_cont %1!',@w_cont

/* CURSOR PARA DETERMINAR EL SALDO PROMEDIO */

declare cursor_saldos cursor for

select distinct tm_fecha_efec

--from tmp_trnmon

-- HMarroquin 05/07/2011

from #tmp_trnmon

where tm_fecha_efec >= @w_rl_fecha_ini -- YA TENGO EN
VARIABLE EL SALDO DE INICIO

and tm_fecha_efec <= @i_fecha

and ((tm_fecha_ult_mov >= @w_rl_fecha_ini and
tm_tipo_tran in (4056, 4057)) or tm_tipo_tran not in (4056,
4057))

and tm_tipo_tran not in (4016, 4051, 4017, 4052, 4067)
-- Transacciones de liq. intereses y Rte.Fte sobre rend.

and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515

union all

select distinct tm_fecha_ult_mov

--HMarroquin 05/07/2011

--from tmp_trnmon

from #tmp_trnmon

where tm_fecha_ult_mov >= @w_rl_fecha_ini

and tm_fecha_ult_mov <= @i_fecha

and tm_tipo_tran in (4056, 4057) -- Transacciones
Notas debito/credito que afectan el saldo

and tm_causa = '1' -- SOLO LAS QUE
AFECTAN CAPITAL

and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515

union all

select distinct tm_fecha

--HMarroquin 05/07/2011

--from tmp_trnmon

from #tmp_trnmon

where tm_fecha >= @w_rl_fecha_ini

and tm_fecha <= @i_fecha

and ((tm_tipo_tran = 4051 and tm_causa in ('3',
'4')) or tm_tipo_tran = 4067)

and tm_signo = 'C'

and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515

order by 1

for read only



open cursor_saldos



select @w_fec_ant = dateadd(dd, -1, @w_rl_fecha_ini),

@w_dias_tot = 0



fetch cursor_saldos into @w_sd_fecha



while @@sqlstatus != 2

begin

if @@sqlstatus = 1

return 400011

if @w_sd_fecha <> @w_fec_ant

begin

exec sp_fechas_360

@i_fecha_ini = @w_rl_fecha_ini,

@i_fecha_fin = @w_sd_fecha,

@o_diferencia = @w_dias output



select @w_dias = @w_dias - 1 -- NO SE DEBE
CONSIDERAR EL DIA DE PAGO DEL SIGUIENTE DEPOSITO



/* ACUMULAR EL SALDO PONDERADO */

if @i_debug = 'S' print "SALDO ANT %1! %2! %3!
%4!",@w_saldo_acum,@w_dias,@w_rl_fecha_ini,@w_sd_fecha



select @w_saldo_acum = @w_saldo_acum +
round(@w_saldo_ini * @w_dias , @i_num_dec)



if @w_saldo_acum > 0 or @w_dias_tot > 0

select @w_dias_tot = @w_dias_tot + @w_dias



if @i_debug = 'S' print "SALDO DES %1! DIAS
%2!",@w_saldo_acum,@w_dias



/* CALCULO DEL SIGUIENTE SALDO = SALDO ANTERIOR +
MOVTOS.CR - MOVTOS.DB*/

/* SUMA DE TRANSACCIONES CREDITO */

select @w_creditos = isnull(sum(tm_valor), 0)

--HMarroquin 05/07/2011

--from tmp_trnmon

from #tmp_trnmon

where tm_fecha_efec = @w_sd_fecha

and tm_signo = 'C'

and tm_tipo_tran not in (4016, 4051, 4017,
4052,4067)

and ((tm_tipo_tran in (4056, 4057) and
tm_fecha_ult_mov >= @w_rl_fecha_ini) or tm_tipo_tran not in
(4056, 4057))

and tm_proc = 'N'

and tm_cta_banco = @i_cta_banco -- HMarroquin Inc_515

> It's not apparent (to me) what you're (technically) doing
> in step 3, so I'd suggest you post a small test case that
> reproduces the issue.
>
> On 10/21/2011 11:59, RGS wrote:
> > Hi!
> >
> > First I am using ASE 15.5
> >
> > I have a chain of stored procedures:
> >
> > sp1 call sp2
> >
> > sp1:
> >
> > 1) create a temporal table #accounts
> >
> > sp2:
> >
> > 1) insert values into #accounts
> > 2) create a cursor from #accounts
> > 3) inside a cursor, execute SELECT's on #accounts
> >
> > When I execute sp1, the next message appears:
> >
> > "Table #accounts doesn't exists"
> >
> > This error appears in step 3 of the sp2 program, e.d.
> > when the program try to execute SELECT's inside the
> > cursor. Before, there are not errors, ASE can find the
> > temporal table
> >
> > Why it happens?
> >
> > Thanks!


Leonid Gvirtz Posted on 2011-10-23 10:03:25.0Z
From: Leonid Gvirtz <lgvirtz@yahoo.com>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Error in Temporal Table (#)
References: <4ea19d54$1@forums-1-dub> <4ea1a28c.70b4.1681692777@sybase.com>
In-Reply-To: <4ea1a28c.70b4.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4ea3e66d$1@forums-1-dub>
Date: 23 Oct 2011 03:03:25 -0700
X-Trace: forums-1-dub 1319364205 10.22.241.152 (23 Oct 2011 03:03:25 -0700)
X-Original-Trace: 23 Oct 2011 03:03:25 -0700, vip152.sybase.com
Lines: 296
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30635
Article PK: 73525

Hi

Generally, querying of a temporary table inside a cursor created on this table should work. At the very least, it is not
supposed to produce the error message that you receive, see an example below. I would suggest you to simplify the
problem case, this may help you to find where the problem is.

create table #t_curs (fid int, fname varchar(30))
go
create procedure test_sp2
as
begin
declare @l_fid int, @l_fname varchar(30), @l_count int

insert into #t_curs values (3, 'test_03')

declare c1 cursor for
select fid, fname from #t_curs
order by fid
for read only

open c1

fetch c1 into @l_fid, @l_fname
while @@sqlstatus = 0
begin
select @l_count = count(*) from #t_curs
print '@l_count: %1!', @l_count
fetch c1 into @l_fid, @l_fname
end

close c1
deallocate cursor c1
end
go
drop table #t_curs
go

create procedure test_sp1
as
begin
create table #t_curs (fid int, fname varchar(30))
insert into #t_curs values (1, 'test_01')
insert into #t_curs values (2, 'test_02')
exec test_sp2
end
go

1> exec test_sp1
2> go

@l_count: 2
@l_count: 2
(return status = 0)

Hope it helps
Leonid Gvirtz
http://www.gvirtz-consulting.com

On 10/21/2011 6:49 PM, RGS wrote:
> Next, I copy a portion of sp2
> The last sentence is the SELECT sentence that generate the
> error "Temporaly table doesn't exist"
>
> Can I upload files to this site?
>
> Thanks!!!
>
>
> -- HMarroquin 05/07/2011
>
> insert into #tmp_trnmon
>
> select tm_cta_banco, tm_fecha, tm_fecha_efec,
> tm_fecha_ult_mov,
>
> tm_tipo_tran, tm_signo, tm_valor,
> tm_saldo_disponible,
>
> tm_causa, tm_hora, 'N'
>
> from ah_tran_monet
>
> where tm_cta_banco = @i_cta_banco
>
>
>
> select @w_cont = count(1) from #tmp_trnmon
>
> print '@w_cont %1!',@w_cont
>
> /* CURSOR PARA DETERMINAR EL SALDO PROMEDIO */
>
> declare cursor_saldos cursor for
>
> select distinct tm_fecha_efec
>
> --from tmp_trnmon
>
> -- HMarroquin 05/07/2011
>
> from #tmp_trnmon
>
> where tm_fecha_efec>= @w_rl_fecha_ini -- YA TENGO EN
> VARIABLE EL SALDO DE INICIO
>
> and tm_fecha_efec<= @i_fecha
>
> and ((tm_fecha_ult_mov>= @w_rl_fecha_ini and
> tm_tipo_tran in (4056, 4057)) or tm_tipo_tran not in (4056,
> 4057))
>
> and tm_tipo_tran not in (4016, 4051, 4017, 4052, 4067)
> -- Transacciones de liq. intereses y Rte.Fte sobre rend.
>
> and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515
>
> union all
>
> select distinct tm_fecha_ult_mov
>
> --HMarroquin 05/07/2011
>
> --from tmp_trnmon
>
> from #tmp_trnmon
>
> where tm_fecha_ult_mov>= @w_rl_fecha_ini
>
> and tm_fecha_ult_mov<= @i_fecha
>
> and tm_tipo_tran in (4056, 4057) -- Transacciones
> Notas debito/credito que afectan el saldo
>
> and tm_causa = '1' -- SOLO LAS QUE
> AFECTAN CAPITAL
>
> and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515
>
> union all
>
> select distinct tm_fecha
>
> --HMarroquin 05/07/2011
>
> --from tmp_trnmon
>
> from #tmp_trnmon
>
> where tm_fecha>= @w_rl_fecha_ini
>
> and tm_fecha<= @i_fecha
>
> and ((tm_tipo_tran = 4051 and tm_causa in ('3',
> '4')) or tm_tipo_tran = 4067)
>
> and tm_signo = 'C'
>
> and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515
>
> order by 1
>
> for read only
>
>
>
> open cursor_saldos
>
>
>
> select @w_fec_ant = dateadd(dd, -1, @w_rl_fecha_ini),
>
> @w_dias_tot = 0
>
>
>
> fetch cursor_saldos into @w_sd_fecha
>
>
>
> while @@sqlstatus != 2
>
> begin
>
> if @@sqlstatus = 1
>
> return 400011
>
> if @w_sd_fecha<> @w_fec_ant
>
> begin
>
> exec sp_fechas_360
>
> @i_fecha_ini = @w_rl_fecha_ini,
>
> @i_fecha_fin = @w_sd_fecha,
>
> @o_diferencia = @w_dias output
>
>
>
> select @w_dias = @w_dias - 1 -- NO SE DEBE
> CONSIDERAR EL DIA DE PAGO DEL SIGUIENTE DEPOSITO
>
>
>
> /* ACUMULAR EL SALDO PONDERADO */
>
> if @i_debug = 'S' print "SALDO ANT %1! %2! %3!
> %4!",@w_saldo_acum,@w_dias,@w_rl_fecha_ini,@w_sd_fecha
>
>
>
> select @w_saldo_acum = @w_saldo_acum +
> round(@w_saldo_ini * @w_dias , @i_num_dec)
>
>
>
> if @w_saldo_acum> 0 or @w_dias_tot> 0
>
> select @w_dias_tot = @w_dias_tot + @w_dias
>
>
>
> if @i_debug = 'S' print "SALDO DES %1! DIAS
> %2!",@w_saldo_acum,@w_dias
>
>
>
> /* CALCULO DEL SIGUIENTE SALDO = SALDO ANTERIOR +
> MOVTOS.CR - MOVTOS.DB*/
>
> /* SUMA DE TRANSACCIONES CREDITO */
>
> select @w_creditos = isnull(sum(tm_valor), 0)
>
> --HMarroquin 05/07/2011
>
> --from tmp_trnmon
>
> from #tmp_trnmon
>
> where tm_fecha_efec = @w_sd_fecha
>
> and tm_signo = 'C'
>
> and tm_tipo_tran not in (4016, 4051, 4017,
> 4052,4067)
>
> and ((tm_tipo_tran in (4056, 4057) and
> tm_fecha_ult_mov>= @w_rl_fecha_ini) or tm_tipo_tran not in
> (4056, 4057))
>
> and tm_proc = 'N'
>
> and tm_cta_banco = @i_cta_banco -- HMarroquin Inc_515
>
>
>
>
>> It's not apparent (to me) what you're (technically) doing
>> in step 3, so I'd suggest you post a small test case that
>> reproduces the issue.
>>
>> On 10/21/2011 11:59, RGS wrote:
>>> Hi!
>>>
>>> First I am using ASE 15.5
>>>
>>> I have a chain of stored procedures:
>>>
>>> sp1 call sp2
>>>
>>> sp1:
>>>
>>> 1) create a temporal table #accounts
>>>
>>> sp2:
>>>
>>> 1) insert values into #accounts
>>> 2) create a cursor from #accounts
>>> 3) inside a cursor, execute SELECT's on #accounts
>>>
>>> When I execute sp1, the next message appears:
>>>
>>> "Table #accounts doesn't exists"
>>>
>>> This error appears in step 3 of the sp2 program, e.d.
>>> when the program try to execute SELECT's inside the
>>> cursor. Before, there are not errors, ASE can find the
>>> temporal table
>>>
>>> Why it happens?
>>>
>>> Thanks!


"Mark A. Parsons" <iron_horse Posted on 2011-10-23 13:31:55.0Z
From: "Mark A. Parsons" <iron_horse@no_spamola.compuserve.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Error in Temporal Table (#)
References: <4ea19d54$1@forums-1-dub> <4ea1a28c.70b4.1681692777@sybase.com> <4ea3e66d$1@forums-1-dub>
In-Reply-To: <4ea3e66d$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4ea4174b$1@forums-1-dub>
Date: 23 Oct 2011 06:31:55 -0700
X-Trace: forums-1-dub 1319376715 10.22.241.152 (23 Oct 2011 06:31:55 -0700)
X-Original-Trace: 23 Oct 2011 06:31:55 -0700, vip152.sybase.com
Lines: 19
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30638
Article PK: 73529

I'm assuming a mismatch in the posted code and what was used to generate the output? ;-)

Running the posted code for test_sp1/test_sp2 in ASE 15.0.3 ESD #4 gives me:

1> exec test_sp1
2> go

@l_count: 3
@l_count: 3
@l_count: 3

On 10/23/2011 06:03, Leonid Gvirtz wrote:
> 1> exec test_sp1
> 2> go
>
> @l_count: 2
> @l_count: 2


"Mark A. Parsons" <iron_horse Posted on 2011-10-23 13:27:47.0Z
From: "Mark A. Parsons" <iron_horse@no_spamola.compuserve.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: Error in Temporal Table (#)
References: <4ea19d54$1@forums-1-dub> <4ea1a28c.70b4.1681692777@sybase.com>
In-Reply-To: <4ea1a28c.70b4.1681692777@sybase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4ea41653@forums-1-dub>
Date: 23 Oct 2011 06:27:47 -0700
X-Trace: forums-1-dub 1319376467 10.22.241.152 (23 Oct 2011 06:27:47 -0700)
X-Original-Trace: 23 Oct 2011 06:27:47 -0700, vip152.sybase.com
Lines: 266
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:30637
Article PK: 73528

Sorry, but your postings are a bit confusing ...

- first post mentions #accounts, sp1, sp2, 3 steps in sp2, and 'execute a select' inside cursor, and a portion of an
error message

- second post mentions ah_tran_monet (but no definition), #tmp_trnmon, one proc (sp_fechas_360, no definition), a
cursor, an 'execute' *and* a 'select' inside the cursor, no actual error message

- I'm assuming the second post was cut-n-pasted from a stored proc otherwise the code you've posted would not run as a
SQL batch (eg, a cursor cannot be defined in a SQL batch along with other SQL code)

While you may be running into an error with ASE 15.5, it's also possible that you have a coding error and/or the error
you're receiving is not related to the SELECT you mention ... it's hard to tell from the various fragments you've posted.

A few suggestions ...

- see if you can come up with a small, *complete* test case that generates the same error (see Leonid's post for an
example); post the *entire* test case, the sample test run, and the *complete* error message

- when you have an error message, post the *entire* error message; in the case of stored procs (and triggers) the error
message also tells us the proc name and the line in the proc where the error occurred; this is quite helpful in insuring
we're looking at the correct query

- if you're unable to reproduce the error with a small, *complete* test case then consider a) opening a case with Sybase
tech support or b) having someone with some Sybase ASE troubleshooting/P&T skills come in to take a look at your system
[the main point here is that it can be very hard, if not impossible, to troubleshoot an issue in a newsgroup/forum when
we only have access to snippets of a non-trivial set of code]

On 10/21/2011 12:49, RGS wrote:
> Next, I copy a portion of sp2
> The last sentence is the SELECT sentence that generate the
> error "Temporaly table doesn't exist"
>
> Can I upload files to this site?
>
> Thanks!!!
>
>
> -- HMarroquin 05/07/2011
>
> insert into #tmp_trnmon
>
> select tm_cta_banco, tm_fecha, tm_fecha_efec,
> tm_fecha_ult_mov,
>
> tm_tipo_tran, tm_signo, tm_valor,
> tm_saldo_disponible,
>
> tm_causa, tm_hora, 'N'
>
> from ah_tran_monet
>
> where tm_cta_banco = @i_cta_banco
>
>
>
> select @w_cont = count(1) from #tmp_trnmon
>
> print '@w_cont %1!',@w_cont
>
> /* CURSOR PARA DETERMINAR EL SALDO PROMEDIO */
>
> declare cursor_saldos cursor for
>
> select distinct tm_fecha_efec
>
> --from tmp_trnmon
>
> -- HMarroquin 05/07/2011
>
> from #tmp_trnmon
>
> where tm_fecha_efec>= @w_rl_fecha_ini -- YA TENGO EN
> VARIABLE EL SALDO DE INICIO
>
> and tm_fecha_efec<= @i_fecha
>
> and ((tm_fecha_ult_mov>= @w_rl_fecha_ini and
> tm_tipo_tran in (4056, 4057)) or tm_tipo_tran not in (4056,
> 4057))
>
> and tm_tipo_tran not in (4016, 4051, 4017, 4052, 4067)
> -- Transacciones de liq. intereses y Rte.Fte sobre rend.
>
> and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515
>
> union all
>
> select distinct tm_fecha_ult_mov
>
> --HMarroquin 05/07/2011
>
> --from tmp_trnmon
>
> from #tmp_trnmon
>
> where tm_fecha_ult_mov>= @w_rl_fecha_ini
>
> and tm_fecha_ult_mov<= @i_fecha
>
> and tm_tipo_tran in (4056, 4057) -- Transacciones
> Notas debito/credito que afectan el saldo
>
> and tm_causa = '1' -- SOLO LAS QUE
> AFECTAN CAPITAL
>
> and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515
>
> union all
>
> select distinct tm_fecha
>
> --HMarroquin 05/07/2011
>
> --from tmp_trnmon
>
> from #tmp_trnmon
>
> where tm_fecha>= @w_rl_fecha_ini
>
> and tm_fecha<= @i_fecha
>
> and ((tm_tipo_tran = 4051 and tm_causa in ('3',
> '4')) or tm_tipo_tran = 4067)
>
> and tm_signo = 'C'
>
> and tm_cta_banco = @i_cta_banco --HMarroquin Inc_515
>
> order by 1
>
> for read only
>
>
>
> open cursor_saldos
>
>
>
> select @w_fec_ant = dateadd(dd, -1, @w_rl_fecha_ini),
>
> @w_dias_tot = 0
>
>
>
> fetch cursor_saldos into @w_sd_fecha
>
>
>
> while @@sqlstatus != 2
>
> begin
>
> if @@sqlstatus = 1
>
> return 400011
>
> if @w_sd_fecha<> @w_fec_ant
>
> begin
>
> exec sp_fechas_360
>
> @i_fecha_ini = @w_rl_fecha_ini,
>
> @i_fecha_fin = @w_sd_fecha,
>
> @o_diferencia = @w_dias output
>
>
>
> select @w_dias = @w_dias - 1 -- NO SE DEBE
> CONSIDERAR EL DIA DE PAGO DEL SIGUIENTE DEPOSITO
>
>
>
> /* ACUMULAR EL SALDO PONDERADO */
>
> if @i_debug = 'S' print "SALDO ANT %1! %2! %3!
> %4!",@w_saldo_acum,@w_dias,@w_rl_fecha_ini,@w_sd_fecha
>
>
>
> select @w_saldo_acum = @w_saldo_acum +
> round(@w_saldo_ini * @w_dias , @i_num_dec)
>
>
>
> if @w_saldo_acum> 0 or @w_dias_tot> 0
>
> select @w_dias_tot = @w_dias_tot + @w_dias
>
>
>
> if @i_debug = 'S' print "SALDO DES %1! DIAS
> %2!",@w_saldo_acum,@w_dias
>
>
>
> /* CALCULO DEL SIGUIENTE SALDO = SALDO ANTERIOR +
> MOVTOS.CR - MOVTOS.DB*/
>
> /* SUMA DE TRANSACCIONES CREDITO */
>
> select @w_creditos = isnull(sum(tm_valor), 0)
>
> --HMarroquin 05/07/2011
>
> --from tmp_trnmon
>
> from #tmp_trnmon
>
> where tm_fecha_efec = @w_sd_fecha
>
> and tm_signo = 'C'
>
> and tm_tipo_tran not in (4016, 4051, 4017,
> 4052,4067)
>
> and ((tm_tipo_tran in (4056, 4057) and
> tm_fecha_ult_mov>= @w_rl_fecha_ini) or tm_tipo_tran not in
> (4056, 4057))
>
> and tm_proc = 'N'
>
> and tm_cta_banco = @i_cta_banco -- HMarroquin Inc_515
>
>
>
>
>> It's not apparent (to me) what you're (technically) doing
>> in step 3, so I'd suggest you post a small test case that
>> reproduces the issue.
>>
>> On 10/21/2011 11:59, RGS wrote:
>>> Hi!
>>>
>>> First I am using ASE 15.5
>>>
>>> I have a chain of stored procedures:
>>>
>>> sp1 call sp2
>>>
>>> sp1:
>>>
>>> 1) create a temporal table #accounts
>>>
>>> sp2:
>>>
>>> 1) insert values into #accounts
>>> 2) create a cursor from #accounts
>>> 3) inside a cursor, execute SELECT's on #accounts
>>>
>>> When I execute sp1, the next message appears:
>>>
>>> "Table #accounts doesn't exists"
>>>
>>> This error appears in step 3 of the sp2 program, e.d.
>>> when the program try to execute SELECT's inside the
>>> cursor. Before, there are not errors, ASE can find the
>>> temporal table
>>>
>>> Why it happens?
>>>
>>> Thanks!