Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Conexión con bases de datos
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Conexión con bases de datos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 01-04-2009
pelacuaz pelacuaz is offline
Registrado
 
Registrado: abr 2009
Posts: 5
Poder: 0
pelacuaz Va por buen camino
Menor tiempo de Ejecucion para una funcion Informix

Hola a todos:
Siempre eh acudido a este foro para encontrar soluciones ya sea en problemas con programacion o bases de datos.

Ahorita tengo una bronquita con una Funcion que hize en Informix, la cual no me deja convencido al 100% ya que tarda 46 min en arrojarme el resultado, eso no es nada bueno. LA funcion al final me devuelve 1189 filas y 84 columnas. Las tablas que utilizo son: manoobra_obra de 9716 filas, mat_vales de 15595 filas, obras de 1189 filas y materialesobra de 21442 filas.


Tengo otra funcion en donde despliego costo, usando las mismas tablas pero esta se ejecuta en 12min .

Espero porfavor puedan apoyarme, necesito optimizar la consulta a mucho menos de la mitad del tiempo, acepto ideas en cuestion de logica, propuestas en disen~o, o lo que sea necesario para que se ejecute de ser posible en 1/4 de tiempo. De hecho si juntara las dos funciones en una misa seria mejor.

SALUDOS espero sus aportaciones
Responder Con Cita
  #2  
Antiguo 01-04-2009
pelacuaz pelacuaz is offline
Registrado
 
Registrado: abr 2009
Posts: 5
Poder: 0
pelacuaz Va por buen camino
Mis funciones son las siguientes:

DROP FUNCTION avanceobrascant(char);

CREATE PROCEDURE "informix".avanceobrascant(p_anio char(4))
RETURNING char(50) as nombrezona, char(500) as obra, integer as anio, char(50) as mat,
char(50) as mo, char(50) as tot, char(2) as matp, char(2) as matr, char(2) as mop,
char(2) as mor, char(2) as totp, char(2) as totr,
integer as matpene, integer as matrene, integer as matpfeb, integer as matrfeb,
integer as matpmar, integer as matrmar, integer as matpabr, integer as matrabr,
integer as matpmay, integer as matrmay, integer as matpjun, integer as matrjun,
integer as matpjul, integer as matrjul, integer as matpago, integer as matrago,
integer as matpsep, integer as matrsep, integer as matpoct, integer as matroct,
integer as matpnov, integer as matrnov, integer as matpdic, integer as matrdic,

integer as manopene, integer as manorene, integer as manopfeb, integer as manorfeb,
integer as manopmar, integer as manormar, integer as manopabr, integer as manorabr,
integer as manopmay, integer as manormay, integer as manopjun, integer as manorjun,
integer as manopjul, integer as manorjul, integer as manopago, integer as manorago,
integer as manopsep, integer as manorsep, integer as manopoct, integer as manoroct,
integer as manopnov, integer as manornov, integer as manopdic, integer as manordic,

integer as totpene, integer as totrene, integer as totpfeb, integer as totrfeb,
integer as totpmar, integer as totrmar, integer as totpabr, integer as totrabr,
integer as totpmay, integer as totrmay, integer as totpjun, integer as totrjun,
integer as totpjul, integer as totrjul, integer as totpago, integer as totrago,
integer as totpsep, integer as totrsep, integer as totpoct, integer as totroct,
integer as totpnov, integer as totrnov, integer as totpdic, integer as totrdic;

define v_nomzona char(50); define v_numzona char(2); define v_obra char(500); define v_anio char(4);
define v_noobra integer; define v_div char(2);

define v_mat char(50); define v_mo char(50); define v_tot char(50); define v_matp char(2); define v_matr char(2);
define v_mop char(2); define v_mor char(2); define v_totp char(2); define v_totr char(2);

