Solved

Can I attach an external SQL file to the 'Execute source code' step during 'Creation'?

  • 21 February 2019
  • 3 replies
  • 230 views

Userlevel 7
Badge +23
To be precise, I have other application which generates a script. This script I would like the Software Factory to run during the 'Execute source code' step of another application. How can I make this work?

My idea is that the Software Factory reads from a certain file path, looking for the SQL file and then attaching it to the 'Execute source code' step, but if there's another/better way I would love to hear it.

(It is not an option to generate the code inside the application where I would like the script to be run on)
icon

Best answer by Anne Buit 21 February 2019, 13:21

View original

3 replies

Userlevel 7
Badge +23
Hi Mark,

You can create a new control procedure in the code group MANUAL. You might have to remove a prefilter from the code groups in the look-up to be able to select it.

The template of this control procedure should contain the code you need to run. This template can be assigned to a program object, also called manual.

This will cause a new code file to appear in the source code execution screen, at the bottom, called (coincidentally) manual.

This method will not read a file from disk, and instead will require you to put the code to be executed in a template. Will this suffice?


Hey Anne, thanks for your answer. This kind of answers it all but I really would want to read a file from a specific location for my purpose. So I used google and found a helpful result which helps me achieve my vision:

code:
declare @filecontents nvarchar(max)

select @filecontents = bulkcolumn
from openrowset(bulk 'path+filename.sql',single_clob) x; -- char

exec sp_executesql @filecontents


So in combination with a Manual control procedure and this piece of code I can make sure my SQL file gets executed on the right database. Thanks!
Userlevel 6
Badge +10

@Anne Buit As part of investigating the possibilities for automating the deployments, I was looking for possibilities to run code at the end of an Custom Application deployment. I finally found this topic with the ‘MANUAL’ Code Group option, but couldn’t find any reference to this in the Docs. 

This is potentially great stuff, could this Manual stored procedure option be added to the Docs?

Userlevel 7
Badge +5
Hi Mark,

You can create a new control procedure in the code group MANUAL. You might have to remove a prefilter from the code groups in the look-up to be able to select it.

The template of this control procedure should contain the code you need to run. This template can be assigned to a program object, also called manual.

This will cause a new code file to appear in the source code execution screen, at the bottom, called (coincidentally) manual.

This method will not read a file from disk, and instead will require you to put the code to be executed in a template. Will this suffice?

Reply