msgbartop
News, views, tips and tricks on Oracle and other fun stuff
msgbarbottom

16 Links to Help You Learn And Use Regular Expressions

Regular expressions can save you hours or even days of work in some cases. For anyone not yet familiar with regular expressions, I definitely recommend to get to know at least the basics. That’s what Tanel Poder advised his readers and I agree with him. To that end, here is a list of resources (in no specific order) that will help you and me understand and learn regular expressions:

  1. The Regex Coach – interactive regular expressions: A graphical application for Windows which can be used to experiment with (Perl-compatible) regular expressions interactively.
  2. RexV.org: This site is a regular expression evaluator for three different regular expression systems, PHP PCRE, PHP Posix and Javascript.
  3. Regular-expressions.info: On this site, you can find a quick start guide, tutorials, references and ready-to-use regular expression examples.
  4. Quick Reference Guide: Regular expressions cheat sheet (PDF).
  5. Know your regular expressions: Essential aids in building and testing regular expressions on UNIX systems.
  6. The absolute bare minimum every programmer should know about regular expressions.
  7. Learning Regular Expressions: Video tutorial.

And here is a list of Oracle related regular expressions links:

  1. Understand Oracle 10g SQL Regular Expression support: The Oracle database has built-in regular expressions built upon the POSIX standard.
  2. Writing Better SQL Using Regular Expressions: The regular expressions feature in Oracle Database 10g is a powerful tool for manipulating textual data.
  3. Using Regular Expressions in Oracle Database: This chapter from the Oracle Database Application Developer’s Guide introduces regular expression support for Oracle Database.
  4. Multilingual Regular Expression Syntax: Lists the full set of operators defined in the POSIX standard that Oracle follows.
  5. Regular Expression Operator Multilingual Enhancements: Oracle’s implementation of the POSIX operators extends beyond the matching capabilities specified in the POSIX standard.
  6. REGEXP_INSTR: Extends the functionality of the INSTR function by letting you search a string for a regular expression pattern.
  7. REGEXP_SUBSTR: Extends the functionality of the SUBSTR function by letting you search a string for a regular expression pattern.
  8. REGEXP_REPLACE: Extends the functionality of the REPLACE function by letting you search a string for a regular expression pattern.
  9. REGEXP_LIKE: It is similar to the LIKE condition, except REGEXP_LIKE performs regular expression matching instead of the simple pattern matching performed by LIKE.

Note that Oracle regular expressions support started with  the Oracle database version 10gR1 and above.

4 Comments | Filed in Links | Tags:


Oracle Database 11g Overview Presentation

I have stumbled upon the following presentation by Mark Townsend, the vice president of database product management, titled The Future of Database Technology. Towards the middle of the presentation, there is a high level overview of many Oracle database 11g features like SQL replay, online table and index redefinition, automatic diagnostic workflow, support for online hot patching and other highlights.

Here is the full document: Continue reading…

2 Comments | Filed in Oracle | Tags:


Cursors Again

Reading through other programmers’ code I often discover interesting things that sometimes I find hard to explain. For example, consider the following simple PL/SQL block:

DECLARE
   CURSOR emp_cur
   IS
      SELECT first_name
        FROM employees
       WHERE employee_id = 100;

   l_emp_name employees.first_name%TYPE;
BEGIN
   IF emp_cur%ISOPEN
   THEN
      CLOSE emp_cur;
   END IF;

   OPEN emp_cur;

   FETCH emp_cur
    INTO l_emp_name;

   CLOSE emp_cur;

END;

The PL/SQL package I was reviewing had the same exact pattern for every query. Basically, every query was declared as an explicit cursor and code similar to the above was used to open, fetch and close every cursor in the program.

I do not understand two things here: the need for an explicit cursor, and the need for this “IF cur%ISOPEN THEN CLOSE cur; END IF;” before “OPEN cur …. CLOSE cur“. Do you?

I would have coded the above like this:

DECLARE
   l_emp_name   employees.first_name%TYPE;
BEGIN
   SELECT first_name
     INTO l_emp_name
     FROM employees
    WHERE employee_id = 100;

EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      DBMS_OUTPUT.put_line ('Not found');
END;

In this example, since the employee_id is the primary key of the employees table, there is no need to code for the TOO_MANY_ROWS exception.

Andrew Clarke has a good post about implicit and explicit cursors in response to Misbah Jalil’s post about the same subject. And here is a virtual book about cursors in Oracle DB 10gR2.

7 Comments | Filed in Oracle | Tags:


The Smallest Database Management System Is Just 359 Kilobytes

