String Operators - Concatenation

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Jamball77
Newbie
Posts: 14
Joined: Tue Aug 11, 2015 2:25 pm

String Operators - Concatenation

Post by Jamball77 » Tue Aug 11, 2015 11:02 pm

I want to concatenate String Part1 + CO_ID_string (from a user input window) + String Part2.

How do I do this? Not yet in the online MacroScheduler docs. Those have really helped.
let>string_part1 = DECLARE @RC int DECLARE @CO_NUMB varchar (15) SET @CO_NUMB = '
Input>CO_ID_string,Enter the CO_ID,
let>string_part2 = ' EXECUTE @RC = dbo.SP_KIC_CO_Entry_USER_9 @CO_NUMB
the debugger of course shows the value for CO_ID_string. after the input screen pops up and I enter a value

I'm using the concatenation as a workaround
I'm using concatenation to "build" a SQL query because I failed to use the input box string variable directly.

Input>CO_ID_string,Enter the CO_ID,
then use the CO_ID_string value into the SQL code using the SET Command.

This "works": look at the SET...
let>SQL=DECLARE @RC int DECLARE @CO_NUMB varchar (15) SET @CO_NUMB = '147113' EXECUTE @RC = dbo.SP_KIC_CO_Entry_USER_9 @CO_NUMB

This Doesn't Work: SET @CO_NUMB probably goes in as 'CO_ID_String' instead of the string's value.
let>SQL=DECLARE @RC int DECLARE @CO_NUMB varchar (15) SET @CO_NUMB = 'CO_ID_string' EXECUTE @RC = dbo.SP_KIC_CO_Entry_USER_9 @CO_NUMB
Do you have an idea about how to SET @CO_NUMB (variable being passed to a stored procedure) to the value input from a user input box?

Both answers are appreciated. If I don't concatenate now I know I will later. Many thanks.

hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: String Operators - Concatenation

Post by hagchr » Wed Aug 12, 2015 5:38 am

Hi, you need to enclose the variables with % ( ie %Variable%) so MS knows how to resolve them. Also be careful when assigning strings to variables. Unless you have IGNORESPACES set to 1 it is better to avoid the spaces, ie use Let>x=ABC instead of Let>x = ABC.

Code: Select all

let>string_part1=DECLARE @RC int DECLARE @CO_NUMB varchar (15) SET @CO_NUMB = '
Input>CO_ID_string,Enter the CO_ID,
let>string_part2=' EXECUTE @RC = dbo.SP_KIC_CO_Entry_USER_9 @CO_NUMB

Let>res=%string_part1%%CO_ID_string%%string_part2%

MDL>res

Jamball77
Newbie
Posts: 14
Joined: Tue Aug 11, 2015 2:25 pm

Re: String Operators - Concatenation

Post by Jamball77 » Wed Aug 12, 2015 12:20 pm

Thanks, my issue was with the spacing.

I had used the %s to stitch things together as per posting:
http://mjtnet.co.uk/forum/viewtopic.php?f=2&t=6457



Related links:
viewtopic.php?t=6856
viewtopic.php?t=1653

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts