Código PHP:
Ver originalCREATE FUNCTION ht_mostrarorden(us_id integer, tipo integer, statusreal integer) RETURNS TABLE(idventa integer, idplan integer, periodicidad integer, carac_uno character varying, carac_dos character varying, carac_tres character varying, precio numeric)
LANGUAGE plpgsql
AS $$DECLARE
numorden integer;
numtipouno integer;
numtipodos integer;
numtipotres integer;
dolar numeric;
idventa integer;
idplan integer;
periodicidad integer;
carac_uno character varying;
carac_dos character varying;
carac_tres character varying;
precio numeric;
BEGIN
SELECT au_dolar.precio INTO dolar FROM au_dolar ORDER BY ID DESC LIMIT 1;
SELECT ID INTO numorden FROM HT_ORDENES WHERE USER_ID=US_ID AND STATUS=STATUSREAL LIMIT 1;
IF(TIPO=1) THEN
SELECT ht_ventas
.id into idventa
, ht_planes1
.id into idplan
, ht_planes1
.periodicidad into periodicidad
, ht_planes1
.espacio into carac_uno
, ht_planes1
.transferencia into carac_dos
, ht_planes1
.dominios into carac_tres
, ht_planes1
.precio into precio FROM ht_ventas RIGHT
JOIN ht_planes1 ON ht_planes1
.id
=ht_ventas
.idplan WHERE ht_ventas
.id_orden
=numorden AND ht_ventas
.tipo
=1;IF(TIPO=2) THEN
SELECT ht_ventas
.id into idventa
, ht_planes2
.id into idplan
, ht_planes2
.periodicidad into periodicidad
, ht_planes2
.espacio into carac_uno
, ht_planes2
.transferencia into carac_dos
, '' into carac_tres
, ht_planes2
.precio into precio FROM ht_ventas RIGHT
JOIN ht_planes2 ON ht_planes2
.id
=ht_ventas
.idplan WHERE ht_ventas
.id_orden
=numorden AND ht_ventas
.tipo
=2;IF(TIPO=3) THEN
SELECT ht_dominiordenado
.id into idventa
, ht_dominiordenado
.id into idplan
,'12' into periodicidad
, ht_dominiordenado
.dominio into carac_uno
,ht_planes3
.extension into carac_dos
, '' into carac_tres
, ht_planes3
.precio
*dolar into precio FROM ht_ventas RIGHT
JOIN ht_dominiordenado ON ht_dominiordenado
.id
=ht_ventas
.idplan RIGHT
JOIN ht_planes3 ON ht_dominiordenado
.idplanreal
=ht_planes3
.id WHERE ht_ventas
.id_orden
=numorden AND ht_ventas
.tipo
=3;
$$;
Me da error el siguiente procedure en plpgsql (postgresql) la tabla ht_planes1 es una tabla e id es el nombre de una columna
Código PHP:
Ver originalERROR: «ht_planes1.id» no es una variable conocida
Saludos y gracias de antemano