Posts

Antlr3 Code Too Big

Antlr3 can generate very large java files for complex grammars. Javac can have a problem compiling them due to the size limit of static initializers in a class file. An error like the following : code too large > > [12:56:12] public static final String[] tokenNames = new String[] { > > [12:56:12] ^ > > [12:56:12] 1 error My solution was to post process the generated Java files. Moving a large section of static final initializers to a seperate interface(s). Then reference (implement) the interface in the original Java file. package oracle.dtools.ant.antlr3; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import org.apache.tools.ant.Task; public class Antlr3PostProcess extends Task { private File oldTarget = null; private String pkg = null; private File newTarget= null; private File currentInterface = null; private int interfaceInd...

Antlr 3 Tips

AntlrWorks When dealing with large grammars start AntlrWorks with more memory otherwise it can hang. java -Xmx1g -jar antlrworks-1.2.3.jar Antlr 3 Parser Some Antlr rule names are not valid in Java and will cause a compilation issue. For example: byte: ... ;

Line Count CLOB or VARCHAR2

I must be missing something, there has to be an easier way to count the number of lines in a VARCHAR2 or CLOB. For the moment this does the trick ,but Id appreciate a heads up for a better solution. length(regexp_replace(regexp_replace(TEXTVALUE,'^.*$','1',1,0,'m'),'\s','')) http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions130.htm#SQLRF06302 The inner regexp_replace matches each line = '^.*$' Replace each line with the '1' character. Beginning character = 1 First occurance = 0 Tell oracle its a multiline string = 'm' The outer regexp_replace removes the new lines left over. Counting the remaining characters gives you the line count. Ill have to look into a better solution. >EDIT Heres a much much more performant solution LENGTH(TEXTVALUE) - LENGTH(replace(TEXTVALUE,chr(10)))) replacing all CHR(10) (linefeed char) with nothing. Then compare with original length. A query which took me 40 minute...

SQL Server 2005 CROSS APPLY conversion

SQL Server 2005 provides a CROSS APPLY clause which in Oracle terms allows a correlated inline view or table function. Heres some SQL Server CROSS APPLY background. http://weblogs.sqlteam.com/jeffs/jeffs/archive/2007/10/18/sql-server-cross-apply.aspx There are a couple of ways to convert this based on what exactly is trying to be done. But here are a few methods. There are 2 main uses of CROSS APPLY 1) CROSS APPLY with a table function 2) CROSS APPLY with a subquery (inline view in Oracleze) 1) CROSS APPLY with a table function Jeff Smith put together this neat example of using a table function with CROSS APPLY http://www.sqlteam.com/article/returning-complex-data-from-user-defined-functions-with-cross-apply I expanded this example to try out a few different scenarios drop table emails go create table emails (ID int primary key, EmailAddress varchar(100)) go --added 2 rows which cant be processed by EmailParse insert into emails select 1,'test1@gmail.com' union all select 2,...

Oracle Open World Migration Sessions

Image
Oracle Open World 2008 is kicking off on the 21st September. www. oracle .com/ openworld There are some migrations sessions scheduled which can be signed up for now. S298684 : Hands-on Lab: Migrate Your Third-Party Database to Oracle Database 11g Today S298684 : Consolidate Your Desktop Databases to Oracle Database 11g Hope to see you there Dermot.

Offline Data Move DATEs

Image
During the offline data move, scripts are created to use BCP to dump out your data in SQL Server or Sybase to .dat files. Other scripts are created to use Oracle SQL*Loader to load the .dat files into the Oracle tables. Your SQL Server/ Sybase database will dump out the DATETIME and SMALLDATETIME values in formats which may not be recognized by Oracle. So you have to specify what the format mask is. SQL Server / Sybase DataTypes DATETIME has millisecond precision. SMALLDATETIME has only second precision. Oracle DataTypes DATE has only second precision TIMESTAMP has millisecond precision You can specify their format mask in the migration preferences. The preferences work like this The Timestamp Mask is applied to the DATETIME Sybase or SQL Server values The Date Mask is applied to the SMALLDATIME Sybase or SQL Server values. So now the full date value is recognized by SQL*Loader. The best bit is that even if you map Sybases/ SQL Servers DATETIME to Oracles DATE (which is the def...

SQL Developer Migration Workbench 1.5.1 for Sybase / SQL Server Quick Guide

This Quick Guide will run through the main steps you should take to perform a Sybase or SQL Server migration to Oracle. Installation Download the latest version of SQL Developer ( using 1.5.1 today), to your Development PC which can access your Oracle database and your SQL Server/ Sybase database. SQL Developer ships with the migration extensions built in. Download and Install Oracle XE if you dont have access to an exiting Oracle database. UnZip SQL Developer into its own directory (for example "SQLDev") Don't use an existing ORACLE_HOME or ORACLE directory Run sqldeveloper Setup the jtds driver (open source JDBC driver for Sybase and SQL Server) with SQL Developer JTDS can be got using the Check For Updates feature. Tools > Prefereneces > Extensions > Check For Updates . Walk through the wizard and choose any new migration updates and the JTDS driver. Setup Connections & Migration Repository Create a connection to Sybase or SQL Server Create a connection...