473,765 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

uppercase trigger

How can I create a trigger that obliges UPPERCASE of a field in the
database?

thanks
Jul 23 '05 #1
3 9576
Fernand St-Georges wrote:
How can I create a trigger that obliges UPPERCASE of a field in the
database?


Don't use a trigger. Set up the front-end to change data to upper case.

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Jul 23 '05 #2
Fernand St-Georges (fe************ ****@videotron. ca) writes:
How can I create a trigger that obliges UPPERCASE of a field in the
database?


CREATE TRIGGER uppercase_tri ON tbl FOR INSERT, UPDATE AS
IF UPDATE(uppercas e_col)
BEGIN
UPDATE tbl
SET uppercase_col = upper(i.upperca se_col)
FROM tbl t
JOIN inserted i ON t.keycol = i.keycol
END

If the data comes from GUI entry, I tend however to agree with MGFoster,
that this should be done in the client, because it's confusing for the
user type 'nisse' and next time he looks at the data he sees 'NISSE'.

In this case you may still want enforce the business rule in the database.
To this end a constraint would do. If you are using a case-sensitive
collation it's as easy as:

col varchar(20) NULL
CONSTRAINT tbl_col_upperca se (CHECK col = upper(col))

If you use a case-insensitive collation, it's trickier. But this should
work:

col varchar(20) NULL
CONSTRAINT tbl_col_upperca se
(CHECK col COLLATE Finnish_Swedish _CS_AS = upper(col))

Instead of Finnish_Swedish _CS_AS, use the case-sensitive collation that
matches your case-insensitive collation.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #3
If you have enabled recursive triggers (by default, they are disabled),
you may want to do something like this:

ALTER TRIGGER uppercase_tri ON tbl FOR INSERT, UPDATE AS
IF @@ROWCOUNT>0 AND UPDATE(uppercas e_col)
BEGIN
UPDATE tbl SET uppercase_col = upper(i.upperca se_col)
FROM tbl t JOIN inserted i ON t.keycol = i.keycol
WHERE t.uppercase_col COLLATE Romanian_CS_AS
<> UPPER(i.upperca se_col)
END

(of course, replace Romanian_CS_AS with the case-sensitive collation
that matches your case-insensitive collation)

Razvan

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
25944
by: Hallvard B Furuseth | last post by:
Has someone got a Python routine or module which converts Unicode strings to lowercase (or uppercase)? What I actually need to do is to compare a number of strings in a case-insensitive manner, so I assume it's simplest to convert to lower/upper first. Possibly all strings will be from the latin-1 character set, so I could convert to 8-bit latin-1, map to lowercase, and convert back, but that seems rather cumbersome.
5
5816
by: Paul Schwann | last post by:
Hi everybody, I have a problem with the following code: #include <iostream> int main(void) { std::cout << std::hex << std::uppercase << 31 <<std::endl; return 0;
8
4318
by: Markus Dehmann | last post by:
My ios::uppercase (and others) seems not to work. #include <iostream> using namespace std; int main(){ int num = 45; cout.setf(ios::hex | ios::showbase | ios::uppercase); cout << "number " << num << endl; return 0; }
13
29274
by: GRoll21 | last post by:
I know there is a function but I cannot seem to find it. There should be a way to uppercase a char right? Here is what I got. cout << "Enter title of a book for look up: "; cin >> firstString; if (strcmp(toupper(firstString), toupper(bookTitle)) == 0)
2
21906
by: Thomas McK | last post by:
Hi all, I'm trying to make a SQL query (against a table in MS Access) where I want to take the value of something, and check to see if the first two letters in that value are capitalized (for importing purposes later on!). For example: re_200_3 <-- I want this to be returned because the "re" isn't uppercase. RE_200_2 <-- This value would be fine because it *is* uppercase.
1
1959
by: Beffmans | last post by:
How can I turn the Uppercase mode on in my TextBoxes? ch B. *** Sent via Developersdex http://www.developersdex.com ***
6
9892
by: feeman | last post by:
I can change a field to upper case by using the after event function and the following code Me. = UCase(Me.) But how can you do it so that the whole form will change to Uppercase, there are 20 fields on this form, and I would have to do the above for all of them. There must be a faster way. Anybody know the answer
6
5678
by: 182719 | last post by:
<?php $testcase = 'AKLWC139'; if (ctype_upper($testcase)) { echo "The string $testcase consists of all uppercase letters. \n"; } else { echo "The string $testcase does not consist of all uppercase letters.\n";
4
12584
by: Hrsoft | last post by:
I'm a newbie with asp.net I need to transform a user textbox to uppercase, when typing. Is this possible? I read about Ajax Maskedit, but it is only to certain formats, like dates, etc Thanks in advance. Hércules Russano HRsoft Informática Rio de Janeiro - Brasil
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5277
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.