Question

GRANT inside for Loop

  • 20 February 2022
  • 3 replies
  • 101 views

Userlevel 1
Badge +3

Hi All,

 

I want to give  grant permission to tables which are more in number.

 

I have executed below logic , it is throwing below error “Encountered the symbol “GRANT” when expecting below “ 

Code used :

 

DECLARE

BEGIN

FOR R IN (SELECT TABLE_NAME FROM IC_TAB_LIST)

LOOP

    GRANT SELECT ON R.TABLE_NAME TO IFSAPP

END LOOP;

END

 

Here : IC_TAB_LIST = Table name, which has around 300 tables where i need to give permission.

 

Please suggest asap.


This topic has been closed for comments

3 replies

Userlevel 5
Badge +9

Hi @TechSriniG 

This May Helpful

 

DECLARE

BEGIN

FOR R IN (SELECT TABLE_NAME FROM IC_TAB_LIST)

LOOP

   EXECUTE IMMEDIATE 'GRANT SELECT ON '||R.TABLE_NAME||' TO IFSAPP';

END LOOP;

END

Userlevel 1
Badge +3

Thank you Shaan, its working

Userlevel 5
Badge +9

Hi @TechSriniG 

Happy to hear the issue was resolved. You can mark this question as solved now :).

Thanks & Regards
Shan