Sql update script. check for existing rows before inserting...

Andy KU7T <[email protected]> Mon, 24 Feb 2020 04:17:14 +0000
Newsgroups gmane.comp.db.sqlite.general
Message-ID <MWHPR1301MB2206B1FF7A13C1E127E79A24AEEC0@MWHPR1301MB2206.namprd13.prod.outlook.com>
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