me fue mal viejo lo deje así
Código SQL:
Ver originalCREATE OR REPLACE FUNCTION prueba(IN idTaller INTEGER,IN Alias VARCHAR(255),OUT VehiculosTaller BIGINT,OUT CapacidadTaller SMALLINT) RETURNS SETOF RECORD AS $BODY$
DECLARE
use_sql TEXT;
BEGIN
use_sql := 'select count(VEHICULOS.id_vehiculo)as VehiculosTaller,locales.capacidad_instalada as CapacidadTaller from SINIESTROS,COMPANIAS,VEHICULOS,LOCALES,TALLERES
where SINIESTROS.id_compania = COMPANIAS.id_compania and SINIESTROS.id_vehiculo = VEHICULOS.id_vehiculo and VEHICULOS.id_estado <> 12 and
VEHICULOS.id_local = LOCALES.id_local and LOCALES.id_taller = TALLERES.id_taller and TALLERES.id_taller =' || idTaller ||'
and COMPANIAS.alias = upper(' || Alias ||' )
group by locales.capacidad_instalada UNION ALL select count(VEHICULOS.id_vehiculo),locales.capacidad_instalada from SINIESTROS,COMPANIAS,VEHICULOS,LOCALES,TALLERES
where SINIESTROS.id_compania = COMPANIAS.id_compania and SINIESTROS.id_vehiculo = VEHICULOS.id_vehiculo and VEHICULOS.id_estado <> 12 and
VEHICULOS.id_local = LOCALES.id_local and LOCALES.id_taller = TALLERES.id_taller and TALLERES.id_taller = ' || idTaller ||' and COMPANIAS.alias <> upper(' || Alias ||')
group by locales.capacidad_instalada';
RETURN QUERY EXECUTE use_sql;
$BODY$
LANGUAGE plpgsql;
y me tira este error
Código SQL:
Ver originalERROR: syntax error at END OF INPUT
LINE 14: $BODY$
^
********** Error **********