exists

Additional hash lookup using 'exists'?

I sometimes access a hash like this: if(exists $ids{$name}){ $id = $ids{$name}; } Is that good practice? I'm a bit concerned that it contains two lookups where really one should be done. Is there a better way to check the existence and assign the value? ...

Oracle performance and memory

Hi, I have two queries, and I want to understand which is better in terms of performance and memory. I also welcome other alternatives for these two. Query 1: SELECT DISTINCT a.no, a.id1 , a.id2 FROM tbl_b b , tbl_a a , tbl_c c , tbl_d d WHERE ( b.id1 ...

MS SQL Server 2000 - check for existing database error

I use MS SQL Server 2000 SP4 and I have this part of script, that checks for existing database: IF EXISTS (SELECT * FROM sysdatabases WHERE name='MY_DBNAME') BEGIN PRINT 'Using the existing database MY_DBNAME.' USE MY_DBNAME END ELSE BEGIN PRINT 'Creating new database MY_DBNAME.' CREATE DATABASE MY_DBNAME END GO I keep...

PHP - extract() type

Hello, PHP's extract() function can take on one of several extract_types. But what's the difference between extr_prefix_same and extr_prefix_if_exists? The manual makes it sound like, in either case, new variables will be prefixed if the variable name already exists. Thanks! ...

Oracle SQL Invalid Identifier

I'm trying to run this query but I get "ORA-00904: "Z1"."LONGITUDE": invalid identifier" Is there a way to rewrite this so I have access to that column in the exists subquery? Or is there generally a better way to achieve what I'm trying to do? Thanks select zip, count(UNIQUE address_id) LOCATIONS from records inner join addresses a...

How do I check if a key exists in a hash in Perl?

I want to check if parameter $PGkey is equal to a key with the same name inside a hash table. Further, I want to do it in a format as close to this as possible: while(<PARAdef>) { my($PGkey, $PGval) = split /\s+=\s+/; if($PGkey == $hash{$PGkey}) { print PARAnew "$PGkey = $hash{$PGkey}->[$id]\n"; } else { pri...

Checking if a collection element exists in Oracle

I create a simple type: create or replace TYPE SIMPLE_TYPE AS OBJECT (ID NUMBER(38), NAME VARCHAR2(20)); Simple test: DECLARE TYPE ObjectList IS TABLE OF SIMPLE_TYPE; tmp SIMPLE_TYPE := SIMPLE_TYPE(1, 'a'); o ObjectList := new ObjectList(SIMPLE_TYPE(2, 'a'), SIMPLE_TYPE(3, 'a')); BEGIN IF tmp.EXISTS(tmp) THEN dbms_out...

How to check if a file exists and is readable in C++?

I've got a fstream my_file("test.txt"), but I don't know if test.txt exists. In case it exists, I would like to know if I can read it, too. How to do that? I use Linux. ...

Actionscript3: Does variable exist?

I'm a little bit new to Actionscript, but I can't figure this one out. I've done a lot of searching on this topic and haven't found a clear answer. I've tried the following solutions that people posted online but none of them work. All the following solutions give the error: 1120: Access of undefined property myVariable Suggestion #1: ...

What do you put in a subquery's Select part when it's preceded by Exists?

What do you put in a subquery's Select part when it's preceded by Exists? Select * From some_table Where Exists (Select 1 From some_other_table Where some_condition ) I usually use 1, I used to put * but realized it could add some useless overhead. What do you put? is there a more efficient wa...

check xml for node that doesn't exist with jQuery?

I've got an xml doc that looks similiar to: <schedule techs="52" date="2009-10-06"> <tech name="Ryan (RI, MA, CT, NH)" value="1"> <time value="4"> <HONAME value="Ronald Baron"/> <ADDRESS value="35 Liepis rd"/> <CITY value="Canterbury"/> <STATE value="CT"/> <ZIP value="06331"/> <JOBNUMBER value="33028"/> <RESULT value="C"/> <NOTES valu...

C# - Delete files from directory if filename contains a certain word

I need to check a directory to see if there are any files whos file name contains a specific keyword and if there are, to delete them. Is this possible? Example: If there are any files in "C:\Folder" whos file name contains the keyword "Apple", delete them. Thanks. ...

which sqlite statement can produce a result to indicate duplicate entries? Android

For my application, I am trying to add entries without having a duplicate entry, and if there are a duplicate notify the user and have him try again. Using SQLite, which I know very very little about, I have tried these two ways and want to know which one is better, more efficient or a better way to develop it? First way: db.execSQL("I...

INSERT IF NOT EXISTS type function for me to use without turning the column into primary key?

This script I'm working on is taking data from the web using python's urllib2 module and then putting it in a table. This data is basically just going to be in a table with one column and one row. How do I have it so that when I run the script it just updates the record? I don't want to make it a primary key because I'm probably going...

How can you check to see if a file exists (on the remote server) in Capistrano?

Like many others I've seen in the Googleverse, I fell victim to the File.exists? trap, which of course checks your local file system, not the server you are deploying to. I found one result that used a shell hack like if [[ -d #{shared_path}/images ]]; then ... but that doesn't sit well with me, unless it were wrapped nicely in a Ru...

Best way to test if a row exists in a MySQL table

I'm trying to find out if a row exists in a table. Using MySQL, is it better to do a query like this: SELECT COUNT(*) AS total FROM table1 WHERE ... and check to see if the total is non-zero or is it better to do a query like this: SELECT * FROM table1 WHERE ... LIMIT 1 and check to see if any rows were returned? In both queries, ...

Is File.Exists an expensive operation?

Re: http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx Does anyone know if this is a particularly slow or locking operation which could impact server performance in a large environment? Thanks, Matt. ...

Check if a database table exists using php/pdo

Hi, I want to check if a table with a specific name exists in a database i've connected to using php and pdo. It has to work on all database backends ... MySQL, SQLite, ... best regards, andre ...

Sql existence check for Xml Schema Collection?

Hey all, writing scripts for Sql Server 2005. I am registering a schema with CREATE XML SCHEMA COLLECTION [dbo].[MySchema] AS N'<xsd:schema ... >' Now, as I make changes, I would like to drop it, say with a call to DROP XML SCHEMA COLLECTION [dbo].[MySchema] I run this stuff fairly frequently as I am developing, like DROP ... CRE...

NHibernate: CreateCriteria and Exists clause

How can I write the following SQL using CreateCriteria: SELECT * FROM FooBar fb WHERE EXISTS (SELECT FooBarId FROM Baz b WHERE b.FooBarId = fb.Id) ...