It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Call Function in Pocket Query

How can I call a Postgresql function that returns a refcursor?

4 answers

Sorry for the late reply! I will set up PocketQuery in a Postgres environment and write an answer.

Hi Albert!

So I gave it a try and it works quite well. The only requirement is that you define your Postgres function in your database directly (i.e. in your database tool) and not in PocketQuery. For example, I added this function to my database via SquirrelSQL:

CREATE FUNCTION print_pocketquery (text) RETURNS TEXT AS '
    BEGIN
        RETURN $1 || $1;
    END;
' LANGUAGE 'plpgsql';

This is my PocketQuery query:

SELECT print_pocketquery(:text);

In the macro browser, I enter this for the variable "text": "PocketQuery-Rocks!!"

Output is: "PocketQuery-Rocks!! PocketQuery-Rocks!! "

Let me know if you need further help!

Regards, Felix [Scandio]

Hi Felix,

 

   I Appreciate your answer but your function returns text not a refcursor. Try to call this one:

 

CREATE OR REPLACE FUNCTION TEST_FUNCTION() RETURNS refcursor AS $$
DECLARE
      result refcursor := 'Result Text';
BEGIN
      RETURN result;
END;
$$ LANGUAGE plpgsql STRICT;


select TEST_FUNCTION();

 

 Thank you,

Albert

 

Hi Albert,

Did you set up your function in a PocketQuery query or in your database itself? Please see my comment above: "The only requirement is that you define your Postgres function in your database directly (i.e. in your database tool) and not in PocketQuery."

If you have both the function and the select statement in one PocketQuery query, it won't work at all, because one query in PocketQuery must be exactly one statement.

Regards, Felix [Scandio]

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Expose your beautifully crafted Dashboard through the Jira Service Desk Customer Portal

  A picture is worth a thousand words, especially when you're trying to find relationships and understand your data. Here, Dashboards play a vital role in gaining insights from a variety of dat...

229 views 3 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you