Subject Re: stored procedure to GRANT priveledges not working
Author Adam
--- In firebird-support@yahoogroups.com, "robertgilland"
<robert_gilland@...> wrote:
>
> I have written this stored proc.
>
> SET TERM #;
> CREATE PROCEDURE PROC_ADDUSER
> ( USERORROLE CHAR(31)) AS
> DECLARE VARIABLE THERELNAME CHAR(80);
>
> BEGIN
> FOR SELECT RDB$RELATION_NAME FROM RDB$RELATIONS
> WHERE RDB$RELATION_NAME NOT LIKE 'RDB$%'
> ORDER BY RDB$RELATION_NAME INTO :THERELNAME
> DO
> BEGIN
> GRANT ALL ON :THERELNAME TO :USERORROLE;
> END
> END#
> SET TERM ;
>
> When I run in IBOConsole I get:
>
> ISC ERROR CODE:335544569
>
> ISC ERROR MESSAGE:
> Dynamic SQL Error
> SQL error code = -104
> Token unknown - line 10, column 6
> GRANT
>
>
> What is wrong with this?

Grant is not DML! It is DDL; like CREATE TABLE or DROP PROCEDURE etc.

It is not normally recommended to do DDL inside the same transaction
as DML. The only way you can do it is to use the execute statement
syntax (see release notes).

Adam