exists

Is there an "exists" function for jQuery

So I know that you can do: if ($(selector).length>0) { // Do something } But is there a more elegant method? ...

MySql - Create Table If Not Exists Else Truncate?

Here is the updated question: the current query is doing something like: $sql1 = "TRUNCATE TABLE fubar"; $sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu"; The first time the method containing this is run, it generates an error message on the truncate since the table doesn't exist yet. Is my only optio...

how to check if a directory exists in a makefile

I need to generate a directory in my makefile and I would like to not get the "directory already exists error" over and over even though I can easily ignore it. I mainly use mingw/msys but would like something that works across other shells/systems too. I tried this but it didn't work, any ideas? ifeq (,$(findstring $(OBJDIR),$(wildc...

How to check if a file exists in javascript?

I'm using the jquery library to load the content of an html file. Something like this: $("#Main").load("login.html") If the file (in this case 'login.html') does not exist, I would like to detect it so that I can redirect the user to an error page for example. Any ideas how I can detect if the file to load exists or not? ...

How do you test for the existence of a user in SQL Server?

I'd like to drop a user in a SQL Server script but I'll need to test for existence first or I'll get script errors. When dropping tables or stored procs, I check the sysobjects table like so: IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[up_SetMedOptions]') AND OBJECTPROPER...

Newbie problem with LINQ in vb.net

Here is the single line from one of my functions to test if any objects in my array have a given property with a matching value Return ((From tag In DataCache.Tags Where (tag.FldTag = strtagname) Select tag).Count = 1) WHERE.... DataCache.Tags is an array of custom objects strtagname = "brazil" and brazil is definately a tag name s...

Oracle checking existence before deletion in a trigger

I have analyzed a hibernate generated oracle database and discovered that a delete of a row from a single table will spawn the firing of 1200+ triggers in order to delete the related rows in child tables. The triggers are all auto-generated the same - an automatic delete of a child row without checking for existence first. As it is impos...

Verify if file exists or not in C#

Hi, I am working on an application. That application should get the resume from the users, so that I need a code to verify whether a file exists or not. I'm using ASP.NET / C#. Thanks, Suresh Kumar ...

Best way to check that a list of items exists in an SQL database column?

If I have a list of items, say apples pairs pomegranites and I want to identify any that don't exist in the 'fruit' column in an SQL DB table. Fast performance is the main concern. Needs to be portable over different SQL implementations. The input list could contain an arbitrary number of entries. I can think of a few ways to do i...

Inserting an object to the db using hibernate, only if it doesn't exist

Let's say I have a mapped User object with a user_id as a primary key, and a mail column with a unique constraint. I want my program to save a User object to the users table only if it doesn't exist. I can do the following thing in my insert function: begin transaction query for a user with the given mail if it doesn't exist, create a...

mkdir -p functionality in python

Is there a way to get functionality similar to mkdir -p on the shell... from within python. I am looking for a solution other than a system call. I am sure the code is less than 20 lines... really I am wondering if someone has already written it? ...

Checking whether the file can be opened in portable C

I'd like to perform a quick check whether or not a file can be opened. It should be written in portable C, or at least to work on Win32 and POSIX systems. #ifdefs are acceptable. I'm trying to avoid this: int openable(const char*filename) { FILE *f = fopen(filename,"r"); if (!f) return 0; /* openable */ fclose(f); ...

Installer does not ask to create a new directory?

(sorry, not exactly a coding question) Say I want to install something to the directory C:\pony but the folder 'pony' does not exist, how can I get InstallShield to inform the user that the folder 'pony' does not exist and ask the user if he or she wants to create the directory. What happens now is the directory is automatically create...

Cause an error in MSBuild if a file exists

We have a process that runs prior to our nightly builds. If the process fails it generates a text file. All I need to do is check to see if the file exists, and if it does, cause a failing MSBuild. I currently have tried the following: <CreateProperty Condition="Exists('C:\Process\Fail.txt')" Value="false"> <Output TaskParame...

C# Cannot check Session exists?

I get an error when I do the following: if(Session["value"] != null) { // code } The error i get is this: Object reference not set to an instance of an object. Why is this? I always check my session this way? I am using the MVC Framework, does this has something to do with it? EDIT: The code is in the constructor of a Controlle...

is_file or file_exists in PHP

Hi there, I need to check if a file is on HDD at a specified location ($path.$file_name). Which is the difference between is_file() and file_exists() functions and which is better/faster to use in PHP? ...

Mysql Query : Where clause if Exists

Dear All I have a MySQL db and inside it a table called ProductMaster with 6 fields "Product_Id,Product_Name,Model,Opening_date,Closing_Date,Status". Opening_Date and Closing Date Can accept null values.So some records has values for this field I have the below query to display records from this table. "select Product_Id,Product_Name,...

How to check if a file exists on a server using c# and the WebClient class

In my application I use the WebClient class to download files from a Webserver by simply calling the DownloadFile method. Now I need to check whether a certain file exists prior to downloading it (or in case I just want to make sure that it exists). I've got two questions with that: What is the best way to check whether a file exists o...

How to check if mysql database exists

Is it possible to check if a (MySQL) database exists after having made a connection. I know how to check if a table exists in a DB, but I need to check if the DB exists. If not I have to call another piece of code to create it and populate it. I know this all sounds somewhat inelegant - this is a quick and dirty app. ...

LINQ - Where not exists

What is the equivalent of following statement in LINQ: Select t1.appname, t1.julianDte, t1.cat From table1 t1 Where NOT EXISTS ( Select * from table t2 where t1.cat = t2.cat AND t2.julianDte < t1.julianDte ) ...