define v_matpene integer; define v_matrene integer;
define v_matpfeb integer; define v_matrfeb integer;
define v_matpmar integer; define v_matrmar integer;
define v_matpabr integer; define v_matrabr integer;
define v_matpmay integer; define v_matrmay integer;
define v_matpjun integer; define v_matrjun integer;
define v_matpjul integer; define v_matrjul integer;
define v_matpago integer; define v_matrago integer;
define v_matpsep integer; define v_matrsep integer;
define v_matpoct integer; define v_matroct integer;
define v_matpnov integer; define v_matrnov integer;
define v_matpdic integer; define v_matrdic integer;

define v_manopene integer; define v_manorene integer;
define v_manopfeb integer; define v_manorfeb integer;
define v_manopmar integer; define v_manormar integer;
define v_manopabr integer; define v_manorabr integer;
define v_manopmay integer; define v_manormay integer;
define v_manopjun integer; define v_manorjun integer;
define v_manopjul integer; define v_manorjul integer;
define v_manopago integer; define v_manorago integer;
define v_manopsep integer; define v_manorsep integer;
define v_manopoct integer; define v_manoroct integer;
define v_manopnov integer; define v_manornov integer;
define v_manopdic integer; define v_manordic integer;

define v_totpene integer; define v_totrene integer;
define v_totpfeb integer; define v_totrfeb integer;
define v_totpmar integer; define v_totrmar integer;
define v_totpabr integer; define v_totrabr integer;
define v_totpmay integer; define v_totrmay integer;
define v_totpjun integer; define v_totrjun integer;
define v_totpjul integer; define v_totrjul integer;
define v_totpago integer; define v_totrago integer;
define v_totpsep integer; define v_totrsep integer;
define v_totpoct integer; define v_totroct integer;
define v_totpnov integer; define v_totrnov integer;
define v_totpdic integer; define v_totrdic integer;

--set debug file to 'd://AvanceObrasCant';
--trace on;

foreach
select no, nombre, division, anio_obra, zona
into v_noobra, v_obra, v_div, v_anio, v_nomzona
from obras ORDER BY nombre ASC

if v_nomzona='4091' then
let v_nomzona='31 - MORELOS';
end if;
if v_nomzona='4096' then
let v_nomzona='81 - ACAPULCO';
end if;
if v_nomzona='4089' then
let v_nomzona='11 - CHILPANCINGO';
end if;
if v_nomzona='4090' then
let v_nomzona='21 - IGUALA';
end if;
if v_nomzona='4092' then
let v_nomzona='41 - TOLUCA';
end if;
if v_nomzona='4095' then
let v_nomzona='71 - VALLE DE BRAVO';
end if;
if v_nomzona='4093' then
let v_nomzona='51 - ALTAMIRANO';
end if;
if v_nomzona='4097' then
let v_nomzona='91 - ZIHUATANEJO';
end if;

select sum(cant) into v_matpene from materialesobra
where fechavencimiento like p_anio||'/01/__' and noobra=v_noobra;

select sum(cantidad) into v_matrene from mat_vales
where fechasalidaalmacen like p_anio||'/01/__' and numobrascod=v_noobra;

select sum(cant) into v_matpfeb from materialesobra
where fechavencimiento like p_anio||'/02/__' and noobra=v_noobra;

select sum(cantidad) into v_matrfeb from mat_vales
where fechasalidaalmacen like p_anio||'/02/__' and numobrascod=v_noobra;

select sum(cant) into v_matpmar from materialesobra
where fechavencimiento like p_anio||'/03/__' and noobra=v_noobra;

select sum(cantidad) into v_matrmar from mat_vales
where fechasalidaalmacen like p_anio||'/03/__' and numobrascod=v_noobra;

select sum(cant) into v_matpabr from materialesobra
where fechavencimiento like p_anio||'/04/__' and noobra=v_noobra;

select sum(cantidad) into v_matrabr from mat_vales
where fechasalidaalmacen like p_anio||'/04/__' and numobrascod=v_noobra;

select sum(cant) into v_matpmay from materialesobra
where fechavencimiento like p_anio||'/05/__' and noobra=v_noobra;

select sum(cantidad) into v_matrmay from mat_vales
where fechasalidaalmacen like p_anio||'/05/__' and numobrascod=v_noobra;

select sum(cant) into v_matpjun from materialesobra
where fechavencimiento like p_anio||'/06/__' and noobra=v_noobra;

