?
Solved

How to pass variable in the  Netezza/Postgresql query?

Posted on 2009-05-07
5
Medium Priority
?
1,748 Views
Last Modified: 2013-11-10
In Netezza database i have table called TableA. This table has many vendor details. Now i need to create .CSV file for each vendor details in the particular folder. File name like "VendorNo_YYYYMMDD.csv" with the help of "create external table command". First thing I don't know how to loop through each vendor no in Netezza query.
 
So i plan to use SQL Server SSIS package. And loop through each vendor number and try to pass this vendor number variable in where condition. Since Netezza doesn't have Stored procedure option with our existing version, i don't know how to pass vendor number variable in the where condition.
 
This task i need to do every day.
 
Please help me. Thanks in advance.
0
Comment
Question by:PKTG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 22

Expert Comment

by:PedroCGD
ID: 24334813
Which is the source you are using to get data from PostgreSQL?
You should pass the query to the source as an expression... inside a for each loop...
Regards,
Pedro
www.pedrocgd.blogspot.com
0
 

Author Comment

by:PKTG
ID: 24337453
I am using Netezza database . It is almost similar to Postgresql. Can you please explain little more. Or if you have example please share with me. I need to pass same query but different venodr no every time in the where class.
Select * from TableA where vendor_No= vintvendorno  -- it is variable name for vendor number.
Thanks
0
 
LVL 22

Expert Comment

by:PedroCGD
ID: 24337630
no... the source component you are using in SSIS... OLEDB Destination? Data Reader Source?
0
 

Author Comment

by:PKTG
ID: 24340375
ODBC conectivity. SOme time i used OLEDB also to connect Netezza.
0
 
LVL 22

Accepted Solution

by:
PedroCGD earned 2000 total points
ID: 24352355
PKTG,
Add a dataflow to your control flow.
In the connection manager create a ADO.NET connection
Inside dataflow add a Data Reader Source and add a SQL query...
ok?
Now, to set it dinamically, go to dataflow, go to properties and pass the query insert before as an expression... see the attached image...
helped?
regards,
Pedro
www.pedrocgd.blogspot.com
SSIS-Expression.JPG
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question