PDA

View Full Version : Issue-Reading a file with vbld_GetFileContents


teognost
04-22-2008, 01:15 PM
I need to read the contents of some sql script files one by one and put the content into a separate file.In order to do this I have a step which sets the macro CURR_SQL_SCRIPT_CONTENT to
[vbld_GetFileContents("%PROCFILES_FULLPATH%")]
and then I have another step which writes into the target file the macro CURR_SQL_SCRIPT_CONTENT
SQL scripts contains brackets like :
IF NOT EXISTS (SELECT * FROM [sm].[DefaultSetting] WHERE [ApplicationType] = 1 AND [ValueId] = 111)

and I see when reading the SQL file everything inside the brackets is just ignored and therefore is not appearing in the target file.
I do not understand what is wrong as in the help it is written vbld_GetFileContents should read everything ok:
"vbld_GetFileContents(Filename): Retrieve the contents of a file and double up characters that are treated specially by Visual Build Pro. Bracket characters [ ] and percent sign % characters are normally interpreted by Visual Build Pro as referencing script code and macros within a field. When retrieving the contents of a file into a field, using this function will cause these characters to be treated as literals by VBP.
"
Any idea how to read everything from SQL script ,including the parts between brackets?

kinook
04-22-2008, 01:51 PM
That works as expected in my tests w/ VBP v6.7. The attached sample appends

IF NOT EXISTS (SELECT * FROM [sm].[DefaultSetting] WHERE [ApplicationType] = 1 AND [ValueId] = 111)

to %TEMP%\test2.sql each time it is built.

teognost
04-22-2008, 02:17 PM
Ok,I tried exactly as in your example and it is fine.The problem was using that intermediate macro CURR_SQL_SCRIPT_CONTENT,the data between macros was lost that way(not sure why).When writing the data directly as you did -works fine.Can you tell me why the macro lost the data?Maybe in the future I would need to store content of such a file in a macro...
see the attachment

kinook
04-22-2008, 02:24 PM
Use

[vbld_EscapeString(vbld_GetFileContents("%TEMP%\test.sql"))]

in the Set Macro step so that the macro value gets stored with special VBP chars escaped.

http://www.visualbuild.com/Manual/sysscriptmisc.htm
http://www.visualbuild.com/Manual/specialchars.htm

teognost
04-23-2008, 01:19 AM
Works perfect,thanks for clarification!