Using SQL to create a flat file and Sequences
Here's my question: I need to create a flat file that looks like this. The first line ('H' record) in this example is a header record, the second ('P' record) is the detail record, followed then by another header, detail, etc.
H6567 DOM HOST 80485 80433 NN2PPDN0N
P6567 DOM000000000000000000075000000 EA 1WSA
H6568 DOM HOST 80400 80468 NN2PPDN0N
P6568 DOM000000000000000000083000000 EA 1WSA
The header's "6567" is derived using an Oracle sequence's NEXTVAL. The detail record's "6567" is derived from the CURRVAL.
I have two queries, one that creates the header, the other the detail. I tried to use a UNION to put them together but I get an error saying I can't do this with a sequence. Does anyone know how I can do this using SQL?
Thanks in Advance,
Steve