ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

help reqd on inserting sql into RPGLE

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

  • help reqd on inserting sql into RPGLE

    In my eval statement

    eval M_MSGDATA
    =
    %trim(%editw(+
    X_AUTHAXY:' , , , , , 0 . -'))


    if you observe there are two spaces after period in in the above statement
    0.(space)(space)-')

    SELECT NUMBER FROM DLESTER/RSFILE WHERE CURRENCYISOCD = 'USD'

    this gives value for NUMBER.


    I want to insert the value of select statement in the two spaces after point (0 . -'))

    My program is RPGLE, Iam making it SQLRPGLE by inserting above SQL line.

    Please help me with the logic I need to make it work.

    Thanks for your help

    Donna.

  • #2
    Re: help reqd on inserting sql into RPGLE

    I know its late in the day....but I have no idea what you are asking here.
    could you please re-phrase also please post a sample of the numeric
    data before and what you would like it to look like after.

    thanks
    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: help reqd on inserting sql into RPGLE


      Iam sorry!
      let me explain in detail:
      here is my select statement:
      SELECT NUMBER FROM DLESTER/RSFILE WHERE CURRENCYISOCD = 'USD'
      I get Number = 2 when I execute this SQL statement.
      ----------
      So I have to insert 2 spaces after period (0.) in the eval statement....
      My eval statement is as below:
      eval M_MSGDATA
      =
      %trim(%editw(+
      X_AUTHAXY:' , , , , , 0 . -'))

      To make it more clear

      eval M_MSGDATA
      =
      %trim(%editw(+
      X_AUTHAXY:' , , , , , 0 .(onespace)(onespace)-'))

      It is hard coded in my program with 2 spaces after period.
      Depending on the NUMBER value after executing SQL statement it should give that many spaces after the period.

      Eg:
      If the NUMBER value after executing SQL statement is 1 then I should insert 1 space after the period.
      If the NUMBER value after executing SQL statement is 3 then I should insert 3 spaces after the period. With 3 spaces it look like below:

      eval M_MSGDATA
      =
      %trim(%editw(+
      X_AUTHAXY:' , , , , , 0 .(onespace)(onespace)(onespace)-'))

      NY offices are getting empty frm 4pm, very chilled weather..

      Comment


      • #4
        Re: help reqd on inserting sql into RPGLE

        Its chilly here also --- I will be in New York for the Christmas Holiday...

        I can't see the data in field X_AUTHAXY and I cant see the data after (im a visual person) plus I never use %editw always use %editc....that said

        to make this easier I would just leave the editw alone with no spaces.

        then I would scan for the "." and do something like this

        PHP Code:
          eval str = %scan('.' M_MSGDATA
        if 
        str > *zeros
        eval M_MSGDATA = %substr(M_MSGDATA:1:str-1)
        eval 
        therest = %substr(M_MSGDATA:Str+1
        for  
        count 1 to number
        eval M_MSGDATA = %trim(M_MSGDATA) + ' '
        endfor 
        eval 
        M_MSGDATA = %trim(M_MSGDATA) + %trim(TheRest)
        endif 
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: help reqd on inserting sql into RPGLE

          Originally posted by jamief View Post
          Its chilly here also --- I will be in New York for the Christmas Holiday...

          I can't see the data in field X_AUTHAXY and I cant see the data after (im a visual person) plus I never use %editw always use %editc....that said

          to make this easier I would just leave the editw alone with no spaces.

          then I would scan for the "." and do something like this

          PHP Code:
            eval str = %scan('.' M_MSGDATA
          if 
          str > *zeros
          eval M_MSGDATA = %substr(M_MSGDATA:1:str-1)
          eval 
          therest = %substr(M_MSGDATA:Str+1
          for  
          count 1 to number
          eval M_MSGDATA = %trim(M_MSGDATA) + ' '
          endfor 
          eval 
          M_MSGDATA = %trim(M_MSGDATA) + %trim(TheRest)
          endif 
          Thanks Jamie! I will try this tomm and let you know
          Can you post some example code to imbed my SQL Select statement into RPGLE?

          We will be going Italy for Christmas holidays....

          Comment


          • #6
            Re: help reqd on inserting sql into RPGLE

            spent some of my early days in Italy, but thats for another day..



            PHP Code:
                 C/Exec sql
                 C
            select *
                 
            C+   into :ffd
                 C
            +   from QTEMP/DSPFFD
                 C
            +  where Whflde = :field_name
                 C
            /end-exec 
            All my answers were extracted from the "Big Dummy's Guide to the As400"
            and I take no responsibility for any of them.

            www.code400.com

            Comment


            • #7
              Re: help reqd on inserting sql into RPGLE

              Originally posted by jamief View Post
              spent some of my early days in Italy, but thats for another day..



              PHP Code:
                   C/Exec sql
                   C
              select *
                   
              C+   into :ffd
                   C
              +   from QTEMP/DSPFFD
                   C
              +  where Whflde = :field_name
                   C
              /end-exec 


              Just one question,
              currently my program is RPG, now Iam changing it to SQLRPG, how do I compile this , the SQL code is nt accepting into the program when I try embed SQL...

              please suggest!

              Donna

              Comment


              • #8
                Re: help reqd on inserting sql into RPGLE

                change the type from RPGLE to SQLRPGLE
                Attached Files
                All my answers were extracted from the "Big Dummy's Guide to the As400"
                and I take no responsibility for any of them.

                www.code400.com

                Comment


                • #9
                  Re: help reqd on inserting sql into RPGLE

                  is it rpg or rpgle. If rpgle just change the type. If it is rpg must first use CVTRPGSRC to convert to rpgle then change type.
                  Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                  Comment


                  • #10
                    Re: help reqd on inserting sql into RPGLE

                    Whats RPG ?
                    All my answers were extracted from the "Big Dummy's Guide to the As400"
                    and I take no responsibility for any of them.

                    www.code400.com

                    Comment


                    • #11
                      Re: help reqd on inserting sql into RPGLE

                      Donna, It needs to be type SQLRPGLE

                      Jaimef, Its # 31

                      Comment


                      • #12
                        Re: help reqd on inserting sql into RPGLE

                        Thanks arrow its nice to have a relaxing laugh......

                        You have a happy Turkey day and dont be %trim ing anyone
                        All my answers were extracted from the "Big Dummy's Guide to the As400"
                        and I take no responsibility for any of them.

                        www.code400.com

                        Comment


                        • #13
                          Re: help reqd on inserting sql into RPGLE

                          Originally posted by jamief View Post
                          Thanks arrow its nice to have a relaxing laugh......

                          You have a happy Turkey day and dont be %trim ing anyone

                          Lol
                          Thanks Jamie & Arrow!


                          Donna

                          Comment

                          Working...
                          X