Welcome! Log In Create A New Profile

Advanced

Calling a Postgres function from Windev

Posted by Greg 
Greg
Calling a Postgres function from Windev
October 04, 2023 07:35AM
Hello All:

I'm using WIndev with Postgres Native driver, and I would like to call a function stored in Postgres DB.
I tried using HExecuteSQLQuery() and it seems the function is found (no SQL errors), but I can't read the result of that call.
Executing the HEcecuteSQLQuery() does return True, but HFound() is false. Also, trying HReadFirst() or HNext() gives an error...

Did someone try this already?

Thanks
Greg
Re: Calling a Postgres function from Windev
October 11, 2023 02:48PM
My experience with pgSQL functions is that sometimes if not coded properly they may not return the result in a valid JSON format.

Check the final output that you get when calling a function in pgSQL console.

Check to see if the structure is something like this or not.

[
  {
    "date": "2021-09",
    "department": "Administration",
    "spending": 9003,
    "budget": 8000
  },
  {
    "date": "2021-09",
    "department": "Finance",
    "spending": 3033,
    "budget": 4000
  },
  {
    "date": "2021-09",
    "department": "Sales",
    "spending": 9230,
    "budget": 8000
  },
  {
    "date": "2021-10",
    "department": "Administration",
    "spending": 13032,
    "budget": 15000
  },
  {
    "date": "2021-10",
    "department": "Finance",
    "spending": 2300,
    "budget": 5000
  },
  {
    "date": "2021-10",
    "department": "Sales",
    "spending": 7323.5,
    "budget": 8000
  },
  {
    "date": "2021-11",
    "department": "Administration",
    "spending": 13000,
    "budget": 16023
  },
  {
    "date": "2021-11",
    "department": "Finance",
    "spending": 3569.5,
    "budget": 3000
  },
  {
    "date": "2021-11",
    "department": "Sales",
    "spending": 10000,
    "budget": 9932
  },
  {
    "date": "2021-12",
    "department": "Administration",
    "spending": 18033,
    "budget": 20000
  },
  {
    "date": "2021-12",
    "department": "Finance",
    "spending": 4890,
    "budget": 4500
  },
  {
    "date": "2021-12",
    "department": "Sales",
    "spending": 9322,
    "budget": 8000
  }
]

--
Yogi Yang
Re: Calling a Postgres function from Windev
October 13, 2023 05:40PM
Hi,

You need HExecuteFunction, see this: [help.windev.com]

Best regards.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: