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

Accepted Solutions (0)

Answers (5)

Answers (5)

chaitalirs
EDB Team Member

Hi mhorvat81,

 

We have a new release for "EDB Migration Portal 2.3.0".

 

https://postgresrocks.enterprisedb.com/t5/EDB-Technical-Updates-and-Alerts/Technical-Update-for-EDB-...

 

This release has the resolution for your reported issue on this thread. Please test and let us know your feedback.

dhananjayjejur
EDB Team Member

Hi mhorvat81,

 

We have escalated this issue to our development team.

We will update you once the issue is fixed.

 

 

dhananjayjejur
EDB Team Member

Hi mhorvat81,

 

Thank you for rasing your query on PostgresRocks.

Currently, we are working on your issue and we will reply to you soon.

 

Regards,

Dhananjay

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.

mhorvat81
Adventurer

Interesting thing if i change call from round to trunc it works:

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:= trunc(N , TMP);
  RETURN TMP2;
END EDB_ROUND;
Ask a Question