Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253

    Unanswered: CURSOR Question 2 - FIRST POST GOT MESSED UP!!!!!!

    This might sound odd but hopefully someone can shed some light on this.

    I have a stored procedure thatr has three SELECT statements that are UNION'ed.

    NOW it turns out the business users don't like seeing the multipole rows and just need the very first row in the cursor. For reasons I can't getinto, the UNIONS must stay (i hate my life).

    Is there any way to just FETCH the first row of a CURSOR. For example:

    DECLARE BONEHEAD CURSOR FOR SELECT
    ......
    ......
    ......

    OPEN BONEHEAD CURSOR <would like to just select the first row here>

    Thanks in advance!!
    Anthony Robinson

    "If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    I am not sure that this will work, but you could try:

    DECLARE BONEHEAD CURSOR for SELECT .... FETCH FIRST 1 ROW ONLY;

    ...


    OPEN BONEHEAD;

    Andy
    Last edited by ARWinner; 10-07-04 at 14:40.

  3. #3
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    I am not sure that this will work, but you could try:

    DECLARE BONEHEAD CURSOR for SELECT .... FETCH FIRST 1 ROW ONLY;

    ...


    OPEN BONEHEAD;


    (I think my first post got messed up)

    Andy

  4. #4
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253
    Tried putting the FETCH FIRST 1 ROW ONLY thing into each of the separate SELECT STATEMENTS. Would still end up returning three rows to the calling application...
    Anthony Robinson

    "If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."

  5. #5
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253
    Got it....!!

    Was putting FETCH FIRST after each SELECT. Needs to go after all of them....

    Thanks AR
    Anthony Robinson

    "If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •