By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,007 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,007 IT Pros & Developers. It's quick & easy.

SQL0440N No authorized routine named error

P: 2
Hi

I get the following error when running the following statement

SELECT R.ROW_NUMBER, random(1, 'Sk1', 1, 100, 1) AS INTEGER_R6_1_100 FROM RANDOM_NUMBERS R;


SQL0440N No authorized routine named "RANDOM" of type "FUNCTION" having
compatible arguments was found. SQLSTATE=42884

Here is the definition of the function RANDOM

Also does anyone know how I can run the debugger in development center when creating a user defined function. It seems when I go into edit mode to edit the function it disables the debugging UI.

CREATE FUNCTION DB15USER.random(v_source INTEGER, v_distribution CHAR(3), v_a DOUBLE, v_b DOUBLE, v_c DOUBLE) RETURNS
INTEGER

LANGUAGE SQL
--MODIFIES SQL DATA
CALLED ON NULL INPUT

BEGIN ATOMIC

DECLARE v_random INTEGER;
DECLARE v_s DOUBLE;
DECLARE v_source2 INTEGER;
DECLARE v_distribution2 CHAR(3);
DECLARE v_a2 DOUBLE;
DECLARE v_b2 DOUBLE;
DECLARE v_c2 DOUBLE;

Set v_source2 = v_source;
Set v_distribution2 = v_distribution;
Set v_a2 = v_a;
Set v_b2 = v_b;
Set v_c2 = v_c;

IF v_a2 IS NULL THEN
SET v_a2 = 0;
END IF;


IF v_b2 IS NULL THEN
SET v_b2 = 1;
END IF;

IF v_distribution2 IS NULL THEN
SET v_distribution2 = 'Uni';
END IF;

IF v_c2 IS NULL THEN
SET v_c2 = (v_a2 + v_b2) / 2;
END IF;

SET v_s = CAST (v_source2 AS DOUBLE) / 100000000;

IF v_distribution2 = 'Exp' THEN
IF (v_source2 = 0) THEN
SET v_source2 = 1;
END IF;

SET v_random = -1 * LN(v_s) * v_a2;
RETURN v_random;
END IF;

IF v_distribution2 = 'Nor' THEN
IF (v_s = 0) THEN
SET v_s = 1;
END IF;
SET v_random = SQRT(-2 * LN(v_s)) * SIN(2 * 3.14 * (CAST (v_c2 AS DOUBLE) / CAST (100000000 AS DOUBLE))) * v_b2 + v_a2;
RETURN v_random;
END IF;

IF v_distribution2 = 'Sk1' THEN
SET v_s = SQRT(v_s);
END IF;

IF v_distribution2 = 'Sk2' THEN
SET v_s =SQRT(v_s);
END IF;

IF (v_s < 0) THEN
SET v_s = 0;
END IF;

IF (v_s > 1) THEN
SET v_s = 0.99999999;
END IF;

SET v_random = v_s * (v_b2 - v_a2 + 1) + v_a2;



RETURN v_random;

END

Thanks
Oct 29 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.