我想用兩個表的部分聯合來創建視圖。使用聯合聲明在pl中創建視圖時出錯sql
下面是聲明:
create view "test" AS
select
ppt.reportingtime reportingtime,
ppt.currency currency,
ppt.channelid channelid,
ppt.transactiontype ttype
FROM preprocessortransactions ppt
union
select
bm.balancetype balancetype
from balancemovements bm
該錯誤消息我得到的是以下幾點:
Error starting at line 1 in command:
create view "test" AS SELECT
ppt.reportingtime reportingtime, ppt.currency currency, ppt.channelid channelid, ppt.transactiontype ttype FROM preprocessortransactions ppt union select bm.balancetype balancetype from balancemovements bmError at Command Line:1 Column:22 Error report: SQL Error: ORA-01789: query block has incorrect number of result columns 01789. 00000 - "query block has incorrect number of result columns" *Cause:
*Action:
我非常新的PL SQL和我想不通的意義報錯。
我還嘗試在第一個AS運算符之前列出括號中的列名,但沒有成功。
你需要有兩個查詢的聯合編號相同數量的字段。目前,您在頂部有4個字段,底部有1個字段。 – Matt
謝謝你的幫助。爲了讓工會聲明起作用,是否有任何創建空白的方法? – ehammer
你想讓bm.balancetype坐在哪個字段? – Matt