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
Solved

How to pass variable in the  Netezza/Postgresql query?

Posted on 2009-05-07
5
1,664 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
  • 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 500 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

856 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