pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: satishchandra999@gmail.com
To: pgsql-performance@postgresql.org
Subject: Calling a SP from Curosor loop
Date: 29 Jun 2006 10:00:35 -0700
Message-ID: <1151600435.709010.253120@j72g2000cwa.googlegroups.com> (raw)

I have SP, which has a cursor iterations. Need to call another SP for
every loop iteration of the cursor. The pseudo code is as follows..

Create proc1 as
Begin

Variable declrations...

declare EffectiveDate_Cursor cursor for
select field1,fld2 from tab1,tab2 where tab1.effectivedate<Getdate()
---/////Assuming the above query would result in 3 records
Open EffectiveDate_Cursor
Fetch next From EffectiveDate_Cursor Into @FLD1,@FLD2
begin
    /*Calling my second stored proc with fld1 as a In parameter
and Op1 and OP2 Out parameters*/
    Exec sp_minCheck @fld1, @OP1 output,@OP2 output
     Do something based on Op1 and Op2.
end
While @@Fetch_Status = 0
Fetch next From EffectiveDate_Cursor Into @FLD1,@FLD2
/* Assume If loop count is 3.
 and If the Fetch stmt is below the begin Stmt, the loop iterations are
4 else the loop iterations are 2*/
begin
    /*Calling my second stored proc with fld1 as a In parameter and Op1
and OP2 Out parameters*/
    Exec sp_minCheck @fld1, @OP1 output,@OP2 output
     Do something based on Op1 and Op2.
end


The problem I had been facing is that, the when a stored proc is called
within the loop, the proc is getting into infinite loops.
Any Help would be appreciated.

Satish




view thread (2+ messages)  latest in thread

Message-ID: <1151600435.709010.253120@j72g2000cwa.googlegroups.com>
Permalink:  ../1151600435.709010.253120@j72g2000cwa.googlegroups.com/
Also on:    postgresql.org/message-id/1151600435.709010.253120@j72g2000cwa.googlegroups.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: satishchandra999@gmail.com
  Subject: Re: Calling a SP from Curosor loop
  In-Reply-To: <1151600435.709010.253120@j72g2000cwa.googlegroups.com>
  References: <1151600435.709010.253120@j72g2000cwa.googlegroups.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox