Re: [EXTERNAL] Sql update script. check for existing rows before inserting...
Hick Gunter <hick-p6o8VmWS/[email protected]> Mon, 24 Feb 2020 07:33:19 +0000
| Newsgroups | gmane.comp.db.sqlite.general |
|---|---|
| Message-ID | <7fae58394053d95efd2bd77b7cb93f76a3e13359@localhost> |
SQLite is not a procedural language. IF is not a programming construct, it is part of an expression. -----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:[email protected]] Im Auftrag von Andy KU7T Gesendet: Montag, 24. Februar 2020 05:17 An: SQLite mailing list <[email protected]> Betreff: [EXTERNAL] [sqlite] Sql update script. check for existing rows before inserting... Hi, I would like to write a script that checks whether certain records already exist, and if not, insert them. If they do exist, it should be a no op. I am trying this: IF (SELECT COUNT(*) FROM [Antennas]) = 0 BEGIN /* Table data [Antennas] Record count: 16 */ INSERT OR REPLACE INTO [Antennas]([Code], [Antenna], [Bands], [Ports], [Offset], [Bidirectional]) VALUES(0, '', '', null, null, '0'); -- a few of those... END; However, I am getting a syntax error near IF. Any ideas where my error is? Thanks Andy Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10 _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0 May be privileged. May be confidential. Please delete if not the addressee. _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users