select sum(cantidad) into v_matrjun from mat_vales
where fechasalidaalmacen like p_anio||'/06/__' and numobrascod=v_noobra;

select sum(cant) into v_matpjul from materialesobra
where fechavencimiento like p_anio||'/07/__' and noobra=v_noobra;

select sum(cantidad) into v_matrjul from mat_vales
where fechasalidaalmacen like p_anio||'/07/__' and numobrascod=v_noobra;

select sum(cant) into v_matpago from materialesobra
where fechavencimiento like p_anio||'/08/__' and noobra=v_noobra;

select sum(cantidad) into v_matrago from mat_vales
where fechasalidaalmacen like p_anio||'/08/__' and numobrascod=v_noobra;

select sum(cant) into v_matpsep from materialesobra
where fechavencimiento like p_anio||'/09/__' and noobra=v_noobra;

select sum(cantidad) into v_matrsep from mat_vales
where fechasalidaalmacen like p_anio||'/09/__' and numobrascod=v_noobra;

select sum(cant) into v_matpoct from materialesobra
where fechavencimiento like p_anio||'/10/__' and noobra=v_noobra;

select sum(cantidad) into v_matroct from mat_vales
where fechasalidaalmacen like p_anio||'/10/__' and numobrascod=v_noobra;

select sum(cant) into v_matpnov from materialesobra
where fechavencimiento like p_anio||'/11/__' and noobra=v_noobra;

select sum(cantidad) into v_matrnov from mat_vales
where fechasalidaalmacen like p_anio||'/11/__' and numobrascod=v_noobra;

select sum(cant) into v_matpdic from materialesobra
where fechavencimiento like p_anio||'/12/__' and noobra=v_noobra;

select sum(cantidad) into v_matrdic from mat_vales
where fechasalidaalmacen like p_anio||'/12/__' and numobrascod=v_noobra;

.... continuara
Responder Con Cita
  #3  
Antiguo 01-04-2009
pelacuaz pelacuaz is offline
Registrado
 
Registrado: abr 2009
Posts: 5
Poder: 0
pelacuaz Va por buen camino
... continuacion


select sum(programado) into v_manopene from manoobra_obra
where fechavencimiento like p_anio||'/01/__' and noobra=v_noobra;
select sum(programado) into v_manopfeb from manoobra_obra
where fechavencimiento like p_anio||'/02/__' and noobra=v_noobra;
select sum(programado) into v_manopmar from manoobra_obra
where fechavencimiento like p_anio||'/03/__' and noobra=v_noobra;
select sum(programado) into v_manopabr from manoobra_obra
where fechavencimiento like p_anio||'/04/__' and noobra=v_noobra;
select sum(programado) into v_manopmay from manoobra_obra
where fechavencimiento like p_anio||'/05/__' and noobra=v_noobra;
select sum(programado) into v_manopjun from manoobra_obra
where fechavencimiento like p_anio||'/06/__' and noobra=v_noobra;
select sum(programado) into v_manopjul from manoobra_obra
where fechavencimiento like p_anio||'/07/__' and noobra=v_noobra;
select sum(programado) into v_manopago from manoobra_obra
where fechavencimiento like p_anio||'/08/__' and noobra=v_noobra;
select sum(programado) into v_manopsep from manoobra_obra
where fechavencimiento like p_anio||'/09/__' and noobra=v_noobra;
select sum(programado) into v_manopoct from manoobra_obra
where fechavencimiento like p_anio||'/10/__' and noobra=v_noobra;
select sum(programado) into v_manopnov from manoobra_obra
where fechavencimiento like p_anio||'/11/__' and noobra=v_noobra;
select sum(programado) into v_manopdic from manoobra_obra
where fechavencimiento like p_anio||'/12/__' and noobra=v_noobra;

