Google Groups Home
Help | Sign in
Message from discussion Seeking simple after insert example
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Dave Hughes  
View profile
 More options May 16, 11:47 pm
Newsgroups: comp.databases.ibm-db2
From: "Dave Hughes" <d...@waveform.plus.com>
Date: Fri, 16 May 2008 22:47:01 -0500
Local: Fri, May 16 2008 11:47 pm
Subject: Re: Seeking simple after insert example

gimme_this_gimme_t...@yahoo.com wrote:
> I'm using DB2 8.1.

> Suppose table foo has columns name and lname:

> create table foo
> (name as varchar(200),
> lname as varchar(200));

> Write a trigger that inserts the lower case value of name after an
> insert:

> So

> insert (name) into foo values ('Hello World");

> Then:

> select * from foo;

> Results in:

> "Hello World","hello world"

> Thanks

Any particular reason you don't want to use a generated column?

CREATE TABLE FOO (
  NAME VARCHAR(200),
  LNAME VARCHAR(200) GENERATED ALWAYS AS (LOWER(NAME))
);

Cheers,

Dave.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google