You have to login in order to post a reply to this topic.

3 replies [Last post]
rreinsch
User offline. Last seen 2 years 10 weeks ago. Offline
Joined: 11/24/2009
Posts: 3

Hello,

This is my first post...

I would like to run a stored procedure that accepts a parameter from another query and then loops through and writes all the data to excel. I was using Automate 7 but it was to expensive so i wanted to try WinAutomation.  In automate i could put all the results into a dataset and then fill in excel from the dataset.  Is this possible in WinAutomation?

Thanks in advance,

Cheers,

RR

codex
codex's picture
User offline. Last seen 18 weeks 4 days ago. Offline
Joined: 11/12/2009
Posts: 161
Re: Automate SQL Stored Procedure

Did you try using the "Execute SQL Statement" action? This action allows you to execute a specific SQL statement on a database and retrieve the results in a variable (as a data table). Then, you will not even have to loop through the results to write them to an Excel file (you can if you want to, but it is not your best option): you can just launch an excel file and write the variable that contains the data table directly to a cell (e.g. A1). The results will automatically take their place in the Excel cells.

If you are retrieving your results in a different way (e.g. through a 3rd party application), please let me know in what form you will have them, and I will let you know the best way to store them to Excel.

P.S: If you want your job to be able to get input from external sources (e.g. in the form of command line arguments), you can use the "Get Command Line Arguments" action. This action will retrieve all the information that you will pass as command line arguments to your job if you execute it through the Command Line or if your job is compiled to an executable.

__________________

Error is not blindness, error is cowardice

__________________

Error is not blindness, error is cowardice

rreinsch
User offline. Last seen 2 years 10 weeks ago. Offline
Joined: 11/24/2009
Posts: 3
Re: Automate SQL Stored Procedure

Thanks for the reply Codex.

Yes I am using Execute SQL Statement from and that part is working but what I can figure out is how to pass a paramater to that stored procedure.  I have another qurey running before that that gets a "Number" that i need to use as the input paramater for the Stored Procedure.  Do you know how i could do that? Do i need to put that in a list?

Thanks for you help!! :-)

Ryan

codex
codex's picture
User offline. Last seen 18 weeks 4 days ago. Offline
Joined: 11/12/2009
Posts: 161
Re: Automate SQL Stored Procedure

I'm not a SQL expert, but I'm guessing that you are trying to do something like this:

CALL ysp(SampleNumberAsInput1);

where ysp = your stored procedure.

The question here is "where do you get the number from? If it is generated inside your job and it is stored in a variable called %MyNumber% for example, then you can just use this:

CALL ysp(%MyNumber%);

If you can tell me how you are retrieving the specific number I will be able to give you more details on how to pass the values that you want to your stored procedure.

__________________

Error is not blindness, error is cowardice

__________________

Error is not blindness, error is cowardice