select sum(real) into v_manorene from manoobra_obra
where fechavencimiento like p_anio||'/01/__' and noobra=v_noobra;
select sum(real) into v_manorfeb from manoobra_obra
where fechavencimiento like p_anio||'/02/__' and noobra=v_noobra;
select sum(real) into v_manormar from manoobra_obra
where fechavencimiento like p_anio||'/03/__' and noobra=v_noobra;
select sum(real) into v_manorabr from manoobra_obra
where fechavencimiento like p_anio||'/04/__' and noobra=v_noobra;
select sum(real) into v_manormay from manoobra_obra
where fechavencimiento like p_anio||'/05/__' and noobra=v_noobra;
select sum(real) into v_manorjun from manoobra_obra
where fechavencimiento like p_anio||'/06/__' and noobra=v_noobra;
select sum(real) into v_manorjul from manoobra_obra
where fechavencimiento like p_anio||'/07/__' and noobra=v_noobra;
select sum(real) into v_manorago from manoobra_obra
where fechavencimiento like p_anio||'/08/__' and noobra=v_noobra;
select sum(real) into v_manorsep from manoobra_obra
where fechavencimiento like p_anio||'/09/__' and noobra=v_noobra;
select sum(real) into v_manoroct from manoobra_obra
where fechavencimiento like p_anio||'/10/__' and noobra=v_noobra;
select sum(real) into v_manornov from manoobra_obra
where fechavencimiento like p_anio||'/11/__' and noobra=v_noobra;
select sum(real) into v_manordic from manoobra_obra
where fechavencimiento like p_anio||'/12/__' and noobra=v_noobra;

let v_totpene=v_matpene+v_manopene; let v_totrene=v_matrene+v_manorene;
let v_totpfeb=v_matpfeb+v_manopfeb; let v_totrfeb=v_matrfeb+v_manorfeb;
let v_totpmar=v_matpmar+v_manopmar; let v_totrmar=v_matrmar+v_manormar;
let v_totpabr=v_matpabr+v_manopabr; let v_totrabr=v_matrabr+v_manorabr;
let v_totpmay=v_matpmay+v_manopmay; let v_totrmay=v_matrmay+v_manormay;
let v_totpjun=v_matpjun+v_manopjun; let v_totrjun=v_matrjun+v_manorjun;
let v_totpjul=v_matpjul+v_manopjul; let v_totrjul=v_matrjul+v_manorjul;
let v_totpago=v_matpago+v_manopago; let v_totrago=v_matrago+v_manorago;
let v_totpsep=v_matpsep+v_manopsep; let v_totrsep=v_matrsep+v_manorsep;
let v_totpoct=v_matpoct+v_manopoct; let v_totroct=v_matroct+v_manoroct;
let v_totpnov=v_matpnov+v_manopnov; let v_totrnov=v_matrnov+v_manornov;
let v_totpdic=v_matpdic+v_manopdic; let v_totrdic=v_matrdic+v_manordic;

let v_mat='Materiales';
let v_mo='Mano de obra';
let v_tot='Totales';
let v_matp='P';
let v_matr='R';
let v_mop='P';
let v_mor='R';
let v_totp='P';
let v_totr='R';

return v_nomzona, v_obra, v_anio, v_mat, v_mo, v_tot, v_matp, v_matr, v_mop, v_mor, v_totp, v_totr,
v_matpene, v_matrene, v_matpfeb, v_matrfeb, v_matpmar, v_matrmar, v_matpabr, v_matrabr,
v_matpmay, v_matrmay, v_matpjun, v_matrjun, v_matpjul, v_matrjul, v_matpago, v_matrago,
v_matpsep, v_matrsep, v_matpoct, v_matroct, v_matpnov, v_matrnov, v_matpdic, v_matrdic,
v_manopene, v_manorene, v_manopfeb, v_manorfeb, v_manopmar, v_manormar, v_manopabr, v_manorabr,
v_manopmay, v_manormay, v_manopjun, v_manorjun, v_manopjul, v_manorjul, v_manopago, v_manorago,
v_manopsep, v_manorsep, v_manopoct, v_manoroct, v_manopnov, v_manornov, v_manopdic, v_manordic,
v_totpene, v_totrene, v_totpfeb, v_totrfeb, v_totpmar, v_totrmar, v_totpabr, v_totrabr,
v_totpmay, v_totrmay, v_totpjun, v_totrjun, v_totpjul, v_totrjul, v_totpago, v_totrago,
v_totpsep, v_totrsep, v_totpoct, v_totroct, v_totpnov, v_totrnov, v_totpdic, v_totrdic
with resume;
end foreach;
END PROCEDURE;
Responder Con Cita
  #4  
