Thread

  1. Convert to upper

    Matthias Teege <matthias@mteege.de> — 2001-03-02T14:29:22Z

    Moin,
    
    is there any way to limit values to upper case strings?
    Somthing like:
    
    name char(15) DEFAULT (upper(name))
    
    or must I use triggers?
    
    Many thanks 
    Matthias
    
    -- 
    Matthias Teege -- matthias@mteege.de -- http://emugs.de
    make world not war
    PGP-Key auf Anfrage
    
    
    
  2. Re: Convert to upper

    Mitch Vincent <mitch@venux.net> — 2001-03-02T15:52:36Z

    > is there any way to limit values to upper case strings?
    > Somthing like:
    > 
    > name char(15) DEFAULT (upper(name))
    >
    > or must I use triggers?
    
    I'd say a trigger is your best bet. 
    
    -Mitch
    
    
    
  3. Re: Re: Convert to upper

    Rod Taylor <rod.taylor@inquent.com> — 2001-03-02T16:05:42Z

    check
    
    create table uppercase (
      name char(15) check (name ~ '[A-Z]')
    );
    
    --
    Rod Taylor
    
    There are always four sides to every story: your side, their side, the
    truth, and what really happened.
    ----- Original Message -----
    From: "Mitch Vincent" <mitch@venux.net>
    To: <pgsql-general@postgresql.org>
    Sent: Friday, March 02, 2001 10:52 AM
    Subject: [GENERAL] Re: Convert to upper
    
    
    > > is there any way to limit values to upper case strings?
    > > Somthing like:
    > >
    > > name char(15) DEFAULT (upper(name))
    > >
    > > or must I use triggers?
    >
    > I'd say a trigger is your best bet.
    >
    > -Mitch
    >
    >
    > ---------------------------(end of
    broadcast)---------------------------
    > TIP 2: you can get off all lists at once with the unregister command
    >     (send "unregister YourEmailAddressHere" to
    majordomo@postgresql.org)
    >
    
    
    
  4. Re: Convert to upper

    Peter Schindler <pschindler@synchronicity.com> — 2001-03-02T16:16:18Z

    Matthias,
    
    the easiest way is to use CHECK constraints. see example below.
    
    Servus,
    Peter
    
    Matthias Teege wrote:
    > is there any way to limit values to upper case strings?
    > Somthing like:
    > 
    > name char(15) DEFAULT (upper(name))
    > 
    > or must I use triggers?
    
    test=# create table bla(bb char(10) CHECK (bb =UPPER(bb)));
    CREATE
    test=# \d bla
                 Table "bla"
     Attribute |     Type      | Modifier
    -----------+---------------+----------
     bb        | character(10) |
    Constraint: ((bb)::text = upper((bb)::text))
    
    test=# insert into bla values ('OTTO');
    INSERT 381409 1
    test=# insert into bla values ('otto');
    ERROR:  ExecAppend: rejected due to CHECK constraint bla_bb
    ERROR:  ExecAppend: rejected due to CHECK constraint bla_bb
    test=# select * from bla;
         bb
    ------------
     OTTO
    (1 row)
    
    
  5. Re: Re: Convert to upper

    Mitch Vincent <mitch@venux.net> — 2001-03-02T16:31:58Z

    Oh, I misunderstood.. I read his post that he wanted anything inserted to be
    converted to upper case.. If you're just looking to throw an error if it's
    not upper case, the check constraint is the way to go..
    
    My apologies, I'll try and read more carefully..
    
    -Mitch
    
    ----- Original Message -----
    From: "Rod Taylor" <rod.taylor@inquent.com>
    To: <pgsql-general@postgresql.org>
    Sent: Friday, March 02, 2001 11:05 AM
    Subject: Re: Re: Convert to upper
    
    
    > check
    >
    > create table uppercase (
    >   name char(15) check (name ~ '[A-Z]')
    > );
    >
    > --
    > Rod Taylor
    >
    > There are always four sides to every story: your side, their side, the
    > truth, and what really happened.
    > ----- Original Message -----
    > From: "Mitch Vincent" <mitch@venux.net>
    > To: <pgsql-general@postgresql.org>
    > Sent: Friday, March 02, 2001 10:52 AM
    > Subject: [GENERAL] Re: Convert to upper
    >
    >
    > > > is there any way to limit values to upper case strings?
    > > > Somthing like:
    > > >
    > > > name char(15) DEFAULT (upper(name))
    > > >
    > > > or must I use triggers?
    > >
    > > I'd say a trigger is your best bet.
    > >
    > > -Mitch
    > >
    > >
    > > ---------------------------(end of
    > broadcast)---------------------------
    > > TIP 2: you can get off all lists at once with the unregister command
    > >     (send "unregister YourEmailAddressHere" to
    > majordomo@postgresql.org)
    > >
    >
    >
    > ---------------------------(end of broadcast)---------------------------
    > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
    >
    
    
    
  6. Re: Convert to upper

    Tomek Zielonka <tomek-lists@mult.i.pl> — 2001-03-03T12:41:16Z

    On Fri, Mar 02, 2001 at 11:05:42AM -0500, Rod Taylor wrote:
    > check
    > 
    > create table uppercase (
    >   name char(15) check (name ~ '[A-Z]')
    > );
    
    If don't want lowercase letters, but allow digits, !@#$%^&*( etc.:
    
    create table uppercase (
      name char(15) check (name !~ '[[:lower:]]')
    );
    
    If you want only uppercase letters:
    
    create table uppercase (
      name char(15) check (name ~ '^[[:upper:]]*$');
    );
    
    Tomek
    
    -- 
    .signature: Too many levels of symbolic links