Received: from hapcibeno.freestart.hu (hapcibeno.freestart.hu [213.197.64.8]) by postgresql.org (Postfix) with ESMTP id 7768847589E for ; Mon, 22 Apr 2002 18:51:06 -0400 (EDT) Received: from line-82-160.dial.freestart.hu ([213.197.82.160] helo=jaguar) by freestart.hu with smtp (Freestart relay 2 (FS-Lin)) id 16zmmD-000226-00; Tue, 23 Apr 2002 00:59:18 +0200 Message-ID: <002d01c1ea50$805c4b20$01fdfea9@jaguar> Reply-To: "Papp, Gyozo" From: "Papp, Gyozo" To: "Ruben Vivas" , References: Subject: Re: RV: calling a pl/pgsql function with array in argument Date: Tue, 23 Apr 2002 00:53:20 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Scanner: exiscan by Freestart X-Archive-Number: 200204/80 X-Sequence-Number: 1104 this is a little bit hidden information somewhere in the manual. Array types is the same the corresponding data type but=20 prepended with an underscore '_', e.g: _int4 _date _smallint btw, you cannot pass PHP array to plpgsql function. You need to=20 convert it to string like: {1,2,23,45} { -- start array=20 ,, -- comma separated values=20 } -- closing tag here is my quote function to PG: function quote($var, $type, $empty_null =3D TRUE) { if ( empty($var) && $empty_null ){ return 'NULL'; } if ( $type{0} =3D=3D '_' ){ $type =3D substr($type, 1); $temp =3D "'{"; foreach ( $var as $item ){ $temp .=3D quote($item, $type).','; } $temp =3D substr($temp, 0, -1); return $temp ."}'"; } switch ( $type ){ case 'int': return intval($var); case 'bool': return ($var ? "'t'::bool": "'f'::bool");=20 case 'date': if ( is_numeric($var) ) { // echo timestamp-kent kezeli return date("'Y-m-d'", $var); } // ha ez sem, akkor sima szovegkent tovabbadja case 'text': if (!get_magic_quotes_gpc()) { $var =3D addslashes($var); } return '\''.$var.'\''; default: trigger_error("unknown type : $type ($value)", E_USER_ERROR); } }=20 ----- Original Message -----=20 From: "Ruben Vivas" To: Sent: Monday, April 22, 2002 10:18 PM Subject: [PHP] RV: calling a pl/pgsql function with array in argument | Hello, i am tryin to pass an array like argument to a pl/pgsql function b= ut | i can not find the correct data type in te function. |=20 | i am using php. |=20 | ex: $dato[][] is the array using php, and i need call: |=20 | 1. $res =3D fn_vea ($dato); ????? |=20 | 2. in pl/pgsql CREATE FUNCTION fn_vea (integer [][]) RETURNS varchar (25)= AS | ......... |=20 |=20 | does it work?? | thank you |=20 |=20 | ---------------------------(end of broadcast)--------------------------- | TIP 6: Have you searched our list archives? |=20 | http://archives.postgresql.org