Antiguo 01-04-2009
pelacuaz pelacuaz is offline
Registrado
 
Registrado: abr 2009
Posts: 5
Poder: 0
pelacuaz Va por buen camino
LA OTRA FUNCION (que se resuelve en 12 min)

DROP FUNCTION avanceobrascosto(char);

CREATE PROCEDURE "informix".avanceobrascosto(p_anio char(4))
RETURNING char(50) as nombrezona, char(500) as obra, integer as anio, char(50) as mat,
char(50) as mo, char(50) as tot, char(2) as matp, char(2) as matr, char(2) as mop,
char(2) as mor, char(2) as totp, char(2) as totr,
decimal(16,2) as cosmatpene, decimal(16,2) as cosmatrene,
decimal(16,2) as cosmatpfeb, decimal(16,2) as cosmatrfeb,
decimal(16,2) as cosmatpmar, decimal(16,2) as cosmatrmar,
decimal(16,2) as cosmatpabr, decimal(16,2) as cosmatrabr,
decimal(16,2) as cosmatpmay, decimal(16,2) as cosmatrmay,
decimal(16,2) as cosmatpjun, decimal(16,2) as cosmatrjun,
decimal(16,2) as cosmatpjul, decimal(16,2) as cosmatrjul,
decimal(16,2) as cosmatpago, decimal(16,2) as cosmatrago,
decimal(16,2) as cosmatpsep, decimal(16,2) as cosmatrsep,
decimal(16,2) as cosmatpoct, decimal(16,2) as cosmatroct,
decimal(16,2) as cosmatpnov, decimal(16,2) as cosmatrnov,
decimal(16,2) as cosmatpdic, decimal(16,2) as cosmatrdic,

decimal(16,2) as cosmanopene, decimal(16,2) as cosmanorene,
decimal(16,2) as cosmanopfeb, decimal(16,2) as cosmanorfeb,
decimal(16,2) as cosmanopmar, decimal(16,2) as cosmanormar,
decimal(16,2) as cosmanopabr, decimal(16,2) as cosmanorabr,
decimal(16,2) as cosmanopmay, decimal(16,2) as cosmanormay,
decimal(16,2) as cosmanopjun, decimal(16,2) as cosmanorjun,
decimal(16,2) as cosmanopjul, decimal(16,2) as cosmanorjul,
decimal(16,2) as cosmanopago, decimal(16,2) as cosmanorago,
decimal(16,2) as cosmanopsep, decimal(16,2) as cosmanorsep,
decimal(16,2) as cosmanopoct, decimal(16,2) as cosmanoroct,
decimal(16,2) as cosmanopnov, decimal(16,2) as cosmanornov,
decimal(16,2) as cosmanopdic, decimal(16,2) as cosmanordic,

decimal(16,2) as totpene, decimal(16,2) as totrene,
decimal(16,2) as totpfeb, decimal(16,2) as totrfeb,
decimal(16,2) as totpmar, decimal(16,2) as totrmar,
decimal(16,2) as totpabr, decimal(16,2) as totrabr,
decimal(16,2) as totpmay, decimal(16,2) as totrmay,
decimal(16,2) as totpjun, decimal(16,2) as totrjun,
decimal(16,2) as totpjul, decimal(16,2) as totrjul,
decimal(16,2) as totpago, decimal(16,2) as totrago,
decimal(16,2) as totpsep, decimal(16,2) as totrsep,
decimal(16,2) as totpoct, decimal(16,2) as totroct,
decimal(16,2) as totpnov, decimal(16,2) as totrnov,
decimal(16,2) as totpdic, decimal(16,2) as totrdic;

