exists

INSERT VALUES WHERE NOT EXISTS

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: OK so I'm trying to improve my asp data entry page to ensure that the entry going into my data table is unique. So in this table I have SoftwareName and SoftwareType. I'm trying to get it so if the entry page sends an insert query with parameters that match whats in the table (so same title and type) then an error is thrown up and the Data isn't entered. Something like this: INSERT INTO tblSoftwareTitles( SoftwareName, SoftwareSystemType) VALUES(@SoftwareName,@SoftwareType) WHERE NOT EXISTS (SELECT SoftwareName FROM tblSoftwareTitles WHERE

How do I create a incrementing filename in Python?

匿名 (未验证) 提交于 2019-12-03 01:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm creating a program that will create a file and save it to the directory with the filename sample.xml. Once the file is saved when i try to run the program again it overwrites the old file into the new one because they do have the same file name. How do I increment the file names so that whenever I try to run the code again it will going to increment the file name. and will not overwrite the existing one. I am thinking of checking the filename first on the directory and if they are the same the code will generate a new filename: fh = open

数据库exists

天大地大妈咪最大 提交于 2019-12-03 01:52:37
  EXISTS用于检查子查询是否返回结果,该子查询返回结果为:TRUE/FALSE。也就是说,EXISTS会根据子查询结果的行数返回TRUE/FALSE。 exists对于子查询结果为null的也视为TRUE。前面已经说过EXISTS会根据子查询结果的行数来判断返回TRUE/FALSE。select null 虽然查出来的结果是null但是还是独占行数的,从行数上而言,select null 的结果是true,只是对于exists而言它是这样。 对于EXISTS而言外查询的内容会匹配EXISTS的子查询的内容。 有下面两个表: FORUM: COMMENT: 可见forum中的数据是一对多于comment中的。 select * from forum f; /*--等同于 两者都是查询出forum表中的所有数据-*/ select * from forum f where exists(select * from comment ); 再看如下: select * from forum f where exists( select * from comment c from c.forum_id=f.forum_id ); /*--等同于-*/ select f.* from forum f where f.forum_id in( select c.forum_id from

PostgreSQL: Create table if not exists AS

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using PostgreSQL and am an SQL beginner. I'm trying to create a table from a query, and if I run: CREATE TABLE table_name AS (....query...) it works just fine. But then if I add 'if not exists' and run: CREATE TABLE IF NOT EXISTS table_name AS (....query...) using exactly the same query, I get: ERROR: syntax error at or near "as" Is there any way to do this? 回答1: CREATE TABLE AS is considered a separate statement from a normal CREATE TABLE , and until Postgres version 9.5 (see changelog entry ) didn't support an IF NOT EXISTS clause. (Be

cannot load shared library that exists in /usr/local/lib (Fedora x64)

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When attempting to run a program I just compiled successfully, I get the following error: ./src/sensors/laser_scan_producer: error while loading shared libraries: liblcm.so.1 : cannot open shared object file: No such file or directory ls /usr/local/lib/liblcm* yields /usr/local/lib/liblcm.la /usr/local/lib/liblcm.so /usr/local/lib/liblcm.so.1 /usr/local/lib/liblcm.so.1.2.0 I have executed sudo ldconfig several times and added /usr/local/lib to LD_LIBRARY_PATH for the sake of redundancy. This exhausts the list of answers I've seen whilst

How do I check if file exists in jQuery or pure JavaScript?

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I check if a file on my server exists in jQuery or pure JavaScript? 回答1: With jQuery: $.ajax({ url:'http://www.example.com/somefile.ext', type:'HEAD', error: function() { //file not exists }, success: function() { //file exists } }); EDIT: Here is the code for checking 404 status, without using jQuery function UrlExists(url) { var http = new XMLHttpRequest(); http.open('HEAD', url, false); http.send(); return http.status!=404; } Small changes and it could check for status HTTP status code 200 (success), instead. 回答2: A similar and

Check if registry key exists

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I thought this would be easy, but apparently nobody does it... I'm trying to see if a registry key exists. I don't care if there are any values inside of it such as (Default). This is what I've been trying. Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv") objRegistry.GetStringValue &H80000003,".DEFAULT\Network","",regValue If IsEmpty(regValue) Then Wscript.Echo "The registry key does not exist." Else Wscript.Echo "The registry key exists." End If I only want to know if HKEY_USERES\.DEFAULT\.Network exists. Anything I find

DynamoDB - Put item if hash (or hash and range combination) doesn't exist

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Here are my use cases: I have a Dynamo table with a hash + range key. When I put new items in the table, I want to do a uniqueness check. Sometimes I want to guarantee that the hash is unique (ignoring the range). Other times I want to allow duplicate hashes, but guarantee that the hash and range combination is unique. How can I accomplish this? I experimented with attribute_not_exists. It seems to handle the second case, where it checks the hash + key combination. Here's a PHP sample: $client -> putItem ( array ( 'TableName' =>

MySQL, Check if a column exists in a table with SQL

匿名 (未验证) 提交于 2019-12-03 01:47:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I thought something like IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='prefix_topic' AND column_name='topic_last_update') BEGIN ALTER TABLE `prefix_topic` ADD `topic_last_update` DATETIME NOT NULL; UPDATE `prefix_topic` SET `topic_last_update` = `topic_date_add`; END; would work, but it fails badly. Is there a way? 回答1: @julio Thanks for the SQL example. I tried the query and I think it needs a small alteration to get it working properly. SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'db_name' AND

How to tell if a file exists always returns false but I can load it via image tag

匿名 (未验证) 提交于 2019-12-03 01:46:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In xcode, I have create a folder called IMAGES and copied all of the images I will be using into that folder. I am updating a table using the following code to insert the image: NSString *picName = [NSString stringWithFormat:@"%@.jpg", [[theemplyees objectAtIndex:indexPath.row] valueForKey:@"EmpNo"]]; cell.empPicture.image = [UIImage imageNamed:picName]; Note the no location needing supplied. What I want to do is, if a users picture does not exist in the directly, then set the image to a default image. Such as: NSArray *paths =