SHRNUTÍ Tento článek popisuje, jak vytvořit tabulky SQL Microsoft Business Solutions – programy založené na
zručnosti great plains.
DALŠÍ INFORMACE: Následující kroky slouží k SQL tabulek, které se nacházejí v integrující aplikaci třetích stran napsané
v aplikaci Dexterity. Tento postup se také týká toho, jak SQL těmto tabulkám udělit oprávnění.
Poznámka: Tato metoda nahrazuje metodu amAutoGrant popsanou v kapitole 41 příručky Dexterity Programmers Guide volume 1 .
1. Vytvořte globální proceduru s názvem Spuštění, pokud ještě neexistuje v programu
třetích stran. Tento skript se spustí, když spustíte Great Plains a obvykle je tam, kde jsou aktivační události registrované.
2. Ve
spouštěcím skriptu vytvořte aktivační událost procedury v Add_Successful_Login_Record pomocí následujícího kódu.
{Name: Startup}
local integer l_result;
l_result = Trigger_RegisterProcedure(script Add_Successful_Login_Record, TRIGGER_AFTER_ORIGINAL, script gp_create_tables);
if l_result <> SY_NOERR then
warning "The Add_Successful_Login_Record trigger is not registered.";
end if;
3. Registrovaná aktivační událost vytvořená v kroku 2 zavolá globální proceduru gp_create_tables pokaždé, když se uživatel přihlásí
k Microsoft Dynamics GP. Tento postup se spustí při prvním otevření společnosti Great Plains nebo při přepnutí uživatele nebo společnosti.
4. Vytvořte globální proceduru s
názvem gp_create_tables. Tento skript vytvoří tabulky pro program třetích stran ve správné SQL Server databáze. Vytvoří také vygenerované uložené procedury (zDP procs) a udělí SQL oprávnění k tabulce a procedurám. Použijte následující kód.
{Name: gp_create_tables}
local boolean result,l_result,OUT_Access;
{if logged in as sa, let them create the tables}
if 'SQLSaUser' of globals then
OUT_Access = true;
else
{This else statement will work only on 8.0. If logged in as a user other than sa,
but they have table access permissions, let them create the tables}
if syUserInRole('User ID' of globals, ROLE_SYSADMIN) or (syUserIsDBO ('User ID' of globals, 'Intercompany ID' of globals)
and syUserIsDBO ('User ID' of globals, SQL_SYSTEM_DBNAME)) then
OUT_Access = true;
end if;
end if;
if 'SQL Server' of globals > 0 and OUT_Access then
{enable table creation mode}
result = Table_SetCreateMode(true);
{Do not display any table errors to the user.}
result = Table_DisableErrorChecks(true);
{accessing the table creates it, list all your tables here, make sure to close the tables when done}
get first table GPSetup; {Purchasing series table}
close table GPSetup;
get first table GPSetup2; {System series table}
close table GPSetup2; {now set permissions, call once for the table and once for the stored procs}
{GPSetup is a purchasing series table so that will be in the company dbo}
l_result = GrantAccess(physicalname(table GPSetup),false,"DYNGRP",'Intercompany ID' of globals)
of form 'SQL Maintenance';
l_result = GrantAccess(physicalname(table GPSetup),true,"DYNGRP",'Intercompany ID' of globals)
of form 'SQL Maintenance';
{GPSetup2 is a system series table so that will be in the DYNAMICS database}
l_result = GrantAccess(physicalname(table GPSetup2),false,"DYNGRP","DYNAMICS") of form 'SQL Maintenance';
l_result = GrantAccess(physicalname(table GPSetup2),true,"DYNGRP","DYNAMICS") of form 'SQL Maintenance';
{Turn off automatic table creation.}
result = Table_SetCreateMode(false);
{Turn table error reporting back on.}
result = Table_DisableErrorChecks(false);
end if;
5. Tabulky a tabulky generované uložené procedury se vytvoří v SQL Server a SQL budou udělena oprávnění. Tento skript se spustí jenom pro uživatele DYNSA nebo DYNSA a po vytvoření tabulek je v pořádku tento skript spustit znovu.
Tento článek byl TECHKnowledge Document ID:33429