Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Table_SetCreateMode and Table_SetDeleteOptions

Dexterity Techniques

Using Table_SetCreateMode and Table_SetDeleteOptions

by  winthropdc  Posted    (Edited  )
Using Table_SetCreateMode and Table_SetDeleteOptions
====================================================

The function library command Table_SetCreateMode() is used to control how Dexterity handles missing tables. If it is set to true, the table is automatically created by Dexterity if it is not found. Otherwise, if set to false Dexterity will not create the table.

The function library command Table_SetDeleteOptions() is used to control how Dexterity handles deleting tables. If it is set to true, the table is physically removed. Otherwise, if set to false Dexterity will leave the table intact but remove its contents.

The Great Plains code sets the appropriate value for these settings during its initialisation. However, the values depend on the platform being used.

On a MS-SQL based platform, the default values should be set to Table_SetCreateMode(false) and Table_SetDeleteOptions(false). This is because only the Database Owner or System Administrator users have the rights to create a new table. In a SQL System all tables (with associated stored procedures) are created during the installation process and access granted to them to allow use by all users. Consequently, physically removing the table will cause problems as it will not be recreated when it is needed.

So, when using these two commands it is vitally important to restore the setting to the default state for the platform. This is because other code within the system is expecting these states to be correct and it may cause problems elsewhere in the application if the mode is left in the incorrect state. In the two examples below, the state is restored after the specific actions have occurred.


{ Create Table Example }

if 'SQL Server' of globals > 0 then
Table_SetCreateMode(true);
end if;

{ Create Tables Here, LAN settings are already correct }

if 'SQL Server' of globals > 0 then
Table_SetCreateMode(false);
end if;


{ Delete Table Example }

if 'SQL Server' of globals > 0 then
Table_SetDeleteOptions(true)
end if;

{ Physically Remove Tables Here, LAN settings are already correct }


if 'SQL Server' of globals > 0 then
Table_SetDeleteOptions(false)
end if;


Below are summaries of the Table_SetCreateMode() and Table_SetDeleteOptions() function library commands from the Dexterity Help file.


Table_SetCreateMode()
---------------------

The Table_SetCreateMode() function allows you to choose whether tables that donÆt already exist will be created automatically when they are accessed at runtime.

Syntax:
Table_SetCreateMode(option)

Parameters:
option û A boolean that sets the table creation mode:
true - Automatically creates the table if it isnÆt found.
false - DoesnÆt create the table if it isnÆt found.

Return value:
The boolean value true.


Table_SetDeleteOptions()
------------------------

The Table_SetDeleteOptions() function allows you to choose whether a delete all or drop will be executed when the delete table statement is used.

Syntax:
Table_SetDeleteOptions(option)

Parameters
option û A boolean that sets the delete table functionality:
true - Use the drop functionality, which removes the data and the table from the database.
This also removes the auto-generated stored procedures for the table.
false - Use the delete all functionality, which removes all of the data in the table,
leaving the empty table intact in the database.

Return value:
The boolean value true.


David Musgrave [MSFT]
Senior Development Consultant
MBS Services - Asia Pacific

Microsoft Business Solutions
http://www.microsoft.com/BusinessSolutions

Any views contained within are my personal views and
not necessarily Microsoft Business Solutions policy.
This posting is provided "AS IS" with no warranties,
and confers no rights.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top