Skip to content

Can not use parameters from other entities in joined user-defined function returning a recordset #3546

@weberhofer

Description

@weberhofer

This issue has been nicely described in https://stackoverflow.com/questions/70745246/h2-how-to-call-a-user-defined-function-with-parameters-in-a-join-query

This refers to h2 version 1.4.200

Creation of the function works properly:

CREATE ALIAS lib_item_label FOR "h2.UserDefinedFunctions.libItemLabel";

Using the function with constant values seem to work:

select
    vlil.lbl, li.id, p.id
from lib_item li
    inner join property__type pt on (pt.property_type = 'LANGUAGE')
    inner join property p on (pt.id=p.property_type_id)
    left join lib_item_label(1,1) vlil;

The following is not working...

select
    vlil.lbl
from lib_item li
    inner join property__type pt on (pt.property_type = 'LANGUAGE')
    inner join property p on (pt.id=p.property_type_id)
    left join lib_item_label(li.id, p.id) vlil;

And resulting in the following error:

nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException:
Column "li.id" not found; SQL statement:
select vlil.lbl from lib_item li inner join property__type pt on (pt.property_type = 'LANGUAGE') inner join property p on (pt.id=p.property_type_id) left join lib_item_label(li.id, p.id) vlil [42122-200]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions