This topic contains 4 replies, has 2 voices, and was last updated by  bceamer 8 years, 11 months ago.

First Lua script, now problems

  • function main()
    local conn = db.connect{api=db.ORACLE_OCI,name=’B01291.WORLD’,user=’V500_READ’,password=’xxx’ }
    for i=1, #rs do

    When I start the translator channel up it writes to the file, but keeps repeating it.
    I thought it would stop at the end of the result set?
    The file keeps getting bigger and bigger until I stop the channel
    What am I missing here?

    Add a test if #rs >0 then …
    Replace queue.push{data=rs[i]} with trace(rs[i]).
    Add to db.connect{} the ‘live’ parameter, e.g. live=true.
    Run it in Translator IDE and inspect visually the content of rs[i] shown in Annotations.
    Datatype for parameter data, in the queue.push{} call, is String; you may have to do type casting by calling tostring() function.
    Above steps may help you to debug your script.

    It all looks good, result set has 83 rows. It writes the 83 rows out fine, but then writes them out again, and again, caught in a loop

    Did you tell the script some criteria to decide which rows to read and which rows already have been processed? I guess not.
    When channel is started, channel invokes script repeatedly as configured in channel configuration, and script keeps reading each time same 83 lines. Mark them as ‘read’ in some way. Design your database to ‘remember’ what had been processed so far and what is still pending the processing.

    Ok, that is what I figured, I thought the channel was ‘smarter’ than that :O)
    I will simulate a ‘W’ flag or something

    Thanks Lev

You must be logged in to reply to this topic.