Trigger to create flat file for new row in table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kk

    Trigger to create flat file for new row in table

    Hello,

    Help! Does anyone have an example of a trigger that will export a
    newly inserted row into a flat file? Basically anytime a row is
    inserted into a specific table a flatfile (fixed width) should be
    created in a hardcoded directory. I have the export command created
    but it doesn't seem to work in a trigger. I am sort of a newb to DB2
    (at least its more advanced functions). I have a project going 'live'
    and I have no idea on how to do this. I had wanted to put it on the
    task scheduler but that got shot down. If anyone has any suggestions
    or better yet a sample of code I could modify I would be very
    grateful.

    Thank You,
    Keith
  • Knut Stolze

    #2
    Re: Trigger to create flat file for new row in table

    kk <kkroculick@hot mail.com> wrote:
    [color=blue]
    > Hello,
    >
    > Help! Does anyone have an example of a trigger that will export a
    > newly inserted row into a flat file? Basically anytime a row is
    > inserted into a specific table a flatfile (fixed width) should be
    > created in a hardcoded directory. I have the export command created
    > but it doesn't seem to work in a trigger. I am sort of a newb to DB2
    > (at least its more advanced functions). I have a project going 'live'
    > and I have no idea on how to do this. I had wanted to put it on the
    > task scheduler but that got shot down. If anyone has any suggestions
    > or better yet a sample of code I could modify I would be very
    > grateful.[/color]

    Have a look here:



    You can call the functions described in the article from a trigger. You can
    also simply implement the functions in Java if you want to and if
    performance is not that important.

    --
    Knut Stolze
    Information Integration
    IBM Germany / University of Jena

    Comment

    • Serge Rielau

      #3
      Re: Trigger to create flat file for new row in table

      Remember to mark the UDF as EXTERNAL ACTION, otherwise DB2 will optimize
      it away.

      Cheers
      Serge
      --
      Serge Rielau
      DB2 SQL Compiler Development
      IBM Toronto Lab

      Comment

      Working...