insert

Best way to access table instances when using SQLAlchemy's declarative syntax.

all the docs for sql alchemy give INSERT and UPDATE examples using the local table instance (i.e. tablename.update()... ) doing this seems difficult with the declarative syntax, I need to reference Base.metadata.tables["tablename"] for get the table reference. Am I sposed to do this another way? Is there a different syntax for INSERT...

hibernate insert batch with postgresql

is there a solution for batch insert via hibernate in partitioned postgresql table? currently i'm getting an error like this... 57286 [pool-1-thread-18] ERROR org.hibernate.jdbc.AbstractBatcher - Exception executing batch: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0...

Using php, how to insert text without overwriting to the beginning of a text file.

I have: <?php $file=fopen(date("Y-m-d").".txt","r+") or exit("Unable to open file!"); if ($_POST["lastname"] <> "") { fwrite($file,$_POST["lastname"]."\n"); } fclose($file); ?> but it overwrites the beginning of the file. How do I make it insert? ...

For std::map, how will insert behave if it has to resize the container and the memory is not available?

For std::map, how will insert behave if it has to resize the container and the memory is not available? ...

Solutions for INSERT OR UPDATE on SQL Server

Assume a table structure of MyTable(KEY, datafield1, datafield2...) Often I want to either update an existing record, or insert a new record if it doesn't exist. essentially if (key exists) Run Update command ELSE run insert command What's the best performing way to write this? ...

How to change slow parametrized inserts into fast bulk copy (even from memory)

I had someting like this in my code (.Net 2.0, MS SQL) SqlConnection connection = new SqlConnection(@"Data Source=localhost;Initial Catalog=DataBase;Integrated Security=True"); connection.Open(); SqlCommand cmdInsert = connection.CreateCommand(); SqlTransaction sqlTran = connection.BeginTransaction(); cmdInsert.Transaction = sq...

Oracle Insert via Select from multiple tables where one table may not have a row

I have a number of code value tables that contain a code and a description with a Long id. I now want to create an entry for an Account Type that references a number of codes, so I have something like this: insert into account_type_standard (account_type_Standard_id, tax_status_id, recipient_id) ( select account_type_standard_seq.nextv...

Potential Pitfalls of inserting millions of records into SQL Server 2005 from flat file

I am about to start on a journey writing a windows forms application that will open a txt file that is pipe delimited and about 230 mb in size. This app will then insert this data into a sql server 2005 database (obviously this needs to happen swiftly). I am using c# 3.0 and .net 3.5 for this project. I am not asking for the app, just ...

In SQL Server can I insert multiple nodes into XML from a table?

I want to generate some XML in a stored procedure based on data in a table. The following insert allows me to add many nodes but they have to be hard-coded or use variables (sql:variable): SET @MyXml.modify(' insert <myNode> {sql:variable("@MyVariable")} </myNode> into (/root[1]) ') So I coul...

Easy mysql question regarding primary keys and an insert

In mysql, how do I get the primary key used for an insert operation, when it is autoincrementing. Basically, i want the new autoincremented value to be returned when the statement completes. Thanks! ...

Double-click double-insert resolutions?

A team member has run into an issue with an old in-house system where a user double-clicking on a link on a web page can cause two requests to be sent from the browser resulting in two database inserts of the same record in a race condition; the last one to run fails with a primary key violation. Several solutions and hacks have been pr...

SQL Server: Is it possible to insert into two tables at the same time?

My database contains three tables called Object_Table, Data_Table and Link_Table. The link table just contains two columns, the identity of an object record and an identity of a data record. I want to copy the data from DATA_TABLE where it is linked to one given object identity and insert corresponding records into Data_Table and Link_T...

How do I handle large SQL SERVER batch inserts?

I'm looking to execute a series of queries as part of a migration project. The scripts to be generated are produced from a tool which analyses the legacy database then produces a script to map each of the old entities to an appropriate new record. THe scripts run well for small entities but some have records in the hundreds of thousands ...

What slows down growing database performance?

Hi all, I'm creating a database, and prototyping and benchmarking first. I am using H2, an open-source, commercially free, embeddable, relational, java database. I am not currently indexing on any column. After the database grew to about 5GB, its batch write speed doubled (the rate of writing was slowed 2x the original rate). I was ...

Insert Into: Is one syntax more optimal or is it preference?

SQL Server (2005/2008) Each of the below statements have the same result. Does anyone know if one outperforms the other? insert into SOMETABLE values ('FieldOneValue','FieldTwoValue',3,4.55,'10/10/2008 16:42:00.000') insert into SOMETABLE select 'FieldOneValue','FieldTwoValue',3,4.55,'10/10/2008 16:42:00.000' insert into SOMETA...

Dynamically look up column names for a table while in an sql query

I'm writing SQL (for Oracle) like: INSERT INTO Schema1.tableA SELECT * FROM Schema2.tableA; where Schema1.tableA and Schema2.tableA have the same columns. However, it seems like this is unsafe, since the order of the columns coming back in the SELECT is undefined. What I should be doing is: INSERT INTO Schema1.tableA (col1, col2, ....

C++ Binary Search Tree Insert via Recursion

So my code is below. I'm not getting any errors and it places everything in the node just fine. But based on my debug statements Everytime anything is inserted it's finding the root. I'm not sure if that is right. But according to output file for the assignment, my answers are different when it comes to the height of the tree, the tr...

Using set.insert( key ) as a conditional?

I am trying to use set.insert (key) as a conditional, where if the key is inserted correctly (meaning that the key does NOT already exsist in the set ) then it should go on and perform some kind of code. For example, something like: if (set.insert( key ) { // some kind of code } Is this allowed? Because the compiler is throw...

Insert firelog into mysql

Hi, im interesting of inserting firewall log which im printing to the stdout to mysql database as well. the line output is: 16:51:56 drop Nova <eth0 Attack Info: MS Word cascading style sheet vulnerability detected (MS08-026); attack: Content Protection Violation; viola profile: Default_Protection; src: udis; dst: Nova; proto: tcp...

Bulk Translation Of Table Contents

I'm currently performing a migration operation from a legacy database. I need to perform migration of millions of originating rows, breaking the original content apart into multiple destination parent / child rows. As it's not a simple 1 to 1 migration and the the resulting rows are parent / children row based on identity generated key...