0

Creating function in database

Hello,

I simple copy the example from nuo db web and the same is not working in my environement. Can you please advise me what should I do ?

 

DROP FUNCTION IF EXISTS fnc_dbobject_privs;
SET DELIMITER @
CREATE FUNCTION fnc_dbobject_privs (i_privmask INTEGER)
RETURNS STRING
AS
VAR l_priv_list STRING='';
FOR SELECT pt.name AS privname FROM system.privtypes pt
WHERE (pt.id & i_privmask) > 0;
l_priv_list=l_priv_list||','||privname;
END_FOR;
RETURN substr(l_priv_list,2,length(l_priv_list)-1);
END_FUNCTION;
@
SET DELIMITER ;

 

****************************************************************

The error Im facing is the following:

00:15:11 START Executing for: 'LocalNuoDB_Admin' [NuoDB], Schema: MYSCHEMA
00:15:11 SUCCESS [DROP - 0 rows, 0.001 secs] OK. No rows were affected
DROP FUNCTION IF EXISTS fnc_dbobject_privs;
00:15:11 FAILED [SET - 0 rows, 0.002 secs] [Code: -1, SQL State: 42000] syntax error on line 2
CREATE FUNCTION fnc_dbobject_privs (i_privmask INTEGER)
^ expected end of statement got CREATE

SET DELIMITER @
CREATE FUNCTION fnc_dbobject_privs (i_privmask INTEGER)
RETURNS STRING
AS
VAR l_priv_list STRING='';
00:15:11 FAILED [FOR - 0 rows, 0.002 secs] [Code: -1, SQL State: 42000] syntax error on line 2
WHERE (pt.id & i_privmask) > 0
^ expected END_FOR got end of statement

FOR SELECT pt.name AS privname FROM system.privtypes pt
WHERE (pt.id & i_privmask) > 0;
00:15:11 FAILED [L_PRIV_LIST=L_PRIV_LIS... - 0 rows, 0.002 secs] [Code: -1, SQL State: 42000] syntax error on line 1
l_priv_list=l_priv_list||','||privname
^ expected statement got l_priv_list

l_priv_list=l_priv_list||','||privname;
00:15:11 FAILED [END_FOR - 0 rows, 0.002 secs] [Code: -1, SQL State: 42000] syntax error on line 1
END_FOR
^ expected statement got END_FOR

END_FOR;
00:15:11 FAILED [RETURN - 0 rows, 0.001 secs] [Code: -1, SQL State: 42000] syntax error on line 1
RETURN substr(l_priv_list,2,length(l_priv_list)-1)
^ expected end of statement got SUBSTR

RETURN substr(l_priv_list,2,length(l_priv_list)-1);
00:15:11 FAILED [END_FUNCTION - 0 rows, 0.001 secs] [Code: -1, SQL State: 42000] syntax error on line 1
END_FUNCTION
^ expected statement got END_FUNCTION

END_FUNCTION;
00:15:11 FAILED [@ - 0 rows, 0.001 secs] [Code: -1, SQL State: 42000] syntax error on line 1
@
^ unrecognized character @
@
SET DELIMITER;
00:15:11 END Execution 8 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.012/0.000 secs [1 successful, 7 errors]

0 comments

Please sign in to leave a comment.