exists

Drools - check if exists/contains string in a List<String>

匿名 (未验证) 提交于 2019-12-03 01:46:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to create a rule to check if a part of string exists inside a List[String]. Is there a way that i could do it? I'm trying using contains but it's not working. rule "New Assistance" when $room:Room($tags : tags) //$room:Room(tags contains "protocol") $value:String() from $tags //Boolean(booleanValue == true) from $value == "protocol" Boolean(booleanValue == true) from $value.contains("protocol") then System.out.println("Error"); end And here is my code ... val room = new Room(null, List[User](), List[Message](message), new Date, null,

Mysql: RENAME TABLE IF EXISTS

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This DROP TABLE IF EXISTS works, too bad that RENAME TABLE IF EXISTS doesn't work. Can anyone suggest a solution for this query? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS video_top_day TO video_top_day_for_delete' at line 1 query: RENAME TABLE IF EXISTS video_top_day TO video_top_day_for_delete 回答1: I've managed to execute a code that always works and generates no errors when the table doesn't exist: SELECT Count(*) INTO @exists FROM

Check if outlook folder exists

匿名 (未验证) 提交于 2019-12-03 01:45:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Following vb.net code checks if ARS folder exists in Outlook. Following code works very well. But I need a better code. Better code means without using On error goto statement. 回答1: VBA does not have structured exception handling (try/catch in C++, C#, VB.Net or try/except in Delphi). Since MAPIFolder.Folders.Item raises an exception if the specified folder is not found, VBA can only handle exceptions using "on error goto". In VBA.Net, try something like the following (off the top of my head): Try myNewFolder = myFolder.Folders("ARS") Catch

Atomic INSERT WHERE NOT EXISTS (Postgres 9.6.3)

匿名 (未验证) 提交于 2019-12-03 01:44:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The following statement suffers a race condition which I can reliably demonstrate by executing it concurrent in very quick succession. Is there a way to remove this race condition from the below of do I need to take a different approach altogether? INSERT INTO scheduled_event_log ("key") SELECT 'test' WHERE NOT EXISTS( SELECT AGE(now() at time zone 'utc', timestamp_utc) FROM scheduled_event_log WHERE "key" = 'test' AND age(now() at time zone 'utc', timestamp_utc) < '6s' FOR UPDATE); Table as follows: CREATE TABLE scheduled_event_log ( "key"

Php mysql create database if not exists

匿名 (未验证) 提交于 2019-12-03 01:44:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to create a database. Why is not the db created with this code? $dbname = 'regulations_db'; $con = mysql_connect("localhost","root","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } if (mysql_num_rows(mysql_query("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '". $dbname ."'"))) { echo "Database $dbname already exists."; } else { mysql_query("CREATE DATABASE '". $dbname ."'",$con); echo "Database $dbname created."; } This is working, but I think the first one is the best practice: if (mysql

Check if MySQL table exists or not [duplicate]

匿名 (未验证) 提交于 2019-12-03 01:42:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible Duplicate: MySQL check if a table exists without throwing an exception I have a dynamic mysql query builder in my project that creates select queries from different tables. I need to check if the current processing table exists or not. Imagine that my tables are table1, table2, and table3. My code is something like this: How can I do this check (Please tell me the simplest way). 回答1: Updated mysqli version: if ($result = $mysqli->query("SHOW TABLES LIKE '".$table."'")) { if($result->num_rows == 1) { echo "Table exists"; } } else {

Insert if not exists

匿名 (未验证) 提交于 2019-12-03 01:40:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How to have only 3 rows in the table and only update them? I have the settings table and at first run there is nothing so I want to insert 3 records like so: id | label | Value | desc -------------------------- 1 start 10 0 2 middle 24 0 3 end 76 0 After this from PHP script I need to update this settings from one query. I have researched REPLACE INTO but I end up with duplicate rows in DB. Here is my current query: $query_insert=" REPLACE INTO setari (`eticheta`, `valoare`, `disabled`) VALUES ('mentenanta', '".$mentenanta."', '0'), ('nr

PostgreSQL Error: Relation already exists

匿名 (未验证) 提交于 2019-12-03 01:40:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to create a table that was dropped previously. But when I do the CREATE TABLE A .. . I am getting below error: Relation 'A' already exists. I verified doing SELECT * FROM A , but then I got another error: Relation 'A' does not exists. I already tried to find it in \dS+ listing all relations, and it is not there. To complicate this, I have tested this by creating this table in another database and I got the same error. I am thinking that could be an error when this table was dropped. Any ideas? Here is the code: I'm using a

check if column exists before ALTER TABLE ― mysql

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way to check if a column exists in a mySQL DB prior to (or as) the ALTER TABLE ADD coumn_name statement runs? Sort of an IF column DOES NOT EXIST ALTER TABLE thing. I've tried ALTER IGNORE TABLE my_table ADD my_column but this still throws the error if the column I'm adding already exists. EDIT: use case is to upgrade a table in an already installed web app-- so to keep things simple, I want to make sure the columns I need exist, and if they don't, add them using ALTER TABLE 回答1: Since mysql control statements (e.g. "IF") only

SQL Anywhere 11 - Check if event exists

匿名 (未验证) 提交于 2019-12-03 01:39:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an SQL script which creates a scheduled event: CREATE EVENT "Daily_1200PM" SCHEDULE "Daily_1200PM" START TIME '12:00' EVERY 24 HOURS HANDLER begin -- Blah blah, do some stuff here end; I would like to remove this event, if it exists. I know I can remove the event with the following: DROP EVENT "Daily_1200PM" But for some databases, the the event doesn't actually exist, so an error is thrown. How do I delete the event only if it exists? 回答1: if exists( select * from sys.sysevent where event_name='Daily_1200PM' ) then drop event Daily