Page 1 of 1

How to pass an array parameter to a stored procedure

Posted: Tue 02 Oct 2018 09:03
by Niels
Hi,
I have a stored procedure with the following header:

Code: Select all

CREATE OR REPLACE FUNCTION "UpdateClassGeneral" (
  "ActiveRatios" integer [],
  "ActiveClass" varchar,
  "ActiveClassProjCodesSQL" varchar []
)
How can I pass the integer- and varchar array to my TPgStoredProc component?
There is no documentation for it available?
Or is there a work around?

Re: How to pass an array parameter to a stored procedure

Posted: Tue 02 Oct 2018 12:48
by azyk
You should pass array parameter as string value of TPgStoredProc parameter. For example:

Code: Select all

  PgStoredProc1.StoredProcName := '"UpdateClassGeneral"';
  PgStoredProc1.Prepare;

  PgStoredProc1.ParamByName('ActiveRatios').AsString := '{1,2,3}';
  PgStoredProc1.ParamByName('ActiveClass').Value := 'some text';
  PgStoredProc1.ParamByName('ActiveClassProjCodesSQL').AsString := '{PgDAC,pass,array param}';

  PgStoredProc1.ExecProc;

Re: How to pass an array parameter to a stored procedure

Posted: Wed 03 Oct 2018 02:19
by Niels
Works perfectly now.
Thank you!

Re: How to pass an array parameter to a stored procedure

Posted: Wed 03 Oct 2018 08:13
by azyk
If you have any questions about our products, feel free to contact us.

Re: How to pass an array parameter to a stored procedure

Posted: Sat 20 Jul 2019 08:54
by belohcka
May somebody help me pls with smtg...

I tryed post data into pg using pgDac and Delphi Berlin.
As date-type i tryed post - array of 'compex-type' with pgStoredProc, and the problem what i have - i cant post array of varchar/text values using '{'attr1','attr2'}' because attr1 and attr2 have values like 'Something ...., something ...'.

p/s. If it so, may u show me a link to a documentation ...

Thank you!