cancel
Showing results for 
Search instead for 
Did you mean: 

Round function overload

Round function overload

Hello,

 

I am doing EDB Postrgres migration portal. I saw that because of my structure of databese none of calls in views for function ROUND works (Acording to documentation ROUND(NUMERIC, INTEGER). So I wrote function:

 

CREATE OR REPLACE FUNCTION MINERVA.ROUND
(
  N IN NUMBER
, D IN NUMBER
) RETURN NUMBER
AS
	tmp INTEGER;
    tmp2 NUMBER;
BEGIN
	TMP:=TRUNC(D,0);
	tmp2:= round(N, TMP);
  RETURN TMP2;
END ROUND;
/

And for that i get errors:

- Incompatible expression found line 1, char 35

- Error in syntax recognition line 13, char 4

 

I guess because of name. So I tryed diferent name:

CREATE OR REPLACE FUNCTION MINERVA.EDB_ROUND
(
  N IN NUMBER
, D IN NUMBER
) RETURN NUMBER
AS
	tmp INTEGER;
    tmp2 NUMBER;
BEGIN
	TMP:=TRUNC(D,0);
	tmp2:= round(N , TMP);
  RETURN TMP2;
END EDB_ROUND;
/

And here I got error:

- Incompatible NUMERIC function line 11, char 18

 

Don't understand what is wrong. I tryed all typecasting found in documentation and nothing helps.

 

any ideas welcome. thank you, Marko

View Entire Topic
mhorvat81
Adventurer

Another intresting thing:

CREATE OR REPLACE FUNCTION EDB_ROUND
(
  N IN NUMBER
, D IN NUMBER
) RETURN NUMBER
AS
	tmp INTEGER;
    tmp2 NUMBER;
BEGIN
	TMP:=TRUNC(D,0);
	tmp2:= ROUND(N , 2);
  RETURN TMP2;
END EDB_ROUND;
/

If I add fixed value of decimals (2 for example) it works also.

Ask a Question