Professional Web Applications Themes

Sybase to MSSQL conversion Looping - Microsoft SQL / MS SQL Server

Hi everyone, Being kind of new at SQL. I need some help with a script. I am currently working on converting stored procedures from a SYBASE environment to MSSQL 2k. I have hit a brick wall with the below query. I know that WHILE is the proper syntax to loop over the statement. But I'm confused on how to create a loop in MSSQL. Any help would be good.. /* Watcom only */ SNAPLOOP: for SNAPFOR as THISSNAP dynamic scroll cursor for execute SP_ORDER_UPDATEAPPLICANT ORDERAPPLICANTID, STATUS, STATUSDATE, LONGNOTE, CREATEDATE break SNAPLOOP end for */ Thanks in advance. Jeremy...

  1. #1

    Default Sybase to MSSQL conversion Looping

    Hi everyone,

    Being kind of new at SQL. I need some help with a script.
    I am currently working on converting stored procedures
    from a SYBASE environment to MSSQL 2k. I have hit a brick
    wall with the below query. I know that WHILE is the proper
    syntax to loop over the statement. But I'm confused on how
    to create a loop in MSSQL.

    Any help would be good..

    /* Watcom only */
    SNAPLOOP: for SNAPFOR as THISSNAP dynamic scroll cursor
    for execute
    SP_ORDER_UPDATEAPPLICANT ORDERAPPLICANTID,
    STATUS,
    STATUSDATE,
    LONGNOTE,
    CREATEDATE
    break SNAPLOOP end for
    */

    Thanks in advance.

    Jeremy
    Jeremy Guest

  2. #2

    Default Re: Sybase to MSSQL conversion Looping

    I'm not familiar with Sybase syntax, but scrolling through a cursor to
    execute a stored procedure for every row goes like this:

    DECLARE c_applicant CURSOR LOCAL FAST_FORWARD FOR
    SELECT........
    OPEN CURSOR

    WHILE 1=1
    BEGIN
    FETCH NEXT FROM c_applicant INTO ORDERAPPLICANTID,
    STATUS,
    STATUSDATE,
    LONGNOTE,
    CREATEDATE
    IF FETCH_STATUS <> 0 BREAK -- No row fetched, bail out of loop
    EXEC SP_ORDER_UPDATEAPPLICANT ORDERAPPLICANTID,
    STATUS,
    STATUSDATE,
    LONGNOTE,
    CREATEDATE
    END

    CLOSE c_applicant
    DEALLOCATE c_applicant


    --
    Jacco Schalkwijk MCDBA, MCSD, MCSE
    Database Administrator
    Eurostop Ltd.


    "Jeremy" <jeremy_watsondialog.com.au> wrote in message
    news:045901c3475b$9b2d9e40$a601280aphx.gbl...
    > Hi everyone,
    >
    > Being kind of new at SQL. I need some help with a script.
    > I am currently working on converting stored procedures
    > from a SYBASE environment to MSSQL 2k. I have hit a brick
    > wall with the below query. I know that WHILE is the proper
    > syntax to loop over the statement. But I'm confused on how
    > to create a loop in MSSQL.
    >
    > Any help would be good..
    >
    > /* Watcom only */
    > SNAPLOOP: for SNAPFOR as THISSNAP dynamic scroll cursor
    > for execute
    > SP_ORDER_UPDATEAPPLICANT ORDERAPPLICANTID,
    > STATUS,
    > STATUSDATE,
    > LONGNOTE,
    > CREATEDATE
    > break SNAPLOOP end for
    > */
    >
    > Thanks in advance.
    >
    > Jeremy

    Jacco Schalkwijk Guest

Similar Threads

  1. #36516 [Com]: Sybase library names have changed in Sybase 15.x
    By jmherod at sbcglobal dot net in forum PHP Bugs
    Replies: 0
    Last Post: October 8th, 12:28 AM
  2. CF5 vs CF6.1 Sybase slow
    By biggreenegg in forum Coldfusion Database Access
    Replies: 2
    Last Post: September 20th, 12:39 PM
  3. --with-mssql vs --with-sybase-ct=/usr/local/freetds
    By Sharif Islam in forum PHP Development
    Replies: 0
    Last Post: December 1st, 02:55 AM
  4. Sybase::DBD
    By Leon Kofman in forum PERL Modules
    Replies: 2
    Last Post: November 10th, 06:22 PM
  5. AIX 4.3.2 and PTF .... and Sybase 11.5
    By Massimiliano Adamo in forum AIX
    Replies: 0
    Last Post: August 5th, 09:41 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139