Advertisement

06.05.2008 at 09:11AM PDT, ID: 23460798
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.7

cursors in Sybase

Asked by maddyforums in Sybase Database

Tags: ,

Hello All,

I need some help regarding the implementation of nested cursers in sybase. I have created a stored procedure below to do the below task. The issue is that I am getting the same string inserted for all the PDBC_PFX in the target table.
I have tried to use SET @lResult='' in the inner cursor and then its inserting all the blank values into the target table. Please advice.
 
Source table : CMC_BSTX_SUM_TEXT
PDBC_PFX   SEQ_NO       BSTX_TEXT                                                              
--------         -----------         ---------                                                              
1579              0                   BCN5, CO20, ER75
1579              1                   FP5, WC6, MATW, OPRH
1579              2                   T
1600              0                   TW, FP5, AS5, MHSA15, DME20
1600              1                   ER100, UR40
 
Expected output in Target table  : CMC_BSTX_SUM_TEXT_TEMP (concatenate multiple rows into a single row in the ascending order of SEQ_NO)

PDBC_PFX        BSTX_TEXT
-------------        -----------------------
1579                  BCN5, CO20, ER75FP5, WC6, MATW, OPRHT
1600                  TW, FP5, AS5, MHSA15, DME20ER100, UR40

************************************************************************************************************
CREATE PROC test11
AS
BEGIN
 DECLARE @CODE1 char(4),
                  @lResult char(255),
                  @lText char(255)
 DECLARE c1 CURSOR
      FOR
      SELECT distinct PDBC_PFX  FROM CMC_BSTX_SUM_TEXT  
      COMMIT
      OPEN  c1
      FETCH c1 INTO @CODE1

  While (@@SQLSTATUS !=2)
  BEGIN
                  DECLARE curmovedown CURSOR
                  FOR
                        SELECT TEXT
                    FROM CMC_BSTX_SUM_TEXT where PDBC_PFX =@CODE1  order by SEQ_NO
        COMMIT
        OPEN  curmovedown
        FETCH curmovedown INTO  @lText
                               While (@@SQLSTATUS !=2)
                               BEGIN
                               SET @lResult= @lResult+@lText                  
                               FETCH curmovedown INTO @lText
                               END
       insert into CMC_BSTX_SUM_TEXT_TEMP values (@CODE1,@lResult)        
       COMMIT
       CLOSE curmovedown
       DEALLOCATE CURSOR curmovedown
FETCH c1 INTO @CODE1
 END
CLOSE c1
DEALLOCATE CURSOR c1
END  
*********************************************************************************************************************
Start Free Trial
Related Solutions: cursor in Sybase
 
Loading Advertisement...
 
[+][-]06.05.2008 at 09:34AM PDT, ID: 21721364

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Sybase Database
Tags: sybase, cursor
Sign Up Now!
Solution Provided By: grant300
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.05.2008 at 09:58AM PDT, ID: 21721603

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 12:26PM PDT, ID: 21723041

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 01:16PM PDT, ID: 21723530

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.05.2008 at 09:16PM PDT, ID: 21726181

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.06.2008 at 09:58AM PDT, ID: 21730781

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.06.2008 at 09:29PM PDT, ID: 21734213

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_Related_20080208