define v_noobra integer; define v_div char(2);
define v_nomzona char(50);
define v_numzona char(2);
define v_obra char(500);
define v_anio integer;
define v_mat char(50);
define v_mo char(50);
define v_tot char(50);
define v_matp char(2);
define v_matr char(2);
define v_mop char(2);
define v_mor char(2);
define v_totp char(2);
define v_totr char(2);
define v_matpene decimal(16,2);
define v_matrene decimal(16,2);
define v_matpfeb decimal(16,2);
define v_matrfeb decimal(16,2);
define v_matpmar decimal(16,2);
define v_matrmar decimal(16,2);
define v_matpabr decimal(16,2);
define v_matrabr decimal(16,2);
define v_matpmay decimal(16,2);
define v_matrmay decimal(16,2);
define v_matpjun decimal(16,2);
define v_matrjun decimal(16,2);
define v_matpjul decimal(16,2);
define v_matrjul decimal(16,2);
define v_matpago decimal(16,2);
define v_matrago decimal(16,2);
define v_matpsep decimal(16,2);
define v_matrsep decimal(16,2);
define v_matpoct decimal(16,2);
define v_matroct decimal(16,2);
define v_matpnov decimal(16,2);
define v_matrnov decimal(16,2);
define v_matpdic decimal(16,2);
define v_matrdic decimal(16,2);

define v_manopene decimal(16,2);
define v_manorene decimal(16,2);
define v_manopfeb decimal(16,2);
define v_manorfeb decimal(16,2);
define v_manopmar decimal(16,2);
define v_manormar decimal(16,2);
define v_manopabr decimal(16,2);
define v_manorabr decimal(16,2);
define v_manopmay decimal(16,2);
define v_manormay decimal(16,2);
define v_manopjun decimal(16,2);
define v_manorjun decimal(16,2);
define v_manopjul decimal(16,2);
define v_manorjul decimal(16,2);
define v_manopago decimal(16,2);
define v_manorago decimal(16,2);
define v_manopsep decimal(16,2);
define v_manorsep decimal(16,2);
define v_manopoct decimal(16,2);
define v_manoroct decimal(16,2);
define v_manopnov decimal(16,2);
define v_manornov decimal(16,2);
define v_manopdic decimal(16,2);
define v_manordic decimal(16,2);

define v_totpene decimal(16,2);
define v_totrene decimal(16,2);
define v_totpfeb decimal(16,2);
define v_totrfeb decimal(16,2);
define v_totpmar decimal(16,2);
define v_totrmar decimal(16,2);
define v_totpabr decimal(16,2);
define v_totrabr decimal(16,2);
define v_totpmay decimal(16,2);
define v_totrmay decimal(16,2);
define v_totpjun decimal(16,2);
define v_totrjun decimal(16,2);
define v_totpjul decimal(16,2);
define v_totrjul decimal(16,2);
define v_totpago decimal(16,2);
define v_totrago decimal(16,2);
define v_totpsep decimal(16,2);
define v_totrsep decimal(16,2);
define v_totpoct decimal(16,2);
define v_totroct decimal(16,2);
define v_totpnov decimal(16,2);
define v_totrnov decimal(16,2);
define v_totpdic decimal(16,2);
define v_totrdic decimal(16,2);

--set debug file to 'd://AvanceObrasCant';
--trace on;

foreach
select no, nombre, division, anio_obra, zona
into v_noobra, v_obra, v_div, v_anio, v_nomzona
from obras ORDER BY nombre ASC

if v_nomzona='4091' then
let v_nomzona='31 - MORELOS';
end if;
if v_nomzona='4096' then
let v_nomzona='81 - ACAPULCO';
end if;
if v_nomzona='4089' then
let v_nomzona='11 - CHILPANCINGO';
end if;
if v_nomzona='4090' then
let v_nomzona='21 - IGUALA';
end if;
if v_nomzona='4092' then
let v_nomzona='41 - TOLUCA';
end if;
if v_nomzona='4095' then
let v_nomzona='71 - VALLE DE BRAVO';
end if;
if v_nomzona='4093' then
let v_nomzona='51 - ALTAMIRANO';
end if;
if v_nomzona='4097' then
let v_nomzona='91 - ZIHUATANEJO';
end if;


