Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fVVsT-0006fj-Sa for pgsql-general@arkaria.postgresql.org; Wed, 20 Jun 2018 05:41:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fVVsQ-0002kD-SI for pgsql-general@arkaria.postgresql.org; Wed, 20 Jun 2018 05:41:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fVVsQ-0002k3-GX for pgsql-general@lists.postgresql.org; Wed, 20 Jun 2018 05:41:54 +0000 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fVVsM-0008H1-CG for pgsql-general@postgresql.org; Wed, 20 Jun 2018 05:41:53 +0000 Received: by mail-io0-x241.google.com with SMTP id e15-v6so2396152iog.1 for ; Tue, 19 Jun 2018 22:41:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=0HmNPHvyg/KflPw5oq/B9eXwrfYMeSeCZliTkJunFBY=; b=flaRlCvn0LCDrv8RG+JqGcaX4SjlN2Zj7qQgh1PnW1wcjdfFHSv40pQft7J4CjgPnb IFpVjlyV4qppusYX7cb3GhXZiStTg+ycRmsiyQsdVr7ysKJ9/ja88ysReFc6jTXDbB1x J97LiS0KQYB34ZgA88UDCmSeB3hSVhzPED5S39VjOCp6ixY64Ff/+OeZdUj/deKuCUD2 M07iUB+RmkP35SL9/rpsi97Cx8g99Rj3FBR2N26l2aF8hBQVAGIHzYuomjvn/TEAid5h a05DFodgrxZ1qIc2WdJSVwW/jqXhC1j6QKYpuOeEip4jHdJM9CmaVO76dt5ps+hhOgzI 4HPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=0HmNPHvyg/KflPw5oq/B9eXwrfYMeSeCZliTkJunFBY=; b=en7+CPMViiTuVhhghKihI+FPgQGVq9G0TyATZSIRDhFXNdRatuOoyGVFVQfVHvYMBW EAnQaO26RbdGCqO7yacsKHl2WqE2NAQAOA24L1FPz9KHCSGRPvTpkrWdi823Mn6y+pVT 4m50JxcbqPRun3URp9uCSkBymktnp1IwYpG6hWk050nSFCHkAFG0uJaW6zXzay8WyKc5 92BOXAgcsHGrqcwBayIE6Uv7Mj6+uKfGjIXv4+UcDcOk8GU2tjxjzAGG00XLldnkyRfp QTsZGOoAhRcy7/zhoMxwVJSAMRs+sbeh3H1AhtSBwCZHUWK0GrFzrqsJyhPsJX1lWqgI eOLQ== X-Gm-Message-State: APt69E3XP7VCLegwShXd9yetUvrc5aoTDCwCgA+GKQsRS+aTWyy8Q9GT GTHngjsGVc+LplRpurRS1kE= X-Google-Smtp-Source: ADUXVKJf7ZsRGbuIlTpRXN8E6UYg24Acc4PmwYaa/pKPmcWbnrFH2vtNRUDc/Of4uXhlXcst8JaRtw== X-Received: by 2002:a6b:b758:: with SMTP id h85-v6mr16919635iof.164.1529473308464; Tue, 19 Jun 2018 22:41:48 -0700 (PDT) Received: from [10.0.0.10] (c-98-202-193-197.hsd1.ut.comcast.net. [98.202.193.197]) by smtp.gmail.com with ESMTPSA id g68-v6sm705710iog.62.2018.06.19.22.41.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jun 2018 22:41:47 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-D9744B36-626A-4D8F-9E39-B8446B35C753 Mime-Version: 1.0 (1.0) Subject: Re: Run Stored procedure - function from VBA From: Rob Sargent X-Mailer: iPhone Mail (15F79) In-Reply-To: Date: Tue, 19 Jun 2018 23:41:46 -0600 Cc: "pgsql-general@postgresql.org" Content-Transfer-Encoding: 7bit Message-Id: <76BF2AC6-2B81-4667-8EDF-04080192851C@gmail.com> References: <0FB3637B-95EC-453A-8458-5A1ED525850E@gmail.com> <40a7adef-672b-a311-1f36-e7b3dc6ab063@gmail.com> To: =?utf-8?Q?=C5=81ukasz_Jarych?= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail-D9744B36-626A-4D8F-9E39-B8446B35C753 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sorry. I don=E2=80=99t use ODBC directly. If it=E2=80=99s not obvious in the= manual, google =E2=80=98ODBC functions=E2=80=99 > On Jun 19, 2018, at 10:39 PM, =C5=81ukasz Jarych wrot= e: >=20 > Thank you Rob, >=20 > exactly. Do you know this odbc constructtion? >=20 > Best, > Jacek=20 >=20 > 2018-06-20 0:08 GMT+02:00 Asif Ali : >> how the fuck i unsubscribe to this mailing list , i get more than 100 ema= ils a day >>=20 >> Bye >>=20 >> =20 >> From: Rob Sargent >> Sent: Wednesday, June 20, 2018 12:54 AM >> To: =C5=81ukasz Jarych >> Cc: pgsql-general@postgresql.org >> Subject: Re: Run Stored procedure - function from VBA >> =20 >>=20 >>=20 >>> On 06/18/2018 09:51 PM, =C5=81ukasz Jarych wrote: >>> Thank you Rob, >>>=20 >>> question is it is the optimal way to run SP from VBA?=20 >>> Or not? >>>=20 >>> Best, >>> Jacek >>>=20 >>> 2018-06-19 1:34 GMT+02:00 Rob Sargent : >>>=20 >>>=20 >>>> On Jun 18, 2018, at 9:47 AM, =C5=81ukasz Jarych wr= ote: >>>>=20 >>>> Hi Guys, >>>>=20 >>>> i have example function : >>>>=20 >>>> 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; >>>>=20 >>>> and i want to run it from VBA using odbc connection.=20 >>>>=20 >>>> What is the best way to use it ? >>>>=20 >>>> something like this:=20 >>>>=20 >>>> Dim dbCon as new ADODB.Connection >>>> Dim rst as new ADODB.Recordset >>>>=20 >>>> Dbcon.connectionstring=3D=E2=80=9DYour connection string goes here!=E2=80= =9D >>>> Dbcon.open >>>>=20 >>>> Rst.open strsql >>>> where strsql is "Select * from totalRecords" or this is not a good solu= tion? >>>>=20 >>>> Best, >>>> Jacek >>>=20 >>> You need the parentheses after the function name: =E2=80=9Cselect * from= totalrecords();" >>>=20 >>>=20 >>=20 >> Depends on the usage pattern. I'm sure there is an ODBC construct for st= ored procedures/function, which you could build once and re-use with new par= ameter values if you're going to call this repeatedly. >=20 --Apple-Mail-D9744B36-626A-4D8F-9E39-B8446B35C753 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Sorry. I don=E2=80=99t use O= DBC directly. If it=E2=80=99s not obvious in the manual, google =E2=80=98ODB= C functions=E2=80=99

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

Thank y= ou Rob,

exactly. Do you know this odbc constructtion?

Best,
Jacek 

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

Bye


From: Ro= b Sargent <rob= jsargent@gmail.com>
Sent: Wednesday, June 20, 2018 12:54 AM
To: =C5=81ukasz Jarych
Cc: pgsql-general@postgresql.org
Subject: Re: Run Stored procedure - function from VBA
 



On 06/18/2018 09:51 PM= , =C5=81ukasz 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 R= ob Sargent <robjsargent@g= mail.com>:


On Jun 18, 2018, at 9:47 AM, =C5=81ukasz 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=3D=E2=80=9DYour connection string goes here!=E2=80=9D
Dbcon.open

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

Best,
Jacek

You need the parentheses after the function name: =E2=80=9Cselect * fro= m totalrecords();"



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

= --Apple-Mail-D9744B36-626A-4D8F-9E39-B8446B35C753--