Print and dbms_output.put_line
wats the diff between prin and dbms_output.put_line
BEDE wrote:
Do not expect that the dbms_output.put or .put_line output show while the procedure or PL/SQL block is running. It will show only after it finished running.Unless something else within that PL/SQL execution reads the dbms_output buffer and directs the output somewhere where it can be read during run-time, such as putting it onto a table using an autonomous transaction or putting it out using a web service to another destination etc. Although generally, people don't do that I agree, but it can be done if required.
Similar Messages
-
Pro*Cobol and DBMS_OUTPUT.PUT_LINE
I am new to Pro*Cobol and had a simple question (I hope).
I have a stored proc that contains DBMS_OUTPUT.PUT_LINE stmts
and I can see those in SQLPlus (when serveroutput=on), but I do
not see them when I call it from Pro*Cobol. Is there a
precompiler setting or something I need to set?'Far as I know, you'll have to repeatedly call
dbms_output.get_line in your Pro*Cobol program to
get the server output generated by your stored procedure.
Hope that helps.
All the best
Michael -
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 -
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 -
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? -
Output from dbms_output.put_line splits and move to next line
Hi All,
I am printing out a list using dbms_output.put_line its like
One or more of following Required Parameters are missing:
1. Primary Field
2. Structure Field
3. Structure
Table
4. List File Name
5. Query Directory
6. Query String
but I don't know why third option is splitting and moving to second line. any idea? its not that long even then.
thanksset linesize 150
or set it as per your requirement -
Please help if anyone knows.
I have an anonymous block that declares a variable as below:
v_return_code varchar2(32767);
I am appending characters that I am building in the begin end block to this variable and at the end printing it out using dbms_output
dbms_output.put_line(v_return_code);
I observe that the output is generated partially when I ran the block through PL/SQL developer SQL window.
My code appends a new line char chr(10) after each new value is appended to the variable.
I have the below settiing in the output window
buffer size: 2000000
Can someone please help why it prints the output partially?
Thanks in advance.
GirishHi Frank,
Thanks for your reply.
I figured out that some other developer in the team had same problem before and he had then written a library function to tokenise the variable into 255 chars and then dbms_output it. So I am good now.
Thanks for coming by and replying though.
Regards,
Girish -
DBMS_Output.put_line doesn't print in one single line
Hi People,
I am using 'DBMS_Output.put_line' in my procedure for the output. Here's the code:
DBMS_OUTPUT.put_line('LOGIT_T. Detail records for act:'||v_count_act||',Detail records for Bal:'||v_count_bal||',Updated records for act:'||v_updat_act||',Updated records for bal:'||v_updat_bal||',Total records for act:'||v_count_act||',Total records for Bal:'||v_count_bal);
When the procedure runs, it prints the output as shown below:
LOGIT_T. Detail records for act:619,Detail records for Bal:324,Updated records
for act:0,Updated records for bal:0,Total records for act:693,Total records for
Bal:410
As a result, when inserting this whole line into table, it only inserts the following text. Hence, ignores the rest of the text (table field width is 2000 bytes):
LOGIT_T. Detail records for act:619,Detail records for Bal:324,Updated records
Looks like, it is automatically wrapping the text to the next line. While I want the above output in a single line as shown below and to be inserted into my table the whole text:
LOGIT_T. Detail records for act:619,Detail records for Bal:324,Updated records for act:0,Updated records for bal:0,Total records for act:693,Total records for Bal:410
Any idea how to achieve this? Any parameter or setting I am missing here?
Hope I made sense above and clearly described my situation.
Thanks in advance guys!in sqlplus, you can use set linesize:
SQL> set serverout on
SQL> set linesize 10
SQL> exec dbms_output.put_line('This is a line of text that exceeds 10 characters');
This is a
line of
text that
exceeds 10
characters
PL/SQL procedure successfully completed.
SQL> set linesize 132
SQL> exec dbms_output.put_line('This is a line of text that exceeds 10 characters');
This is a line of text that exceeds 10 characters
PL/SQL procedure successfully completed. -
Hi Guys.
I upgraded from 1.2 and it appears that dbms_output.put_line is now broken.
Consider the following:
begin
dbms_output.put_line('hello world');
end;Process:
1. Load SQL Developer
2. Open a connection to DB
3. Go to DBMS Output tab
4. Enable server output
5. Type in the code (as above)
6. Hit F5
The bug/new feature:
After hitting f5, the DBMS Output tab switches to Script output where by I am presented with "anonymous block completed". In 1.2 (and previous versions) I used to see
anonymous block completed
hello world
in the Script Output tab.
Now I have to switch back to the DBMS Output tab. My problem with this is that there is far too much clicking. Why redirect me away from the tab that is going to actually display the script output only for me to have to click back into that tab? I just don't get it.
Regards
Kristian Jones
http://kristianjones.blogspot.com
Message was edited by:
Kris JonesHi,
I also have the problem with the new Released.
SQL Dev 1.2.0.29.98 upgraded with Check for Updates to 1.2.1.32.00
On Windows XP.
I did exactly as Kris Jones post, using Run Script
but, it seems that my SQL Developer doesn't do anything.
The progress bar is active like processing somthing, well, it processes forever.
I tried to cancel the process (button Cancel), but the panel shows that it is still trying to cancel the process (all buttons are disabled except Cancel), although I can do another select (use CTRL + Enter because F9 doesn't work) within the same SQL Worksheet and the panel goes back to the active panel again.
Well, there must be something wrong with the Run Script.
Since any query or pl/sql block seems running forever if I use Run Script.
I try on the SQL Developer 1.2.0.29.98 (luckily, I still keep the backup, just in case) and it shows the result as wanted.
Is there something wrong within my SQL Developer 1.2.0.32.00?
Or there is some patches which I should download?
Is it another bug?
Many thanks,
Buntoro -
HI all,
please see the following script where the variable length is more than a 100 charecters...
When i run this in sqlplus with SERVEROUTPUT ON, i see the ouput being truncated to 100 charecters.
sql> ed
Wrote file afiedt.buf
1 declare
2 l_var varchar2(400);
3 begin
4 l_var := 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh
5 dbms_output.put_line(length(l_var));
6 dbms_output.put_line(l_var);
7* end;
8 /
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvI think I am looking for a sqlplus "SET XXXX..." command, but my search has been futile so far.
Please advice.
Thanks,
John.Thanks for your reply .. Frank.
Sorry... I Previewed the post but did not notice my code being truncated in my sqlplus sesssion.
The actual script has the output to 130 charecters. but when i close the edit (afeidt.buf) and execute it, the display only shows 100 charecters...
My SQLPLUS version is 9.2.0.1.
I am using the "WE8ISO8859P1" charecter set.
declare
l_var varchar2(500) := 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';
begin
dbms_output.put_line(length(l_var));
dbms_output.put_line(l_var);
end;
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv
1 declare
2 l_var varchar2(500) ;
3 begin
4 for i in 1 .. 5 loop
5 l_var := l_var || 'abcdefghijklmnopqrstuvwxyz';
6 end loop;
7 dbms_output.put_line(length(l_var));
8 dbms_output.put_line(l_var);
9* end;
sql> /
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -
Printing blank spaces using dbms_output.put_line
There is one string getting generated dynamically. Upon generation, it may or may not contain blank spaces in the beginning. Then I am trying to print this on standard I/O using DBMS_OUTPUT.PUT_LINE. But if there are some leading spaces in the string, they are ignored. Is there any other way to print the exact string as it is?
hi..
it's depend on your client configuration.. you can configure the wrap option at the serveroutput parameter...
set serveroutput on size 100000 for wrap;
begin
2 dbms_output.put_line(' Hello world.');
3 end;
4 /
Hello world.
PL/SQL procedure successfully completed. -
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; -
Dbms_output.put_line does not write to stdout
I expect the following code to fail and to write 'ERRORE' to stdout:
------------------- mm.sql
set serveroutput on
BEGIN
select 1/0 from dual;
exception
when others then
dbms_output.put_line('ERRORE');
END;
I execute this from the command line
sqlplus rmsas_test/rmsas_test < mm.sql > mm.log 2>&1
It produces
---------------------------- mm.log
SQL*Plus: Release 9.2.0.6.0 - Production on Gio Lug 13 16:42:27 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
JServer Release 9.2.0.6.0 - Production
SQL> SQL> 2 3 4 5 6 7 Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
JServer Release 9.2.0.6.0 - Production
But no 'ERRORE' has been written to stdout????
Why?
Thanks
MauroJust a comment. There are no STDOUT or STDERR devices when dealing with PL/SQL programs.
The code runs inside an Oracle server process. That process itself is detached from any display device, any input device (e.g. mouse or keyboard) and any peripheral device (e.g. printer).
DBMS_OUTPUT is simply a persistant PL/SQL buffer that can be created in an Oracle session. The contents of this buffer can be displayed by a client (using the DBMS_OUTPUT API to read and clear the buffer). Do not confuse it with a proper STDOUT/STDERR device. -
Dbms_output.put_line not working
Hi, i am trying to use dbms_output.put_line to execute a sql in a bat script on windows...i get no errors , but the "alter tablespace" just prints but does not execute.
What exactly am i missing? Part of the script shown below..
thanks
set HFILE=%SCRIPT_HOME%\remove_bkupmode.sql
echo connect sys/%INTPWD% as sysdba >>%HFILE%
echo set termout off heading off feedback off >>%HFILE%
echo set linesize 300 pagesize 0 >>%HFILE%
echo set serveroutput on size 1000000 >>%HFILE%
echo spool %SCRIPT_HOME%\cleanup.sql >>%HFILE%
echo Declare >>%HFILE%
echo cursor c1 is SELECT t.name FROM V$DATAFILE d, V$TABLESPACE t, V$BACKUP b WHERE d.TS#=t.TS# AND b.FILE#=d.FILE# AND b.STATUS='ACTIVE'; >>%HFILE%
echo Begin >>%HFILE%
echo for tbs in c1 loop >>%HFILE%
echo dbms_output.put_line(' alter tablespace '^|^|tbs.name ^|^|' end backup;'); >>%HFILE%
echo end loop; >>%HFILE%
echo dbms_output.put_line('exit;'); >>%HFILE%
echo End; >>%HFILE%
echo / >>%HFILE%
echo spool off >>%HFILE%
echo exit; >>%HFILE%
START /wait SQLPLUS /NOLOG @%HFILE%thanks guys...did i bring back memories?
yeah its an old script. part of an old hot backup script i inherited, for a 24/7 live 9.2.0.1 database that can't be upgraded due to customizations lol
i setup rman, but since i'n still new to rman, i wanted to continue with the user- managed hot backups
this script will run afer the backup, just in case, to ensure that no tablespaces are left in backup mode.
J
Maybe you are looking for
-
Conversion of characteristic values before displaying in Bex Analyzer
Dear all, does anybody know whether it's possible to get influence on the manner in which a characteristic is embedded into an BEx Analyzer sheet (may be via user exit, function module exits or something else) . In our project we have characteristics
-
I just installed Forms 11.1.2 on a Windows XP PC (deployment option). The installation completed without any problem, but I don't seem to be able to get to the Fusion Middleware Control to configure a new Forms section. I start the Admin server and c
-
Logic Can't Locate Audio Files, Random Freak Occurrence?
I'm not sure if anyone else has experienced this, but today I was asked to bounced down an instrumental of a remix that I had finished a few weeks ago. So when I went to go open up the project, Logic was saying that it couldn't find 3 audio files now
-
Mail 2.0.7 - Earthlink Passwords Rejected
Hello, I would appreciate any help anyone can give with this problem. My Mail app worked fine last night with my Earthlink accounts; today, I receive repeated "password rejected" messages. I checked with an Earthlink online rep who had me re-enter my
-
What is the best type of camcorder to edit videos easily with iMovie HD and which brand, out of the categories below? I am kind of a nooby with camcorders. I have a budget of about $300-$350. -DVD -MiniDV -Hard Drive -Flash Memory -Canon -JVC -Sony -