Feedback
Did this article resolve your question/issue?

   

Article

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

« Go Back

Information

 
TitleHow to generate SQL script to GRANT Read and Write privileges on all the database tables using 4GL?
URL Name000039715
Article Number000161932
EnvironmentProduct: Progress
Version: 9.1x
Product: OpenEdge
Version: 10.x, 11.x
OS: All Supported Platforms
Question/Problem Description
How to generate SQL script to GRANT Read and Write 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 a USER?
Sample 4GL/ABL source code to generate SQL-92 script to Grant Privileges on Schema tables.
How to generate a Batch file to grant SQL92 permissions on all the connected database tables to Public?
Steps to Reproduce
Clarifying Information
Error Message
Defect/Enhancement Number
Cause
Resolution
The following procedure generates an SQL script file to GRANT Read Write privileges on all the connected database tables to a user.  
  • To generate the SQL script, simply connect to the database and run the following 4GL/ABL code.
  • To GRANT READ WRITE privileges on all the connected database tables to the USER, simply execute the SQL script generated by this 4GL/ABL procedure. The resulting SQL script files may be executed using any JDBC client like the Progress SQL Explorer Tool.
In the code sample below, "me" would be replaced with the "user name" that the GRANT privileges are needed for.  If "Public" is used, all users will be granted Read Write privileges on all the connected database tables.
 
Steps:
 
1. Connect to the database with a 4GL client.
$   prowin32 dbname [-S <portnumber> -H <hostname>]
 
2. Run the following program from the Progress 4GL session, it will create a file named ReadWrite.sql in the current working directory:
 
OUTPUT TO .\ReadWrite.SQL.

FOR EACH _file WHERE _file._file-num GT 0 AND _file._file-num LT 32000 NO-LOCK:
     PUT UNFORMATTED 'grant select, update, insert,delete  on PUB."' + _file._file-name + '" to me ~;'
     SKIP.
     PUT UNFORMATTED 'COMMIT;'
     SKIP.
END.
 
3. Execute the file ReadWrite.SQL file from SQL Explorer in batch mode as follows, to grant the privileges to the user:
 
$   sqlexp -char -infile ReadWrite.SQL -outfile report.txt -db -S -H -user <SQL_Admin_User> -password < password>
 
 
The SQL-92 script file, "ReadWrite.SQL", generated by running the above 4GL code will look similar to the following sample: from the Sports2000 database and can be further edited as required.
 
grant select, update, insert,delete  on PUB."Invoice" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Customer" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Item" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."OrderLine" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Salesrep" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."State" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."LocalDefault" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."RefCall" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Feedback" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Employee" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."TimeSheet" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Vacation" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Family" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Department" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Benefits" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."ShipTo" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."BillTo" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Order" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Supplier" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Warehouse" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."Bin" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."InventoryTrans" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."PurchaseOrder" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."POLine" to me ;
COMMIT;
grant select, update, insert,delete  on PUB."SupplierItemXref" to me ;
Workaround
Notes
Last Modified Date11/20/2020 7:14 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.