Transformer Stage with zero input link

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
news78
Participant
Posts: 44
Joined: Fri Jul 07, 2006 1:37 pm

Transformer Stage with zero input link

Post by news78 »

I need to just delete data from a table in a server job. How do I acheive this using DRS stage? I am trying the following:

[Transformer] > [DRS Stage]

In the DRS stage, I have configured the table name and given a User defined sql which will delete the data.

Now during compile, it complains Transformer requires an input link. How to get around that? I did a quick search but could not find anything. I remember it has something to do with setting a constraint but what exactly?

Any suggestions? All i need is to delete data from a oracle table and it has to be from a Server job.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Define a stage variable. That should calm down the compiler.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to define a stage variable so the job will compile, no need to actually use it. Then a constraint to ensure that only one record goes to the database stage, otherwise the job will run forver. I use:

@OUTROWNUM=1
-craig

"You can never have too many knives" -- Logan Nine Fingers
kura
Participant
Posts: 21
Joined: Sat Mar 20, 2004 3:43 pm

Re: Transformer Stage with zero input link

Post by kura »

you can use sequential file stage before transformer reading "dev/null" file.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ah, yes... but you don't need to. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
news78
Participant
Posts: 44
Joined: Fri Jul 07, 2006 1:37 pm

Post by news78 »

chulett wrote:You need to define a stage variable so the job will compile, no need to actually use it. Then a constraint to ensure that only one record goes to the database stage, otherwise the job will run forver. I use:

@OUTROWNUM=1
I tried this.
1. I tried with defining the table name in DRS. Also I defined one column. The sql tab has the delete sql statement.
In the transformer stage, I defined a stage variable and assigned it to this column on the tranformer out put link. Then I defined the constraint as you mentioned. Is this correct? I am getting an:

Abnormal termination of stage test1..Transformer_0 detected and job fails without any results.
=========
Also. I tried with just defining the table name in DRS (without specifying any cols). This gives me "No Cols on Transofrmer Output link" error.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That was just to get your job compiling and running with a chance of success. The actual setup of the DRS stage for this is a completely different issue.

Post your delete SQL.
-craig

"You can never have too many knives" -- Logan Nine Fingers
news78
Participant
Posts: 44
Joined: Fri Jul 07, 2006 1:37 pm

Post by news78 »

chulett wrote:That was just to get your job compiling and running with a chance of success. The actual setup of the DRS stage for this is a completely different issue.

Post your delete SQL.
The sql is realy simple.

delete from tablename where col1=1

In the DRS stage, I have specified the tabel name in the "General" tab and Update action is "User-defined sql". I have specified col1 in the Columns tab(this also reflects in the Transofrmer output link. In that derived col I have put a constant say 5).

=======================
It seems simple, only thing is I dont understand if anything is wrong on the link going from Transofrmer to DRS stage.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'd suggest stepping back and not using user-defined sql, it's not needed here. Create one column in the stage for col1 in the table and mark it as a Key field. Use an Update action of 'Delete existing rows only'. Set the value of the key field passed down from the Transfomer to 1. Done.
-craig

"You can never have too many knives" -- Logan Nine Fingers
news78
Participant
Posts: 44
Joined: Fri Jul 07, 2006 1:37 pm

Post by news78 »

chulett wrote:I'd suggest stepping back and not using user-defined sql, it's not needed here. Create one column in the stage for col1 in the table and mark it as a Key field. Use an Update action of 'Delete existing rows only'. Set the value of the key field passed down from the Transfomer to 1. Done.
OK that works!!!
On similar lines in another job(same scenario) if I need

delete from tablename where col2 < firstday_of_currentmonth

here I was hoping to use the User -defined sql (oracle sql):
delete from tablename where col2 < trunc(sysdate,'MM')

This is throwing the same xfmer error. Any pearls of advise here?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Same pearl with a different shine. You'll probably need to use user-defined sql. :wink:

First, clarify what 'col2 < firstday_of_month' means. Col2 is a date? I doubt you can use 'MM' here without also including the year as well. I'm guessing you need a sql statement more akin to this:

Code: Select all

delete from tablename where to_char(col2,'YYYY-MM) < to_char(sysdate,'YYYY-MM') 
Since the stage wants at least one column and that column must be bound into the query, you can play this game: make your one column in the link a dummy column, mark it as a key and set its value to '1' in the transformer. Then make your sql statement look like this:

Code: Select all

delete from tablename where to_char(col2,'YYYY-MM) < to_char(sysdate,'YYYY-MM') and 1=?
You get the sql you need with a harmless "and 1=1" constraint tacked on the end. 8)
-craig

"You can never have too many knives" -- Logan Nine Fingers
news78
Participant
Posts: 44
Joined: Fri Jul 07, 2006 1:37 pm

Post by news78 »

chulett wrote:Same pearl with a different shine. You'll probably need to use user-defined sql. :wink:

First, clarify what 'col2 < firstday_of_month' means. Col2 is a date? I doubt you can use 'MM' here without also including the year as well. I'm guessing you need a sql statement more akin to this:

Code: Select all

delete from tablename where to_char(col2,'YYYY-MM) < to_char(sysdate,'YYYY-MM') 
Since the stage wants at least one column and that column must be bound into the query, you can play this game: make your one column in the link a dummy column, mark it as a key and set its value to '1' in the transformer. Then make your sql statement look like this:

Code: Select all

delete from tablename where to_char(col2,'YYYY-MM) < to_char(sysdate,'YYYY-MM') and 1=?
You get the sql you need with a harmless "and 1=1" constraint tacked on the end. 8)


excellent Craig you totally rock man! :)
I used the only one col in xfmer as a dummy col(as a varchar) and then it worked.

delete from table where col2 < trunc(sysdate,'MM') and '1'=:1

I guess the main point i was missing here is that in the DRS stage any place other than the Before/After tabs , your sql (generated or user-defined) needs to atleast 1 column must be bound into the query. :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Excellent, glad it all worked out. Seems like all of the database stages - with the exception of the ODBC stage for some reason - want to have all of the columns mentioned in the stage bound into the sql. And as you've found, it doesn't matter if it is generated or user-defined sql, bondage is required. Or should that be 'boundage'? :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

BINDING is what is required.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Did you miss the smiley, Uncle Ray? :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply