Generate a GUID or UUID in DB2

Want to generate the equivalent of a GUID or UUID in DB2? The closest you’ll get is with GENERATE_UNIQUE(), but beware that you need to do some conversion on it as the value is “BIT DATA” and not character data. To put the value into a typical CHAR or VARCHAR field (like you would with a java UUID), use this…

select TRIM(CHAR(HEX(GENERATE_UNIQUE()))) from sysibm.sysdummy1;

I should probably also mention that there is the IDENTITY and SEQUENCE, but the GENERATE_UNIQUE() function is the closest you’ll get to a GUID or UUID.

Weekly Round-Up: 10/13/13 to 10/19/13

The Weekly Round-Up is a once weekly collection of my #1Aday daily shares. Hope you find something of interest!

Mon 10/14
Peter Shankman @PeterShankman says: Stop Tying Your Employee’s Hands – http://markjacobsen.net/l/1875

Change permissions on files of a specific type in linux

Need to change all *.ksh files to be executable under a directory, but not having luck with a recursive chmod? The issue is you need to combine chmod with a find and xargs like so…

find /home/user -name '*.ksh' | xargs chmod 744

The first piece lists all the files under the path that match *.ksh and passes them to xargs and chmod. If you want to see an example without changing any permissions, just substitute ls -l like so…

find /home/user -name '*.ksh' | xargs ls -l

Find the column causing a DB2 import to fail

Ever run DB2 IMPORT and get a super helpful error like…

SQL0407N  Assignment of a NULL value to a NOT NULL column "TBSPACEID=7,
TABLEID=265, COLNO=2" is not allowed.  SQLSTATE=23502

SQL3185W  The previous error occurred while processing data from row "126" of 
the input file.

After you calm down from wanting to smack a DB2 developer in the face, remember the syscat tables and run this SQL to find out the table and column giving you grief…

select  * 
from    syscat.columns c
            inner join syscat.tables t
                on  c.TABSCHEMA = t.TABSCHEMA
                    and c.TABNAME = t.TABNAME
where   c.COLNO = 2 
        and t.TABLEID = 265
        and t.TBSPACEID = 7

How do I send email from the linux command line?

Need to email from your linux command line? Assuming the underlying pieces are configured correctly (run the 1st example to see) here are the basics…

Send a test email

mail -s "Hi there" someone@somewhere.com

Include some body text…

echo "This is some body text" | mail -s "Hi there" someone@somewhere.com

Email the contents of a file to someone…

mail -s "My Subject" someone@somewhere.com < /path/to/your/file.txt

You can find more here

Weekly Round-Up: 10/6/13 to 10/12/13

The Weekly Round-Up is a once weekly collection of my #1Aday daily shares. Hope you find something of interest!

Mon 10/7
Emily Co on: Ways to Make Passive Income – http://markjacobsen.net/l/1871

Tue 10/8
Krissy Brady @writtenbykrissy on: 12 Habits of Perfectly Organized People – http://markjacobsen.net/l/1872

Wed 10/9
MMM @MrMoneyMustache on: Wealth Advice that Should Be Obvious – http://markjacobsen.net/l/1873

Thu 10/10
iOS 7’s Biggest Annoyances (and How to Fix Them) – http://markjacobsen.net/l/1874

Weekly Round-Up: 9/29/13 to 10/5/13

The Weekly Round-Up is a once weekly collection of my #1Aday daily shares. Hope you find something of interest!

Mon 9/30
11 Tips to Keep iOS 7 From Destroying Your Battery Life – http://markjacobsen.net/l/1866

Tue 10/1
The Minimalists @JFM reminds us: A Rolex Won’t Give You More Time – http://markjacobsen.net/l/1867

Wed 10/2
What to Do (and Not Do) When You’re in a Car Accident – http://markjacobsen.net/l/1868

Thu 10/3
Craig Dewe @LifestyleOutlaw on: How To Double (Or Triple) Your Current Income – http://markjacobsen.net/l/1869

Fri 10/4
Tom Webster @webby2001 says: Open Plan Offices Make People Unhappy – and I would tend to agree – http://markjacobsen.net/l/1870