Forum Discussion

SL12345's avatar
SL12345
New Contributor III
6 months ago
Solved

Best Approach for Handling CSV Import with Truncate in Pipeline: Ensuring Correct Execution Order

I want to ask: I’m attaching a screenshot of the pipeline that should: Read a CSV file, truncate SQL tables, and after the successful truncate, insert all the records from the CSV into the truncat...
  • koryknick's avatar
    6 months ago

    SL12345 - you need to remember that SnapLogic is a streaming platform, meaning that by placing the truncate where you did, it is performing the truncate for every record in the file before inserting each record, which doesn't make sense.  You can move the truncate before the File Reader so that the sequence is truncate, read, parse, insert. 

    If you want to ensure that the file exists before truncating the target, you can put a Directory Browser snap at the beginning of the pipeline so it can stop successfully if the file doesn't exist and won't truncate the table in that case.  If it does exist, it will continue along with the truncate, file read, parse, and load.

    Hope this helps!