我很抱歉这个混乱,但我想要做的是为操作$ u2970创建一个变量。我尝试过一些在网上找到的方法但是没有用。这是一个更大的查询的一部分,所以用变量替换ops $ u2970会很好,特别是因为它将来需要在整个查询中进行更改。这在Python中很容易,但这是sql。
--***Creates a VIEW of all TIS GN's with their Corridor ID, Accum Mile and XY coords
create or replace view GN_DC_LOCATE as
select distinct t.gn_id, n.tcr_rt||n.tcr_rb DC_ID,
case when n.beg_brkm<n.end_brkm then
round(((t.gn_km-n.beg_brkm)+n.beg_tcrkm)*.6213712,3)
else round(((n.beg_brkm-t.gn_km)+n.beg_tcrkm)*.6213712,3)
end as GN_DCMI,c.x_coord TIS_XCOORD, c.y_coord TIS_YCOORD
from tis.tis_gn_locate t,tis.tis_tcr_lookup n,tis.tis_gn_coords c
where t.route=n.br_id and t.gn_km>=n.beg_abskm and t.gn_km<=n.end_abskm
and t.gn_id=c.gn_id
--***Creates a VIEW of all begin and end GN's on ops$u2087.sec_segments
--from the view GN_DC_LOCATE and adds in the records where GN=999999999999
create or replace view PVMGT_SEGS_GNs_DCMI as
select p.corridor_code_rb,
b.gn_id,b.GN_DCMI TIS_MI,
b.TIS_XCOORD TIS_X,b.TIS_YCOORD TIS_Y
from ops$u2970.sec_segments p, GN_DC_LOCATE b
where p.corridor_code_rb=b.DC_ID and p.beg_gn=b.gn_id
UNION
select p.corridor_code_rb,
e.gn_id,e.GN_DCMI TIS_MI,e.TIS_XCOORD TIS_X,e.TIS_YCOORD TIS_Y
from ops$u2970.sec_segments p,GN_DC_LOCATE e
where p.corridor_code_rb=e.DC_ID and p.end_gn=e.gn_id
UNION
select p.corridor_code_rb,999999999999 GN_ID, NULL TIS_MI,NULL TIS_X,NULL TIS_Y
from ops$u2970.sec_segments p
where p.beg_gn=999999999999 or p.end_gn=999999999999
order by 1,3
答案 0 :(得分:0)
无法在Oracle VIEW
定义中使用变量。存储过程,函数,触发器和包中允许使用变量。