A couple of days ago i discovered Oracle SQL Developer, a new and free graphical tool for database development. At first i was impressed by all it’s features but when i tried to modify a couple of existing stored procedures the application freezed. EricH directed me to the FAQ: Can I suppress Code Insight (and why would I want to)?. Now that i have added the ‘AddVMOption -J-Dsdev.insight=false’ to my sqldeveloper.conf the application runs smooth
Monthly Archives: August 2006
Dynamic CSS with PHP
Both html and css are simply text. Thus you should be able to generate css as easily as html with php. Now if you add a reference to the css.php file in your html (eg: <link rel=”stylesheet” href=”http://example.com/css.php” type=”text/css” media=”screen” />) you’ll probably experience that your browser ignores the file. How is this possible? Here is an example of a simple css.php file
body {
background-color: <?php echo 'yellow'; ?>;
}
Here is a simulation of what your browser recieves when it requests the file:
HTTP/1.1 200 OK
Date: Sat, 26 Aug 2006 23:36:21 GMT
Server: Apache/1.3.34 (Unix) PHP/4.4.2 mod_macro/1.1.2
X-Powered-By: PHP/4.4.2
Connection: close
Content-Type: text/html; charset=iso-8859-1
body {
background-color: yellow;
}
Where did that content-type header come from? Well, php outputs a default content-type header (text/html) when you don’t set value explicitely. This means that your browser will try to interpret the file as html instead of css. Although it may seem weird, this behaviour is explicitely defined in RFC 2616.
So the solution is pretty simple: explicitely generate content-type header. Here is an example for css: (You’re smart enough to figure it out for csv, m3u, …)
<?php header('Content-type: text/css');?>
body {
background-color: <?php echo 'white'; ?>
}
Unable to enlist in a distributed transaction
Earlier today we were confronted with the following OracleException: Unable to enlist in a distributed transaction. Our code (and accompanying tests) had been running fine for the last two weeks thus we expected there was a problem with the database. A member of the DBA team assurred us there was nothing wrong with the database. Finally we discovered that we had created a circular reference and thus the program ended up in an endless loop (well untill the database decided it had been enough anyway :p). Here is a simplified version of the problem:
public void DoA() {
using (TransactionScope scope = new TransactionScope()) {
using (OracleConnection con = new OracleConnection(connectionString)) {
con.Open();
DoB();
scope.Complete();
}
}
}
public void DoB() {
using (TransactionScope scope = new TransactionScope()) {
using (OracleConnection con = new OracleConnection(connectionString)) {
con.Open();
DoA();
scope.Complete();
}
}
}
Without the use of TransactionScope this results in a Connection request timed out exception.
Experimenting with Oracle and PL/SQL
As i already wrote, last couple of days i’ve been experimenting with PL/SQL. At work we use Toad for Oracle but since TOADSoft only offers a limited freeware version i decided to write my code with GVim and use SQL*Plus at home. Here are a couple of lines i added to my login.sql file:
DEFINE _EDITOR='gvim -c "set filetype=sql"' SET SERVEROUTPUT ON SET LINESIZE 120 SET AUTOCOMMIT OFF ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD';
In a stored procedure i created and filled an instance of NUMBER_TABLE (CREATE TYPE NUMBER_TABLE AS TABLE OF NUMBER) and my stored procedure tried to select all the rows in that table (SELECT * FROM V_NUMBER_TABLE). Apparently the engine didn’t know this type @runtime despite the fact that i declared it in my stored procedure (V_NUMBER TABLE NUMBER_TABLE := NUMBER_TABLE();) and the engine compiled the package without errors. I got round that problem as following:
SELECT * FROM (CAST(V_NUMBER_TABLE AS NUMBER_TABLE));
Installing MSDN Library May 2006
Today i downloaded the freely available MSDN Library (May 2006 Edition). I appended .iso to the filenames and mounted the first image with Nero ImageDrive. After a while i got the following error message: “Source file not found: _17693_RTL_x86_enu_NET_Framework_SDK_HxS.cab”.

Apparently this file exists on the second disk (Why doesn’t the installer ask me to insert the second disk?). And yes, a little while later the same thing happens again when the third disk is expected….
Inserting pause to your Console Applications
When i write Console Applications i find myself to write the following two lines quite often:
Console.Write("{0}Press any key to continue...", Environment.NewLine);
Console.ReadKey();
As you already know i’m lazy so i decided to write an IntelliSense Code Snippet. When i type “pau” Intellisense show the following:

Next i hit the tab button twice and i get the following effect:

Download pause.txt and save it as Pause.snippet in your %My DocumentS\Visual Studio 2005\Code Snippets\Visual C#\My Code Snippets% folder.
I’ve made it even simpler, you can install the snippet by simply running the pause.vsi package (Visual Studio Installer).
