in reply to Re^2: Updating database question
in thread Updating database question

UPDATE foo SET col3 = 'EN' WHERE LOWER( col4 ) LIKE '%ENG%'
(or LCASE or LC or whatever, depending on the function for your specific database)

lots of options ... personally, I like the Class::DBI one. This is kinda what Class::DBI was created for.


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^4: Updating database question
by shiza (Hermit) on Jun 30, 2005 at 19:26 UTC
    I'll all for Class::DBI. Wouldn't the best solution be to add a handler to the class for that table:
    __PACKAGE__->set_sql(query_name_here => qq{ UPDATE __TABLE__ SET col3 = ? WHERE LOWER( col4 ) LIKE CONCAT('%', ?, '%') };
    I'm not sure if the CONCAT function would be necessary.
      If you're doing the concatenation in SQL, then it's necessary. (Note, CONCAT() is MySQL-specific. Oracle, for example, would use the || operator.)

      Yes, it's possible and probably preferable to do it that way. However, I was demonstrating how CDBI makes simple-to-conceive-of tasks simple-to-do. It's the difference between Assembler (DBI) and Perl (CDBI).


      My criteria for good software:
      1. Does it work?
      2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?