gears_sm

As you may already know, Google recently released Google Gears, an open source browser extension that lets developers create web applications that can run offline using JavaScript APIs.

Google Gears provides three key features:

  • A local server, to cache and serve application resources (HTML, JavaScript, images, etc.) without needing to contact a server.
  • A database, to store and access data from within the browser.
  • A worker thread pool, to make web applications more responsive by performing expensive operations in the background.

Apart from the coolness and usefulness of Gears (I can now read my Google Reader feeds offline), what also caught my attention was its use of a database to store and access data. After all, that’s what databases are good at, data storage and management. I was curious to know what type of a database Gears uses. Well, according to its database module API, Google Gears uses the open source SQLite database system.sqlitelogo

SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine.

SQLite is really interesting. There is no set up procedure to initialize it before using it. Databases need minimal or no administration. There is no need to maintain a separate server process dedicated to SQLite. It supports ACID and is thread-safe.

SQLite supports a large subset of SQL-92 data definition and manipulation features. You can create tables, indexes, triggers, and views. You can manipulate stored information using INSERT, DELETE, UPDATE, and SELECT SQL constructs. However, some SQL-92 features are not yet supported.

SQLite stores an entire database in a single, ordinary native file that can reside anywhere in a directory of the native file system. Any user who has a permission to read the file can read anything from the database.

sqlite3What’s also interesting about SQLite is its size. The whole code footprint ranges from 224KB up to 513KB depending on what compiler optimizations are used. I downloaded the pre-compiled SQLite binaries for windows, it is just one 359KB file, sqlite3.exe.

sqlite3 is somewhat similar to Oracle’s SQL*Plus. You can use it to enter SQL commands. For example, from the DOS command prompt, the following creates a database file named eddie.db:

C:\Users\Eddie\Documents\sqlite>sqlite3 eddie.db
SQLite version 3.3.17
Enter “.help” for instructions
sqlite>

Now, let’s do some DML and DDL:

sqlite> create table tbl1(one varchar(10), two smallint);
sqlite> insert into tbl1 values(‘hello!’,10);
sqlite> insert into tbl1 values(‘goodbye’, 20);
sqlite> select * from tbl1;
hello!|10
goodbye|20
sqlite> CREATE TABLE tbl2 (
   …>    f1 varchar(30) primary key,
   …>    f2 text,
   …>    f3 real
   …>    );
sqlite>

Does SQLite have a data dictionary? Yes it does, and it’s only one table called sqlite_master:

sqlite> select * from sqlite_master;
table|tbl1|tbl1|2|CREATE TABLE tbl1(one varchar(10), two smallint)
table|tbl2|tbl2|3|CREATE TABLE tbl2 (
   f1 varchar(30) primary key,
   f2 text,
   f3 real
   )
index|sqlite_autoindex_tbl2_1|tbl2|4|
sqlite>

Interesting. Going back to Gears, if you are wondering where the location of the database file is, it basically depends on the browser and the platform you are using.

If you are wondering what can SQLite be used for, of course, you have Google Gears as a perfect example. But, there are other appropriate uses as well.

By now, you may be thinking about Oracle Database Express Edition as also being an entry-level, small-footprint database, but hey, SQLite does not even come close to Oracle XE. Each one serves and is suitable for different types of applications. Moreover, do you really think that a 359KB RDBMS can put a dent into a 165MB RDBMS?

Comments Off | Filed in Oracle, Technology | Tags: , , ,


When ANSI SQL Join Syntax Does Not Work in Oracle

I have lost confidence in Oracle’s ANSI style SQL. Eric, in his comment to the post Back to basics: anti-joins and semi-joins, warned me of the following gotcha:

If you are writing queries that select from many tables, like denormalizing data for warehousing, and the sum of the columns in those tables exceeds 1,050, you always get ORA-01445. This occurs from 9i through 10g2, and has happened often enough to me that I avoid my preference for ANSI syntax on Oracle databases, unless I’m just selecting from a few tables.

Well, it just happened to me. Below are two queries. They both select from standard Oracle E-Business Suite (11.5.10) tables. The two queries are identical except that the first uses the ANSI style syntax, and the second uses the Oracle syntax. As you can see below, the query that uses ANSI joins failed miserably with the error:

ORA-01445: cannot select ROWID from, or sample, a join view without a key-preserved table.

This looks like a bug to me. Interestingly, if you change the SELECT NULL to SELECT COUNT(*), the query executes successfully. Continue reading…

17 Comments | Filed in Joins, Oracle | Tags: ,


Oracle SQL Developer 1.2 Released

Oracle SQL Developer, the free graphical tool for database development, has just been upgraded from 1.1 to 1.2. Here is the list of bug fixes and here is the release notes document including new features and known issues.

If you are already running production release 1.1 (v 1.1.0.23.64) or above, you can use Help > Check for Updates to update your SQL Developer environment. Otherwise, you can download Oracle SQL Developer 1.2 from here.

1 Comment | Filed in Oracle | Tags:


Oracle Database 11g to Launch on July 11

Here is the email I received from Oracle:

Dear Edward Awad,

The history of information technology is a journey, defined by innovations such as the internet and grid computing. Oracle would like to personally welcome you to see the next generation of innovation by inviting you to the launch of Oracle Database 11g.

This is your opportunity to join Oracle President Charles Phillips and Oracle Senior Vice President Andy Mendelsohn, as well as leading industry experts from some of the most innovative companies of our time. Collectively, they will help you understand what’s needed to compete at this point in history, and how Oracle’s latest database release will help meet those needs.

The launch event is going to take place on July 11 in New York city.

Moreover, watch for 11g demos up on Morgan’s Library within a week of the production release.

1 Comment | Filed in Oracle | Tags: ,


Why Resumes Are Useless Plus Links to Interview Questions

Resumes seem to be mostly useless, this is what Andrew Wulf thinks, and I can’t agree more. I have been conducting a few interviews lately to fill a PL/SQL contract position, and in almost all cases the resume was so overcharged with buzzwords and all kinds of technologies created in the past 10 years. However, when the moment of truth (the interview) comes, few candidates know the answer to very basic questions.

Moreover, the resumes I have seen were obviously made to order. I know that when I get the resume as an email file attachment and the Word document file name is something like: JohnDoeCompanyName.doc. This is an obvious hint that a different Word document (resume) is created for every company the staffing agency or the candidate submits the resume to. They basically tailor the resume to the specific job requirement the hiring company is looking for.

I totally agree with these quotes from Andrew Wulf’s article:

  1. Resumes become a kind of worm to dangle in front of the recruiter or HR fish, just enough to hook some interest.
  2. Tests rarely demonstrate ability other than memorization anyway; I’ve known people who aced certification tests and were utterly unable to develop any useful applications. Certifications themselves seem mostly ignored as well, probably for this good reason.
  3. It’s all in the way they communicate their knowledge, respond to specific questions on projects they claim to have worked on, and demonstrate a willingness to learn.
  4. Would you hire a homebuilder on the basis of ability to hit a nail into a board?
  5. The end result is not to find that one person with the exact resume matching a laundry list of technologies (they have 3.14159 years of JUnit!) but someone who can work successfully with the other team members, is capable of doing or learning anything required, knows how to think, and has some kind of track record of actual work.

In any case, here are a few links to Oracle interview questions:

  1. www.geekinterview.com/Interview-Questions/Oracle
  2. www.get-best.com/IT_Interview_Questions/oracleDBAQA1.htm
  3. www.techinterviews.com/index.php?cat=12
  4. www.kyapoocha.com/category/oracle-interview-questions
  5. dev.fyicenter.com/interview/oracle.html
  6. thinkoracle.blogspot.com/2007/06/sql-interview-questions.html
  7. www.oraclemusings.com/?p=61
7 Comments | Filed in Oracle | Tags: , ,


Have You Heard of Tumblelogs?

I’m not a big fan of blogrolls. A blogroll is a collection of links to other blogs. I believe what’s more interesting and useful is to have a a collection of links to other blog posts and web pages, or a linkblog. Some bloggers use the shared items in Google Reader as their linkblog. Robert Scoble uses this approach for his famous linkblog.

But even a linkblog can be limiting. What if you want to blog not only links, but also photos, quotes, dialogues and video, quickly and easily. Well, there is a special type of blog, called tumblelog, that does exactly that. Unlike blogs, there is no commenting on tumblelogs.

I like this tumblelog idea. So I set up one, Eddie Awad Randomized (feed). I’ll be posting interesting, educational, useful or just plain fun tumbles, Oracle and non-Oracle related. I also set it up to to automatically import my shared items in Google Reader. But unlike Google Reader’s shared items, I can search my tumblelog using any known blog search service.

Eddie Awad Randomized is powered by tumblr, a free and extremely easy online tool for creating tumblelogs.

EddieAwadRandomized

Note: I’m writing this blog post using Windows Live Writer, I like it. 

5 Comments | Filed in Links, Oracle, Technology | Tags: