我有一个存储过程,目前输出一个包含CSV的zip文件,这没有问题。
CREATE OR REPLACE PROCEDURE generate_fbdi_sp (
p_id_proceso_oic IN VARCHAR2,
p_source IN VARCHAR2,
p_file_reference IN VARCHAR2,
out_result OUT VARCHAR2,
out_message OUT VARCHAR2
) IS
--Query when all categories were found
CURSOR c_csv_fbdi IS
SELECT
status_code
|| ','
|| ledger_id
|| ','
|| effective_date_of_transaction
|| ','
|| journal_source
|| ','
|| journal_category
|| ','
|| currency_code
|| ','
|| journal_entry_creation_date
|| CHR(10) AS linea
FROM
int_dat_journals_fbdi_layout
WHERE
journal_source = p_source
AND id_proceso_oic = p_id_proceso_oic;
--variables
v_csv_line CLOB;
g_zipped_blob BLOB;
v_blob_csv_line BLOB;
BEGIN
--Iterate lines to create CSV File into CLOB variable 'v_csv_line'
FOR curr_line IN c_csv_fbdi LOOP
v_csv_line := v_csv_line || curr_line.linea;
END LOOP;
--Convert csv clob variable 'v_csv_line' to blob into variable 'v_blob_csv_line'
SELECT
clob_to_blob_fn(v_csv_line)
INTO v_blob_csv_line
FROM
dual;
--Zip FBDI file
as_zip.add1file(g_zipped_blob, 'GlInterface_'
|| replace(p_source, ' ', '_')
|| '_'
|| p_id_proceso_oic
|| '.csv', v_blob_csv_line);
--Close zip file
as_zip.finish_zip(g_zipped_blob);
--Insert csv file
INSERT INTO journals_fbdi (
file_name,
file_content,
id_proceso_oic,
file_name_cv027,
source
) VALUES (
'FBDI_'
|| replace(p_source, ' ', '_')
|| '_'
|| p_id_proceso_oic
|| '.zip',
g_zipped_blob,
p_id_proceso_oic,
p_file_reference,
p_source
);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
out_result := 'ERROR: ' || sqlerrm;
out_message := dbms_utility.format_error_backtrace;
END;
目前,该过程从表中获取所有记录(例如,单个文件中可以有五千条记录)并生成CSV。但现在他们要求我将其更改为每千条记录生成一个文件。
如何才能实现这一目标?
1条答案
按热度按时间9cbw7uwe1#
下面是修改后的代码,以处理您的任务。这是未经测试的,但你应该得到的一般想法。希望我能帮上忙。