+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16

Thread: Update with "order by" and "fetch first 1 rows only"

  1. #1
    K.Forsythe Guest

    Default Update with "order by" and "fetch first 1 rows only"

    I did not get a chance to test the whole thing but try this... update test1 a set a.zona12 = (select coalesce(b.zona22,a.zona12) from test2 b where a.zona11 = b.zona21 AND b.zona23 = (select Max(c.zona23) from test2 c where a.zona21 = c.zona21 and b.zona22=c.zona22)) Let me know how that works out...

  2. #2
    Guest.Visitor Guest

    Default Update with "order by" and "fetch first 1 rows only"

    "Result of SELECT more than one row"...

  3. #3
    K.Forsythe Guest

    Default Update with "order by" and "fetch first 1 rows only"

    try... update test1 a set a.zona12 = (select coalesce(b.zona22,a.zona12) from test2 b where a.zona11 = b.zona21 AND b.zona23 = (select Max(c.zona23) from test2 c where a.zona21 = c.zona21 and b.zona22=c.zona22) fetch first 1 rows only) or update test1 a set a.zona12 = (select coalesce(min(b.zona22) ,a.zona12) from test2 b where a.zona11 = b.zona21 AND b.zona23 = (select Max(c.zona23) from test2 c where a.zona21 = c.zona21 and b.zona22=c.zona22))

  4. #4
    Guest.Visitor Guest

    Default Update with "order by" and "fetch first 1 rows only"

    thank you - i tried them both. the first one says "Keyword FETCH not expected" (same problem as with my query), and the second one doesn't update the file as I want. i'm not good in explaining what i want, so i just wrote a little program that does the job (code below) - but I still want to use SQL instead
    Code

  5. #5
    K.Forsythe Guest

    Default Update with "order by" and "fetch first 1 rows only"

    I'll take a look at this when I have more time to recreate your file structure and get you a tested syntax. Sorry for not having it right (yet).

  6. #6
    Guest.Visitor Guest

    Default Update with "order by" and "fetch first 1 rows only"

    thank you for your time - of course it's not an urgent matter. My real problem is that I'm not allowed to put RPG code in production (I only use it to make tools in the development environment), as the "official" programming language of the company where I am in this moment is Cobol. And I HATE writing Cobol code after getting used to RPG )

  7. #7
    K.Forsythe Guest

    Default Update with "order by" and "fetch first 1 rows only"

    OK not that I am biased or anything.... But COBOL? I admit 15 years ago RPG was not THAT much better than COBOL. But RPG has evolved since then. And COBOL... What exactly is the draw?

  8. #8
    Guest.Visitor Guest

    Default Update with "order by" and "fetch first 1 rows only"

    this box uses an application written a long time ago (maybe a little less than 15 years ) and since then they bring only consultants that are familiar with Cobol. so I'm the only RPG programmer among 10 Cobol developers that don't understand RPG maybe I should just leave

  9. #9
    K.Forsythe Guest

    Default Update with "order by" and "fetch first 1 rows only"


  10. #10
    Guest.Visitor Guest

    Default Update with "order by" and "fetch first 1 rows only"

    I agree with the principle, but Cobol doesn't give me much appetite ) Otherwise, I didn't built well my example, sorry for that (it's 23:35 here in France...). The unique key on the second file is ZONE21 & ZONE23. I post below the complete and correct info (2 files & 1 program), waiting for the replacement of these 16 lignes of code with one SQL statement, rather than 100 lines of Cobol code...
    Code

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Creating vertical rows into horizontal rows
    By Guest.Visitor in forum SQL
    Replies: 5
    Last Post: 06-23-2005, 01:45 PM
  2. Multi Row fetch in ILE RPG
    By Guest.Visitor in forum RPG
    Replies: 1
    Last Post: 10-06-2003, 12:30 PM
  3. Fetch overflow with external printer files?
    By Guest.Visitor in forum Programming
    Replies: 9
    Last Post: 07-10-2001, 04:42 PM
  4. Fetch Overflow Gotcha
    By David Abramowitz in forum Programming
    Replies: 2
    Last Post: 05-31-2001, 04:39 AM
  5. CWBDB0099 stream fetch request
    By Guest.Visitor in forum Programming
    Replies: 2
    Last Post: 02-13-2001, 07:55 AM

Posting Permissions

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