cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hcl_60
Level 3

creating and calling stored procedures of mysql from installshield 2010

hi

How to create a stored procedure and call the created stored procedure(via script) of MYSQL from installshiled.


thanks in advance..
Labels (1)
0 Kudos
(1) Reply
Install_guy
Level 4

Hi hcl_60

You can use LaunchAppAndWait:

Below i have a .sql file that i would like to run,
in my case i use SQL osql Command line:

osql -S \ -U -P

You would need to know the mysql command line:

LaunchAppAndWait("\"" + MSDETARGETLOCATION + "\\binn" + "\\osql.exe\""," -S (local)\\SL -U sa -P -i \"" + TARGETDIR ^ "\\TestProc.sql\" -o \"" + TARGETDIR ^ "\\TestProc.log\"",WAIT);

If you want, you can create your stored procedure dynamically or just have the file ready to use with the command, but the following code will create the stored procedure dynamically and execute it:

// Create the stored proc
OpenFileMode( FILE_MODE_NORMAL );
CreateFile( nvFilehandle, TARGETDIR", "TestProc.sql" );
WriteLine( nvFilehandle, "CREATE PROCEDURE [dbo].[TestProc]" );
WriteLine( nvFilehandle, "@ColName as sysname")
WriteLine( nvFilehandle, "AS")
WriteLine( nvFilehandle, "DECLARE @STR AS VARCHAR(200)");
WriteLine( nvFilehandle, "SET @STR = " select count(*) from " + @TableName + " where " + @ColName + " is not null");
WriteLine( nvFilehandle, "EXEC (@STR)");
WriteLine( nvFilehandle, "GO");
CloseFile (nvFilehandle);

// Launch the stored procedure
LaunchAppAndWait("\"" + MSDETARGETLOCATION + "\\binn" + "\\osql.exe\""," -S (local)\\SL -U sa -P -i \"" + TARGETDIR ^ "\\TestProc.sql\" -o \"" ^ "\\TestProc.log\"",WAIT);
0 Kudos