The Unsuccessful Success: Trondheim - Oslo 2016
Mein erfolgreicher Weg zum Misserfolg
Inzwischen sind einige Wochen seit meinem Saison-Höhepunkt dem Styrkeprøven vergangen, die Aufregung und Entäuschung haben sich wieder gelegt bzw. sind auf ein normales Maß zurückgegangen. Drei wichtige Erkenntnisse bleiben. Erstens: Dieses Rennen ist eine absolute Herausforderung. Das Wesen jeder Herausforderung ist es, dass Scheitern eine der möglichen Optionen ist. Wäre das nicht der Fall, würde die Herausforderung ihren Sinn verlieren. Zweitens: Der Weg kann genauso wichtig sein wie das Ziel. Drittens: Nicht zu sehr auf die Technik verlassen! Diese Erfahrungen nehme ich mit in mein Gepäck, doch nun erzähle ich die Geschichte ganz von vorne.
How to set manual locks to synchronize processes in Oracle
|
Read more: How to set manual locks to synchronize processes in Oracle
How to copy data with "Long Raw" columns
From time to time I will be faced the problem to move data from one table to another. Under normal circumstances this is not a big deal, but if the source table contains a long-/raw column this is impossible to manage that with plain SQL. So here is a suitable workaround to solve this problem with a few lines of PL/SQL code
Starting point is a table with a long raw column:
insert into long_table select 'new id', long_column /* LONG-Feld */ from long_table a where a.long_id = 'some old id';
This ends up with "ORA-00997: illegal use of LONG datatype error"
The workaround is:
How to create a relation from Oracle to another physical database
... exactly this was the question of a customer, because he wants to join tables between two Oracle databases. Well, the idea for this solution is based upon the fact, that we can have a foreign key constraint on a view. So let's go ahead:
1. We create a view which points to a table/view on the foreign database, using a database link:
create view test_view_dblink as select * from some_table@external_oracle_database;
2. We create a foreign key constraint on that view
alter view test_view_dblink add constraint test_view_dblink_fk foreign key (column_name) references table_in_local_database(column_name) disable;
The "disable" clause at the end of the statement is the important thing because constraints on views must be disabled.
2b. If we would need a primary key we also can define one:
alter view test_view_dblink add constraint test_view_dblink_pk primary key (column_name) disable;
Last but not least: with this technique, we can create relations to all databases for which we have a oracle connector/gateway (e.g. IBM DB2, ...). Check it out!
String Tokenizer with Oracle PL/SQL
|
The solution is based on the ability of oracle to use regular expressions within a SQL statement. In the first example we have comma seperated string, containing the most important crew members of the USS Enterprise:
SELECT regexp_substr(str, '[^,]+', 1, LEVEL) AS splitted_element, LEVEL AS element_no FROM (SELECT rownum AS id, 'Kirk,Spock,Scotty,McCoy,Uhura' str FROM dual) CONNECT BY instr(str, ',', 1, LEVEL - 1) > 0 AND id = PRIOR id AND PRIOR dbms_random.value IS NOT null;
How to Java programming in Oracle Database
However, a weak point of this is the actuality of Java! The version within the database is "lagging" behind the current versions. This is because that a stable Java version is the base of the development of a new database release. While this new release than is productive for years, there are no changes in the internal version of Java, whereas the Java world outside of the Oracle database has already seen significant developments. The result is, that a Oracle version 11.2, which is very common right now (the first release dates from 2007), has the Java Runtime version 1.5.0_10 (2005!) included. The entire source code of the directory list example you will find here! |
Stored Procedures with Java?
The most common language within the Oracle database is still PL/SQL. This is the prefered language to develop Stored Procedures, Packages or Triggers. In order to develop with Java, the Java sources must be uploaded into the database. From this, the classes are extracted and displayed in the Data Dictionary as a schema object. It allows Java sources (.java) and class files (.class) or archives (.jar, .zip) to be uploaded.