Often, when getting a web site or online service started the ‘shop front’ can look bare until you build up content. Producing your own content can take time. One option is to use free articles from other sources. The Computer Software section at Article Alley has hundreds of software product and software development articles that are free to use. The software articles cover a wide range of sub topics such as security, integration, gaming, office productivity, business management and lots more. Article Alley does have a broader article directory with articles on almost any topic. Their content is free to use if a working hyperlink is retained to the source page on Article Alley and the author has selected their articles to be free to republish.
Author: pobalopalous
TrImport – Trim your insert statements
Did you ever want to copy data from database to another and want to exclude certain columns? With the basic export utility in SQL Developer one can specify a selection criteria (effectively a where clause) to export certain rows. It will produce an SQL script with insert statements. However, virtual, or calculated, columns are also included, even though their data can be derived. This is a problem only when attempting to run the script against the target database, it will not allow you to perform an insert on a virtual column. It is my understanding that this is to be addressed in a later Oracle Database 11g release. Until then, what are you to do?
Well, you could use Oracle Data Pump to export only the specific columns. However, in my case, I had the export SQL scripts to start with, provided my someone else, and not the original DB.
I put together a very simple Java Swing application (called TrImport) which allows you to remove columns, and their corresponding values, from an insert statement in an SQL script.
With TrImport now you can easily change the following SQL statement
insert into TABLE_A set (ROW_ID, NAME, DESC, NAME_VC) values (456, ‘Record Two’, ‘This is a record’, ‘record two’);
to this
insert into TABLE_A set (ROW_ID, NAME, DESC) values (456, ‘Record Two’, ‘This is a record’);
with ease. Obviously the benefit is not that this can be done with just one insert statement, but all of the insert statements in a file.
The steps are really simple:
1. Open the file with you SQL script. This can be a mixed script with inserts, updates, comments, just about anything.
2. Open the columns window to see the tables and columns that TrImport has identified in any insert statements it has found.
3. Tick the columns you want to exclude and press OK.
4. Save the file to a new location.
TrImport is not just for virtual columns either, it can also be used in a situation where the table in the destination database has fewer columns.
To get TrImport and run it simply download the trimport-0.1.jar and from the command line execute ‘java -jar trimport-0.1.jar’. If you wanted to, you could setup a short cut. TrImport is provided without any support. It has only been tested with a small set of SQL scripts and only with one function, that is to_timestamp.
Broadband in India
Normally I would not provide a link to a site without a privacy policy. However, for India Broadband Forum I will make an exception with a warning: do not post, just browse for information to see what others are saying about broadband providers in India. The reason I’m doing this is to highlight the huge differences in services provided in different regions. This is important particularly if you are relying on staff in India to work from home at times that overlap with Eastern or Pacific timezones.
You could use the World Speed Test to compare download and upload speeds between regions, cities and service providers in India. Mumbai (10.08 Mbps max) is better off than Madra (9.09 Mbps max), which in turn is better off than Bangalore (7.21 Mbps max). This, however, only gives you part of the picture. The forum, with it’s groups and blogs can give you better insight into user’s experiences with reliability, cost and support. Fast internet access removes one of the barriers to effective distributed teams.
Coherence failed to load the factory
getConfigurableCacheFactory “Failed to load the factory”
and
Caused by: (Wrapped: Failed to load the factory) java.lang.reflect.InvocationTargetException
at com.tangosol.util.Base.ensureRuntimeException(Base.java:286)
at com.tangosol.net.CacheFactory.getConfigurableCacheFactory(CacheFactory.java:607)
at com.tangosol.net.CacheFactory.getCache(CacheFactory.java:686)
at com.tangosol.net.CacheFactory.getCache(CacheFactory.java:664)
When is a string literal too long?
When it’s a multi-byte encoded string, that’s when.
Recently I came across a runtime problem where an ORA-01704 (string literal too long) error was occuring when inserting some text into a database table. The column had been set to the maximum amount of characters allowed for VARCHAR2, that is 4000 characters. Before inserting any values, the text was put through a truncation method to make sure it did not exceed 4000 characters. That’s what made the issue such a conundrum. If we had code limiting the string to 4000 characters, and the logs for the SQL statement were showing that the truncation to 4000 characters was happening, why was the Oracle database reporting that the string was longer than 4000 characters?
This is where the logs became very important. I noticed that the some of the text contained non-Western European characters, which was perfectly valid. However, while these characters are counted as single characters, depending on the encoding, they could be multi-byte characters. Not only is 4,000 the maximum number of characters for VARCHAR2, it is also the maximum number of bytes. In our case, we had a string of 4,000 characters, but in UTF-8 it required 4,017 bytes to store it. So, the solution was to make a slight change to the truncation logic, by introducing a maximum number of bytes for a specific character encoding. Now the truncation method has the following:
try {
while (truncatedString.getBytes(charSetName).length > maxBytes) {
// remove the last character and check the bytes lenght again
truncatedString = truncatedString.substring(truncatedString.length() - 2);
}
} catch (UnsupportedEncodingException e) {
logger.log(Level.SEVERE, "The character set " + charSetName +
" is not supported. Unable to truncated string if it is too long.", e);
}
The variable charSetName is set to the character set used by the database (in our case UTF-8) and the maxBytes variable is the maximum number of bytes allowed (in our case 4000). In the rare cases when there are over 4000 bytes in the string, this code will systematically remove the last character until the number of bytes come down. This code could be improved to be more efficient. For example, the code could check how many characters need to be removed and then remove that chunk, rather than removing a character at a time. It performs in the scenario it is used because the string is already chopped down to 4,000 characters. If the system begins to receive a large amount of multi-byte characters in a single string, then reducing the string to 4,000 characters may still leave you with an 8,000 byte string. Let me know if you determine a more efficient approach.