Re: Ayuda con Array

From: Ovidio Jimenez <oviman(dot)h(at)gmail(dot)com>
To: Daymel Bonne <daymel(dot)bonne(at)2ndquadrant(dot)ec>
Cc: Ayuda Esp PostgreSQL <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Ayuda con Array
Date: 2018-01-29 21:21:05
Message-ID: CAFQ5tmTje3XjScpq8r195RNUuCOhMdO96BvRKApQDhO6YkxYqQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Resuelto

for x in 1..cardinality($1) loop

insert into detalle(codiarti, cantidad, precio) values ($1[x],$2[x],$3[x]);
end loop;

Gracias Daymel Bonne

2018-01-29 16:52 GMT-04:00 Daymel Bonne <daymel(dot)bonne(at)2ndquadrant(dot)ec>:

> Hola:
>
> Puedes ver en la documentación oficial en este enlace:
> https://www.postgresql.org/docs/current/static/functions-array.html
>
> En concreto es la función array_length.
>
> Saludos
>
>
> El 29 ene. 2018 3:34 p.m., "Ovidio Jimenez" <oviman(dot)h(at)gmail(dot)com> escribió:
>
> Saludos a todos.
>
>
> Como puedo saber cuantos elementos tengo en el array para que sea el
> limite de la sentencia FOR.
>
> /**
>
> for x in 1..10 loop
>
> Ejemplo for x in 1..*N* loop
>
> **/
>
>
> CREATE OR REPLACE FUNCTION insertar_detalle( *_articulo *integer[],
> _cantidad numeric[], _precio numeric[])
> RETURNS void AS
> $BODY$ declare x integer;
> begin
>
> *for x in 1..10 loop*
>
> insert into detalle(codiarti, cantidad, precio) values ($1[x],$2[x],$3[x]);
> end loop;
> end;
> $BODY$ LANGUAGE plpgsql;
>
>
>
> Gracias!
>
> PostgreSQL 9.4.5, compiled by Visual C++ build 1800, 64-bit
> Microsoft Windows [Version 10.0.10240] 64-bit
>
>
>
>
>
> --
> Ing. Ovidio Jiménez
> Cel.: 809-390-4299 <(809)%20390-4299>
>
>
>

--
Ing. Ovidio Jiménez
Cel.: 809-390-4299

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Martin Marques 2018-01-29 21:27:41 Re: Consulta de tabla con millones de registros
Previous Message Alberto Cardenas Cardenas 2018-01-29 21:15:47 Re: Insertar datos en tabla remota