AS/400-DB2/400

620 pts.
Tags:
AS/400
I have a file (customer) that have 50 records. How we can select the 34th record with out using rrn() and fetch. Would you please help me with the query.
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 11  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • philpl1jb

    Interview question?

    Who else would want a specific physical record?

    What tool are you using? "with the query"

    54,090 pointsBadges:
    report
  • chowas400
    Thank you for the response.
    No Philpl1jb, it's not an interview question.
    i want a specific record in a file.
    i'm practicing with mocha soft(v5r3), i think it's in db2/400..

    620 pointsBadges:
    report
  • philpl1jb

    Generally the client is irrelevant [mocha soft(v5r3)]

    But would you be using SQL or RPGLE or some query tool .. query 400

    Or could you use the cpyf command which allows a from and to record number ..


    54,090 pointsBadges:
    report
  • ToddN2000
    I assume this is a flat file with no keys. IF doing this in RPGLE just use a DO loop and exit when it has looped 34 times.
    135,525 pointsBadges:
    report
  • chowas400
    So it's not possible in db2/400? If it possible in query/400 the can you
    please provide a query for my question?

    620 pointsBadges:
    report
  • bvining
    I'm having some real difficulty understanding your request. For some reason you know you want the 34th row/record in the table/file but you don't want to have to specify that it's the 34th row that you want. What is it about the 34th row that makes it unique in your application? 

    There are several ways of getting the 34th row but they all come down, in one way or another, to accessing the 34th row relative to the start of the table (whether you use a RRN function or not) as that's the only criteria you have given for selection.

    More information is really needed about your application requirements and the knowledge that you want only the 34th row (without telling the system it's the 34th row).

    Bruce Vining
    .
    7,070 pointsBadges:
    report
  • philpl1jb

    Yes .. here you go you can see the contents of a data file member with the command DSPMBR myfile. That will show all records .. Then type +33 in the control and that should move you to the 34th record.

    This will show the actual contents of the file member

     .. packed numeric fields will be very interesting in appearance. 

    54,090 pointsBadges:
    report
  • ToddN2000
    I you use Philip1jb's suggestion with the DSPPFM, if you want, you can unpack the numeric fields with a F10 to see the data in hexidecimal format.
    135,525 pointsBadges:
    report
  • chowas400
    Hi All,

    Thank you very much for your responses...

    i'm looking for query as like below without using rrn().Is it possible? please suggest..
    Select *from customer where rrn(customer)=34.

    620 pointsBadges:
    report
  • philpl1jb

    Wish you had specified SQL query .. would have saved us a lot of time.

    Without using RRN this is not possible.

    In fact, the order that records are returned from the Select statement is not predictable without an order by clause. 

    54,090 pointsBadges:
    report
  • ToddN2000
    I agree with philp1jb.

    It's not possible without an order by clause.

    Seems like an odd request, can you explain the business logic behind the request?
    135,525 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: