insert

NHibernate Transaction fails with Insert and Update on Oracle

Hi, Post Update: I have tracked down the problem at the command "ExecuteNonQuery". That's the one that fails during an update or hangs during an insert. Trying a simple example using plain ADO.NET and their transactions works perfect. Also... it works great on my local home computer connection an Oracle Express edition. Pointing it agai...

Efficent way to insert thousands of records into a table (SQLite, Python, Django)

I have to insert 8000+ records into a SQLite database using Django's ORM. This operation needs to be run as a cronjob about once per minute. At the moment I'm using a for loop to iterate through all the items and then insert them one by one. Example: for item in items: entry = Entry(a1=item.a1, a2=item.a2) entry.save() What is...

Problem when inserting an entity in the database through a service

I have a Silverlight application and I'm using a WCF service to access my database information. For this I'm using EntityFramework. I have a class Items (mapped on my DB table Items) which has an ObservableCollection of Keywords (class mapped on my DB table Keywords) objects. From the interface I create an Items object with all the pro...

Entity Framework: equivalent of INSERT OR IGNORE

I'm using a database as a kind of cache - the purpose is to store currently known "facts" (the details aren't that interesting). Crucially, however, I'd like to avoid inserting duplicate facts. To do so, the current data access code uses insert or ignore in many places. I'd like to use the entity framework to benefit from it's managea...

NHibernate 2.1.0.4000 doesn't seem to like batch insert

I am using NHibernate 2.1.0.4000 in one of the projects. I have set adonet.batch_size to 100 in the cfg file however I still see that insert statement is treated as single statement. Update seems to work fine. What's going on? Updated: Is it because I've chosen identity as the primary key generator? <id name="Id" column="Id" unsaved-v...

Solutions for insertion of duplicate keys.

NO MySQL answers please! The basic query is as follows (assume A is Key) INSERT INTO destination (A,B,C) SELECT a1,b1,c1 FROM source WHERE (selectconditions) ; Source contains many records that may or may not already be in destination, which means that the insert will fail as soon as a duplicate record is encountered. Desired Behav...

SQL Insert rows from two corresponding comma delimited sets of strings

I would like to take two separate strings of value pairs delimited by commas and insert each pair into a row in the database. For example: X = "1,2,3" Y = "A,B,C" => X | Y --------- 1 | A 2 | ...

Mysql Update or Insert with empty values

A quick question. I'm using php to insert new records in a database table - if the record exists, an update command is run instead. My question is, if the incoming record has fields that are empty but the data already in the database is not empty, does the update command overwrite the existing data with the empty values? Much appreci...

Inserting records into an XML table with a unique key

Hi, Maybe I'm just spoiled by SQL, but is there some cool LINQ way to insert a new record into an "XML table" and have the indexed ID update automatically (or at least semi-automatically)? Here's what I mean by "XML table": <myElements> <myElement> <id>1</id> <value>blah</value> </myElement> <myElement> <id>...

When INSERTing into a table can I get the value of the automatically incremented primary index?

I am inserting a row into a table and would like to get the value of the automatically incremented primary index. The primary index is the only unique value in the table so I don't want to do anything like "SELECT [primary index] FROM [table] WHERE [the columns = the data I just inserted]" to prevent ambiguity. I also don't want to SELE...

PDO Prepared Inserts multiple rows in single query

Hello, I am currently using this type of SQL on MySQL to insert multiple rows of values in one single query: INSERT INTO tbl (key1,key2) VALUES ('r1v1','r1v2'),('r2v1','r2v2'),... On the readings on PDO PDO, the use prepared statements should give me a better security than static queries. I would therefore like to know whether ...

C# Container Question

Hi, I'm having a weird problem with adding stuff to my Container. Whenever I try to add the items it simply exits the while loop, even though isServer is still 1. I've tried to make a custom function, same result. Then i tried calling the Add(..) function directly and still same result. I don't see how inserting items to my container is...

Dependency in identity column values after multiple SQL inserts

If the next is right: There are SQL string with multiple inserts (using a stored procedure): "EXEC SPInsertData ... EXEC SPInsertData ... EXEC SPInsertData ..." The id in identity column, which is auto incremented, of every new record is smaller than the id of the next one. E.g. after executing the given SQL string the id of the first...

MySQL INSERT/UPDATE without ON DUPLICATE KEY

I may have either misunderstood how to use the ON DUPLICATE KEY syntax, alternatively my database structure needs some work but here goes. I have a table (bookings-meta) which represents meta data associated with another table (bookings) , different rows in the bookings table may or may not have specific meta data associated with them i...

how to use recently entered id in another table for primary key

declare @@newid int, @@newRequestId int INSERT INTO Projects (ProjectName) VALUES ('first') SELECT [@@newId] = SCOPE_IDENTITY() -- Insert statements for procedure here INSERT INTO Requests (projectId, Title, RequestedBy, ReviewedBy, AssignedTo, EstimatedHours, ActualHours, Status, DateCreated, DateDue, DateAssigned, DateQC, De...

Sql insert query performance

I want to insert n records into a single table. There may be many concurrent users and they may insert/update/select data from this table. What is better way to insert in a such table say 1000 records: Send a single sql query to a database with multiple inserts. This saves server to database calls, but (I not sure) locks the table unti...

SQL: Populate single row(tbl 1) from multiple rows(tbl 2); cross DB

I have created a single table in my primary DB called tblGlobalIDMapping that will assign a GUID to all entries and store the other 3 primary ID's across the App to provide for a single ID repository. The new Table is in the following structure --> AppGlobalID uniqueidentifier NoNulls PersonID int NoNul...

Oracle INSERT giving error in C#.

DbCommand command = new OracleCommand( "insert into hardware (HardwareID) VALUES (6);", myConnection); command.ExecuteNonQuery(); Hardware is a NUMBER(7, 0). I am trying to make this simple Oracle INSERT work using C#. However, I keep getting an 911 error saying that there is an invalid character. What am I doing wrong? I ca...

Is this an invalid linq-to-sql detached design?

Consider the following: I have a high level component that deals with detached Linq to Sql entities. We'll call them Foo and Prop, where a single Foo may be associated with many Prop, but every Prop is always associated with exactly one Foo. So: +------+ 1 0..n +------+ | Foo |-----------| Prop | +------+ +------+ Ver...

MySQL trigger to update a field to the value of id

I would like to have a trigger to perform following operation for inserted records: # pseudocode if new.group_id is null set new.group_id = new.id else # don't touch it end More clearly: say I have one table with three columns: id primary key, group_id int, value varchar. When I insert with group_id like that: INSERT INT...