Mar 31, 2014, 3:28 PM
Post #4 of 4
Hmm, is this really a Perl question? I doubt...
Re: [PapaGeek] SQL if then else situation
[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)