insert

insert record if not exists in sql, duplicate column name

i wanted a solution to insert a record if it isn't there so i searched here and found a solution but i have another problem INSERT INTO closed_answers (question_id, subject_id) SELECT * FROM (SELECT 2, 2) AS tmp WHERE NOT EXISTS ( SELECT question_id FROM closed_answers WHERE question_id = 2 AND subject_id = 2 ) LIMIT 1 the output...

Problem when try to insert in Content Provider[RESOLVED]

Look what Im doing. Im getting a SMS message and breaking word by word using the StringTokenizer class.I've done this, but when I try to insert the word in the content provider, the application stops, and the emulator says the application stoped unexpectadly. I don't know what to do anymore, I've tryied everything you can think about, b...

Where to rollback a transaction in PDO ?

my problem is , i have a database design from this link http://stackoverflow.com/questions/3305825/is-my-database-overdesigned edit* ok maybe useing transaction ? but where should i put the rollback if it fails ? $dbConnect->beginTransaction(); $RegisterInsert = $dbConnect->prepare("INSERT INTO companies ( `name`, `address`, `ema...

SQL/ASP - Invalid column name 'Email'.

hey all, i am having trouble adding stuff into the Email column. I can add stuff into the Username column but for some reason i get the following error: Microsoft OLE DB Provider for SQL Server error '80040e14' Invalid column name 'Email'. When I use this code: Set rstSimple = cnnSimple.Execute("insert into SALT (Email, Username, Fi...

NoNullAllowedException error when inserting data to a datagridview despite identity column is set to be auto-incremented

hi I have put a DataGridView in my program such that this DataGridView is corresponding to a dataset of one table and this table has a auto-incremented identity column(also,this column is set to be primary key). This identity column is not visible in DataGridView and when a user fills other cells and clicks "save",NoNullAllowedExceptio...

Ruby : Datamapper don't insert in database.

I a have the following datamapper ressource : class Job include DataMapper::Resource storage_names[:default] = 'job' property :id, Serial property :at, Integer, :required => true, :min => 0 property :name, Float, :required => true, :default => 0 property :cpu, Float, :required => true, ...

SQL Populate table with random data

Hello. I have a table with two fields: id(uuid) that is primaryKey and description (var255) I want to insert random data with sql sentance. I would like that description would be something random. Can some1 please help me with this? PS: im using postgresql. ...

How to insert date and time with fractional seconds in Oracle?

I'm using oracle 11g. I'm inserting date and time using function SYSDATE into column with type TIMESTAMP. But fractional seconds always are 0. How can I insert date and time of database server with fractional seconds? Is there any functions? ...

How do I insert collection of objects using MyBatis 3.x?

Hi. I'm a beginner with MyBatis. I just want to know how to insert a collection of objects from an instance of a class. Say I have a class User related to a Note in one-to-many relationship. I just like to mention that I built my schema using JPA 2 annotations via Hibernate's hbm2ddl. I'll add the key JPA annotations I used in the sampl...

Oracle INSERT only if values are in another table

Hi, I have two tables: players (has a team name column) and teams (also has a team name column) I want to only allow inserts of new players if the team name exists in the team table. Any help would be appreciated. Please keep it simple because I'm still learning. ...

Insert text into iframe at cursor point (using JQuery)

Hi, i tried different methods to insert a text into an iframe. My iframe runs in "designMode='on'". Which makes it possible to be editable. I use the jquery.fieldselection plugin to get the current selection which i had to fix to be able to read from iframes. The problem is now i want to add a simple plain text in the ifram at the curr...

Using LAST_INSERT_ID() within a multi row insert

Is it possible to use LAST_INSERT_ID() within an insert query? INSERT INTO mytable (col1, col2) VALUES ('val1', null), ('val2', LAST_INSERT_ID()) Trying the above LAST_INSERT_ID() returns 0, Just seeing if i can combine the query. ...

How to refresh record after an update with a SP

Hello Everybody, I am dealing with the following problem: I use a MSSQL Stored Procedure for displaying my data in a DataGridView. The Update and Insert Commands work, but there is one problem: On inserting a new Row, the auto-numbered primary key isn't send back to my DataAdaptar. So the insertion is successfull in the database, but ...

INSERT or return row if entry already exists in a table with UNIQUE constraint

Greetings, I have this table, on a postgreSQL 8.4 server : CREATE TABLE tags ( tagid bigserial PRIMARY KEY, name text NOT NULL, value text NOT NULL, UNIQUE(name,value) ); The normal INSERT behavior is to throw an error when new values break the unique...

How to convert a sorted std::list of std::pair to a std::map

Hello! I have got a std::list< std::pair<std::string,double> >, which I know is sorted according to the std::string element. Since I would like to do a lot of std::find_if based on the std::string element, I believe a std::map<string,double,MyOwnBinaryPredicate> with lower_bound and upper_bound would be more adequate. The fact is tha...

ORACLE Insert Performance On Indexed Tables

Why Insert Statemets Perform Slower on a Indexed Table? ...

Correct way to insert Many-to-Many objects in Django?

Hi, I was working on a many-to-many model with extra fields and i saw the documentation for extra fields in many to many relations on their exemple, to create a membership they use m2 = Membership.objects.create(person=paul, group=beatles,date_joined=date(1960, 8, 1), invite_reason= "Wanted to form a band.") but that means that they...

android sqlite insert problem with error code 19

Hi everybody! when I'm trying to run the ContentValues cv = new ContentValues(); cv.put(table_LocalSettings_Unit, input); mDb.insert(table_LocalSettings, "", cv); I got the following error: Error inserting unit = 0; SqliteConstraintException: error code 19 constraint failed. What should be the problem ? The table...

Insert Code Into HTML

I have a web site that gets a new page every couple weeks, and that means I need to update the menu to have the new page in every single one. I'm wondering if there is a way to have an external text or .htm file that I can basically insert into the web page. That way I can put the menu in the external file and call it wherever I want it....

INSERT..SELECT in MySQL

INSERT INTO tblprofile (fldDate,fldemployeeno,fldLName,fldFName,fldMI,fldEmployeeName, fldShiftCode,fldProjectGroup,fldTask,fldSuperior,fldPosition) SELECT now(),tblprofile.fldemployeeno,tblprofile.fldlname,tblprofile.fldfname,tblprofile.fldmi,tblprofile.fldemployeename, tblprofile.fldshiftcode,tblprofile.f...