Answer the question
In order to leave comments, you need to log in
Why can't I create a procedure?
I create a procedure
CREATE OR REPLACE PROCEDURE UNPIVOT_TEMP_CRE AS
BEGIN
INSERT INTO test( DATETIME, QUARTER, "YEAR", ID_LOCATION, ID_TYPE, PRICE )
Select
p.DATETIME
, p.QUARTER
, p."YEAR"
, p.ID_LOCATION
, t."ID"
, p.PRICE
FROM
( SELECT DATETIME
, QUARTER
, "YEAR"
, ID_LOCATION
, "TYPE"
, PRICE
FROM TEMP
UNPIVOT (
PRICE FOR "TYPE" IN (OFFICES_BUSINESS_CENTER,
OFFICES_OTHER,
RETAIL_SHOPPING_CENTER,
RETAIL_STREET,
RETAIL_OTHER,
WAREHOUSE_COMPLEX,
WAREHOUSE_OTHER,
LAND_LIVING,
LAND_COMMERCIAL,
LAND_INDUSTRIAL)
)
) p
JOIN TYPES_RE t
ON LOWER(SUBSTR(p."TYPE", 1, INSTR(p."TYPE", '_')-1)) = LOWER(t.subtype1)
AND LOWER(SUBSTR(p."TYPE", INSTR(p."TYPE", '_')+1)) = LOWER(t.subtype2);
--
execute immediate 'DROP TABLE TEMP';
--NULL;
END UNPIVOT_TEMP_CRE;
INSERT INTO AVG_PRICE_HISTORY ( DATETIME, QUARTER, "YEAR", ID_LOCATION, ID_TYPE, PRICE )
and on the LAND_INDUSTRIAL)
Error(3,5): PL/SQL: SQL Statement ignored
Error(30,15): PL/SQL: ORA-00904: "LAND_INDUSTRIAL": недопустимый идентификатор
Answer the question
In order to leave comments, you need to log in
The campaign in unpivot needs to specify string values through as , which will replace the fields (and the fields, in turn, must be present in the expanded table):
unpivot price for "TYPE" in (
OFFICES_BUSINESS_CENTER as 'OFFICES_BUSINESS',
OFFICES_OTHER as 'OFFICES_OTHER',
...
LAND_INDUSTRIAL as 'INDUSTRIAL'
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question