Re: Run Stored procedure - function from VBA - Mailing list pgsql-general

From Rob Sargent
Subject Re: Run Stored procedure - function from VBA
Date
Msg-id 76BF2AC6-2B81-4667-8EDF-04080192851C@gmail.com
Whole thread Raw
In response to Re: Run Stored procedure - function from VBA  (Łukasz Jarych <jaryszek@gmail.com>)
Responses Re: Run Stored procedure - function from VBA  (Łukasz Jarych <jaryszek@gmail.com>)
List pgsql-general
Sorry. I don’t use ODBC directly. If it’s not obvious in the manual, google ‘ODBC functions’

On Jun 19, 2018, at 10:39 PM, Łukasz Jarych <jaryszek@gmail.com> wrote:

Thank you Rob,

exactly. Do you know this odbc constructtion?

Best,
Jacek 

2018-06-20 0:08 GMT+02:00 Asif Ali <asif2k@hotmail.com>:
how the fuck i unsubscribe to this mailing list , i get more than 100 emails a day

Bye


From: Rob Sargent <robjsargent@gmail.com>
Sent: Wednesday, June 20, 2018 12:54 AM
To: Łukasz Jarych
Cc: pgsql-general@postgresql.org
Subject: Re: Run Stored procedure - function from VBA
 



On 06/18/2018 09:51 PM, Łukasz Jarych wrote:
Thank you Rob,

question is it is the optimal way to run SP from VBA? 
Or not?

Best,
Jacek

2018-06-19 1:34 GMT+02:00 Rob Sargent <robjsargent@gmail.com>:


On Jun 18, 2018, at 9:47 AM, Łukasz Jarych <jaryszek@gmail.com> wrote:

Hi Guys,

i have example function :

CREATE OR REPLACE FUNCTION totalRecords ()
RETURNS integer AS $total$
declare
total integer;
BEGIN
   SELECT count(*) into total FROM COMPANY;
   RETURN total;
END;
$total$ LANGUAGE plpgsql;

and i want to run it from VBA using odbc connection. 

What is the best way to use it ?

something like this: 

Dim dbCon as new ADODB.Connection
Dim rst as new ADODB.Recordset

Dbcon.connectionstring=”Your connection string goes here!”
Dbcon.open

Rst.open strsql
where strsql is "Select * from totalRecords" or this is not a good solution?

Best,
Jacek

You need the parentheses after the function name: “select * from totalrecords();"



Depends on the usage pattern.  I'm sure there is an ODBC construct for stored procedures/function, which you could build once and re-use with new parameter values if you're going to call this repeatedly.

pgsql-general by date:

Previous
From: Łukasz Jarych
Date:
Subject: Re: Run Stored procedure - function from VBA
Next
From: Łukasz Jarych
Date:
Subject: Re: Run Stored procedure - function from VBA