El 7 de julio de 2010 14:58, Miguel Angel Hernandez Moreno < miguel.hdz....@gmail.com> escribió:
> Hola lista > > disculpen me salio la necesdad de saber cuantos registros feron insertado > usando un insert into > de hecho lo tengo en una funcion que hace una busqueda a una tabla e > inserta los datos > pero no se cuantos datos me inserta, si alguien me pudiera ayudar se lo > agradeceria mucho. > > esta es la funcion que uso para alinear las tablas. solo quiciera que la > funcion me retornara > cuantas inserciones se hicieron > > CREATE OR REPLACE FUNCTION procmty.alinearb(character varying, character > varying) > RETURNS integer AS > $BODY$ > DECLARE > nombre_tabla text:=''; > solofecha text:=''; > recibo1 timestamp:= NOW()::timestamp; > BEGIN > --select NOW()::timestamp+interval '1 day' into recibo; > select 'cadenas2_'||substr(recibo1::text,1,4) > ||'_'||substr(recibo1::text,6,2) ||'_'|| > substr(recibo1::text,9,2) into nombre_tabla; > > EXECUTE 'insert into procmty.'||nombre_tabla||' > (cadena, id , recibo, puerto, fecha, pid,linea ,fecha2, enviado) ( > SELECT * FROM dblink(''host=207.249.166.212 dbname=feria3'', > ''SELECT cadena, id , recibo, puerto, fecha, pid,linea , > fecha2, enviado FROM procmty.'||nombre_tabla||' where > recibo>='''' '||$1||' '''' and recibo<='''' '||$2||' '''' '') > AS t(cadena text, id character varying, recibo timestamp, > puerto integer, fecha timestamp, pid integer,linea integer, > fecha2 timestamp, enviado integer) > where (t.id,t.recibo::timestamp without time zone)::varchar not in ( > select (id,recibo::timestamp without time zone)::varchar > from procmty.'||nombre_tabla||' where recibo>='' '||$1||' '' and > recibo<='' '||$2||' '') )'; > > > RETURN NULL; > END; > $BODY$ > LANGUAGE 'plpgsql' VOLATILE > COST 100; > > Gracias > Puedes usar: get diagnostics no_rows = ROW_COUNT;