Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/09/2016, 10:18
EdVaMaTe
 
Fecha de Ingreso: enero-2010
Mensajes: 20
Antigüedad: 14 años, 11 meses
Puntos: 0
Problema en Consulta SQL

Tengo una base de datos de nómina con el siguiente script, el cual en una base de datos funciona, y lo ejecuto en otra base de datos de copia y no lo hace. No he podido encontrar el error. Agradecería cualquier sugerencia.

Código SQL:
Ver original
  1. -- View: etitc_basicpayrollsiif_vt
  2. -- DROP VIEW etitc_basicpayrollsiif_vt;
  3.  
  4. CREATE OR REPLACE VIEW etitc_basicpayrollsiif_vt AS
  5.  SELECT DISTINCT 1000003 AS ad_client_id, 1000003 AS ad_org_id,
  6.     'es_CO'::text AS ad_language, m.hr_process_id, e.hr_payroll_id,
  7.     e.c_bpartner_id, m.validfrom, m.validto, b.name, b.VALUE,
  8.     ( SELECT m.qty
  9.            FROM hr_movement m
  10.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000208::NUMERIC) AS quatity,
  11.     ( SELECT m.amount
  12.            FROM hr_movement m
  13.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000247::NUMERIC) AS salary,
  14.     ( SELECT m.amount
  15.            FROM hr_movement m
  16.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000252::NUMERIC) AS foodsubsidy,
  17.     ( SELECT m.amount
  18.            FROM hr_movement m
  19.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000143::NUMERIC) AS transportsubsidy,
  20.     ( SELECT m.qty
  21.            FROM hr_movement m
  22.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000215::NUMERIC) AS extrahoursquantity,
  23.     ( SELECT m.amount
  24.            FROM hr_movement m
  25.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000192::NUMERIC) AS totalvalueextrahours,
  26.     ( SELECT m.amount
  27.            FROM hr_movement m
  28.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000144::NUMERIC) AS servicebonus,
  29.     ( SELECT SUM(m.amount) AS amount
  30.            FROM hr_movement m
  31.           WHERE m.c_bpartner_id = e.c_bpartner_id AND (m.hr_concept_id = ANY (ARRAY[1000230::NUMERIC, 1000232::NUMERIC]))) AS bonustechnicalnosalary,
  32.     ( SELECT m.amount
  33.            FROM hr_movement m
  34.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000228::NUMERIC) AS bonuscoordination,
  35.     ( SELECT m.amount
  36.            FROM hr_movement m
  37.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000231::NUMERIC) AS bonustechnicalsalary,
  38.     ( SELECT m.amount
  39.            FROM hr_movement m
  40.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000261::NUMERIC) AS totalaccrued,
  41.     ( SELECT m.amount
  42.            FROM hr_movement m
  43.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000171::NUMERIC) AS employeehealthquote,
  44.     ( SELECT m.amount
  45.            FROM hr_movement m
  46.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000275::NUMERIC) AS employeeboardquote,
  47.     ( SELECT m.amount
  48.            FROM hr_movement m
  49.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1001154::NUMERIC) AS employeeisaquote,
  50.     ( SELECT m.amount
  51.            FROM hr_movement m
  52.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000189::NUMERIC) AS pensionsolidarityfund,
  53.     ( SELECT m.amount
  54.            FROM hr_movement m
  55.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000169::NUMERIC) AS coeeducol,
  56.     ( SELECT m.amount
  57.            FROM hr_movement m
  58.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000276::NUMERIC) AS credivalores,
  59.     ( SELECT m.amount
  60.            FROM hr_movement m
  61.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000197::NUMERIC) AS bancopopularcharge,
  62.     ( SELECT m.amount
  63.            FROM hr_movement m
  64.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000279::NUMERIC) AS daviviendacharge,
  65.     ( SELECT m.amount
  66.            FROM hr_movement m
  67.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000198::NUMERIC) AS compensarcharge,
  68.     ( SELECT m.amount
  69.            FROM hr_movement m
  70.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000304::NUMERIC) AS complementaryplanhealth,
  71.     ( SELECT m.amount
  72.            FROM hr_movement m
  73.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000168::NUMERIC) AS canapro,
  74.     ( SELECT m.amount
  75.            FROM hr_movement m
  76.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000280::NUMERIC) AS afc,
  77.     ( SELECT m.amount
  78.            FROM hr_movement m
  79.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000305::NUMERIC) AS bayport,
  80.     ( SELECT m.amount
  81.            FROM hr_movement m
  82.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000251::NUMERIC) AS tradeunion,
  83.     ( SELECT m.amount
  84.            FROM hr_movement m
  85.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000250::NUMERIC) AS bolivarinsurance,
  86.     ( SELECT m.amount
  87.            FROM hr_movement m
  88.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000175::NUMERIC) AS liensandfines,
  89.     ( SELECT m.amount
  90.            FROM hr_movement m
  91.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000277::NUMERIC) AS withholdingwages,
  92.     ( SELECT m.amount
  93.            FROM hr_movement m
  94.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000260::NUMERIC) AS totaldeductions,
  95.     ( SELECT m.amount
  96.            FROM hr_movement m
  97.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000199::NUMERIC) AS netpay,
  98.     ( SELECT m.amount
  99.            FROM hr_movement m
  100.           WHERE m.c_bpartner_id = e.c_bpartner_id AND m.hr_concept_id = 1000199::NUMERIC) AS pay
  101.    FROM hr_employee e
  102.    JOIN hr_payroll p ON p.hr_payroll_id = e.hr_payroll_id
  103.    JOIN c_bpartner b ON b.c_bpartner_id = e.c_bpartner_id
  104.    LEFT JOIN hr_movement m ON m.c_bpartner_id = e.c_bpartner_id;
  105.  
  106. ALTER TABLE etitc_basicpayrollsiif_vt
  107.   OWNER TO adempiere;
  108.  
  109. [B]ERROR:[/B]
  110. ERROR:  una subconsulta utilizada como expresión retornó más de un registro
  111. ********** Error **********
  112.  
  113. ERROR: una subconsulta utilizada como expresión retornó más de un registro
  114. SQL state: 21000

Última edición por gnzsoloyo; 01/09/2016 a las 10:57