Link to home
Start Free TrialLog in
Avatar of angel7170
angel7170Flag for United States of America

asked on

PL/SQL export results into a table and Excel

Hello,

I have a PL/SQL that follows like below

1. Drop table A
2. Create table A with select statement
3. Drop table B
4. Create table B with select statement
5. Select * from table A that does not exist in Table B
6. Select * from Table B that does not exist in Table A
7. Select * from Table A and B that does not match values in certain columns

What I want to be able to do is

1. Drop table A
2. Create table A with select statement
3. Select count (*) from Table A and insert into a table C
4. Drop table B
5. Create table B with select statement
6. Select count (*) from Table B and inserts the count into Table C
7. Select * from table A that does not exist in Table B
8. Export the results into Excel spreadsheet
9. Select count (*) from table A that does not exist in Table B and inserts the count into Table C
10. Select * from Table B that does not exist in Table A
11. Export the results into Excel spreadsheet
12. Select count (*) from table B that does not exist in Table A and inserts the count into Table C
13. Select * from Table A and B that does not match values in certain columns
14. Export the results into Excel spreadsheet
15. Select count (*) from Table A and B that does not match values in certain columns and inserts the count into Table C

and of course I want to create a table C to hold all the counts.

Can someone please assist on how I can exporting the results to Excel?

Thank you
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Best way is to create a CSV file and load that into Excel.  Just spool out the results.

There are MANY string aggregation examples out there.

In 11g there is LISTAGG as long as the concatenated string is less than 4000 characters.

I like the XML version:
https://www.experts-exchange.com/questions/24120361/Simple-Query.html?anchorAnswerId=23572892#a23572892


For table c:
insert into tablec (select 'tableA count: ' || tochar(count(*)) from tablea);
Sorry, the XMLAGG example above takes a column and generates a CSV.

I have an example of taking a table's rows and generating a csv.  I'll post it when I find it.
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of angel7170

ASKER

Thank you .

I am getting an error when trying to execute XMLCAST.

Execution (121: 8): ORA-04030: out of process memory when trying to allocate 1032 bytes (qmxlu subheap,qmemNextBuf:alloc)
How many rows are being returned from the MINUS?
Can you post the table description?
What is your specific database version number (all 4 numbers please)?