Compile my first Pro*C program — unloader from asktom

  • Read

These days I needed to export some tables to CSV files, and usually I could finish such task using SQLcl, but this time the table is too big (more than 120G) so although I still could export it with SQLcl, I also want to find a more efficient tool.

SQLULDR2 was the first tool I wanted to have a try, and I did try to make it work but got some errors about ORA-24345, and finally I decided to find other tool.

I found below webpage from Tom:

How Can I unload data to a flat file?

From this page I got the source code, while I did spend some time to make it work, and that is why I want to share my experience here.

  1. find your library path, usually under /usr/lib/gcc/x86_64-redhat-linux for RHEL/CentOS/Oracle Linux systems, for me it is /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include.
  2. Add the above path to the $ORACLE_HOME/precomp/admin/pcscfg.cfg
  3. Add below line to the head of the Pro*C source code: #include <stdlib.h>
  4. Try to compile it to C source code
    [oracle@oradump orajson]$ proc unload.pc
    Pro*C/C++: Release - Production on Thu Apr 27 18:24:14 2017
    Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.
    System default option values taken from: /oracle/base/12cR2/precomp/admin/pcscfg.cfg
  5. Try to build the C code to execute file
    gcc -I/oracle/base/12cR2/precomp/public -I/oracle/base/12cR2/xdk/include $ORACLE_HOME/lib/ unload.c -o sqluldr
  6. Unload the data as below example
    ./sqluldr userid=system/xxxxxxxx "sqlstmt=select USERID,to_char(ENDTIME),to_char(DATAVALUE,'fm99990.999999999999999999'),STATUSID from test" arraysize=100
  7. Please check your statement carefully, and convert date and double to char using to_char function.
  8. Compare some sample rows first to make sure you will not miss any valid data

  • by Published on 29/04/2017 00:10:51
  • Repost please keep this link:


Anonymous Write

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: