Skip to content

Possibility to use Recursive function? #79

Description

@HorstBrack

Hello,
I am currently evaluating APIs to use with our setup and yours really comes close.
However, I am using a few recursive functions in postgreSQL, a function looks like this:

CREATE FUNCTION recursive_geo(integer[]) RETURNS TABLE(id integer, parent_id integer)
    LANGUAGE sql
    AS $_$
WITH RECURSIVE included_geo(iid, iparent) AS (
    SELECT id, parent FROM geo WHERE id = ANY($1)
  UNION ALL
    SELECT p.id, p.parent
    FROM included_geo pr, geo p
    WHERE p.parent = pr.iid
  )
SELECT iid, iparent
FROM included_geo;
$_$;

Which I then call like this:
select id as hasid from recursive_geo(${data.all.geo})
where data.all.geo is the parameter passed to the query
is it possible to do this with RestSQL?
Could I f.e. just declare "recursive_geo" as a table? (It is actually a temporary table after all)

Thanks a lot in advance for any help!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions