Bleh i'm not Oracle guru, which I freely admit (and should be fairly clear from my question).
What i'm trying to do is create a flat file that will be used to insert data into a specific table on a duplicate DB to fill it up with test data.
The query i'm trying to do is as follows:
The problem I have is the order by. If I do a SELECT DISTINCT I have to add <fooZ> as a second output column (which isn't a big deal as I can just discard the second column later on) but the problem that i'm having is the ORDER By seems to break the union.
It's probably a very simple solution, but I admit it's something i'm not sure how to do.
What i'm trying to do is create a flat file that will be used to insert data into a specific table on a duplicate DB to fill it up with test data.
The query i'm trying to do is as follows:
Code:
SELECT
'INSERT INTO <TABLE_NAME> (A, B, C) VALUES ('''||<fooA>''', '''||<fooB>''', '''||<fooC>''');' AS INSERT_STATEMENT
WHERE <fooB> = XXX
ORDER BY <fooZ>
UNION ALL
SELECT 'COMMIT;' FROM dual
The problem I have is the order by. If I do a SELECT DISTINCT I have to add <fooZ> as a second output column (which isn't a big deal as I can just discard the second column later on) but the problem that i'm having is the ORDER By seems to break the union.
It's probably a very simple solution, but I admit it's something i'm not sure how to do.


Comment