RESUMO Este artigo discute como criar SQL tabelas para o Microsoft Business Solutions - Programas baseados em
Grande Destreza de Plains.
MAIS INFORMAÇÕES Use ofollowingsteps para criar SQL que residem em um programa de terceiros
de integração escrito em Destreza. Essas etapas também abrangem como conceder SQL permissão a essas tabelas.
Observação Este método substitui o método amAutoGrant descrito no Capítulo 41 do Guia de Programadores de Destreza, Volume 1.
1. Crie um procedimento global chamado
Startup se ainda não existir em seu programa de terceiros. Esse script é executado quando você inicia Great Plains e normalmente é onde os gatilhos são registrados.
2. No script
Inicializar, crie um gatilho de procedimento no Add_Successful_Login_Record usando o código a seguir.
{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. O gatilho registrado criado na etapa 2 chamará o procedimento global gp_create_tables sempre que o usuário
entrar no Microsoft Dynamics GP. Esse procedimento é executado quando uma empresa great plains é inicialmente aberta quando o usuário ou a empresa é comutado.
4. Crie o procedimento global chamado
gp_create_tables. Este script criará as tabelas para o programa de terceiros no banco de dados SQL Server correto. Ele também irácriar a tabela gerada storedprocedures (zDP procs) e conceder SQL permissões à tabela e procedimentos. Use o código a seguir.
{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. As tabelas e os procedimentos armazenados gerados na tabela serão criados SQL Server e SQL permissões serão concedidas. Esse script só será executado para usuários doSA ou DYNSA e, depois que as tabelas são criadas, não há problema em executar esse script novamente.
Este artigo foi TechKnowledge Document ID:33429