Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.