Skip to Content
avatar image
Former Member

Delete records using Script, variables and multiple values

Hi

I have a source file in one DB and target file in another DB.

I want to delete records in the target file where targetfile.month=sourcefile.month

How can I achieve this?

I tried to use scripts with variables

Example :

$variable1 = sql('DB1', 'select month from sourcefile');

sql('DB2', ' delete from target file where month = {$variable1} ')

But apparently since $variable1 can hold only one value I am not getting the results I want. I have multiple values for the first statement above and its not fixed. How do I store multiple values in a variable or create an array? please eplain with the format for any function if we have one.

Cheers.

Using DS Designer 14.2.1.568

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 21, 2015 at 06:49 AM

    You can implement a delete in a data flow, too.

    • Start with source table.
    • In Query transform: select month from source.
    • Then add a Map_Operation transform to change row types from Normal to Delete.
    • Connect to target table.
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 20, 2015 at 07:46 PM

    Are the DBs on same server? Use a post load command on the target table.

    Some thing like this -

    Delete from table1 inner join table2 on table1.month = table2.month

    Add comment
    10|10000 characters needed characters exceeded