如题 请高手指点
解决方案 »
- 查询某一个分区很慢
- asp.net+oracle开发项目,数据库session超值,帮帮忙,急!~高分
- 两台机器间的数据库迁移用什么方法最好
- oracle10g删除表为什么在管理器里还是能看到,用什么方法删除它(最好是命令)
- oracle客户端连接问题请大家帮忙
- 不用goto怎么实现?
- sql Develper 是个什么东东啊?它与Sqlplus 有什么关系没有啊?
- 发现变了星,放分.
- server 2008 oracle1521端口问题
- 数据量少时的select into和游标
- 问下 oracle备份的问题 oracle的一些面试基础问题?
- structured complex objects(构造的复杂对象)
或者sqlplus的spool
10/17/2005
By ITtoolbox Popular Q&A Team for ITtoolbox as adapted from Oracle-Apps-L discussion groupSummary:
I would like to export data from a table into Excel through PL/SQL scripts. Are there any codes available?Full Article:
Disclaimer: Contents are not reviewed for correctness and are not endorsed or recommended by ITtoolbox or any vendor. Popular Q&A contents include summarized information from ITtoolbox Oracle Applications discussion unless otherwise noted.1. Adapted from a response by venkay2 On Tuesday, September 06, 2005The following code may be helpful to you.v_OutPutFile :=
UTL_FILE.FOPEN(p_outfile_loc,p_file_name,'w');
p_file_name='test.csv'2. Adapted from a response by rafique On Wednesday, September 07, 2005We used the following PL/SQL code to convert table data to excel. Sample
code as follows.PROCEDURE EXCEL_FILE IScursor dtl is select * from accounts_icd order by auth_dt,ich_ven_cd;row_num number;
col_num number;
cell_val number;app_acc OLE2.OBJ_TYPE;
dbs OLE2.OBJ_TYPE;
dc OLE2.OBJ_TYPE;
args_acc OLE2.OBJ_TYPE;
app OLE2.OBJ_TYPE;
args OLE2.LIST_TYPE;
args2 OLE2.LIST_TYPE;
ws OLE2.OBJ_TYPE;
wb OLE2.OBJ_TYPE;
wss OLE2.OBJ_TYPE;
wbs OLE2.OBJ_TYPE;
cell OLE2.OBJ_TYPE;
ctr1 NUMBER := 0;
ctr2 NUMBER := 0;
ctr3 PLS_INTEGER := 0; --NUMBER := 0;
m_row number:=1;
m_len number:=0;m_flag number:=0;Begin---------------- Initialise Excelapp := OLE2.CREATE_OBJ('Excel.Application');
OLE2.SET_PROPERTY(app, 'Visible','True');
wbs := OLE2.GET_OBJ_PROPERTY(app,'Workbooks');
wb := OLE2.INVOKE_OBJ(wbs,'Add');
wss := OLE2.GET_OBJ_PROPERTY(app,'Worksheets');
ws := OLE2.INVOKE_OBJ(wss,'Add');---For I in 1..2 loopargs := OLE2.CREATE_ARGLIST;OLE2.ADD_ARG(args, m_row); --- Row
OLE2.ADD_ARG(args, I); --- Columncell := OLE2.GET_OBJ_PROPERTY(ws,'Cells', args);
OLE2.DESTROY_ARGLIST(args);if I=1 then
OLE2.SET_PROPERTY(cell, 'Value','Auth. Date');
elsif I=2 then
OLE2.SET_PROPERTY(cell, 'Value','ICD Doc.No');
end if;OLE2.RELEASE_OBJ(cell);
end loop;
--- Heading-- DataFor J in Dtl loopFor I in 1..2 loop-- Repeat Row
args := OLE2.CREATE_ARGLIST;OLE2.ADD_ARG(args, m_row); --- Row
OLE2.ADD_ARG(args, I); --- Columncell := OLE2.GET_OBJ_PROPERTY(ws,'Cells', args);
OLE2.DESTROY_ARGLIST(args);if I=1 then
OLE2.SET_PROPERTY(cell, 'Value',J.AUTH_DT);
elsif I=2 then
OLE2.SET_PROPERTY(cell, 'Value',J.ICD_DOC_NO);
end if
end loop
end loop
---- EndOLE2.RELEASE_OBJ(wbs);
OLE2.RELEASE_OBJ(ws);
OLE2.RELEASE_OBJ(wbs);
OLE2.RELEASE_OBJ(wb);
OLE2.RELEASE_OBJ(app);END;
Export Data into Excel using PL/SQL Scripts
spool test.txt
select 字段1||'&'||字段2||... from table .
spool off
然后EXCEL中有一个可以根据特殊字符把一行字符分开处理的功能.这要就直接导入了.我就是这样用的.
我用TOAD
一般第三方工具都有导入导出EXECL功能的