Author: Laurent Schneider

Export to Excel

One more neat solution from Michaels about exporting the data to Excel in this otn post set feed off markup html on spool on alter session set nls_date_format=’YYYY-MM-DD’; spool emp.xls select * from emp; spool off set markup html off spool off And it perfectly opens in Excel. No hassle with separator, no time lost […]

clob hello world

write to a clob SQL> var x clob SQL> begin 2 dbms_lob.createtemporary(:x,true); 3 dbms_lob.writeappend(:x,12,’Hello World!’); 4 end; 5 / PL/SQL procedure successfully completed. SQL> print x X ————————————————– Hello World! read from a clob SQL> var c varchar2(10) SQL> var n number SQL> exec :n := 5 /* read 5 characters, if possible */ PL/SQL […]

csv part 3

In part 1, I tried with pure SQL+XML, but empty columns were missing. In Part 2, I had a mix between PL/SQL and XML functions. Now I would like to publish the solution Vadim Tropashko posted in the OTN Forums. It is a NO XML pipelined function. I did a bit formatting in it. And […]

csv format with select *

One more trick with xml. I want to get a semi-column separated format without having to specify the columns alter session set nls_date_format=’YYYY-MM-DD’; Session altered. select regexp_replace(column_value,’ *<[^>]*>[^>]*>’,’;’) from table(xmlsequence(cursor(select * from emp))); ;7369;SMITH;CLERK;7902;1980-12-17;800;20; ;7499;ALLEN;SALESMAN;7698;1981-02-20;1600;300;30; ;7521;WARD;SALESMAN;7698;1981-02-22;1250;500;30; ;7566;JONES;MANAGER;7839;1981-04-02;2975;20; ;7654;MARTIN;SALESMAN;7698;1981-09-28;1250;1400;30; ;7698;BLAKE;MANAGER;7839;1981-05-01;2850;30; ;7782;CLARK;MANAGER;7839;1981-06-09;2450;10; ;7788;SCOTT;ANALYST;7566;1987-04-19;3000;20; ;7839;KING;PRESIDENT;1981-11-17;5000;10; ;7844;TURNER;SALESMAN;7698;1981-09-08;1500;0;30; ;7876;ADAMS;CLERK;7788;1987-05-23;1100;20; ;7900;JAMES;CLERK;7698;1981-12-03;950;30; ;7902;FORD;ANALYST;7566;1981-12-03;3000;20; ;7934;MILLER;CLERK;7782;1982-01-23;1300;10;

updatable views and instead of triggers

I am data-modeling those days. Each table has it own description table (yes, it is Java). To keep it simple, FRUIT[id,description] and MEAT[id,description] (35 of them right now). There must be one table which contains all descriptions in it GLOBAL[type,id,description]. I wish to preserve the data quality. Both the little (FRUIT,MEAT) and the big (GLOBAL) […]

How do i store the counts of all tables …

How do i store the counts of all tables … My answer to the question above using dbms_xmlgen SQL> select 2 table_name, 3 to_number( 4 extractvalue( 5 xmltype( 6 dbms_xmlgen.getxml(‘select count(*) c from ‘||table_name)) 7 ,’/ROWSET/ROW/C’)) count 8 from user_tables; TABLE_NAME COUNT —————————— —— DEPT 4 EMP 14 BONUS 0 SALGRADE 5

CPU2007Apr

I just downloaded and installed the Critical Patch Update April 2007 $ lsnrctl stop … The command completed successfully $ sqlplus / as sysdba SQL> shutdown immediate … ORACLE instance shut down. SQL> quit $ cd /tmp/5901891 $ ORACLE_HOME/OPatch/opatch apply … Finish at Wed Apr 18 10:28:17 CEST 2007 $ lsnrctl start … The command […]

why is bitmap index not designed for OLTP

In case you do not know it yet, having a bitmap on columns like GENDER(male/female) is a very bad practice in OLTP, because each insert does lock the whole table create table t(name varchar2(10), gender varchar2(10)); create bitmap index bi on t(gender); +——————————–+ +——————————–+ | Session 1 | | Session 2 | +——————————–+ +——————————–+ | […]

How to load BLOB in the database?

I have been asked yesterday how to read and write blobs in the database. With java : read from an input stream InputStream myBlobInputStream = connection . createStatement() . executeQuery(“select myBlob from t”) . getBlob(1) . getBinaryStream(); write to an output stream OutputStream myBlobStream = connection . createStatement() . executeQuery(“select myBlob from t for update”) […]

user identified externally with SSL certificate

Today I configured my database to identify users with certificates. Check my previous post listener with tcps to find out how to configure a listener with SSL, which is a requisite. Ok, I have a listener.ora and a tnsnames.ora with SSL. I do not need a sqlnet.ora, the default values work. listener.ora LISTENER= (DESCRIPTION_LIST= (DESCRIPTION= […]

8.1.7 desupport exceptions

In the Critical Patch Update 2007 January Pre-Release Announcement, you may wonder why there is a 8.1.7.4 CPU patch. The reason is, Oracle 8.1.7.4 is still supported for some application supported by Oracle like Siebel, E-Business and Clinical. Have a look at Metalink Note 148054.1

RAC workshop

As announced, I have been speaking for Credit Suisse employees last week. The objective was to give the database project and team leaders the keys arguments for going or not going to RAC. First : what is RAC ? Oracle Real Application Cluster. You have a shared storage, and two instances accessing the same database. […]

Fit for RAC

I will be speaking tomorrow in German and Wednesday in English in Credit Suisse Bank. The workshop is about the differences between single instance and RAC Some of them : architecture, availability, scalability, manageability, skills required, price. I will talk also about the operational aspects, upgrade, dictionary, parameter file.