ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Issue with a date in embedded RPG

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

  • Issue with a date in embedded RPG

    My shop likes to use '9999-12-31' as a default in a date column.

    When I read this in an embedded SQL statement I get the error below.

    Sqlcod -181 THE STRING REPRESENTATION OF A DATETIME VALUE IS NOT A VALID DATETIME VALUE


    If I change the date to something like '2030-01-01' there is no error and the date column is read into the DS without issue.

    Is there a setting I am missing?


    exec sql
    declare db_vf01aa cursor for
    select idnumber,vacompany,vapoltype,variskstat,
    vaunitcat,vaunitcatd,vaexpdte,vadspord, vafetmp
    from vf01aa
    where vacompany = :scompany;

    exec sql
    open db_vf01aa;

    exec SQL
    fetch next from db_vf01aa into :inColumns;

    PS I see other posts where code is in a little window. I do not see anything that allows me to do that.


  • #2
    You need to set the sql date format, there are rules about what it uses if you don't which I don't remember. You are getting a date format that doesn't allow all years. Here is how to set, *ISO allows the full range of dates. Look in the RPG Reference for the various date formats and the range they allow.

    Code:
    exec sql set option DATFMT=*ISO;
    To put in a code block, highlight and then select the '#' on the tool bar. Hovering over it says 'wrap [CODE] tags around the selected text'. You can type them manually if you want.

    Comment


    • #3
      Thank you. That worked.


      Comment

      Working...
      X