Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2011
    Posts
    85

    Unanswered: Pass Date parameters

    Hi I want to pass a date parameters like startdate and enddate
    And check LL col results exist in the parameter range

    select u.userid, p.passwordmodifydate, p.is_latest,s.PASSWORDEXPIRYDAYS,date(days(p.passw ordmodifydate) + s.PASSWORDEXPIRYDAYS) as ll
    from user u,PASSWORDCREDENTIALS p, SECURITYPROFILE s
    where u.userid = p.userid
    and p.userid = s.userid
    and s.PASSWORDEXPIRYDAYS = 90
    and p.PASSWORDMODIFYDATE is not null
    and IS_LATEST = 'Y'
    and [is is the place i should pass parameter]

    Any help would appreciated

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You need to give more information. What DB2 version and OS? How are you executing this SQL?

    Andy

  3. #3
    Join Date
    Sep 2011
    Posts
    85
    Im using DB2 9.7 fp5 in linux RHEL 5

    For now im running this on Aqua Data Studio. So if you can guide me a way to do that would be really helpful

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    If you are just using the tool to execute the SQL, then the tool has to be able to do parameters. DB2 has no way to pass parameters on a Query. You could create a Stored Procedure to do the parameters.

    Andy

  5. #5
    Join Date
    Sep 2011
    Posts
    85
    Hi Andy

    I want the last AND statement to be corrected.

    select u.userid, p.passwordmodifydate, p.is_latest,s.PASSWORDEXPIRYDAYS,date(days(p.passw ordmodifydate) + s.PASSWORDEXPIRYDAYS) as ll
    from user u,PASSWORDCREDENTIALS p, SECURITYPROFILE s
    where u.userid = p.userid
    and p.userid = s.userid
    and s.PASSWORDEXPIRYDAYS = 90
    and p.PASSWORDMODIFYDATE is not null
    and IS_LATEST = 'Y'
    and ll and ll between '2012-01-05' and '2012-02-37'

    Think the above two dates are the parameters i passed. i wanted to check ll col's data exist between passed dates.
    I want to check this before take this to code.

    Thanx

  6. #6
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    I do not understand what you want to do.

    Andy

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    This syntax of a BETWEEN predicate is:
    Code:
    <expr> BETWEEN <expr1> AND <expr2>
    So in your case, leave out one of the "ll and" things - if that's what you are wondering about.

    Also, if you want to build the query based on some input, you can either use (host) variables or you have to run the query as dynamic statement.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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