Selecting all records which are in upper case - Mailing list pgsql-general

From Amitabh Kant
Subject Selecting all records which are in upper case
Date
Msg-id CAPTAQB+DBM4BRi0Z45SmEWm83PwF-frXm=_mGONujgFAGgNM4A@mail.gmail.com
Whole thread Raw
Responses Re: Selecting all records which are in upper case
List pgsql-general
Hello

I have a simple table 'location' :
id -> Int (associated with a sequence)
name -> Character varying (100)

I have to delete all records where values in name field are all in upper case. For example, if the test data is as follows:

id    name
1    abccvvvv
2    Abc dsase
3    CDF FDER
4    Amcddd FFR
5    EE DFEW
6    Sedcd

Only reecords #3 and #5 are to be deleted. The closest I could reach was this:
"delete from location where (ascii(substring(name from 1 for 1)) between 65 and 90) and (ascii(substring(name from char_length(name) for 1)) between 65 and 90)"
The problem with this query is it would also delete record #4.

How do I get it to select only those records in which all characters are in uppercase?


Amitabh

pgsql-general by date:

Previous
From: pasman pasmański
Date:
Subject: Re: Need help with dropping a view please
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Selecting all records which are in upper case