请问在VC中通过ADO编程,怎么把Oracle里面的记录导出为excel文件或者文本文件?有什么直接的SQL语句吗?谢谢
------解决方案--------------------
把Oracle里面的记录导出为CSV
CONNECT scott/tiger@w2k1
CREATE OR REPLACE PROCEDURE EMP_CSV AS
CURSOR c_data IS
SELECT empno,
ename,
job,
mgr,
TO_CHAR(hiredate, 'DD-MON-YYYY ') AS hiredate,
sal,
comm,
deptno
FROM emp
ORDER BY ename;
v_file UTL_FILE.FILE_TYPE;
BEGIN
v_file := UTL_FILE.FOPEN(location => 'EXTRACT_DIR ',
filename => 'emp_csv.txt ',
open_mode => 'w ',
max_linesize => 32767);
FOR cur_rec IN c_data LOOP
UTL_FILE.PUT_LINE(v_file,
cur_rec.empno || ', ' ||
cur_rec.ename || ', ' ||
cur_rec.job || ', ' ||
cur_rec.mgr || ', ' ||
cur_rec.hiredate || ', ' ||
cur_rec.empno || ', ' ||
cur_rec.sal || ', ' ||
cur_rec.comm || ', ' ||
cur_rec.deptno);
END LOOP;
UTL_FILE.FCLOSE(v_file);
EXCEPTION
WHEN OTHERS THEN
UTL_FILE.FCLOSE(v_file);
END;
/
------解决方案--------------------
楼上的需要在oracle数据库服务器指定目录,如果用户想任意导出的话就不行了