Forum Discussion

Siva_Venna's avatar
Siva_Venna
Contributor
7 years ago

Drop few columns before inserting into Oracle table

I am reading data from csv file before inserting the data into Oracle table,I want to delete or omit unnecessary columns. How to achieve this?Thanks in advance

8 Replies

  • cstewart's avatar
    cstewart
    Former Employee

    If you put a mapper Snap in between, you can put the source fields in the source column, if you put no target for those fields, it will drop them in the data flow. Use the pass-through option to get all other fields passed to the output without having to put them all in the table

  • Thanks @cstewart. It worked.
    I am getting below error while inserting data into Oracle table :

    Invalid timestamp format:
    Resolution:
    Please check for valid timestamp format.

    My coulmn datatype is DATE.
    The timestamp snaplogic fetching : 2019-03-20T13:03:45+00:00
    how to convert the this timestamp to Oracle DATE datatype?

    • Siva_Venna's avatar
      Siva_Venna
      Contributor

      Thank you @dmiller
      that post helped me.
      I want to truncate the table before loading/ inserting the data for every execution. is it possible?

  • dmiller's avatar
    dmiller
    Former Employee

    You can use the Mapper Snap.
    If you put the source fields in the source column and do not specify a target for those fields, it will drop them in the data flow.

    • Siva_Venna's avatar
      Siva_Venna
      Contributor

      Using mapper to drop fields is fine. I am asking is it possible to truncate the table before inserting data?. i.e table will have only latest execution data

      • pedro_almeida's avatar
        pedro_almeida
        New Contributor

        As I see it, you have 2 options:

        1. Add an “Oracle Delete” Snap without any delete condition (DELETE FROM TableName) before inserting the data.
        2. If you really need to execute the Truncate instead of the Delete, you may try to create a stored procedure (On your Oracle DB) with “EXECUTE IMMEDIATE 'TRUNCATE TABLE ’ || TableName;” statement and then call this stored procedure on SnapLogic with the “Oracle Stored Procedure” Snap.

        I would go for option 1 for simplicity.