insert

MySQL - COUNT before INSERT in one query

Hey all, I am looking for a way to query my database table only once in order to add an item and also to check what last item count was so that i can use the next number. strSQL = "SELECT * FROM productr" After that code above, i add a few product values to a record like so: ID | Product | Price | Description | Qty | D...

MySQL Analyze and Optimize - Are they required if only inserts - and the table has no joins?

Hi, I have a MyISAM table in MySQL which consists of two fields (f1 integer unsigned, f2 integer unsigned) and contains 320 million rows. I have an index on f2. Every week I insert about 150,000 rows into this table. I would like to know what is the frequency with which I need to run "analyze" and "optimize" on this table (as it would ...

Some problems with MapperExtension of sqlalchemy

There are two classes: User and Question A user may have many questions, and it also contains a question_count to record the the count of questions belong to him. So, when I add a new question, I want update the question_count of the user. At first, I do as: question = Question(title='aaa', content='bbb') Session.add(question) ...

Inserting rows into matrix matlab

I have a ~ 100000/2 matrix. I'd like to go down the columns, average each vertically adjacent value, and insert that value in between the two values. For example... 1 2 3 4 4 6 7 8 would become 1 2 2 3 3 4 3.5 5 4 6 5.5 7 7 8 I'm not sure if there is a terse way to do this in matlab. I took a look at http://www.mathwo...

MySQL Triggers - AFTER INSERT trigger + UDF sys_exec() issue

Problem: I've got a table which holds certain records. After the insert has been done, I want to call an external program (php script) via MySQL's sys_* UDFs. Now, the issue - the trigger I have passes the ID of the record to the script. When I try to pull the data out via the script, I get 0 rows. During my own testing, I came to a conc...

Entity Framework 4 update and insert one function

I'm migrating from SubSonic to EF4. In SubSonic models had a function called Save, if the key of the model was 0 an insert was done, otherwise an update. Is there a way to make a generic Save function like in SubSonic? For exmaple using an extension method? ...

MySQL INSERT on large table - can I improve speed performance?

Hi, I have a MyISAM table with 2 fields f1 and f2, both Unsigned integers and cannot be null. The table purposely has no primary key but it has an index on f2. The table currently has 320 million rows. I would like to be able to insert new rows (about 4000 once every week) into this table at a decent speed. However, currently I insert ...

Insert picture image to the ABUnknownPersonViewController view in iPhone application contact page

Hi! I am working on 'About" section of my iPhone application. I want to show some of the contributors details as a standard ABUnknownPersonViewController view. I am creating person view using simple 'school' code: ABRecordRef aContact = ABPersonCreate(); ABMultiValueAddValueAndLabel(email, @"[email protected]", kABOtherLabel, NULL...

SQL Server 2005: Insert missing records in table that is in another reference table

Hi to all, I need help with the following. I have 2 tables. The first holds data captured by client. example. [Data] Table PersonId Visit Tested Done 01 Day 1 Eyes Yes 01 Day 1 Ears Yes 01 Day 2 Eyes Yes 01 Day 3 Eyes Yes 02 ...

How to use the Insert Key (like in traditional windows) for a WPF 4 App?

Ok, I know that the new versions of windows do not use the insert key by default and you have to program for it. I want to be able to type in my text box and override the content that is in it just like in old windows when you could activate the insert key. This is just for my WPF 4, VB.net Application. Updated Information: That what I...

INSERT fails on server with magic_quotes on

Ive been struggling to get my data to insert into my table. The data is pulled from an xml file into an array and echo'ing the results are fine but it fails on insertion. $dbhost = 'XXXX'; $dbuser = 'XXXX'; $dbpass = 'XXXX'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); if($conn) { echo "D...

Javascript jQuery best way to insert a big piece of code into DOM

I have a big piece of code that needs to be inserted into DOM at some point. The code also contain some variables: <ul id="info'+value+'" class="info"><li class="hide"></li><li class="lock"><ul> // just a piece of the code with variable "value" Right now I am doing: var codeToInsert = "<some code/>" codeToInsert.insertAfter('#someID'...

inserting "this" into an STL map from the constructor

VERSION 1 class Doh { private: static std::map<const std::string, const Doh*> someMap; std::string stringValue_; public: Doh(std::string str) : stringValue_(str) { Doh::someMap.insert( std::make_pair<const std::string,const Doh*> (this->stringValue_,this) ); } } The above wa...

Is bulk insert atomic?

I have table with auto increment primary key. I want insert a bunch of data into it and get keys for each of them without additional queries. START TRANSACTION; INSERT INTO table (value) VALUES (x),(y),(z); SELECT LAST_INSERT_ID() AS last_id; COMMIT; Could MySQL guarantee, that all data would be inserted in one continuous ordered flow...

[Django] Insert params into database as full object?

hi, un rails i can simply insert the params into the database with one command, when all form-field names are the same like the model-field names. is this possible in django as well, or do i have to set each param individually. i have like 20 fields, so it's a bit of a mess.. :) something like: blah = Contact() blah.content = params[]...

Can I use aliases in an INSERT statement?

Can we use aliases with insert into syntax? None of the following work: INSERT INTO tableblabla AS bla INSERT INTO bla tableblabla INSERT INTO tableblabla bla I can't seem to find any information about this; is there a valid way to use aliases in an INSERT statement? About the possible reasons: http://bugs.mysql.com/bug.php?id=3275 ...

Insert new relation 'B' for all data where relation 'A' does not exist?

Ok 3 tables, Users, Groups, and UserGroups. The important columns are Users.UserID, Groups.GroupID, UserGroups.UserID, and UserGroups.GroupID. I have a group we'll call group 'A', there are a bunch of Users in this group because there are many rows of UserGroups where the GroupID is the GroupID of group 'A'. Now for all the users who ...

In MySQL, how do I insert only when row doesn't exist and update only when existing version is less

I am looking for a way to only insert when the row does not exist in MySQL, and update when the row exists AND the version of the existing row is less than (or equal to) the version of the new row. For example, the table is defined as: CREATE TABLE documents ( id VARCHAR(64) NOT NULL, version BIGINT UNSIGNED NOT NULL, data BLOB,...

How can I INSERT data into two tables simultaneously in SQL Server?

Let's say my table structure looks something like this: CREATE TABLE [dbo].[table1] ( [id] [int] IDENTITY(1,1) NOT NULL, [data] [varchar](255) NOT NULL, CONSTRAINT [PK_table1] PRIMARY KEY CLUSTERED ([id] ASC) ) CREATE TABLE [dbo].[table2] ( [id] [int] IDENTITY(1,1) NOT NULL, [table1_id] [int] NOT NULL, [data] [v...

Defaulting Column in SharePoint DataView Insert Mode to a QueryString Parameter

I have a SharePoint Dataview with a Querystring parameter. I am able to use the Parameter in a Datasource filter. I've enabled the New button and it works. There is a column in my view that is required. I really don't want to display it in my DataView, but must. When I select Insert, the column (a lookup dropdown), comes up. I'd l...