[Info-ingres] create function, if test and javascript

Martin Bowes martin.bowes at ndph.ox.ac.uk
Tue Jun 15 12:43:42 UTC 2021


Hi All,

create or replace function max(
    a float8 not null not default,
    b float8 not null not default
)
return (float8 not null) as
begin
    if (:a >= :b) then
        return :a;
    else
        return :b;
    endif;
end;
\p\g

Now that doesn't work as SQL based UDFs can't use the IF-THEN-ENDIF syntax. That seems way too restrictive to me.

But I thought, we could just as easily do the test in JavaScript which is supposed to be supported. So...
create or replace function max(
    a float8 not null not default,
    b float8 not null not default
)
return (float8 not null) as LANGUAGE JAVASCRIPT SOURCE = 'if (a >= b) {return a} else {return b}';
Executing . . .

E_PS0316 Unrecognised UDF language: 'javascript'

Any suggestions?

Marty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.planetingres.org/pipermail/info-ingres/attachments/20210615/c02fb7fe/attachment.html>


More information about the Info-ingres mailing list