Feedback
Did this article resolve your question/issue?

   

Article

How to generate SQL script to GRANT all privileges on all the database tables using 4GL?

« Go Back

Information

 
TitleHow to generate SQL script to GRANT all privileges on all the database tables using 4GL?
URL NameP95289
Article Number000156050
EnvironmentProduct: OpenEdge
Version: Progress 9.x
OpenEdge 10.x, 11.x
OS: All Supported Operating Systems
Other: RDBMS, SQL92
Question/Problem Description
How to generate SQL script to GRANT all privileges on all the database tables using 4GL?

How to generate a Batch file to grant SQL92 permissions on all the connected database tables to PUBLIC?

Sample 4GL/ABL source code to generate SQL-92 script to Grant Privileges on a Schema tables.
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution

The following procedure generates an SQL script file to to GRANT ALL privileges on all the connected database tables to PUBLIC.  To generate the SQL script, simply connect to the database and run the following 4GL/ABL code.

To GRANT ALL privileges on all the connected database tables to PUBLIC, simply execute the SQL script generated for it by this 4GL/ABL procedure. The resulting SQL script files may be executed using any JDBC client like the Progress SQL Explorer Tool.

To generate SQL script syntax to run using an ODBC client like WinSQL, run the GenerateScriptForWinSQL.p version of this code in the note below:
 

/***************GenerateScriptForJDBC.p************/

OUTPUT TO VALUE("GrantAll.sql").

FOR EACH _File WHERE _Tbl-Type = "T":
    PUT UNFORMATTED "GRANT ALL ON PUB." + QUOTER(_File-Name) + " TO PUBLIC;" SKIP.
END.
PUT UNFORMATTED "COMMIT WORK;" SKIP.

OUTPUT CLOSE.

 

The SQL-92 script file, "GrantAll.sql", generated by running the above 4GL code will look like the following sample:
 

GRANT ALL ON PUB."Benefits" TO PUBLIC;
GRANT ALL ON PUB."BillTo" TO PUBLIC;
GRANT ALL ON PUB."Bin" TO PUBLIC;
GRANT ALL ON PUB."Customer" TO PUBLIC;
GRANT ALL ON PUB."Department" TO PUBLIC;
GRANT ALL ON PUB."Employee" TO PUBLIC;
GRANT ALL ON PUB."Family" TO PUBLIC;
GRANT ALL ON PUB."Feedback" TO PUBLIC;
GRANT ALL ON PUB."InventoryTrans" TO PUBLIC;
GRANT ALL ON PUB."Invoice" TO PUBLIC;
GRANT ALL ON PUB."Item" TO PUBLIC;
GRANT ALL ON PUB."LocalDefault" TO PUBLIC;
GRANT ALL ON PUB."Order" TO PUBLIC;
GRANT ALL ON PUB."OrderLine" TO PUBLIC;
GRANT ALL ON PUB."POLine" TO PUBLIC;
GRANT ALL ON PUB."PurchaseOrder" TO PUBLIC;
GRANT ALL ON PUB."RefCall" TO PUBLIC;
GRANT ALL ON PUB."Salesrep" TO PUBLIC;
GRANT ALL ON PUB."ShipTo" TO PUBLIC;
GRANT ALL ON PUB."State" TO PUBLIC;
GRANT ALL ON PUB."Supplier" TO PUBLIC;
GRANT ALL ON PUB."SupplierItemXref" TO PUBLIC;
GRANT ALL ON PUB."TimeSheet" TO PUBLIC;
GRANT ALL ON PUB."Vacation" TO PUBLIC;
GRANT ALL ON PUB."Warehouse" TO PUBLIC;
COMMIT WORK;

The SQL-92 statements in the above "GrantAll.sql" file may be executed using any ODBC or JDBC client. For example, the following command executes the above script using the Progress SQL Explorer Tool Character JDBC Client:

sqlexp -char -db sports2000 -S 23456 -H hostname -infile GrantAll.sql -outfile GrantAll.out -user YourUserId -password YourPassword



WinSQL example code (the required syntax is slightly different):




/***************GenerateScriptForWinSQL.p************/
OUTPUT TO VALUE("GrantAll.sql").

FOR EACH _File WHERE _Tbl-Type = "T":
    PUT UNFORMATTED "GRANT ALL ON PUB." + QUOTER(_File-Name) + " TO PUBLIC" SKIP.
    PUT UNFORMATTED "GO" SKIP.
END.

OUTPUT CLOSE.

The SQL-92 script file, "GrantAll.sql", generated by running the above 4GL code will look like the following sample:
 

GRANT ALL ON PUB."Benefits" TO PUBLIC

GO
GRANT ALL ON PUB."BillTo" TO PUBLIC
GO
GRANT ALL ON PUB."Bin" TO PUBLIC
GO
GRANT ALL ON PUB."Customer" TO PUBLIC
GO
GRANT ALL ON PUB."Department" TO PUBLIC
GO
GRANT ALL ON PUB."Employee" TO PUBLIC
GO
GRANT ALL ON PUB."Family" TO PUBLIC
GO
GRANT ALL ON PUB."Feedback" TO PUBLIC
GO
GRANT ALL ON PUB."InventoryTrans" TO PUBLIC
GO
GRANT ALL ON PUB."Invoice" TO PUBLIC
GO
GRANT ALL ON PUB."Item" TO PUBLIC
GO
GRANT ALL ON PUB."LocalDefault" TO PUBLIC
GO
GRANT ALL ON PUB."Order" TO PUBLIC
GO
GRANT ALL ON PUB."OrderLine" TO PUBLIC
GO
GRANT ALL ON PUB."POLine" TO PUBLIC
GO
GRANT ALL ON PUB."PurchaseOrder" TO PUBLIC
GO
GRANT ALL ON PUB."RefCall" TO PUBLIC
GO
GRANT ALL ON PUB."Salesrep" TO PUBLIC
GO
GRANT ALL ON PUB."ShipTo" TO PUBLIC
GO
GRANT ALL ON PUB."State" TO PUBLIC
GO
GRANT ALL ON PUB."Supplier" TO PUBLIC
GO
GRANT ALL ON PUB."SupplierItemXref" TO PUBLIC
GO
GRANT ALL ON PUB."TimeSheet" TO PUBLIC
GO
GRANT ALL ON PUB."Vacation" TO PUBLIC
GO
GRANT ALL ON PUB."Warehouse" TO PUBLIC
GO

Workaround
Notes

References to Other Documentation:

Progress SQL-92 Guide 

Progress Article(s):

"How to generate SQL-92 script to execute UPDATE STATISTICS for all user tables of a database using 4GL?"

Last Modified Date11/20/2020 7:34 AM
Attachment 
Files
Disclaimer The origins of the information on this site may be internal or external to Progress Software Corporation (“Progress”). Progress Software Corporation makes all reasonable efforts to verify this information. However, the information provided is for your information only. Progress Software Corporation makes no explicit or implied claims to the validity of this information.

Any sample code provided on this site is not supported under any Progress support program or service. The sample code is provided on an "AS IS" basis. Progress makes no warranties, express or implied, and disclaims all implied warranties including, without limitation, the implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample code is borne by the user. In no event shall Progress, its employees, or anyone else involved in the creation, production, or delivery of the code be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample code, even if Progress has been advised of the possibility of such damages.