pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Run Stored procedure - function from VBA
9+ messages / 3 participants
[nested] [flat]

* Run Stored procedure - function from VBA
@ 2018-06-18 15:47 Łukasz Jarych <jaryszek@gmail.com>
  2018-06-18 23:33 ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-18 23:34 ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  0 siblings, 2 replies; 9+ messages in thread

From: Łukasz Jarych @ 2018-06-18 15:47 UTC (permalink / raw)
  To: pgsql-general

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

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Run Stored procedure - function from VBA
  2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
@ 2018-06-18 23:33 ` Rob Sargent <robjsargent@gmail.com>
  1 sibling, 0 replies; 9+ messages in thread

From: Rob Sargent @ 2018-06-18 23:33 UTC (permalink / raw)
  To: Łukasz Jarych <jaryszek@gmail.com>; +Cc: pgsql-general



> On Jun 18, 2018, at 9:47 AM, Łukasz Jarych <jaryszek@gmail.com> wrote:
> 
> 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;

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Run Stored procedure - function from VBA
  2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
@ 2018-06-18 23:34 ` Rob Sargent <robjsargent@gmail.com>
  2018-06-19 03:51   ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  1 sibling, 1 reply; 9+ messages in thread

From: Rob Sargent @ 2018-06-18 23:34 UTC (permalink / raw)
  To: Łukasz Jarych <jaryszek@gmail.com>; +Cc: pgsql-general



> 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();"

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Run Stored procedure - function from VBA
  2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-18 23:34 ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
@ 2018-06-19 03:51   ` Łukasz Jarych <jaryszek@gmail.com>
  2018-06-19 19:54     ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Łukasz Jarych @ 2018-06-19 03:51 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-general

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();"
>
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Run Stored procedure - function from VBA
  2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-18 23:34 ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-19 03:51   ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
@ 2018-06-19 19:54     ` Rob Sargent <robjsargent@gmail.com>
  2018-06-19 22:08       ` Re: Run Stored procedure - function from VBA Asif Ali <asif2k@hotmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Rob Sargent @ 2018-06-19 19:54 UTC (permalink / raw)
  To: Łukasz Jarych <jaryszek@gmail.com>; +Cc: pgsql-general



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 
> <mailto:robjsargent@gmail.com>>:
>
>
>
>>     On Jun 18, 2018, at 9:47 AM, Łukasz Jarych <jaryszek@gmail.com
>>     <mailto: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 asnew ADODB.Connection Dim rst asnew ADODB.Recordset
>>     Dbcon.connectionstring=”Your connection string goes
>>     here!”Dbcon.openRst.openstrsql|
>>     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.

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Run Stored procedure - function from VBA
  2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-18 23:34 ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-19 03:51   ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-19 19:54     ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
@ 2018-06-19 22:08       ` Asif Ali <asif2k@hotmail.com>
  2018-06-20 04:39         ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Asif Ali @ 2018-06-19 22:08 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; £ukasz Jarych <jaryszek@gmail.com>; +Cc: pgsql-general

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<mailto:robjsargent@gmail.com>>:


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

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Run Stored procedure - function from VBA
  2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-18 23:34 ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-19 03:51   ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-19 19:54     ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-19 22:08       ` Re: Run Stored procedure - function from VBA Asif Ali <asif2k@hotmail.com>
@ 2018-06-20 04:39         ` Łukasz Jarych <jaryszek@gmail.com>
  2018-06-20 05:41           ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Łukasz Jarych @ 2018-06-20 04:39 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; pgsql-general

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.
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Run Stored procedure - function from VBA
  2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-18 23:34 ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-19 03:51   ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-19 19:54     ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-19 22:08       ` Re: Run Stored procedure - function from VBA Asif Ali <asif2k@hotmail.com>
  2018-06-20 04:39         ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
@ 2018-06-20 05:41           ` Rob Sargent <robjsargent@gmail.com>
  2018-06-20 05:58             ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Rob Sargent @ 2018-06-20 05:41 UTC (permalink / raw)
  To: Łukasz Jarych <jaryszek@gmail.com>; +Cc: 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.
> 

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Run Stored procedure - function from VBA
  2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-18 23:34 ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-19 03:51   ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-19 19:54     ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
  2018-06-19 22:08       ` Re: Run Stored procedure - function from VBA Asif Ali <asif2k@hotmail.com>
  2018-06-20 04:39         ` Re: Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
  2018-06-20 05:41           ` Re: Run Stored procedure - function from VBA Rob Sargent <robjsargent@gmail.com>
@ 2018-06-20 05:58             ` Łukasz Jarych <jaryszek@gmail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Łukasz Jarych @ 2018-06-20 05:58 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-general

Thank you Rob,

I googled it and there a loit about ODBC but not a lot about ODBC and
postgresql.

Best,
Jacek

2018-06-20 7:41 GMT+02:00 Rob Sargent <robjsargent@gmail.com>:

> 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.
>>
>
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2018-06-20 05:58 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-18 15:47 Run Stored procedure - function from VBA Łukasz Jarych <jaryszek@gmail.com>
2018-06-18 23:33 ` Rob Sargent <robjsargent@gmail.com>
2018-06-18 23:34 ` Rob Sargent <robjsargent@gmail.com>
2018-06-19 03:51   ` Łukasz Jarych <jaryszek@gmail.com>
2018-06-19 19:54     ` Rob Sargent <robjsargent@gmail.com>
2018-06-19 22:08       ` Asif Ali <asif2k@hotmail.com>
2018-06-20 04:39         ` Łukasz Jarych <jaryszek@gmail.com>
2018-06-20 05:41           ` Rob Sargent <robjsargent@gmail.com>
2018-06-20 05:58             ` Łukasz Jarych <jaryszek@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox