UTF_FILE.PUT_LINEで特定の文字で異常終了
初めて投稿させていただきます。
あるシステムにて下記の事象が発生し、原因の調査を行っているのですが解決の糸口がつかめず困っております。
解決のきっかけを求めて有識者のご意見を聞きたいと思い、投稿いたしました。
よろしくお願いいたします。
■事象
UTF_FILE.PUT_LINEを使用してCSVファイルを出力する際に
「ORA-29285:ファイル書込みエラーが発生しました。」
のエラーが特定の文字列で発生することがある。
■質問内容
1.過去に同様の事象やその原因についてご存じないでしょうか。
2.ご存じの場合、どのように対処すればよいでしょうか。
3.ご存じでない場合、調査方法について良い方法はないでしょうか。
■構成
OS:Red Hat Enterprise Linux Server release 6.2(Santiago)
NLS_LANG:JAPANESE_JAPAN.AL32UTF8
Oracle:Oracle Database Standard Edition One 11.2.0.3.0
NLS_CHARACTERSET:AL32UTF8
■詳細
・エラーが発生する出力行の最後が「~作業台"←」(~:文字列の省略、←:改行コード(LF))
・出力行の最後が「~作業台"←」のレコードでも正常に出力されるレコードもある。
・エラーが発生したデータを使用して出力すると必ず同じレコードでエラーが発生する。(再現性有)
・エラーが発生したレコードのみを同一のプログラムでヘッダ行と合わせて2行だけ出力すると正常に出力される。
・エラーデータからエラーレコードを除いて出力すると、先ほどまでエラーとなっていなかった最後が「~作業台"←」のレコードでエラーが発生する。
・エラーデータのCSV出力項目の順序を入れ替えると正常に出力される。
(出力行の最後が指定の文字以外となるように変更した場合は正常に出力される。)
・アラートログ、トレースファイルには何も出力されていない。
・DBサーバの文字コードはUTF-8であるが、出力したCSVをユーザー様がWindowsクライアントで使用するため、CONVERT関数でSJISへの変換を行っている。
シェルスクリプトで変換を行うと変換できない文字があった場合にエラーとするか無視して変換(その文字が出力されない)となるが、
ユーザー様より「?」に変換して出力してほしいとの依頼があったため、プロシージャ内で変換を行っている。
・どのようなデータでも発生するのではなく大半のデータは正常に出力される。
エラー発生時もエラー直前のレコードまでは正常に出力されている。
そのため、ファイルパスの不整合やパーミッションの問題ではないという認識。
■ソース(一部抜粋)
1行ごとに下記の処理で出力しています。
FUNCTION OutputLine (
pv_buffer IN VARCHAR2
RETURN NUMBER IS
v_buffer VARCHAR2(32767) DEFAULT NULL; --出力文字列
n_rtn NUMBER; -- リターンコード
BEGIN
-- 出力文字列の文字コードをSJISに変換
v_buffer := CONVERT(pv_buffer, 'JA16SJISTILDE');
prc_put_line(
n_rtn , -- エラーコード
mfp_out_file , -- ファイルポインタ
v_buffer -- 出力文字列
IF n_rtn <> constant.N_0 THEN
RAISE APP_ERROR; -- 独自定義の例外
END IF;
RETURN 0;
EXCEPTION
WHEN OTHERS THEN
RETURN 9;
END OutputLine;
PROCEDURE prc_put_line(
pn_Rtn OUT NUMBER , -- 戻り値
pf_Fp IN UTL_fILE.FILE_TYPE , -- ファイルポインタ
pv_Data IN VARCHAR2 -- 1行に記述されるデータ
) IS
BEGIN
-- フィールドデータの書込み処理
UTL_FILE.PUT_LINE( pf_Fp , pv_Data );
-- 正常終了
pn_Rtn := 0;
EXCEPTION
WHEN OTHERS THEN
-- 異常終了
pn_Rtn := 9;
END prc_put_line ;
■出力文字列例(1行が上記ソースのpv_bufferに当たる)
"品目コード","品目名称","メーカーコード","商品ランク","公開フラグ","分類コードA","分類コードB","分類コードC","分類コードD","2013年度分類コードA","2013年度分類名称A","2013年度分類コードB","2013年度分類名称B","2013年度分類コードC","2013年度分類名称C","2013年度分類コードD","2013年度分類名称D"
"AKDTH23957 4526 ","トーサン ステンレス作業台キャスター付","0000845623","","1 ","F ","20","34","1934 ","F","物流保管用品","20","作業台","34","ステンレス作業台","1934","ステンレス作業台"
user12075536123様
> リンク先の中で改行コードの出力について触れられておりましたので、
> Oracleまかせで改行コードを出力せず、プロシージャ内で明示的に指定して出力を試してみようと思います。
> ・UTL_FILE.PUT_LINE → UTL_FILE.PUT に変更
> ・出力文字列の最後に「CHR(13) || CHR(10)」を追加
これだけの修正でエラーが発生しなくなるかも知れません。
テストしていたら結果を教えて下さい。
テストを実施してみました。結果としてはエラー解消されました!
ただ、記載していた変更のみではダメでしたので、試してみた修正内容と結果を記載します。
■修正内容
【パターン1】改行コードを明示的に出力
・UTL_FILE.PUT_LINE → UTL_FILE.PUT に変更
・出力文字列の最後に「CHR(13) || CHR(10)」を追加
【パターン2】改行コードを明示的に出力(その2:1行のバッファ解放処理を追加)
・UTL_FILE.PUT_LINE → UTL_FILE.PUT に変更
・出力文字列の最後に「CHR(13) || CHR(10)」を追加
・UTL_FILE.PUT の実行直後に UTL_FILE.FFLUSH を実行
【パターン3】改行コードを文字列の出力とは別でOracleまかせで出力
・UTL_FILE.PUT_LINE → UTL_FILE.PUT に変更
・UTL_FILE.PUT の実行直後に UTL_FILE.NEW_LINE を実行
■結果
【パターン1】
エラーは発生せず、全レコードの処理がされたが、出力されたファイルには途中のレコードまでしか出力されていなかった。
どうもPUTの1行のバッファサイズ(32K)までしかファイル出力されなかったよう。
【パターン2】
パターン1を踏まえてバッファを解放する処理を追加したところ、エラー無く全レコードが正しく出力された、
【パターン3】
文字列と別に改行の処理をすれば正常に出力されるのではないかと考え、実施。
エラーは発生せず、全レコード出力されたが、当初エラーとなっていたレコードの終端文字が不正な文字に置き換わっていた。
本来の出力文字列 :「~作業台"←」
出力された文字列 :「~作業▲△△←」
(~:文字列の省略、▲:文字コード「8a」の文字(※)、△:半角スペース←:改行コード)
※SJISには存在しない、後ろの半角スペースと合わせて全角文字としても存在しない
結果としてパターン2で解決できそうですので、これでこの質問はクローズしようと思います。
user12075536123様、本当にありがとうございました。
Similar Messages
-
I was told I was able to generate out a CSV file through UTL_FILE method. Can someone provide the skeleton of how should I create it in PL/SQL?
I tried google search but it only says in words and not code itself.
I have this PL/SQL that I will want to generate a CSV file.
SET SERVEROUTPUT ON;
SET TIMING ON;
DECLARE
CURSOR C1
IS
select balance from contract ;
BEGIN
FOR i IN C1 LOOP
IF i.balance <> '0' THEN
DBMS_OUTPUT.PUT_LINE('Amount is not 0 ');
I will like to put the statement 'Amount is not 0 ' in a CSV file here
else
DBMS_OUTPUT.PUT_LINE('Amount is 0 ');
END IF;
end loop;
END;
/How am I suppose to do this?
Edited by: JoannaLee on Aug 26, 2008 7:14 PMYour question is a bit confusing. In your subject line, and again in your question, you talk about generating a CSV file. That is a file of comma-separated values (hence the acryonym). But your question seems to be asking about generating a file with a sentence in it-- that would be a flat file but not a CSV file.
The links that were provided show you exactly how to generate a CSV file based on an arbitrary query.
If you are not looking to generate a CSV file, and instead you just want to generate a flat file to which you can write data, you'd just need to use the UTL_FILE package. Assuming you're on a recent version of Oracle, you would need to create a directory object, i.e.
CREATE DIRECTORY directory_name AS 'path_to_directory_on_database_server'Then you'd grant privileges on that directory object to whatever user will own the procedure that wants to write to the directory
GRANT read, write ON directory_name TO some_userIn your code, you'd just need to open the file and write to it
DECLARE
l_file utl_file.file_type;
BEGIN
l_file := utl_file.fopen( 'DIRECTORY_NAME', 'name_of_file', 'w' );
<<Other code>>
utf_file.put_line( l_file, 'String you want to write to the file' );
<<More code>>
utl_file.fclose( l_file );
END;Justin -
Hello
I will explain the scenario:
In our java web page, we are using three text boxes to enter "Part number,Description and Aircraft type". Every time the user no need to enter all these data. The person can enter any combination of data or only one text box. Actually the output data corresponding to this input entries is from five Oracle table. If we are using a single query to take data from all the five tables, the database will hang. So I written a procedure "SEARCH1",this will accept any combination of values (for empty values we need to pass NULL to this procedure) and output data from all the five tables. When I executing this procedure in SQL editor, the execution is very fast and giving exact result. I used "dbms_output.put_line" clause for outputing multiple records in my procedure. The output variables are "Serial No, part Number, Description, Aircraft type,Part No1,Part No2,Part No3,Part No4". I want to use the same procedure "SEARCH1" for outputing data in java web page.The passing argument I can take from the text box provided in java web page. I am using jdbc thin driver to connect our java web page to Oracle 9i database.
Note1 : If any combination of search item not available, in procedure itself I am outputing a message like "Part Number not found". Here I am using four words ("Part" is the first word,"Number" is the second,"Not" s the third, and "found" is the fourth) for outputing this message.Is it necessary to equalise number of words I am using here to the record outputing eight variable?
Our current development work is stopped because of this issue. So any one familier in this field,plese help me to solve our issue by giving the sample code for the same scenario.
My Email-id is : [email protected]
I will expect yor early mail.
With thanks
Pramod kumar.Hello Avi,
I am trying to solve this issue by using objects. But the following part of code also throwing some warning like "PLS-00302: component must be declared". Plese cross check my code and help me to solve this issue.
drop type rectab;
create or replace type rectype as object(PartNo varchar2(30),Description varchar2(150),AIrcraft_type varchar2(15),status_IPC varchar2(30),status_ELOG varchar2(30),status_SUPCAT varchar2(30),status_AIRODWH varchar2(30));
create or replace type rectab as table of rectype;
create or replace package ioStructArray as
procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab);
end ioStructArray;
create or replace package body ioStructArray as
procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab) is
mdescription varchar2(150);
mpartnum varchar2(30);
mpno varchar2(30);
mdes varchar2(150);
mair varchar2(15);
mstat varchar2(1);
cursor c1 is select partnum,description,aircraft_type from master_catalog where partnum=mpno and aircraft_type=mair and description like ltrim(rtrim(mdes))||'%';
cursor c2 is select partnum from ipc_master where partnum=mpartnum;
cursor c3 is select partnum from fedlog_data where partnum=mpartnum;
cursor c4 is select partnum from superparts where partnum=mpartnum;
cursor c5 is select part_no from supplier_catalog where part_no=mpartnum;
mpno1 varchar2(30);
mpno2 varchar2(30);
mpno3 varchar2(30);
mpno4 varchar2(30);
mpno5 varchar2(30);
maircraft_type varchar2(15);
mstat1 varchar2(30);
mstat2 varchar2(30);
mstat3 varchar2(30);
mstat4 varchar2(30);
begin
mstat:='N';
mpno:=pno;
mdes:=pdes;
mair:=air;
if mpno is not null and mdes is not null and mair is not null then
begin
mstat:='N';
mpno:=pno;
mdes:=pdes;
mair:=air;
for i in c1 loop
mstat:='N';
mstat1:='N';
mstat2:='N';
mstat3:='N';
mstat4:='N';
mpno1:=i.partnum;
mpartnum:=i.partnum;
mdescription:=i.description;
maircraft_type:=i.aircraft_type;
for j in c2 loop
mpno2:=j.partnum;
end loop;
for k in c3 loop
mpno3:=k.partnum;
end loop;
for l in c4 loop
mpno4:=l.partnum;
end loop;
for m in c5 loop
mpno5:=m.part_no;
end loop;
if mpno2=mpartnum then
mstat1:=mpno2;
end if;
if mpno3=mpartnum then
mstat2:=mpno3;
end if;
if mpno4=mpartnum then
mstat3:=mpno4;
end if;
if mpno5=mpartnum then
mstat4:=mpno5;
end if;
if mpno1=mpartnum then
mstat:='Y';
orec.PartNo:=mpno1;
orec.Description:=mdescription;
orec.AIrcraft_type:=maircraft_type;
orec.status_IPC:=mstat1;
orec.status_ELOG:=mstat2;
orec.status_SUPCAT:=mstat3;
orec.STATUS_AIRODWH:=status_AIRODWH;
end if;
end loop;
end;
end if;
end testsch2;
end ioStructArray;
Expecting your early reply.
With thanks
Pramod kumar. -
Concurrent HOST program calling a proc to log using fnd_file.put_line
Hello all,
I have a concurrent HOST program that does 3 main things
1. Calls a sqlplus program to do some initializing. This program is a proc in a package.
2. Runs sqlldr to load data to custom tables.
3. Calls a sqlplus program to do manipulate the data. This program is a proc in a package.
In step 3 of above, the package procedue does a "submit_request" to call the "Supplier Open Interface Import". This
request actually fires. However my problem is the subsequent call to fnd_file.put_line(fnd_file.log, 'Test message'), does not get logged
to the log file of the HOST program, nor to the log file of the "Supplier Open Interfface Import" log file. A check
of $APPLPTMP (or /usr/tmp) shows that a file of say " l0023761.tmp" contains my 'Test message' text.
I believe the problem is that the put_line() call has no association with the HOST or the "Supplier Open Interface Import. How
do I associate the logging to either program? Is it even possible? I want the logging, so as to see the progress
of the HOST program.
The sniippet of proc code is:
PROCEDURE abc() IS
BEGIN
request_id:= FND_REQUEST.SUBMIT_REQUEST
(Application => 'SQLAP'
,Program => 'APXSUIMP'
,Description => NULL
,Start_time => SYSDATE
,Sub_Request => FALSE
,Argument1 => 'ALL'
,Argument2 => 1000
,Argument3 => 'N'
,Argument4 => 'N'
,Argument5 => 'N'
fnd_file.put_line (fnd_file.log,'Test message');
COMMIT;
END abc;
Alex.Shell scripts are very hard to develop and maintain. Many things that developers previously had to do in shell scripts, developers can now do in PL/SQL. Hence, I recommend that you avoid shell scripts as much as possible.
As well, SQL*Loader is an old, inflexible tool. Instead, define your OS file as an external table, and then extract from the external table using a normal select statement. http://www.orafaq.com/node/848 I recommend that you avoid SQL*Loader and use external tables instead.
Using PL/SQL and external tables - and avoiding the shell script and SQL*Loader - a much better way to accomplish the same thing all inside one packaged procedure that is registered as a concurrent program:
- initialize
- select from the external table
- manipulate the data -
PL/SQL function not showing DMBS_OUTPUT.PUT_LINE result
I have compiled a function and when I call it, the DMBS value is not shown.
I have set serveroutput on
I am using 9i.
The function completes and provides a result:
SQL> select textrawio.HEXTONUM('0D') from dual;
TEXTRAWIO.HEXTONUM('0D')
13
The script:
CREATE OR REPLACE PACKAGE BODY textrawio
AS
FUNCTION hextonum(v_hex VARCHAR2) RETURN NUMBER
IS
hex VARCHAR2(4);
num NUMBER;
num1 NUMBER;
num2 NUMBER;
BEGIN
dbms_output.put_line ('hello');
hex := SUBSTRB(v_hex,1,1);
IF ( hex >= '0' and hex <= '9' ) THEN
num1 := TO_NUMBER(hex);
END IF;
IF hex = 'A' TH...Any ideas from this snippet?
I have never had a prob with DBMS_OUTPUT previously.
There is no DMBS_OUTPUT_GET_LINE code.The full PL/SQL is
CREATE OR REPLACE PACKAGE TEXTRAWIO
IS
FUNCTION tidblobchar(v_object_id char) RETURN VARCHAR2;
END; -- Package Specification TEXTRAWIO
SET SERVEROUTPUT ON
CREATE OR REPLACE PACKAGE BODY textrawio
AS
FUNCTION tidblobchar(v_object_id char) RETURN VARCHAR2
-- This function converts the long raw column of TIDBLOB to
-- its character representation for manipulation.
-- It can only be called for an object type of T.
IS
raw_data LONG RAW;
rawlen NUMBER;
hex_data VARCHAR2(32760);
char_data VARCHAR2(32760);
loop_counter NUMBER;
BEGIN
-- Get the blob using the rowid passed in.
-- Will always retrun only one row.
dbms_output.put_line ('1');
SELECT data
INTO raw_data
FROM ifsapp.client_profile_load
WHERE v_object_id = rowid;
dbms_output.put_line ('2');
-- Convert the raw data to hex.
hex_data := rawtohex(raw_data);
rawlen := length(hex_data);
loop_counter := 1;
dbms_output.put_line ('3');
-- Loop through and convert the hex to characters.
WHILE loop_counter <= rawlen LOOP
char_data := char_data || CHR(to_number(SUBSTRB(hex_data,loop_counter,2),'xx'));
loop_counter := loop_counter + 2;
END LOOP;
RETURN char_data;
END;
END;
/Both parts compile but when I run it:
SQL> select
2 user_name, profile_name, data_length, textrawio.tidblobchar(rowid) data, timestamp
3 from ifsapp.client_profile_load
4 where data is not null
5 ;
user_name, profile_name, data_length, textrawio.tidblobchar(rowid) data, timestamp
ERROR at line 2:
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "IFSAPP.TEXTRAWIO", line 18I was hoping to use DBMS_OUTPUT to find which is the actual line having the error and later, what values it was dealing with.
Thanks -
Dbms_output.put_line not printing in inner for loop using a parameter
I cannot get the inner loop to print output. I can run both loops independent (hardcoding a value for the inner loop) Any help is apprecicated... Listed is the code
set serveroutput on
DECLARE
cursor ACCNO_CUR is
select accession_number from didb_studies where insert_time > to_date('02-JUN-12');
cursor PATH_CUR (p1_accno VARCHAR2) is
select distinct l.FILE_SYSTEM || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),1,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),4,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),7,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),10,3) || '/' ||
s.STUDY_DB_UID || '/' || i.SERIES_DB_UID || '/'||
i.RAW_IMAGE_DB_UID || '.img' as FULLY_QUALIFIED_IMAGE_NAME
, l.image_size
, i.image_need_backup
, i.sop_class_uid
from medistore.didb_studies s
, medistore.didb_raw_images_table i
, medistore.didb_image_locations l
where s.accession_number = 'p1_accno'
and s.study_db_uid = i.study_db_uid
and i.raw_image_db_uid = l.raw_image_db_uid
and l.file_system is not null and INSTR(l.file_system, '.img') = 0
UNION
select distinct(l.FILE_SYSTEM) as FULLY_QUALIFIED_IMAGE_NAME
, l.image_size
, i.image_need_backup
, i.sop_class_uid
from medistore.didb_studies s, medistore.didb_raw_images_table i,
medistore.didb_image_locations l
where s.accession_number = 'p1_accno'
and s.study_db_uid = i.study_db_uid
and i.raw_image_db_uid = l.raw_image_db_uid
and l.file_system is not null and INSTR(l.file_system, '.img') > 0
order by 1;
BEGIN
FOR accno_rec in accno_cur LOOP
DBMS_OUTPUT.put_line('ACCESSION_NUMBER is: '|| accno_rec.accession_number);
FOR path_rec in path_cur(accno_rec.accession_number) LOOP
DBMS_OUTPUT.put_line('Inner loop accession_number is :'||accno_rec.accession_number);
DBMS_OUTPUT.put_line('Full path is : ' || path_rec.FULLY_QUALIFIED_IMAGE_NAME);
END LOOP;
END LOOP;
END;Maybe
DECLARE
cursor ACCNO_CUR is
select accession_number
from didb_studies
where insert_time > to_date('02-JUN-12');
cursor PATH_CUR (p1_accno VARCHAR2) is
select distinct
l.FILE_SYSTEM || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),1,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),4,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),7,3) || '/' ||
substr(LPAD(s.PATIENT_DB_UID, 12, '0'),10,3) || '/' ||
s.STUDY_DB_UID || '/' || i.SERIES_DB_UID || '/'||
i.RAW_IMAGE_DB_UID || '.img' as FULLY_QUALIFIED_IMAGE_NAME,
l.image_size,
i.image_need_backup,
i.sop_class_uid
from medistore.didb_studies s,
medistore.didb_raw_images_table i,
medistore.didb_image_locations l
where s.accession_number = to_number(p1_accno) /* to_char(s.accession_number) = p1_accno */
and s.study_db_uid = i.study_db_uid
and i.raw_image_db_uid = l.raw_image_db_uid
and l.file_system is not null
and INSTR(l.file_system, '.img') = 0
UNION
select distinct
l.FILE_SYSTEM as FULLY_QUALIFIED_IMAGE_NAME,
l.image_size,
i.image_need_backup,
i.sop_class_uid
from medistore.didb_studies s,
medistore.didb_raw_images_table i,
medistore.didb_image_locations l
where s.accession_number = to_number(p1_accno) /* to_char(s.accession_number) = p1_accno */
and s.study_db_uid = i.study_db_uid
and i.raw_image_db_uid = l.raw_image_db_uid
and l.file_system is not null and INSTR(l.file_system, '.img') > 0
order by 1;
BEGIN
FOR accno_rec in accno_cur
LOOP
DBMS_OUTPUT.put_line('ACCESSION_NUMBER is: '|| accno_rec.accession_number);
FOR path_rec in path_cur(accno_rec.accession_number)
LOOP
DBMS_OUTPUT.put_line('Inner loop accession_number is :'||accno_rec.accession_number);
DBMS_OUTPUT.put_line('Full path is : ' || path_rec.FULLY_QUALIFIED_IMAGE_NAME);
END LOOP;
END LOOP;
END;Regards
Etbin -
TEXT_IO.PUT_LINE resulting in partial file at a consistant size of 40KB
Overview:
In client server mode the report opens a file on the desktop, writes a tab delimited text line for a specific repeating frame and then closes the file. However, the resulting file is incomplete but the previewer displays the compete report with no error. The first 40K contains text lines that are OK and then the output just stops at one line at the 40K threshold even if I change the data model query to select different data. This appears to be a max size buffer size but I'm not sure. I know that the UTL_FILE on the database contains a FFLUSH function but no such function exists for TEXT_IO. Hum...
Any ideas?
Report Text_io steps:
1. After Form trigger:
s_file.out_file := TEXT_IO.FOPEN('c:\temp\output_file.tab', 'W');
2. Repeating frame format trigger:
buf:='';
buf:=to_char(nvl(:QTY,0))||CHR(9);
buf:=buf || to_char(nvl(:M_PRICE1,0))||CHR(9);
TEXT_IO.PUT_LINE(s_file.out_file,buf);
3. After Report trigger:
TEXT_IO.FCLOSE(s_file.out_file);I seem to recall having a similar problem. I thought it was that the after report trigger was not firing properly (i.e. at all).
I solved it by putting a field at the end of the report (outside the topmost repeating frame) and attaching the code to that -
How to Populate a table with DBMS_OUTPUT.put_line
Hey Guys, it's Xev.
Please only pleasant people reply to this.
I have a PL/SQL Program that searches for strings and then at the end of it it prints out to DBMS_OUTPUT.put_line.
I have the owner, the table_name, the column name and the count, then it goes to DBMS_OUTPUT.put_line
What i want to do, is take the results of DBMS_OUTPUT.put_line and insert it into a table.
Here is the script I am talking about, as you can see it's simple, yet for me it works. I want to take the results of this and insert it into a table. How can i do that??
set serveroutput on size unlimited
execute DBMS_OUTPUT.ENABLE (buffer_size => NULL);
DECLARE
FND_GOVIDS INTEGER;
BEGIN
FOR t IN (SELECT owner, table_name, column_name
FROM all_tab_columns
WHERE owner = upper('&SCHEMA_NAME'))
LOOP
BEGIN
EXECUTE IMMEDIATE 'with a as ( select case when REGEXP_LIKE(' || t.column_name ||
--This searches for 8 Alpha Digits
',''^([[:alpha:]]{2}|[[:alpha:]]{4})?[ ]?[0-9]{8}[ ]?([[:alpha:]]{2}|[[:alpha:]]{4})?$'')
then ''Match Found''
else ''No Match Found'' end as output from ' || t.owner || '.' || t.table_name || ')
select count(*) from a where a.output=''Match Found'' '
INTO FND_GOVIDS ;
IF FND_GOVIDS > 0 THEN
DBMS_OUTPUT.put_line (
t.owner
|| '.'
|| t.table_name
|| ' '
|| t.column_name
|| ' '
|| FND_GOVIDS);
END IF;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Generic Error '
|| t.column_name
|| ' from '
|| t.owner
|| '.'
|| t.table_name);
END;
END LOOP;
END;Nope, the table is empty....
But it ran without error??!?! Wait a minute, I think i have to commit right? Since it's not straight sql, ok, that's what I am going to try..
set serveroutput on size unlimited
execute DBMS_OUTPUT.ENABLE (buffer_size => NULL);
DECLARE
FND_GOVIDS INTEGER;
BEGIN
FOR t IN (SELECT owner, table_name, column_name
FROM all_tab_columns
WHERE owner = upper('&SCHEMA_NAME'))
LOOP
BEGIN
EXECUTE IMMEDIATE 'with a as ( select case when REGEXP_LIKE(' || t.column_name ||
--This searches for 6 Alpha Digits
',''^([[:alpha:]]|[[:alpha:]]{3})[0-9]{6}$'')
then ''Match Found''
else ''No Match Found'' end as output from ' || t.owner || '.' || t.table_name || ')
select count(*) from a where a.output=''Match Found'' '
INTO FND_GOVIDS ;
/*Table insert for resulting */
IF FND_GOVIDS > 0 THEN
INSERT INTO "SMEG"."DYNAMIC_COUNTS" (T_OWNER, T_TABLE_NAME, T_COLUMN_NAME, FND_GOVIDS) VALUES
('t.owner','t.table_name','t.column_name','FND_GOVIDS');
END IF;
/* dbms_output */
IF FND_GOVIDS > 0 THEN
DBMS_OUTPUT.put_line (t.owner || '.' || t.table_name || ' ' || t.column_name || ' ' || FND_GOVIDS);
END IF;
/* Exception Handeling */
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Generic Error '
|| t.column_name
|| ' from '
|| t.owner
|| '.'
|| t.table_name);
END;
END LOOP;
END; -
I am using Oracle 10.1.0.4.2 SQL Plus, and dbms_output.put_line is not working. It returns the dbms_output ONLY from outside the procedure. I have dbms_output INSIDE my procedure, and none of it gets returned. Please help!
Here is what I enter:
set serveroutput on size 1000000;
DECLARE
x number:=0;
begin
DBMS_OUTPUT.ENABLE;
c2reports.c2proc(x,'TEST');
DBMS_OUTPUT.PUT_LINE('testX');
END;
testX
There should be more besides the 'testX' that gets returned. The first line in my procedure has output code to print testY. Thanks in advance!This is the forum for the Oracle's SQL Developer (Not for general SQL/PLSQL questions). You should ask question like this in the PL/SQL forum
-
Printing messages in Log File and Output File using Dbms_output.put_line
Hi,
I have a requirement of printing messages in log file and output file using dbms_output.put_line instead of fnd_file.put_line API.
Please let me know how can I achieve this.
I tried using a function to print messages and calling that function in my main package where ever there is fnd_file.put_line. But this approach is not required by the business.
So let me know how I can achieve this functionality.
Regards
SandyWhat is the requirement that doesn't allow you using fnd_file.put_line?
Please see the following links.
https://forums.oracle.com/forums/search.jspa?threadID=&q=Dbms_output.put_line+AND+Log+AND+messages&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
https://forums.oracle.com/forums/search.jspa?threadID=&q=%22dbms_output.put_line+%22+AND+concurrent&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein -
How to print extract value in dbms_output.put_line
CREATE OR REPLACE PROCEDURE pr_srch_data
AS
xml_data_val xmltype:=null;
vPropertyName clob;
vstr varchar2(1000);
operation varchar2(1000);
vQuery VARCHAR2(4000):=NULL;
vQry VARCHAR2(4000):=NULL;
vPartyid VARCHAR2(2000):=NULL;
vPerson varchar2(4000);
BEGIN
FOR I IN (SELECT EAPP_XML_DATA
FROM binary_xml
WHERE extractvalue(eapp_xml_data,'/OLifE/Party[@id="Party1"]/Person/LastName') Like 'Rajesh%'
LOOP
BEGIN
SELECT extractvalue(value(t),'/Relation/@RelatedObjectID')
INTO vPartyid
FROM TABLE (XMLSEQUENCE (EXTRACT (xml_data_val,'/OLifE/Relation'))) t
WHERE extractvalue(value(t),'/Relation/RelationRoleCode')='Owner'
AND existsnode(value(t),'/Relation/@RelatedObjectID')=1 ;
END;
SELECT extract(value(t),'/OLifE/Party[@id='''||vPartyid ||''']/Person')
INTO vPerson
FROM TABLE (XMLSEQUENCE (EXTRACT (I.EAPP_XML_DATA,'/OLifE')))t;
dbms_output.put_line('vPerson'||'--'||vPerson);
END LOOP;
END;
But when i am printing vPerson i am getting error. I need to print that extract value.Things to remember (that you should know by now)
Please remind us of which version of 11g you are using in this post and all future posts.
Look at the FAQ under your sign-in name to see how to use the tag to retain formatting of your code as you have seen our examples to you look like.
We can't see your screen or your data so how about the error message and some data from your table?
Please start using either XMLTable or XMLCast/XMLQuery as odie_63 as shown you.
What are you trying to do? -
Dear Experts,
My Requirement is to have Debug of Concurrent Program using FND_FILE.PUT_LINE(FND_FILE.OUTPUT,'<some text>'):
i have Following code
IF lb_reservation_completed THEN
fnd_file.put_line(fnd_file.output ,'');
fnd_file.put_line(fnd_file.output,'RESERVATION COMPLETED');
COMMIT;
ELSE
fnd_file.put_line(fnd_file.output ,'');
fnd_file.put_line(fnd_file.output ,'RESERVATION REVERTED BACK SINCE COMPLETE QUANTITY OF BOM ITEMS ARE NOT AVAILABLE');
ROLLBACK;
END IF;
the text in red does not get printed even if conditions lb_reservation_completed is false
however the transaction is rolled back, and the requirement of My object is to print this statement for Debugging purpose.
and text in Blue gets printed everytime .
i tried by removing Rollback , it did not work.
any Suggestion are welcome.
Thanks in advance
Abdul Rahman
Edited by: Abdul Rahman Gerab on Nov 24, 2008 2:13 AMDear Sir,
thanks for your message, this time we coded it explicitly to
IF lb_reservation_completed = TRUE THEN
COMMIT;
ELSIF lb_reservation_completed = FALSE THEN
ROLLBACK;
END IF;
and it gave this error
**Starts**24-NOV-2008 15:54:50
ORACLE error 20100 in FDPSTP
Cause: FDPSTP failed due to ORA-20100: File o0026657.tmp creation for FND_FILE failed.
You will find more information on the cause of the error in request log.
ORA-06512: at "APPS.FND_FILE", line 396
ORA-06512
one more question, i have this complete IF clause in a loop.
Does Having Rollback in LOOP play this kind of error.
lemme try by keeping commit and rollback outside loop
will update now .
thanks again for your message, if you have any suggestion please do inform. -
Hello,
I'm trying to export a CLOB field to a txt file. It's a xml string in the CLOB. I have used different methods but the only which i can use is PUT, PUT_LINE.
But:
- PUT does only export the 32565 characters. I see that the output of l_pos is 4202084 but these are not exported. I have tried FFLUSH, but this gives a error or my syntax is not correct.
- PUT_LINE is exporting the complete CLOB, but after every 32656 is new line is added and if I want to look with altove then I have to remove 129 times the new line. Thats not the way I want to go.
Is it an idea, if it is possible, that I write 32565 chars to the buffer (file), read these 32565 from the buffer minus one (=without \r\n), delete the last 32565 chars from buffer and append/put the chars 32565 minus the \r\n to the buffer again. I hope there will be a better idea but....
Has anybody an idea how I can solve this? Or what do I wrong?
Any help would be appreciated.
Beneath my code.
Nico
CREATE OR REPLACE DIRECTORY documents AS 'D:\TEST';
SET SERVEROUTPUT ON
DECLARE
l_file UTL_FILE.FILE_TYPE;
l_clob CLOB;
l_buffer VARCHAR2(32767);
l_amount BINARY_INTEGER := 32565;
l_pos INTEGER := 1;
l_lengte number;
l_lineCount number := 0;
BEGIN
SELECT PAYLOAD
INTO l_clob
FROM icepayloadext ext
WHERE EXT.PAYLOADTYPE in ('POST')
AND substr(payload, 0, 2000) like '%181015%'
AND ext.LSTIME between to_date('10-10-2012 00:00:00', 'dd-mm-rrrr HH24:mi:ss') and to_date('10-10-2012 17:30:00', 'dd-mm-rrrr HH24:mi:ss');
l_lengte := DBMS_LOB.GETLENGTH (l_clob);
DBMS_OUTPUT.PUT_LINE('lengte clob veld: ' || l_lengte);
l_file := UTL_FILE.fopen('DOCUMENTS', 'Sample1.txt', 'w', 32767);
LOOP
DBMS_LOB.read (l_clob, l_amount, l_pos, l_buffer);
UTL_FILE.PUT(l_file, l_buffer);
UTL_FILE.FFLUSH (l_file);
--UTL_FILE.PUT_LINE(l_file,'alles geschreven');
l_pos := l_pos + l_amount;
DBMS_OUTPUT.PUT_LINE('Offset position: ' || l_pos);
if (l_pos > l_lengte) then
exit;
end if;
END LOOP;
UTL_FILE.fclose(l_file);
--EXCEPTION
--WHEN OTHERS THEN
-- DBMS_OUTPUT.put_line(SQLERRM);
--UTL_FILE.fclose(l_file);
END;
/You can always try it the binary way:
DECLARE
l_file UTL_FILE.FILE_TYPE;
l_clob CLOB;
l_buffer VARCHAR2(32767);
l_amount BINARY_INTEGER := 32565;
l_pos INTEGER := 1;
l_lengte number;
l_lineCount number := 0;
BEGIN
l_clob := rpad( to_clob( 'test' ), 60000, 'test' );
l_lengte := DBMS_LOB.GETLENGTH (l_clob);
DBMS_OUTPUT.PUT_LINE('lengte clob veld: ' || l_lengte);
l_file := UTL_FILE.fopen( 'MY_DIR', 'Sample1.txt', 'wb', 32767 );
LOOP
begin
DBMS_LOB.read (l_clob, l_amount, l_pos, l_buffer);
exception
when no_data_found then exit;
end;
-- UTL_FILE.PUT_RAW( l_file, utl_raw.cast_to_raw( l_buffer ) ); -- file in database character set
UTL_FILE.PUT_RAW( l_file, utl_i18n.string_to_raw( l_buffer, 'WE8MSWIN1252' ) );
l_pos := l_pos + l_amount;
DBMS_OUTPUT.PUT_LINE('Offset position: ' || l_pos);
END LOOP;
UTL_FILE.fclose(l_file);
END;Anton -
We need to export a large amount of data from some Oracle tables to be uploaded into a Sybase database using BCP. I had no issues exporting the data using the PUT_LINE command using the open command below.
l_file := utl_file.fopen( l_dir, l_name, 'W',32767);
The problem is, we do not want to use system's default line terminators because our data may contain embedded line terminators; We want to defined our own line terminators. But when we changed from UTL_FILE.PUT_LINE to UTL_FILE.PUT the application will run for a few seconds and then produce the following errors:
ORA-29285: file write error
ORA-06512: at "SYS.UTL_FILE", line 77
ORA-06512: at "SYS.UTL_FILE", line 690
ORA-06512: at "ADVCONV.P_WRITE", line 244
ORA-06512: at line 2.
If I use UTL_FILE.PUT to export smaller tables these errors do not occur so it looks like our data is larger then some limit. Does anyone have any suggestions/solutions? Thanks893730 wrote:
We need to export a large amount of data from some Oracle tables to be uploaded into a Sybase database using BCP. I had no issues exporting the data using the PUT_LINE command using the open command below.
l_file := utl_file.fopen( l_dir, l_name, 'W',32767);
The problem is, we do not want to use system's default line terminators because our data may contain embedded line terminators; We want to defined our own line terminators. But when we changed from UTL_FILE.PUT_LINE to UTL_FILE.PUT the application will run for a few seconds and then produce the following errors:
ORA-29285: file write error
ORA-06512: at "SYS.UTL_FILE", line 77
ORA-06512: at "SYS.UTL_FILE", line 690
ORA-06512: at "ADVCONV.P_WRITE", line 244
ORA-06512: at line 2.
If I use UTL_FILE.PUT to export smaller tables these errors do not occur so it looks like our data is larger then some limit. Does anyone have any suggestions/solutions? Thanks
>We need to export a large amount of data from some Oracle tables to be uploaded into a Sybase database using BCP. I had no issues exporting the data using the PUT_LINE command using the open command below.
l_file := utl_file.fopen( l_dir, l_name, 'W',32767);
The problem is, we do not want to use system's default line terminators because our data may contain embedded line terminators; We want to defined our own line terminators. But when we changed from UTL_FILE.PUT_LINE to UTL_FILE.PUT the application will run for a few seconds and then produce the following errors:
ORA-29285: file write error
ORA-06512: at "SYS.UTL_FILE", line 77
ORA-06512: at "SYS.UTL_FILE", line 690
ORA-06512: at "ADVCONV.P_WRITE", line 244
ORA-06512: at line 2.
If I use UTL_FILE.PUT to export smaller tables these errors do not occur so it looks like our data is larger then some limit. Does anyone have any suggestions/solutions? Thanks
consider using PUT_RAW instead of PUT_LINE -
PLS-00306 wrong number or types of arguments in call to 'PUT_LINE'
Hi Guys,
I'm practising the plsql workouts,during a anonymous PL/SQL block i got the below error,what the mistake i did ?
declare
v1 employee_290512%rowtype;
cursor c1 is select * from employee_290512;
begin
open c1;
loop
fetch c1 into v1;
exit when c1% notfound;
dbms_output.put_line(v1);
end loop;
end;
{/code}
And i got the below error
Error:
ORA-06550: line 10, column 1:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 10, column 1:
PL/SQL: Statement ignored
/Error.
Please help me on this.
Regards
ThelakHi there,
i got the same error. kindly check what's wrong with my below coding;
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 TYPE Type_Tab_Data IS RECORD
3 (
4 ARMZIG_Q2SFX char(3),
5 somme number(20,2),
6 ARMZIG_Q2AN8 number(8),
7 ARMZIG_Q2DOC number(8),
8 ARMZIG_Q2DCT char(2),
9 ARMZIG_Q2CO varchar2(15 char)
10 );
11 TYPE Tab_Data IS TABLE OF Type_Tab_Data INDEX BY BINARY_INTEGER ;
12 t_flexnum5 Tab_Data;
13 v_test pls_integer;
14 v_text_erreur varchar2(200 char);
15 BEGIN
16 SELECT b.ARMZIG_Q2SFX,a.somme,a.ARMZIG_Q2AN8,a.ARMZIG_Q2DOC,a.ARMZIG_Q2DCT,a.ARMZIG_Q2CO
17 BULK COLLECT INTO t_flexnum5
18 from
19 (
20 SELECT sum(ARMZIG_Q2AAP/100)as somme,ARMZIG_Q2AN8,ARMZIG_Q2DOC,ARMZIG_Q2DCT,ARMZIG_Q2CO
21 from ARMAST_ZIG_EUR
22 where ENVZIG_ID = 'E'
23 group by ARMZIG_Q2AN8,ARMZIG_Q2DOC,ARMZIG_Q2DCT,ARMZIG_Q2CO
24 ) a, ARMAST_ZIG_EUR b
25 where a.ARMZIG_Q2AN8 = b.ARMZIG_Q2AN8
26 and a.ARMZIG_Q2DOC = b.ARMZIG_Q2DOC
27 and a.ARMZIG_Q2DCT = b.ARMZIG_Q2DCT
28 and a.ARMZIG_Q2CO = b.ARMZIG_Q2CO
29 and b.ENVZIG_ID = 'E';
30
31 DBMS_OUTPUT.put_line(t_flexnum5);
32
33 END;
34 /
DBMS_OUTPUT.put_line(t_flexnum5);
ERROR at line 31:
ORA-06550: line 31, column 7:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
ORA-06550: line 31, column 7:
PL/SQL: Statement ignored
Maybe you are looking for
-
Sychronisation AD - OID: Is it possible to read the user password from AD?
Hi. We are using the Oracle Internet Directory shipped with the Oracle 9i Database Rel. 2 (9.2.0.1). I try to synchronise the user accounts from AD to OID using JAVA JNDI. I'm able to read all necessary user information except the user password (MD5
-
ECC 6.0 installation error - DB2/ AIX
Hello, I am installing ECC 6.0 using DB2 database Version 8 Fixpak 12 on AIX system in HACMP clustering envt. I have insatlled DB2 & Central Instance in Node A and DB2 and Dialog Instance in Node B. But now while starting DB2 in node B by command "st
-
How to store a RSA pair key in Java Key Store (jks) and VS
Hi Everyone , I have generated a RSA pair key . now I need to store my public key in a Java Key Store (.jks file) . and then I need to read this .jks file in another application and get this public key to use for verification . I'll appreciate it if
-
IPod won't connect to iTunes/Computer
Soo I plug my iPod into the cord which is plugged into the computer, the computer makes the little beep that lets me know its detected a device and... Nothing. It doesn't show up in iTunes. It doesn't show the little charging symbol on the iPod. Noth
-
WF of "IDOC error Notification" via WF Task giving error
Work item 000012210441: Object FLOWITEM method EXECUTE cannot be executed <b>Error at start of an IF branch</b> Error when evaluating the IF condition for node 0000000035 Error at start of an IF branch Error during result processing of work item 0000