CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: DBI: Re: [PapaGeek] SQL if then else situation: Edit Log

Veteran / Moderator

Mar 31, 2014, 3:28 PM

Views: 46391
Re: [PapaGeek] SQL if then else situation

Hmm, is this really a Perl question? I doubt...

But anyway...

In Reply To
If all else fails I can just query the table first to see if the record already exists. Not the best way, but it is the Microsoft way!

Nothing wrong with this approach. As far as I can say, the replace query is not a standard SQL command, but probably an extension available on only some relational database engines. If you don't have it, just do it in a two-step (or perhaps even three-step) procedure along the following lines:
- update it it exists, else create, or
- delete if it exists, then create.
After all, Perl is a procedural language that enables you to do thiunks that can't be done in pure SQL. In fact, I did something similar that recently in PL/SQL (so nothing to do with Microsoft, and, although I might be wrong, I do not think that a replace query exists in Oracle SQL). (I wish I could have done it in Perl with DBI, I would have saved quite a bit of time, but the client unfortunately demanded explicitely programs to be written in PL/SQL.)

(This post was edited by Laurent_R on Mar 31, 2014, 3:28 PM)

Edit Log:
Post edited by Laurent_R (Veteran) on Mar 31, 2014, 3:28 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives