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

an ‘SQLRTComponentUninstall’: undefined identifier

We have a requirement during uninstall to ask the user if they would like to drop a database.

So when the feature TestPro is uninstalled we’d offer the user the option to drop the database. I’m trying to use SQLRTComponentUninstall

A feature called DataseDrop is in the install only to be called by SQLRTComponentUninstall, and has an sql script associated with it to drop a database to run during uninstallation.

I’m getting an ‘SQLRTComponentUninstall’: undefined identifier but I can’t work out what .rul or header files I need to include.


Our sample code is shown below.

export prototype TestPro_UnInstalled();
function TestPro_UnInstalled()
NUMBER nResult;
begin
if (AskYesNo("Preserve Database. Would you like to leave the database " +

"after uninstalling?", YES) = YES) then


nResult = SQLRTComponentUninstall( "DatabaseDrop" );


endif;
end;
Labels (1)
0 Kudos
(4) Replies
hidenori
Level 17

Did you add a connection and your SQL script in the SQL Scripts view? The SQLRTComponentUninstall function is designed to work in conjunction with the view.
0 Kudos
tparks
Level 3

Hi
I've added a feature called DatabaseDrop, and then created an SQLConnection with an associated SQL script and have associated this script with the DatabaseDrop feature.

But my problem seems to relate more on the scripting side where the SQLRTComponentUninstall is not recognised.

It looks like I'm missing a #include for either a .h or .rul file by I can't quite work out which

T.
0 Kudos
hidenori
Level 17

Instead of calling the SQLRTComponentUninstall function directly, I would suggest that you will modify the OnSQLComponentInstalled and/or OnSQLComponentUninstalled event to run or not run your SQL script based on your end user's input. Your code will look like this:

BOOL g_bPreserveDatabase;
export prototype TestPro_UnInstalled();

function TestPro_UnInstalled()
NUMBER nResult;
begin
g_bPreserveDatabase = FALSE;
if (AskYesNo("Preserve Database. Would you like to leave the database " +
"after uninstalling?", YES) = YES) then

g_bPreserveDatabase = TRUE;

endif;
end;

function OnSQLComponentUninstalled(szComponent)
string szMessage, szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
number nResult;
BOOL bvOpt1, bvOpt2;
begin

if(g_bPreserveDatabase = TRUE) then
return 0;
endif;

if( SQLRTGetBatchMode() ) then

// Queue up the component to run later
nResult = SQLRTAddToBatchInstall( szComponent );

else
// Run scripts now
nResult = SQLRTComponentInstall( szComponent );

if( nResult = SQL_ERROR_ABORT ) then

// Get error message
SQLRTGetScriptErrorMessage( szMessage );

// Display error
MessageBox( szMessage, SEVERE );

// Rollback SQL Scripts
SQLRTDoRollbackAll();

// Close the current dialog.
EndCurrentDialog();


//Display Finish dialog.
szTitle = "";
szMsg1 = SdLoadString( SD_STR_ONCANCELING_FINISH_MSG1 );
szMsg2 = SdLoadString( SD_STR_ONCANCELING_FINISH_MSG2 );
szOpt1 = "";
szOpt2 = "";
bvOpt1 = FALSE;
bvOpt2 = FALSE;
SdFinish ( szTitle, szMsg1, szMsg2 , szOpt1, szOpt2, bvOpt1, bvOpt2 );

abort;

endif;

endif;

end;
0 Kudos
tparks
Level 3

thanks for the reply. I've got it working now. I had to change from an Installscript MSI project to an Installscript to get access to the SQLRT routines.

I also made a small additional modification to check for a specific component "dropit" which is specifically for droping the database. As I don't want to block any other scripts that might be scheduled to run on feature uninstall. See code below in red

thanks
T.

function OnSQLComponentUninstalled(szComponent)
string szMessage, szTitle, szMsg1, szMsg2, szOpt1, szOpt2;
number nResult;
BOOL bvOpt1, bvOpt2;
begin

if(g_bPreserveDatabase = TRUE) then
if(szComponent="dropit.sql_SQLComponent") then

return 0;
endif;


endif;
0 Kudos