... continuara
Responder Con Cita
  #5  
Antiguo 01-04-2009
pelacuaz pelacuaz is offline
Registrado
 
Registrado: abr 2009
Posts: 5
Poder: 0
pelacuaz Va por buen camino
...continuacion

select sum(cant*preciounitario) into v_matpene from materialesobra
where fechavencimiento like p_anio||'/01/__' and noobra=v_noobra;
select sum(cant*preciounitario) into v_matpfeb from materialesobra
where fechavencimiento like p_anio||'/02/__' and noobra=v_noobra;
select sum(cant) into v_matpmar from materialesobra
where fechavencimiento like p_anio||'/03/__' and noobra=v_noobra;
select sum(cant) into v_matpabr from materialesobra
where fechavencimiento like p_anio||'/04/__' and noobra=v_noobra;
select sum(cant) into v_matpmay from materialesobra
where fechavencimiento like p_anio||'/05/__' and noobra=v_noobra;
select sum(cant) into v_matpjun from materialesobra
where fechavencimiento like p_anio||'/06/__' and noobra=v_noobra;
select sum(cant) into v_matpjul from materialesobra
where fechavencimiento like p_anio||'/07/__' and noobra=v_noobra;
select sum(cant) into v_matpago from materialesobra
where fechavencimiento like p_anio||'/08/__' and noobra=v_noobra;
select sum(cant) into v_matpsep from materialesobra
where fechavencimiento like p_anio||'/09/__' and noobra=v_noobra;
select sum(cant) into v_matpoct from materialesobra
where fechavencimiento like p_anio||'/10/__' and noobra=v_noobra;
select sum(cant) into v_matpnov from materialesobra
where fechavencimiento like p_anio||'/11/__' and noobra=v_noobra;
select sum(cant) into v_matpdic from materialesobra
where fechavencimiento like p_anio||'/12/__' and noobra=v_noobra;

let v_matrene = 0.0;
let v_matrfeb = 0.0;
let v_matrmar = 0.0;
let v_matrabr = 0.0;
let v_matrmay = 0.0;
let v_matrjun = 0.0;
let v_matrjul = 0.0;
let v_matrago = 0.0;
let v_matrsep = 0.0;
let v_matroct = 0.0;
let v_matrnov = 0.0;
let v_matrdic = 0.0;


select sum(programado*preciounitario) into v_manopene from manoobra_obra
where fechavencimiento like p_anio||'/01/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopfeb from manoobra_obra
where fechavencimiento like p_anio||'/02/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopmar from manoobra_obra
where fechavencimiento like p_anio||'/03/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopabr from manoobra_obra
where fechavencimiento like p_anio||'/04/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopmay from manoobra_obra
where fechavencimiento like p_anio||'/05/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopjun from manoobra_obra
where fechavencimiento like p_anio||'/06/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopjul from manoobra_obra
where fechavencimiento like p_anio||'/07/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopago from manoobra_obra
where fechavencimiento like p_anio||'/08/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopsep from manoobra_obra
where fechavencimiento like p_anio||'/09/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopoct from manoobra_obra
where fechavencimiento like p_anio||'/10/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopnov from manoobra_obra
where fechavencimiento like p_anio||'/11/__' and noobra=v_noobra;
select sum(programado*preciounitario) into v_manopdic from manoobra_obra
where fechavencimiento like p_anio||'/12/__' and noobra=v_noobra;

select sum(real*preciounitario) into v_manorene from manoobra_obra
where fechavencimiento like p_anio||'/01/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manorfeb from manoobra_obra
where fechavencimiento like p_anio||'/02/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manormar from manoobra_obra
where fechavencimiento like p_anio||'/03/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manorabr from manoobra_obra
where fechavencimiento like p_anio||'/04/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manormay from manoobra_obra
where fechavencimiento like p_anio||'/05/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manorjun from manoobra_obra
where fechavencimiento like p_anio||'/06/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manorjul from manoobra_obra
where fechavencimiento like p_anio||'/07/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manorago from manoobra_obra
where fechavencimiento like p_anio||'/08/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manorsep from manoobra_obra
where fechavencimiento like p_anio||'/09/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manoroct from manoobra_obra
where fechavencimiento like p_anio||'/10/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manornov from manoobra_obra
where fechavencimiento like p_anio||'/11/__' and noobra=v_noobra;
select sum(real*preciounitario) into v_manordic from manoobra_obra
where fechavencimiento like p_anio||'/12/__' and noobra=v_noobra;

