Using dbms_output .put( substr( blobfield, 1, 20))
Hello,
is it possible to print out part of a blob-field using dbms_output.put() or dbms_output.putline() ?
I just want to visualize that it is filled with informations.
Thanks for help,
Dirk
null
Hi
To manipulate a blob, use dbms_lob package.
You cannot do a substr of BLOB.
HTH
Arvind Balaraman
Similar Messages
-
Displaying table using DBMS_OUTPUT using OWA
Dear All,
I have created a procedure to display a table in DBMS_OUTPUT (Thanks to Michaels) using OWA package.
PROCEDURE showtable (tablename VARCHAR2)
AS
b BOOLEAN;
OUT CLOB;
irows INTEGER := 1;
BEGIN
OWA.cgi_var_name (1) := 1;
OWA.init_cgi_env (OWA.cgi_var_name);
HTP.adddefaulthtmlhdr (FALSE);
b :=
OWA_UTIL.tableprint (ctable => tablename,
cattributes => 'border=1',
ntable_type => OWA_UTIL.pre_table
WHILE irows > 0
LOOP
OUT := OWA.get_line (irows);
IF RTRIM (OUT, CHR (10)) NOT IN ('<PRE>', '</PRE>')
THEN
DBMS_OUTPUT.put_line (OUT);
END IF;
END LOOP;
END;
This procedure displays proper tabular output.
But in few cases it shows tabular output along with <PRE> </PRE> tags.
Also in few cases it inserts unnecessary carriage returns in the output and therefore the rows in output gets misaligned.
Is this the problem with tool that displays output?
I have tested it with SQL * Plus, Toad, Oracle SQL Developer but it displays same output in each case.
Please help me in improving this procedure.
Thanks in advance.
-SameerYou can try this. It displays fine (in the spool file) even for very wide tables as long as the overall output size does not exceed 32767 (limitation of dbms_output):
SQL> declare
2 b boolean;
3 out clob;
4 irows integer := 1;
5 offset integer := 1;
6 amt integer := 255;
7 tablename varchar2 (40) := 'flows_030000.wwv_flows';
8 i integer := 1;
9 begin
10 owa.cgi_var_name (1) := 1;
11 owa.init_cgi_env (owa.cgi_var_name);
12 htp.adddefaulthtmlhdr (false);
13 b := owa_util.tableprint (ctable => tablename,
14 cattributes => 'border=1',
15 ntable_type => owa_util.pre_table,
16 nrow_max => 3
17 );
18
19 while irows > 0
20 loop
21 out := out || replace (replace (owa.get_line (irows), '<PRE>' || chr (10)), '</PRE>' || chr (10));
22 end loop;
23
24 while dbms_lob.substr (out, amt, offset) is not null
25 loop
26 dbms_output.put (dbms_lob.substr (out, amt, offset));
27 offset := offset + amt;
28 end loop;
29
30 dbms_output.new_line;
31 end;
32 /
| ID | SECURITY_GROUP_ID | GLOBAL_ID | ALIAS | DISPLAY_ID | OWNER | NAME | DEFAULT_PAGE_TEMPLATE | HOME_LINK | BOX_WIDTH | WEBDB_LOGGING | PRINTER_FRIENDLY_TEMPLATE | DEFAULT_REGION_TEMPLATE | DEFAULT_LABEL_TEMPLATE | DEFAULT_REPORT_TEMPLATE | DEFAULT_LIST_TEMPLATE | DEFAULT_MENU_TEMPLATE | DEFAULT_BUTTON_TEMPLATE | DEFAULT_CALENDAR_TEMPLATE | ERROR_TEMPLATE | FLOW_LANGUAGE | FLOW_LANGUAGE_DERIVED_FROM | CHARSET | FLOW_IMAGE_PREFIX | AUTHENTICATION | LOGIN_URL | LOGOUT_URL | LOGO_IMAGE | LOGO_IMAGE_ATTRIBUTES | PUBLIC_URL_PREFIX | PUBLIC_USER | DBAUTH_URL_PREFIX | PROXY_SERVER | CUSTOM_AUTHENTICATION_PROCESS | CUSTOM_AUTHENTICATION_PAGE | CUSTOM_AUTH_LOGIN_URL | FLOW_VERSION | FLOW_STATUS | FLOW_UNAVAILABLE_TEXT | RESTRICT_TO_USER_LIST | APPLICATION_TAB_SET | EXACT_SUBSTITUTIONS_ONLY | CSV_ENCODING | BUILD_STATUS | VPD | SECURITY_SCHEME | REJOIN_EXISTING_SESSIONS | CHECKSUM_SALT | CHECKSUM_SALT_LAST_RESET | SUBSTITUTION_STRING_01 | SUBSTITUTION_VALUE_01 | SUBSTITUTION_STRING_02 | SUBSTITUTION_VALUE_02 | SUBSTITUTION_STRING_03 | SUBSTITUTION_VALUE_03 | SUBSTITUTION_STRING_04 | SUBSTITUTION_VALUE_04 | SUBSTITUTION_STRING_05 | SUBSTITUTION_VALUE_05 | SUBSTITUTION_STRING_06 | SUBSTITUTION_VALUE_06 | SUBSTITUTION_STRING_07 | SUBSTITUTION_VALUE_07 | SUBSTITUTION_STRING_08 | SUBSTITUTION_VALUE_08 | SUBSTITUTION_STRING_09 | SUBSTITUTION_VALUE_09 | SUBSTITUTION_STRING_10 | SUBSTITUTION_VALUE_10 | SUBSTITUTION_STRING_11 | SUBSTITUTION_VALUE_11 | SUBSTITUTION_STRING_12 | SUBSTITUTION_VALUE_12 | SUBSTITUTION_STRING_13 | SUBSTITUTION_VALUE_13 | SUBSTITUTION_STRING_14 | SUBSTITUTION_VALUE_14 | SUBSTITUTION_STRING_15 | SUBSTITUTION_VALUE_15 | SUBSTITUTION_STRING_16 | SUBSTITUTION_VALUE_16 | SUBSTITUTION_STRING_17 | SUBSTITUTION_VALUE_17 | SUBSTITUTION_STRING_18 | SUBSTITUTION_VALUE_18 | SUBSTITUTION_STRING_19 | SUBSTITUTION_VALUE_19 | SUBSTITUTION_STRING_20 | SUBSTITUTION_VALUE_20 | LAST_UPDATED_BY | LAST_UPDATED_ON | DEFAULT_CHART_TEMPLATE | DEFAULT_REPORTR_TEMPLATE | DEFAULT_FORM_TEMPLATE | DEFAULT_WIZARD_TEMPLATE | DEFAULT_TABFORM_TEMPLATE | DEFAULT_MENUR_TEMPLATE | DEFAULT_LISTR_TEMPLATE | THEME_ID | GLOBAL_NOTIFICATION | PAGE_PROTECTION_ENABLED_Y_N |
| 4411 | 10 | 26203551107945 | 4411 | 4411 | FLOWS_030000 | APEX - System Messages | 36912332266496846 | f?p=4411:1:&SESSION. | 98% | YES | 36911425616496846 | 36915002366496846 | 36912920899496846 | | 36916121240496847 | 36916209479496847 | | | 36911425616496846 | en-us | BROWSER | utf-8 | /i/ | COOKIE | | | | | | APEX_PUBLIC_USER | | | | | | &PRODUCT_NAME. 3.0.1.00.07 | AVAILABLE_W_EDIT_LINK | This application is currently unavailable. | | 1 | Y | | RUN_AND_BUILD | | | N | | 18-AUG-07 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 18-AUG-07 | | | | | | | | 101 | | |
| 4000 | 10 | 26616754121304 | BUILDER | 4000 | FLOWS_030000 | APEX - Application Builder | 3181227431044578 | f?p=4000:1:&SESSION. | 98% | YES | 7403029749876837 | 344742548 | 93372822814585113 | 6600628282501516 | 35066701739635046 | 13734421012904391 | 18498019930416612 | | 7403029749876837 | en-us | BROWSER | utf-8 | /i/ | CUSTOM2 | | wwv_flow_custom_auth_std.logout?p_this_flow=&FLOW_ID.&p_next_flow_page_sess=4550:8:&SESSION. | #IMAGE_PREFIX#htmldb/apex_logo.gif | width="300" height="30" alt="&PRODUCT_NAME." | | APEX_PUBLIC_USER | | | .60856310633085148. | | | &PRODUCT_NAME. 3.0.1.00.07 | AVAILABLE_W_EDIT_LINK | This application is currently unavailable at this time. | | 1 | N | Y | RUN_AND_BUILD | | FLOW: EDIT | | | 18-AUG-07 | LOGOUT | Logout | PRODUCT_NAME | Application Express | MSG_COMPANY | Workspace: &COMPANY. | MSG_LANGUAGE | Language | MSG_COPYRIGHT | Copyright © 1999, 2007, Oracle. All rights reserved. | MSG_USER | User | MSG_JSCRIPT | You must run this product with JavaScript enabled. | MSG_TBL_SUMMARY | Page Layout Table | EDIT | Edit | DONE | Done | TOP | Top | CLOSE | Close | CONFIRM | Confirm | DATE_FORMAT | mm/dd/yyyy | LONG_DATE_FORMAT | fmDay, Month dd, yyyy | TIME_FORMAT | hh:mi:ss AM | DATE_TIME_FORMAT | mm/dd/yyyy hh:mi:ss AM | RETURN_TO_APP | Return to Application | DELETE_MSG | Would you like to perform this delete action? | PAGE | Page | | 18-AUG-07 | 61427218674569660 | 61427218674569660 | 61427218674569660 | 91980429263284255 | 61427218674569660 | | 61427218674569660 | 3 | | N |
| 4350 | 10 | 683611196230867 | HTMLDB_HOME | 4350 | FLOWS_030000 | APEX - Workspace Admin | 6322904659084760 | f?p=4500:1000:&SESSION. | 98% | YES | 6322904659084760 | 60932116232746047 | 107534131274292840 | 6659715068668103 | 77000120193659142 | | 153893729392735447 | | 6322904659084760 | en-us | BROWSER | utf-8 | /i/ | CUSTOM2 | development_service_home_login | wwv_flow_custom_auth_std.logout?p_this_flow=&FLOW_ID.&p_next_flow_page_sess=4550:8:&SESSION. | #IMAGE_PREFIX#htmldb/apex_logo.gif | width="300" height="30" alt="&PRODUCT_NAME." | | APEX_PUBLIC_USER | | | .60874129745270430. | | | &PRODUCT_NAME. 3.0.1.00.07 | AVAILABLE_W_EDIT_LINK | This application is currently unavailable. | | 1 | Y | Y | RUN_AND_BUILD | | | | | 18-AUG-07 | LOGOUT | Logout | PRODUCT_NAME | Application Express | MSG_COMPANY | Workspace: &COMPANY. | MSG_LANGUAGE | Language | MSG_COPYRIGHT | Copyright © 1999, 2007, Oracle. All rights reserved. | MSG_USER | User | MSG_JSCRIPT | You must run this product with JavaScript enabled. | MSG_TBL_SUMMARY | Page Layout Table | DONE | Done | TOP | Top | CLOSE | Close | EDIT | Edit | DATE_FORMAT | mm/dd/yyyy | LONG_DATE_FORMAT | fmDay, Month dd, yyyy | TIME_FORMAT | hh:mi:ss AM | DATE_TIME_FORMAT | mm/dd/yyyy hh:mi:ss AM | DELETE_MSG | Would you like to perform this delete action? | | | | | | | | 18-AUG-07 | | | | | | | | 3 | | N |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Sorry for the wide display, but thats what I wanted to demonstrate anyway ;-) -
How to print new line using DBMS_OUTPUT package
Hi,
I am trying to print a new line using DBMS_OUTPUT package. but it do not print the new line.
set serveroutput on size 200000
set feedback on
BEGIN
DBMS_OUTPUT.PUT_LINE('First Line');
DBMS_OUTPUT.PUT_LINE('');
DBMS_OUTPUT.PUT_LINE('Second Line');
END;
I expect following output ...
First Line
Second Line
but i got following output....
First Line
Second Line
why DBMS_OUTPUT.PUT_LINE( '); is not printing a new line ?You can try the following:
SQL> ED
Wrote file afiedt.buf
1 BEGIN
2 DBMS_OUTPUT.PUT('ONE LINE...');
3 DBMS_OUTPUT.PUT('SECOND LINE...');
4 DBMS_OUTPUT.NEW_LINE;
5 DBMS_OUTPUT.PUT_LINE('THIRD LINE WITH NEW LINE...');
6 DBMS_OUTPUT.PUT('TEST');
7 DBMS_OUTPUT.NEW_LINE;
8 DBMS_OUTPUT.PUT_LINE('FOURTH LINE'||CHR(10)||'EXAMPLE');
9 DBMS_OUTPUT.PUT_LINE(CHR(10));
10 DBMS_OUTPUT.PUT_LINE('FIFTH LINE');
11* END;
SQL> /
ONE LINE...SECOND LINE...
THIRD LINE WITH NEW LINE...
TEST
FOURTH LINE
EXAMPLE
FIFTH LINE
PL/SQL procedure successfully completed.Documentation:
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_output.htm#i1000062 -
Using dbms_output in Trigger
hi
I asked my question previous;y but couldnt get an exact answer for my question
I have three table grade
grade(studentno,courseno,grade)
courses(courseno,coursename)
prerequisite(courseno,prereqcourseno)
prereq(courseno) is foreign key on courses(courseno)
I want to make I trigger that when one try to add a course in grade table
the trigger will check the prerequisite of that course
and if the course is not exist in grade table( which means student has not take the prereq before)
the trigger will give an error and will report the prerequisites that the student need for that course;
The problem is I cant show the prerequisite courses that the student need, when I insert a course without prerequisite.
for example let say prereq of course C is A and B
so when I try to insert A into grade, the trigger should say that u cant do it, because u nedd A and B
thanks in advanceI agree totally with Kamal Kishores opinion. even i discourage my friends , the usage of DBMS_OUTPUT package.
It should be used more or less as a tool for debugging. As a beginner it may be advantageous and easy to learn abt the
stored procedure programming. But keeping in view that PL/SQL is more used in the backend processing. Just keep in view that
we are using a front end tool and we are writing our programs in back end (PL/SQL) then the use of DBMS_OUTPUT package and
dependency on that is waste of efforts. infact the point of DBMS_OUTPUT using to output a big chunk of varchar2 string to the
client SQL*PLUS window may / may not be advantageous.
coz if we are using Windows client and using the DBMS_OUTPUT put display the message on the screen then we may not be seeing
the messages immediately on the screen unless the execution of the program is completed. For that we are using our debugging in a separate way.
Suppose if i want to know what is the program doing at the current instance of time , then it may not be possible using DBMS_OUTPUT package.
my debugging style is in this way. I have created a procedure with AUTONOMOUS TRANSACTION with a single arguement of VARCHAR2;
CREATE OR REPLACE PROCEDURE SEND_MES(MES VARCHAR2) IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
INSERT INTO DEBUG_TRAP VALUES(MES,TO_CHAR(SYSDATE,'HH24-MI-SS'));
COMMIT;
end;
EVEN THOUGH IT MAY BE AN OVER HEAD but it is very very advantageous to findout how the program is behaving and
where the current control is in the program. i monitor the values inputted in the table DEBUG_TRAP using another session. which makes me easily understandable where my program is
and gives me idea how to improve / tune my program .
prakash -
PL-SQL Solve: Using INSTR and SUBSTR
I am trying to work on this and cannot get a solution. Please help
You have to use INSTR and SUBSTR to solve
Question:
You have the following acceptable value
Numberic: 0-34
80-100
or Non Numberic X S U D- D D+
Im have to use INSTR and SUBSTR functions to test that the value is a valid (as above) number before TO_NUMBER is called:
SELECT TO_NUMBER('?? ') //HERE ?? and a space (for 100 etc) is for the values as above
FROM DUAL
WHERE ....INSTR(......)<=;
(Hence if the number is true then number comes back or it says no rows)
and also id non numberic it should also be tested.
I am completely unsure about it but tried this
SELECT TO_NUMBER('34 ')
FROM DUAL
WHERE INSTR('0123456789',1,1)<=9 (looking at first number ?)
AND
INSTR('0123456789',2,2)<=9
AND
INSTR('0123456789',3,3)=0;
Please helpWe have the following value that we can use:
Numeric: 0-34 and 80-100 only
or Non Numberic X S U D- D D+
Have to use INSTR and SUBSTR functions to test that the value is a valid
(for now only trying to create a function which can later be put into a procedure.)
SELECT TO_NUMBER('12 ') //e.g HERE 12 and a space for the values as above
FROM DUAL
the where clause looks at all three spaces to make sure values are correct (given number or non-numberic values only)
(Hence if the number is true then number comes back (meaning true)
or it says NO rows)
If value is non numeric, test it to allow non numberic also.
I am completely unsure about it but tried this
SELECT TO_NUMBER('34 ')
FROM DUAL
WHERE INSTR('0123456789',1,1)<=9 (looking at first number ?)
AND
INSTR('0123456789',2,2)<=9
AND
INSTR('0123456789',3,3)=0;
Something like this has to be done.....subst (instr, x,x,) i think mite help. -
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 -
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 -
How to use string functions (substr or ltrim or replace) in OLAP universe.
cost element (0COSTELMNT) - 10 CHAR
Controlling area (0CO_AREA) - 4 CHAR
[0COSTELMNT].[LEVEL01].[[20COSTELMNT]].[Value]
cOST ELEMENT is compounded/prefixed with Controlling Area. I just want to see cost element without conrolling area in the BO report.
Currenlty BO unierse is build based on bex query. I am able to suppress the compounding object in bex query by chaning controlling area to 'No display'. But still BO Webi report displaying compounded values in the report. (Bex report works as expected)
eg: Current display in reort.
controlling area/cost element.
AB00/2222
AB00/2223
AB00/2224
Wanted like below:
2222
2223
2224
I think by using string fucntions (substring, ltrim or replace etc.), I can get the required result. But I am having issues with syntax. I have used like below.
substr(0COSTELMNT ; 5 ; 10)
substr(0COSTELMNT; 5 ; Length(0COSTELMNT)-5)
substr(0COSTELMNT; Pos(0COSTELMNT;"/")+1;10)
ltrim(0COSTELMNT,'AB00/')
What is the syntax for substring/replace functions in OLAP universe. Technical name of cost element in OLAP universe is [0COSTELMNT].[LEVEL01].[[20COSTELMNT]].[Value].
I want to fix this at universe level not at report level as i am using cost element in filter/variable section of the report. Please provide me syntax for above example.Hi,
In fact SAP BW MDX supports limited string manipulation and only with NAME and UNIQUENAME attributes.
Here are some samples that you can use in universes:
MID([0COSTELMNT].currentmember.NAME,1,4)
LEFT([0COSTELMNT].currentmember.NAME,2)
RIGHT([0COSTELMNT].currentmember.NAME,3)
MID([0COSTELMNT].currentmember.UNIQUENAME ,1,4)
LEFT([0COSTELMNT].currentmember.UNIQUENAME ,2)
RIGHT([0COSTELMNT].currentmember.UNIQUENAME ,3)
Didier -
How to generate idoc PODRCH02 using out put type
Hi All,
I need to generate outbound idoc PORDCH02 and message type PORDCH using out put types (messages).But i unable to generated this idoc using message type. System is giving error as *No recipient found for message type PORDCH in the ALE model*
To do this , i have done the following steps.
1. In BD64 i have configure the business object BUS2012, using add bapi. ( In cust.distn model it doesn't allowing the message type. so i have given BAPI )
2. In partner profile (WE20), for sending logical sytems
i have configure the message type in outbound parametes.
3. In NACE for out put type NEU i have given medium as Distribution (ALE), Partner function as LS
Could you please help me out , what are the necessary steps i need to take care and what are the steps i missed out.
Thanks and regards
PraveenIn distribution model, you have to configure both the sending system and receiving system. The Tcode of Distribution model is BD64.
-
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. -
Db- put blocks sometimes, mulit-thread uses Db- put to write DB file
My environment : redhat Linux 5, gcc version 4.1.2
BDB version: 4.8.24
Hi Guys
I used multi-thread application to write DB file. The application used Transactional Data Store and I used flags DB_TXN_NOSYNC . The DB file type is BTREE. I give 180M for the buffer cache and 8M for the log cache. And I used Db->put to write DB file ; five threads is used.
But the Db->put will block for one or two seconds sometimes.
Now I have found that the problem is in the lock/lock.c :: __lock_get_internal , line 953 : MUTEX_LOCK(env, newl->mtx_lock);. My application blocks here .+_
Could anyone give me some advice to avoid these blocks as possible as we can?
By the way, I have tried many of the lock set APIs which BDB offered. No effect -_- .
ThanksHi,
You should have posted this new piece of information in the original thread you opened:
Db->put block sometimes , when mulit-thread uses Db->put to write DB file
In the future please do not open a new thread for a problem you already reported.
Now I have found that the problem is in the lock/lock.c :: __lock_get_internal , line 953 : MUTEX_LOCK(env, newl->mtx_lock);. My application blocks here .+_This only confirms that one of your threads is blocked waiting for a requested lock, which is already held by another thread. Until the thread that holds the lock will not have released it, your thread waiting on it will not make progress.
You can collect the locking statistics at the moment you observe the slowness using either the db_stat utility with the -CA or -Co options (if the environment is not opened with DB_PRIVATE, that is, backing its region files into per-process private/heap memory) or programmatically using DB_ENV->lock_stat_print():
[http://www.oracle.com/technology/documentation/berkeley-db/db/api_reference/C/db_stat.html]
[http://www.oracle.com/technology/documentation/berkeley-db/db/api_reference/C/lockstat_print.html]
Examining the locking statistics will help determine what is the problematic lock, what is the locked object and which thread is holding it.
In addition to standard deadlock detection you can look into configuring lock timeouts. If your lock request is not satisfied within a given time it will time out and return DB_LOCK_DEADLOCK or DB_LOCK_NOTGRANTED. Lock timeouts may be configured per environment wide basis or per-lock or per-transaction basis:
[http://www.oracle.com/technology/documentation/berkeley-db/db/programmer_reference/lock_timeout.html]
[http://www.oracle.com/technology/documentation/berkeley-db/db/gsg_txn/C/lockingsubsystem.html#configdeadlkdetect]
As Mike already suggested it would help if you could put together a test case program to demonstrate this issue.
Regards,
Andrei -
Can we use dbms_output.put_line package with forall statement
Hello Everybody
Can we use dbms_output.put_line package with forall or can we use insert,update and delete only
declare
type emp_rec is table of emp%rowtype
index by binary_integer;
t emp_rec;
begin
select * bulk collect into t from emp;
forall i in t.first..t.last
dbms_output.put_line(t(i).name);
end;Thanks & Regards
peeyush
Edited by: Peeyush on Nov 25, 2010 11:45 PMMichaelS wrote:
Well as the docs explain (though not very clear and detailed, I admit) you can use a dynamic sql statement (execute immediate) with FORALL.You got me interested in the performance side doing this Michael - running PL/SQL code via a FORALL loop.
It is faster than using a normal FOR loop to execute dynamic PL/SQL - a bit surprising as I expected another context switch to be in there. But seems like the PL/SQL engine is a more clever at optimisation than what I originally credited it with.. ;-)
Of course - pre-compiled/static PL/SQL code in a FOR loop is the fastest, as expected.
SQL> declare
2 type TNumbers is table of number;
3
4 type TTimes is record(
5 for_all number,
6 for_dynamic number,
7 for_static number
8 );
9
10 type TTimesTable is table of TTimes;
11
12 MAX_ITERATIONS constant number := 10;
13
14 plBlock varchar2(1000) :=
15 'declare i number;
16 begin i:= :var / 10; end;';
17
18 performance TTimesTable;
19 t1 number;
20 bindVar TNumbers;
21 n number;
22 begin
23 select
24 level bulk collect into bindVar
25 from dual
26 connect by level <= 10000;
27
28 dbms_output.put_line( 'Iterations: '||bindVar.Count||' for loop cycle(s)' );
29
30 performance := new TTimesTable();
31 performance.Extend( MAX_ITERATIONS );
32
33 for j in 1..MAX_ITERATIONS
34 loop
35 t1 := dbms_utility.get_time;
36 forall i in 1..bindVar.Count
37 execute immediate plBlock using bindVar(i);
38 performance(j).for_all := dbms_utility.get_time-t1;
39
40 t1 := dbms_utility.get_time;
41 for i in 1..bindVar.Count
42 loop
43 execute immediate plBlock using bindVar(i);
44 end loop;
45 performance(j).for_dynamic := dbms_utility.get_time-t1;
46
47 t1 := dbms_utility.get_time;
48 for i in 1..bindVar.Count
49 loop
50 n := bindVar(i) / 10;
51 end loop;
52 performance(j).for_static := dbms_utility.get_time-t1;
53 end loop;
54
55 dbms_output.put_line( 'Times in 100th of a second' );
56 dbms_output.put_line( rpad('for all',15) || rpad('for dynamic',15) || rpad('for static',15) );
57 for i in 1..performance.Count
58 loop
59 dbms_output.put_line(
60 rpad( performance(i).for_all, 15 )||' '||
61 rpad( performance(i).for_dynamic, 15 )||' '||
62 rpad( performance(i).for_static, 15)
63 );
64 end loop;
65
66 end;
67 /
Iterations: 10000 for loop cycle(s)
Times in 100th of a second
for all for dynamic for static
10 72 0
6 37 0
6 37 0
6 37 0
6 36 0
6 37 1
5 37 0
5 37 0
6 37 1
5 37 0
PL/SQL procedure successfully completed.
SQL> -
My iphone was lost and was sent to lost mode after some days I found my iphone but it was disable. And now I'm not able to activate my phone. it doesn't accept the Apple ID that I used to put my phone in lost mode. How can I activate my iphone now?
Hi Krisunita,
Thanks for visiting Apple Support Communities.
Try using these steps to stop Lost Mode from iCloud.com:
Stop Lost Mode or change your contact info
Sign in to icloud.com/#find with your Apple ID (the one you use with iCloud).If you’re using another iCloud app, click the app’s name at the top of the iCloud.com window, then click Find My iPhone.
Click All Devices, then select the device that’s in Lost Mode.
Click Lost Mode, then change the information or click Stop Lost Mode.
You can find this information here:
iCloud: Use Lost Mode
http://support.apple.com/kb/PH2700
If you are not able to log into iCloud.com, see this link for more help:
iCloud: If you can’t sign in to iCloud.com
http://support.apple.com/kb/ph2611
Best,
Jeremy -
How to send message using Head,PUT,DELETE method
we can use Get,Post method in a form, but how to use Head,Put,DELETE method to submit. I try to use "method=head" in form tag, and write some code in doHead() method in servlet, but after I submit the form, the doHead() is not called by the servlet.
In HTML there is no Tag that support HEAD or PUT. You might create your own HTTP Client and implement HEAD and PUT Requests. Have a look at the HTTP Protocol to learn what they are used for and how they are to be implemented.
-
Not able to create an object using dbms_metadata.put function
Hi,
I have the metadata of an object in one of my database table as xml. I failed to recreate the object in the other schema using metadata api. I developed a stored function to do the above job. My function doesn't throw any error meanwhile it doesn't create the object.
My code snippet is
CREATE OR REPLACE PROCEDURE DDI.move_table(
table_name in VARCHAR2,
from_schema in VARCHAR2,
to_schema in VARCHAR2 )
AUTHID CURRENT_USER
IS
-- Define local variables.
h1 NUMBER; -- handle returned by OPEN
h2 NUMBER; -- handle returned by OPENW
th1 NUMBER; -- handle returned by ADD_TRANSFORM for MODIFY
th2 NUMBER; -- handle returned by ADD_TRANSFORM for DDL
xml XMLTYPE; -- XML document
errs sys.ku$_SubmitResults := sys.ku$_SubmitResults();
err sys.ku$_SubmitResult;
result BOOLEAN;
BEGIN
SELECT REPOS INTO xml from ddi.ddi_repos_t where obj_id = '1801';
-- Specify the object type using OPENW (instead of OPEN).
h2 := DBMS_METADATA.OPENW('TABLE');
-- First, add the MODIFY transform.
th1 := DBMS_METADATA.ADD_TRANSFORM(h2,'MODIFY');
-- Specify the desired modification: remap the schema name.
DBMS_METADATA.SET_REMAP_PARAM(th1,'REMAP_SCHEMA',from_schema,to_schema);
-- Now add the DDL transform so that the modified XML can be
-- transformed into creation DDL.
th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'DDL');
-- Call PUT to re-create the object.
result := DBMS_METADATA.PUT(h2,xml,0,errs);
DBMS_METADATA.CLOSE(h2);
IF NOT result THEN
-- Process the error information.
FOR i IN errs.FIRST..errs.LAST LOOP
err := errs(i);
FOR j IN err.errorLines.FIRST..err.errorLines.LAST LOOP
dbms_output.put_line(err.errorLines(j).errorText);
END LOOP;
END LOOP;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20510,'No xml is available as metadata');
END;
Could you tell me where is the probelm?
The schema where i created and execute my function having dba privilege also.
Regards,
Madhavi.Hi Madhavi,
The below code works for me:
SQL> conn sys as sysdba
Connected.
SQL> select count(*) from dba_objects where object_name = 'DEPT' and owner = 'OE';
COUNT(*)
0
SQL> CREATE OR REPLACE PROCEDURE move_table(
2 table_name in VARCHAR2,
3 from_schema in VARCHAR2,
4 to_schema in VARCHAR2 )
5 AUTHID CURRENT_USER
6 IS
7 -- Define local variables.
8 h1 NUMBER; -- handle returned by OPEN
9 h2 NUMBER; -- handle returned by OPENW
10 th1 NUMBER; -- handle returned by ADD_TRANSFORM for MODIFY
11 th2 NUMBER; -- handle returned by ADD_TRANSFORM for DDL
12 xml clob; -- XML document
13 errs sys.ku$_SubmitResults := sys.ku$_SubmitResults();
14 err sys.ku$_SubmitResult;
15 result BOOLEAN;
16 BEGIN
17
18 select DBMS_METADATA.GET_XML('TABLE','DEPT','SCOTT') into xml from dual;
19
20 -- Specify the object type using OPENW (instead of OPEN).
21 h2 := DBMS_METADATA.OPENW('TABLE');
22
23 -- First, add the MODIFY transform.
24 th1 := DBMS_METADATA.ADD_TRANSFORM(h2,'MODIFY');
25
26 -- Specify the desired modification: remap the schema name.
27 DBMS_METADATA.SET_REMAP_PARAM(th1,'REMAP_SCHEMA',from_schema,to_schema);
28
29 -- Now add the DDL transform so that the modified XML can be
30 -- transformed into creation DDL.
31 th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'DDL');
32
33 -- Call PUT to re-create the object.
34 result := DBMS_METADATA.PUT(h2,xml,0,errs);
35
36 DBMS_METADATA.CLOSE(h2);
37 IF NOT result THEN
38
39 -- Process the error information.
40 FOR i IN errs.FIRST..errs.LAST LOOP
41 err := errs(i);
42 FOR j IN err.errorLines.FIRST..err.errorLines.LAST LOOP
43 dbms_output.put_line(err.errorLines(j).errorText);
44 END LOOP;
45 END LOOP;
46 END IF;
47 EXCEPTION
48 WHEN NO_DATA_FOUND THEN
49 RAISE_APPLICATION_ERROR(-20510,'No xml is available as metadata');
50 END;
51 /
Procedure created.
SQL> exec move_table('DEPT','SCOTT','OE');
PL/SQL procedure successfully completed.
SQL> select count(*) from dba_objects where object_name = 'DEPT' and owner = 'OE';
COUNT(*)
1
SQL> spool off;The xml returned by the get_xml function contains the tablespace name and storage parameters of the schema in which the object is present.
Check these parameters for both your schemas.
Maybe you are looking for
-
[HELP!]open a pop-up and lock the window
Hi guys, the thing is : In a page (call it P1), when click a button there will come a pop-up page(P2), when P2 shows, P1 is locked, user can not perform any action on P1. the point is, P2 is not a real pop-up, it's inside the same window as P1. just
-
How to make the fonts in Firefox sharper so there more like the fonts in Google Chrome?
I'm currently in the process of moving from Google Chrome to Firefox, and I noticed that the fonts in Firefox are allot more smoother then what they are in Google Chrome, is there anyway to make the Firefox fonts look as sharp as what the fonts are i
-
How to import TRT_Send_Jython_HTML_Email
Hi, Iam trying to send emails from odi using TRT_Send_Jython_HTML_Email procedure. I have downloaded it from oracle site and how to get that one into odi. Iam trying to do import into odi by right clicking on the procedure and import procedure and i
-
My i phone 4 very slow when downloading from wifi..
please help me out what should i do my ip 4 very slow when downloding with wifi....
-
How to add a -ve sign into a quantyty field
Hi, I have a requirement where i need to loop the internal table with a condition if the condition becomes true then a particula field of that row should be added with a -ve sign,and modify that row. The field is of type quantity.