ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

HELP! insert source line outside of PDM

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

  • HELP! insert source line outside of PDM

    I have been working on a project and I am currently STUCK. I need to enter a line of code in a source member (programmatically). I am using sql in my program and the INSERT command but the lines always end up at the bottom of the source. How can I insert the lines in a specific sequence?
    This is kinda what I've got going on:

    begsr insert_line;

    newseq# = seq# + 0.01;
    newline = 'auto code test';
    newdate = udate;

    exec sql
    insert into insert1
    (srcseq, srcdat, srcdta)
    values(:newseq#, :newdate, :newline);

    endsr;

    Thanks for the help.

  • #2
    Re: HELP! insert source line outside of PDM

    Its not really a solution, but a workaround. When I have had to do this I simply read the source template member line by line, and output it to a new member, making any insertions/deletion/modifications on the way.

    Comment


    • #3
      Re: HELP! insert source line outside of PDM

      Originally posted by arrow483 View Post
      Its not really a solution, but a workaround. When I have had to do this I simply read the source template member line by line, and output it to a new member, making any insertions/deletion/modifications on the way.
      That's the only way I've ever been able to do this.
      "Time passes, but sometimes it beats the <crap> out of you as it goes."

      Comment


      • #4
        Re: HELP! insert source line outside of PDM

        I agree also..... the source member is not keyed so just changing the sequence number works.....I have not tried using sql to key by sequence number and then rewrite.....test that for us will ya
        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! insert source line outside of PDM

          If I'm not mistaken (and I'm sure Brigitta would be glad to correct me) I believe that SQL is not sequence based. It finds the first available record to replace (if deleted records exists) or appends to the end of the table when doing an insert.

          Seems like I read something about this back before YouTube, Microwave Ovens and Compact Discs. About the same time as Captain Caveman and LP records...

          Comment


          • #6
            Re: HELP! insert source line outside of PDM

            Originally posted by jde700s View Post
            newseq# = seq# + 0.01;
            ......
            newdate = udate;
            I would renumber the source member first as duplicate numbers are allowed in source members. (SEU re-numbers the duplicates when you edit the member.)

            Something like below would most likely be better than using udate (which is the date the job started, not the actual date).
            Code:
            newdate =  %dec(%char(%date(): *ymd0): 6: 0);
            Regards

            Kit
            http://www.ecofitonline.com
            DeskfIT - ChangefIT - XrefIT
            ___________________________________
            There are only 3 kinds of people -
            Those that can count and those that can't.

            Comment


            • #7
              Re: HELP! insert source line outside of PDM

              Ok... here's the full thing

              Code:
              1. Create LF over the source file 
              loopstart: (get member name)
              2. Resquence your member - to avoid duplicates.
              3. Insert your record(s) with non-duplicating seq nrs.
              4. RGZPFM MYMBR using the KEYFILE parameter (maybe the SRCOPT parameter as well)
              5. get next member 
              goto loopstart/exit loop
              6. Voila
              Regards

              Kit
              http://www.ecofitonline.com
              DeskfIT - ChangefIT - XrefIT
              ___________________________________
              There are only 3 kinds of people -
              Those that can count and those that can't.

              Comment

              Working...
              X