Call functions created in PostgreSQL

Hi,

I created a function in a PostgreSQL database : GetUserByID(UserID Int). It is a simple SELECT function that returns RECORD.

How do I call it from Xojo?

About functions, could they replace normal queries of prepared statements in my applications? What are their main purpose ?

Thanks!

Roger

RecSet = Database.SQLSelect ( “SELECT GetUserByID( 1234 );” ) // ???

http://www.postgresql.org/docs/9.4/static/xfunc-sql.html

[quote=197129:@Roger St-Arneault]Hi,

I created a function in a PostgreSQL database : GetUserByID(UserID Int). It is a simple SELECT function that returns RECORD.

How do I call it from Xojo?

About functions, could they replace normal queries of prepared statements in my applications? What are their main purpose ?

Thanks!

Roger[/quote]

Basically IF a function / procedure in a database returns rows you call it using SQSelect
If it doesn’t return rows you usually use SQLExecute

Thank you very much…

About functions, is there any interest in using them instead of using SQL commands?

There’s a lot of debate about using procedures / functions IN the database as the “middle tier” in many set ups

I tend to write functions that are functions for use in sql queries & not as a replacements for a middle tier

I’m sure others will chime in with other thoughts