Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Location
    Montreal, Canada
    Posts
    151

    Unanswered: Using a While loop instead of a Cursor plz help

    what iam trying to do is use a while loop instead of a cursor and iam in the dark can someone please show me the way here is my code:

    Declare cursor for
    SELECT * FROM VI82BHDT, VI16HPRO
    WHERE (NIV182 = NIV116) AND (TYIN16 = 1) AND (PROD82 = PROD16) AND
    (NIV182 = :NIV180) AND (NIV282 = :NIV280) AND
    (NIV382 = :NIV380) AND (TYIN82 = :TYIN80) AND
    (TYTR82 = :TYTR80) AND (NOTR82 = :NOTR80) AND
    ((:@IEENT = 'I' AND ENTR82 NOT IN(:@ENT01, :@ENT02,
    :@ENT03, :@ENT04, :@ENT05) OR ENTR82 = 0) OR
    (:@IEENT = 'E' AND ENTR82 IN(:@ENT01, :@ENT02,
    :@ENT03, :@ENT04, :@ENT05) AND ENTR82 <> 0)) AND
    ((:@IEPRO = 'I' AND PROD82 NOT IN(:@PRD01, :@PRD02,
    :@PRD03, :@PRD04, :@PRD05, :@PRD06, :@PRD07, :@PRD08)) OR
    (:@IEPRO = 'E' AND PROD82 IN(:@PRD01, :@PRD02, :@PRD03,
    :@PRD04, :@PRD05, :@PRD06, :@PRD07, :@PRD08))) AND
    ((:@IEDE1 = 'I' AND DES116 NOT IN(:@DES11, :@DES12,
    :@DES13, :@DES14, :@DES15, :@DES16, :@DES17, :@DES18,
    :@DES19, :@DES10) OR DES116 = ' ') OR
    (:@IEDE1 = 'E' AND DES116 IN(:@DES11, :@DES12,
    :@DES13, :@DES14, :@DES15, :@DES16, :@DES17, :@DES18,
    :@DES19, :@DES10) AND DES116 <> ' ')) AND
    ((:@INBD2 = 'X' AND DES216 = ' ') OR
    (:@IEDE2 = 'I' AND DES216 NOT IN(:@DES21, :@DES22,
    :@DES23, :@DES24, :@DES25) AND DES216 <> ' ') OR
    (:@IEDE2 = 'E' AND DES216 IN(:@DES21, :@DES22,
    :@DES23, :@DES24, :@DES25) AND DES216 <> ' ')) AND
    ((:@INBD3 = 'X' AND DES316 = ' ') OR
    (:@IEDE3 = 'I' AND DES316 NOT IN(:@DES31, :@DES32,
    :@DES33, :@DES34, :@DES35) AND DES316 <> ' ') OR
    (:@IEDE3 = 'E' AND DES316 IN(:@DES31, :@DES32,
    :@DES33, :@DES34, :@DES35) AND DES316 <> ' ')) AND
    ((:@INBD4 = 'X' AND DES416 = ' ') OR
    (:@IEDE4 = 'I' AND DES416 NOT IN(:@DES41, :@DES42,
    :@DES43, :@DES44, :@DES45) AND DES416 <> ' ') OR
    (:@IEDE4 = 'E' AND DES416 IN(:@DES41, :@DES42,
    :@DES43, :@DES44, :@DES45) AND DES416 <> ' '))

  2. #2
    Join Date
    Jul 2004
    Posts
    76
    Can u pls. provide detais regarding your requirements and what are all things u have?

  3. #3
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    retrieve the SQL in some kind of datastore
    for (int i = 1; i <= datastore.rowCount(); i++) {
    // do whatever you want to do with record[i]
    }

    Is this an answer to your question ?

    PS. I would never use "SELECT *" in a program, only use it interactively in an ad hoc way when you explore a database. In a program you should allways specify which columns you want. Just in case an ALTER TABLE happens after jou compiled and deployed your program.

    Wim

  4. #4
    Join Date
    Jan 2004
    Location
    Montreal, Canada
    Posts
    151
    1) How can you code a selection where you can either "include" all records from a specified table "except" up to 5 variables "OR"
    "exclude" all records from a specified table "except" up to 5 variables.

    2) Is there a way to access the records(one a a time) resulting from the query without using DECLARE CURSOR and FETCH

  5. #5
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    > 1) How can you code a selection where you can either "include" all records from a specified table "except" up to 5 variables "OR"
    "exclude" all records from a specified table "except" up to 5 variables.

    I don't understand. Please give an example, with the definition of the tables. What do you mean with a "variable" of a table, do you mean "column" ?

    > 2) Is there a way to access the records(one a a time) resulting from the query without using DECLARE CURSOR and FETCH

    What programming language do you use ?

Posting Permissions

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