Solved

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

  • 21 February 2019
  • 2 replies
  • 53 views

Userlevel 4
Badge +2
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

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?
View original

2 replies

Userlevel 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?
Userlevel 4
Badge +2
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!

Reply

    Cookie policy

    We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

    Accept cookies Cookie settings