Warning: Undefined array key "birthday_search" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 173

Warning: Undefined array key "joindate" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 190

Warning: Undefined array key "posts" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 191

Warning: Undefined array key "posts" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 197

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 6509

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 212

Warning: Undefined array key "privacy_options" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/api/user.php on line 251

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 4998

Warning: Undefined array key "userid" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 1585

Warning: Undefined array key "lastactivity" in phar:///home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb/vb.phar/library/user.php on line 1601

Warning: Trying to access array offset on value of type bool in /home/duptmor/public_html/prod.mcpressonline.com/forum/core/vb5/route/profile.php on line 74
Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL - MC Press Online Forums

Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL

    ** This thread discusses the article: Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL **

    Is there a reason you would not have used the SQL value retrieval instead of referencing SYSIBM/SYSDUMMY1?
    Exp. exec sql values week(:argDate) into :svWoy;
    Last edited by D.Uptmor; 01-20-2012, 11:07 AM.

  • #2
    Simpler

    ** This thread discusses the article: Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL **
    Tom, I think a simpler way to take advantage of SQL functions is to make your program SQLRPGLE and embed the statement directly in it. Also, you don't have to use SYSDUMMY1 to get the result. Yes, it's a very useful table for certain times but unnecessary here. My example just uses the SET statement - as you can see, you can put several together in one statement. I think this is simpler than invoking a service pgm to replace essentially one line of code.

    /free
    mydate = %date();

    EXEC SQL
    set :weekDay = dayOfWeek(:mydate),
    :dayOfYr = dayOfYear(:mydate),
    :weekNum1 = week(:mydate),
    :weekNum2 = week_iso(:mydate);

    dsply mydate;
    dsply weekDay;
    dsply dayOfYr;
    dsply weeknum1;
    dsply weekNum2;
    *inLR = *on;
    /end-free

    Russ K

    Comment


    • #3
      Great Alternatives

      ** This thread discusses the article: Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL **
      Thanks tstephens55 and R.Khoury for some great alternatives!

       

      tstephens55

      I don‘t see any reason why you couldn‘t use values instead. I‘ve used values in statements before, but never like that. I think it‘s a great alternative and I‘ll be using it. Thanks!

       

      R.Khoury

      You are absolutely right. For programmers that are used to using embedded SQL it would be easier to just code it in the statement. For situations where you‘re in a staff that is early in adoption of embedded SQL then using procedures could let programmers who do not feel comfortable with embedded SQL programs to access the functionality without dealing with the details or changes in the way they compile. And if for some reason you put your functions in a service program it could be like a code repository for code snippets that embedded SQL programmers, like yourself, could use to copy and paste juicy pieces of code.

       

      Thanks a lot for the posts! Happy Coding!

      Tom
      Last edited by Guest; 01-19-2012, 02:39 PM. Reason: HTML Editing

      Comment


      • #4
        ** This thread discusses the article: Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL **
        Tom, thanks for taking the time to write your articles. I already knew about the using SQL SET but sometimes your articles teach me something new and then at times you get to learn something new too. We all improve our skills.

        Exec SQL SET : iUserID = Upper(: P0iUserID ) ;

        Chris Ringer

        Comment


        • #5
          What it's all about

          ** This thread discusses the article: Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL **
          And Thank You Chris! You‘re so right, that‘s what it‘s all about. Thanks everyone for the alternatives. You took the article a step beyond what I put out there and taught me some new tricks. Thank You!

           

          Thanks for introducing me to set R.Khoury. Nice use of it Chris!

           

          Have a great day!

          Tom

          Comment


          • #6
            ** This thread discusses the article: Get the Day of the Week, Full Text Date Values, and More Within RPG Using SQL **
            Actually, I did learn from R.Khoury that one SET statement can do multiple sets, separating each SQL statement by a comma.

            Comment

            Working...
            X