6

I have created custom sql function in hasura and tracked it. But need to write table name in "RETURNS SETOF <table-name>" (Refer: https://docs.hasura.io/1.0/graphql/manual/schema/custom-functions.html). Here I cannot create new table having schema same as the function is returning columns. I have lots of function to create so that I want a solution where I can create a function having return SETOF without table name.

Even in hasura function can't returns virtual table (i.e. RETURNS Table(column1 text, column2 text, column3 text) )

I tried "create type" and use it as

CREATE TYPE temp_type AS
(column1 text, column2 text, column3 text
);

But didn't work and giving following error:

"the function "my_function" cannot be tracked because the function does not return a SETOF table"

Any solution on this?

Here is my function

CREATE  FUNCTION my_function(fromDate text, toDate text)
RETURNS  SETOF  <table-name>  AS $$

// My function logic here 
// which returns column1, column2, column3

$$ LANGUAGE sql STABLE; 
Shivprsad Sammbhare
  • 410
  • 3
  • 7
  • 20

0 Answers0