let v_totpene=v_matpene+v_manopene; let v_totrene=v_matrene+v_manorene;
let v_totpfeb=v_matpfeb+v_manopfeb; let v_totrfeb=v_matrfeb+v_manorfeb;
let v_totpmar=v_matpmar+v_manopmar; let v_totrmar=v_matrmar+v_manormar;
let v_totpabr=v_matpabr+v_manopabr; let v_totrabr=v_matrabr+v_manorabr;
let v_totpmay=v_matpmay+v_manopmay; let v_totrmay=v_matrmay+v_manormay;
let v_totpjun=v_matpjun+v_manopjun; let v_totrjun=v_matrjun+v_manorjun;
let v_totpjul=v_matpjul+v_manopjul; let v_totrjul=v_matrjul+v_manorjul;
let v_totpago=v_matpago+v_manopago; let v_totrago=v_matrago+v_manorago;
let v_totpsep=v_matpsep+v_manopsep; let v_totrsep=v_matrsep+v_manorsep;
let v_totpoct=v_matpoct+v_manopoct; let v_totroct=v_matroct+v_manoroct;
let v_totpnov=v_matpnov+v_manopnov; let v_totrnov=v_matrnov+v_manornov;
let v_totpdic=v_matpdic+v_manopdic; let v_totrdic=v_matrdic+v_manordic;

let v_mat='Materiales';
let v_mo='Mano de obra';
let v_tot='Totales';
let v_matp='P';
let v_matr='R';
let v_mop='P';
let v_mor='R';
let v_totp='P';
let v_totr='R';

return v_nomzona, v_obra, v_anio, v_mat, v_mo, v_tot, v_matp, v_matr, v_mop, v_mor, v_totp, v_totr,
v_matpene, v_matrene, v_matpfeb, v_matrfeb, v_matpmar, v_matrmar, v_matpabr, v_matrabr,
v_matpmay, v_matrmay, v_matpjun, v_matrjun, v_matpjul, v_matrjul, v_matpago, v_matrago,
v_matpsep, v_matrsep, v_matpoct, v_matroct, v_matpnov, v_matrnov, v_matpdic, v_matrdic,
v_manopene, v_manorene, v_manopfeb, v_manorfeb, v_manopmar, v_manormar, v_manopabr, v_manorabr,
v_manopmay, v_manormay, v_manopjun, v_manorjun, v_manopjul, v_manorjul, v_manopago, v_manorago,
v_manopsep, v_manorsep, v_manopoct, v_manoroct, v_manopnov, v_manornov, v_manopdic, v_manordic,
v_totpene, v_totrene, v_totpfeb, v_totrfeb, v_totpmar, v_totrmar, v_totpabr, v_totrabr,
v_totpmay, v_totrmay, v_totpjun, v_totrjun, v_totpjul, v_totrjul, v_totpago, v_totrago,
v_totpsep, v_totrsep, v_totpoct, v_totroct, v_totpnov, v_totrnov, v_totpdic, v_totrdic
with resume;


end foreach;
END PROCEDURE;
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Funcion de tiempo pedromanuel JAVA 7 29-11-2006 00:00:58
Utileria para Informix cacuna Varios 2 19-08-2006 01:21:59
como hago para minimizar un Form en tiempo de ejecucion y se coloque en la barra de t Shidalis Varios 3 20-10-2005 22:22:02
Creacion de DSN con ODBC para MySql en tiempo de ejecucion meosre MySQL 1 28-09-2005 22:00:01
¿Cómo cargar un Glyph para un botón en tiempo de ejecución? Feñiz Gráficos 2 09-12-2003 12:38:53


La franja horaria es GMT +2. Ahora son las 04:16:13.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi