Re: Run Stored procedure - function from VBA

From: Asif Ali <asif2k(at)hotmail(dot)com>
To: Rob Sargent <robjsargent(at)gmail(dot)com>, Łukasz Jarych <jaryszek(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Run Stored procedure - function from VBA
Date: 2018-06-19 22:08:14
Message-ID: DM5PR2001MB1083191C6BE148A8343959978B700@DM5PR2001MB1083.namprd20.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

how the fuck i unsubscribe to this mailing list , i get more than 100 emails a day

Bye

________________________________
From: Rob Sargent <robjsargent(at)gmail(dot)com>
Sent: Wednesday, June 20, 2018 12:54 AM
To: Łukasz Jarych
Cc: pgsql-general(at)postgresql(dot)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(at)gmail(dot)com<mailto:robjsargent(at)gmail(dot)com>>:

On Jun 18, 2018, at 9:47 AM, Łukasz Jarych <jaryszek(at)gmail(dot)com<mailto:jaryszek(at)gmail(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James Keener 2018-06-19 22:11:50 Re: Load data from a csv file without using COPY
Previous Message Asif Ali 2018-06-19 22:07:14 Re: Is postorder tree traversal possible with recursive CTE's?