SQL Server supports the execution of SQL not within the context of a stored procedure or trigger. This is quite a handy feature when debugging as it allows one to write thowaway code without the overhead of declaring a new stored procedure that later has to be dropped.
Although it is possible to do this in DB2 too, it isn’t as transparent as it is in SQL Server (because – I expect – DB2 is more ANSI SQL compliant than SQL Server). The trick is to declare the code that one wants executed in an ATOMIC block:
begin atomic
declare var_a char(1);
set var_a = (select ibmreqd from sysibm.sysdummy1);
end
@
This may be executed from a Command Center session, or (having connected to a database, and the above dumped into a file called "script.sql") via the CLP:
$ db2 -td@ -vf script.sql
Thanks to DHRUV for a detailed post on the subject.
I have recently acquired a Sansa Fuze and (paired with Sennheiser HD 435 headphones) and I’m very impressed. Its a good looking device with great build quality and – most importantly – fantastic sound quality. It’s so good that I passed up on a 2nd generation iPod Touch (those who know me will know how big a deal that is).
While reports suggest that it supports synching playlists in MTP mode flawlessly, my experience – as a Mac user – is that creating playlists with the device in MSC mode is tricky. Although the Fuze supports M3U playlists, it is very picky about the format. Get it wrong, and the Fuze will refuse (refuze?) to read it, rendering it simply as [Empty]. Thanks to various people on the Sansa forums I better understand the Fuze’s quirks and have hacked together the following script to generate playlists:
#!/bin/bash
# ---------------------------------------------------------------------------- #
# Sansa Fuze M3U playlist creator #
# - run from $SANSA_ROOT/MUSIC #
# ---------------------------------------------------------------------------- #
# Don't descend more than 1 level. In my collection each directory represents
# an album. Multi-disc albums - with the individual discs in subdirectories -
# will have all discs in a single playlist, which is what I want.
for file in $(find . -maxdepth 1 -type d)
do
if [ $file != "." ]
then
# Write the playlist in the main album directory
cd $file
# Tell find to render the names of the MP3s that it finds using the
# Windows standard CR-LF line terminator. (Sansa requirement)
find . -name \*.mp3 -printf %p\\r\\n | \
# Convert the '/' file separator to the Windows standard '\' (Sansa
# requirement).
sed -e '/\//s//\\/g' | \
# The Sansa doesn't seem to handle relative paths correctly. If the
# filenames in the playlist contain a leading '.\' the device cannot read
# the playlist and renders it as '[Empty]'. So we cut those characters
# from the filename/path produced by 'find'.
cut -b 3- > $file.m3u
# Head back for more ...
cd - > /dev/null
fi
done