TÓM TẮT Bài viết này thảo luận về cách tạo SQL bảng cho các giải pháp Kinh doanh của Microsoft - Các chương trình dựa trên Sự
khéo léo của Đơn giản Tuyệt vời.
THÔNG TIN THÊM Sử dụng công cụ theo dõi để tạo SQL bảng nằm trong chương trình tích hợp của bên thứ ba được viết trong
Dexterity. Các bước này cũng đề cập đến cách cấp SQL quyền đối với những bảng này.
Lưu ý Phương pháp này sẽ thay thế phương pháp amAutoGrant được mô tả trong Chương 41 của Hướng dẫn Lập trình Viên Lập trình Dexterity, Tập 1.
1. Tạo một thủ tục toàn cầu có
tên là Khởi động nếu quy trình này không tồn tại trong chương trình của bên thứ ba. Tập lệnh này chạy khi bạn khởi động Great Plains và thường là nơi đăng ký trình kích hoạt.
2. Trong tập
lệnh Khởi động, tạo quy trình kích hoạt trên Add_Successful_Login_Record thủ tục bằng cách sử dụng mã sau đây.
{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. Yếu tố kích hoạt đã đăng ký được tạo ở bước 2 sẽ gọi đến thủ tục toàn cầu gp_create_tables khi người dùng đăng nhập
vào Microsoft Dynamics GP. Quy trình này chạy khi công ty Great Plains được mở lần đầu hoặc khi người dùng hoặc công ty được chuyển đổi.
4. Tạo thủ tục toàn bộ có tên
là gp_create_tables. Tập lệnh này sẽ tạo các bảng cho chương trình của bên thứ ba trong cơ sở dữ liệu SQL Server chính xác. Quy trình này cũng sẽ tạo bảng được tạo ra các quy trình lưu trữ (quy trình lưu trữ zDP) và cấp SQL quyền đối với bảng và thủ tục. Sử dụng mã sau đây.
{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. Bảng và thủ tục lưu trữ đã tạo bảng sẽ được tạo SQL Server và SQL quyền sẽ được cấp. Tập lệnh này sẽ chỉ chạy cho người dùngSA hoặc DYNSA và sau khi các bảng được tạo, bạn có thể chạy lại tập lệnh này.
Bài viết này đã được TechKnowledge Document ID:33429