Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem Using UNION with NEXTVAL inside a Select

Status
Not open for further replies.

mozgheib

Programmer
Dec 14, 2003
50
0
0
KW
Hello,

I am using the following statement and running into problems. The message I am getting is "sequence number not allowed here". Kindly advise as how to write it. See below.

select a.orion_tank, b.OrionCrude, a.prop_modified_value,
a.DayInserted, SEQ5_CRDINV.nextval, sysdate, user
from ps_staging_data a, ps_crude_map b
where a.Orion_tank = b.OrionTank
and to_char(a.dayInserted,'dd/mm/yyyy') = to_char(sysdate, 'dd/mm/yyyy')
and a.validated = 1 and a.phd_confidence >= 100 and src_flag = 'PHD'

UNION
select a.orion_tank, b.OrionCrude, a.prop_modified_value,
a.DayInserted, SEQ5_CRDINV.nextval, sysdate, user
from ps_staging_data a, ps_crude_map b
where a.Orion_tank = b.OrionTank
and to_char(a.dayInserted,'dd/mm/yyyy') = to_char(sysdate, 'dd/mm/yyyy')
and a.validated = 1 and src_flag <> 'PHD';
 
Try this.

Aryeh Keefe

select orion_tank, OrionCrude, prop_modified_value,
DayInserted, SEQ5_CRDINV.nextval, sysdate, user
from
(
select a.orion_tank, b.OrionCrude, a.prop_modified_value,
a.DayInserted, sysdate, user
from ps_staging_data a, ps_crude_map b
where a.Orion_tank = b.OrionTank
and to_char(a.dayInserted,'dd/mm/yyyy') = to_char(sysdate, 'dd/mm/yyyy')
and a.validated = 1 and a.phd_confidence >= 100 and src_flag = 'PHD'
UNION
select a.orion_tank, b.OrionCrude, a.prop_modified_value,
a.DayInserted, sysdate, user
from ps_staging_data a, ps_crude_map b
where a.Orion_tank = b.OrionTank
and to_char(a.dayInserted,'dd/mm/yyyy') = to_char(sysdate, 'dd/mm/yyyy')
and a.validated = 1 and src_flag <> 'PHD'
)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top