sql conditional insert if row doesn't already exist

sql conditional insert if row doesn't already exist

I'm creating a sproc that will insert rows into a 'staging' table with an insert into + subquery like so:INSERT INTO myStagingTableSELECT col1, col2, col3FROM myRealTableI need to put a conditional in there somehow to determine if the value

iOS Safari 8 input overflow scroll

iOS Safari 8 input overflow scroll

I have an issue with form fields on mobile Safari, version 8.1. This appears to be a bug with all version of Safari 8 on mobile.When you type text into an input and that text is then longer than the input itself, the cursor keeps moving rig

MongoDB empty string value vs null value

MongoDB empty string value vs null value

In MongoDB production, if a value of a key is empty or not provided (optional), should I use empty string value or should I use null for value.1) Is there any pros vs cons between using empty string vs null?2) Is there any pros vs cons if I

How do I distinguish a file from a directory in Perl?

How do I distinguish a file from a directory in Perl?

I'm trying to traverse through all the subdirectories of the current directory in Perl, and get data from those files. I'm using grep to get a list of all files and folders in the given directory, but I don't know which of the values return

Should there be one SQLiteOpenHelper for each table in the database?

Should there be one SQLiteOpenHelper for each table in the database?

Is it better to have a single big SQLiteOpenHelper subclass that defines onCreate and onUpgrade methods for every table in the database, or is better to have many SQLiteOpenHelper subclasses, one for each table?Is there a best practice? Or

Python: Dictionary merge by updating but not overwriting if value exists

Python: Dictionary merge by updating but not overwriting if value exists

If I have 2 dicts as follows:d1 = {('unit1','test1'):2,('unit1','test2'):4}d2 = {('unit1','test1'):2,('unit1','test2'):''}In order to 'merge' them:z = dict(d1.items() + d2.items())z = {('unit1','test1'):2,('unit1','test2'):''

Oracle: How can I select records ONLY from yesterday?

Oracle: How can I select records ONLY from yesterday?

I've spent hours searching the web for an answer to this question...Here's what I currently have:select *from order_header ohwhere tran_date = sysdate-1Thanks in advance. 1:Use:AND oh.tran_date BETWEEN TRUNC(SYSDATE - 1) AND TRUNC(

Check if a file exists using a wildcard

Check if a file exists using a wildcard

In Ruby, how can I check if a file exists using a wildcard?Apparently this does not seem to work:File.exists?("/folderOfFile/Filename*.ext") 1:Your wildcard would refer to a set of files, not a single file. You could use Dir::glob for t

How to check if an object is defined?

How to check if an object is defined?

I would like to check if an object is defined or exists using C#.Something like this:if (defined(Object)){} 1:You check if it's null in C# like this:if(MyObject != null) { //do something}If you want to check against default (tough to un

Why doesn't IList support AddRange

Why doesn't IList support AddRange

List.AddRange() exists, but IList.AddRange() doesn't.This strikes me as odd. What's the reason behind this? 1:Because an interface shoud be easy to implement and not contain "everything but the kitchen". If you add AddRange you should th

Rails: Find rows without connection in HABTM relation

Rails: Find rows without connection in HABTM relation

I have two models, Users and Leads connected with HABTM relation:class Lead How can I now get only those Leads which are not connected to Users?Thanks in advance! 1:What you're looking for is known as an anti join .There are three standa

Can i force mysql to perform subquery first?

Can i force mysql to perform subquery first?

I have query like this:SELECT `table_1`.* from `table_1` INNER JOIN `table_2` [...] INNER JOIN `table_3` [...]WHERE `table_1`.`id` IN( SELECT `id` FROM [...])AND [more conditions]When I use EXPLAIN, there is 'DEPENDENT SUBQUERY' at the e

SQLite: Preventing Duplicate Rows

SQLite: Preventing Duplicate Rows

CREATE TABLE Permission ( permissionID INTEGER PRIMARY KEY UNIQUE, user INTEGER location INTEGER );I don't want to have user or location to be UNIQUE because I can have multiple rows with user containing the same data,

Trying to check if username already exists in MySQL database using PHP

Trying to check if username already exists in MySQL database using PHP

I've looked at the many other posts that were similar to my issue and implemented their solutions (as far as I can tell) as exactly as I could. However, every time I execute this script, the code in the else block is executed (even when the

Three ways to know existence of an akka actor

Three ways to know existence of an akka actor

I am working on akka actors(JAVA) and recently came to know that there are 3 ways(may be more) to know existing of an actor.Sending a Identify message:ActorSelection sel = actorSystem.actorSelection("akka://test/user/TestActor");AskableActo

git github cannot push to origin

git github cannot push to origin

I may be missing something, but I'm sure that I've checked everything,I forked a repo and cloned it on my system,made some changesafter commiting did git push origin masterit says fatal: remote error: You can't push to git://github.com/my

Auto delete a record in table when date is expired?

Auto delete a record in table when date is expired?

I would like to know how can I auto delete a record when date is expired, I'm creating a Air-ticket booking website. I need to delete from my mysql database all the expired flight details. I read somewhere that I can use cron but I have no

PHP Detecting if source image url link leads to a “broken” image?

PHP Detecting if source image url link leads to a “broken” image?

Suppose you have a thumbnail generator script that accepts source images in the form of a URL. Is there a way to detect if the source URL is "broken" - whether nonexistent or leads to an non-image file? Just brute force using getimagesize()

Help with a WHERE on a LEFT JOIN SQL Query

Help with a WHERE on a LEFT JOIN SQL Query

I'm trying to construct a query that will include a column indicating whether or not a user has downloaded a document. I have a table called HasDownloaded with the following columns: id, documentID, memberID. Finding out whether a user has

How can I check the existence of attributes and tags in XML before parsing?

How can I check the existence of attributes and tags in XML before parsing?

I'm parsing an XML file via Element Tree in python and and writing the content to a cpp file. The content of children tags will be variant for different tags. For example first event tag has party tag as child but second event tag doesn't

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

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

Finding Plus Sign in Regular Expression

Finding Plus Sign in Regular Expression

var string = 'abcd+1';var pattern = 'd+1'var reg = new RegExp(pattern,'');alert(string.search(reg));I found out last night that if you try and find a plus sign in a string of text with a Javascript regular expression, it fails. It will not

Find first element matching condition in Swift array (e.g. EKSource)

Find first element matching condition in Swift array (e.g. EKSource)

I would like to find the first EKSource of type EKSourceType.Local with a "single"-line expression in Swift. Here is what I currently have:let eventSourceForLocal = eventStore.sources[eventStore.sources.map({ $0.sourceType }) .in

Official image host for GitHub projects?

Official image host for GitHub projects?

Whenever I need to include a picture in a GitHub project's README file I usually just stick it in a Screenshots folder and relatively link to it. However this unnecessarily bloats the file size of the project, especially if I include an ani

Directed graph implementation

Directed graph implementation

I need to implement a digraph(Directed graph) in c++ as part of a homework and I'm having some issues with how to represent the vertices and edges data types.Can anybody please point me to a example or a simple c++ class that implements thi