Set Private Data to SQL result

Post Reply
kheslin
Newbie
Posts: 5
Joined: Tue Jun 27, 2017 11:37 pm

Set Private Data to SQL result

Post by kheslin »

Using Switch 2018.

I'd like to do a SQL query and store the result in Private Data.

This is my SQL statement

EXEC SW_GetDeadlineDate_r1
'[Job.PrivateData:Key="p1"]' ,
'[Job.PrivateData:Key="deadline"]'
____________________________________________________________________
Here is my SQL Stored Procedure

CREATE PROCEDURE [dbo].[SW_GetDeadlineDate_r1]
@PubID char(6), @Deadline int output
AS
BEGIN

Set @Deadline = (SELECT [Deadline]
FROM [dbo].[Publications] where [Publication_ID] = @PubID)

END

GO
____________________________________________________________________

The SQL works in SSMS, but the Private Data does not get updated in Switch.

Thanks
Padawan
Advanced member
Posts: 358
Joined: Mon Jun 12, 2017 8:48 pm
Location: Belgium
Contact:

Re: Set Private Data to SQL result

Post by Padawan »

How are you storing the result in private data?

Personally, I would create a database Switch variable to get the result of your SQL query and store it in private data via the private data property in a folder in Switch. If something goes wrong this way, then I would expect errors in the messages. Do you see something like that?
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Set Private Data to SQL result

Post by gabrielp »

You likely have the Switch database module/configurators which I'm not familiar with but I figured I'd share this script which uses ODBC and has several ways to save results as private data. You can save a single result or a series result as private data. You also can save the result as a dataset https://github.com/open-automation/switch-sql-query
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Post Reply