insert

How to insert new row to database with AUTO_INCREMENT column without specifying column names ?

I have a table with the following columns: id - INT UNSIGNED AUTO_INCREMENT name - VARCHAR(20) group - VARCHAR(20) I know that I can add a row like this: INSERT INTO table_name (name, group) VALUES ('my name', 'my group') I wonder if there is a way to add a row without specifying the column names, like when there is no AUTO_INCREM...

INSERT - PHP & SQL Server

I don't know what is going on, but it just doesn't want to work. I keep getting this error when I submit my form: Array ( [0] => Array ( [0] => 22001 [SQLSTATE] => 22001 [1] => 8152 [code] => 8152 [2] => [Microsoft][SQL Server Native Client 10.0][SQL Server]String or binary data would be truncated. [message] => [Microsoft][SQL Serve...

Android SQLite database: slow insertion

I need to parse a fairly large XML file (varying between about a hundred kilobytes and several hundred kilobytes), which I'm doing using Xml#parse(String, ContentHandler). I'm currently testing this with a 152KB file. During parsing, I also insert the data in an SQLite database using calls similar to the following: getWritableDatabase()...

How to insert xml into Mysql?

Hi, this questions looks really easy but I'm a noob in C++ and MySQL so it still doesn't work. Here is the deal: I have a string (_bstr_t) that contains the xml and I want to store it in a longblolb column in MySql. Ways I tried that failed: write my xml on a local file and use mysql command LOAD_FILE, this worked localy but not on...

SQL INSERT IGNORE: skip values in a special case

Hi, I'm trying to skip an INSERT in a particular case, where one of two involved values is a specific value: // this can work if Beech allready exists INSERT IGNORE INTO my_table (col_wood_name, col_type) VALUES ("Beech", 0) // this should be skipped if Beech allready exists with col_type = 1 INSERT IGNORE INTO my_table (col_wood_name,...

Mysql Trigger error

1.I m using mysql 5.2.2 version 2.I create table in my test database CREATE TABLE account (acct_num INT, amount DECIMAL(10,2)); 3.I also Create trigger CREATE TRIGGER ins_sum BEFORE INSERT ON account FOR EACH ROW SET @sum = @sum + NEW.amount; 4.I insert data into account table INSERT INTO account VALUES(137,14.98),(141,1937.50),...

Execute SQLite Inserts in several foreach loops in C# ?

Hello everybody, this is my code I have: I have read that setting up the CommandText should happen only once and not in a loop... but how do I then get the individually item data from the foreach? Someone smart enough to refactor that code, that would be nice :) using (SQLiteTransaction trans = DataAccess.ConnectionManager.BeginTrans...

Simple LINQ insert record not working

I have an .mdf file which I'm trying to add a record to, using linq in C#. My code is: dbDataContext context = new dbDataContext(); book b = new book(); b.title = "Test Book"; b.isbn = "123789"; context.books.InsertOnSubmit(b); context.SubmitChanges(); When this code runs, the record is not inserted, and I get no error messages. If I ...

Segfault in map

Hello, I can't understand why does this code fail with segfault: #include <cstdlib> #include <iostream> #include <map> #include <string> using namespace std; int main(int argc, char** argv) { map <string, string> temp; map <string, string>::iterator it; S string text = ""; string thatChange = ""; str...

Sort of Insert/Update statement in LINQ to XML for XElement

I have this xml structure: <Departments> <Department Id="a Guid" IsVisible="True" /> </Departments> I have created the xml file with: <Departments /> Now I want to add a bool value to IsVisible for a certain Id If that Id does not exist in the xml file I want to make an insert creating a new Department with Id + IsVisible. My...

how to insert same data into two tables in mysql

dear all. is this possible if i want to insert some data into two tables simultanously? but at table2 i'm just insert selected item, not like table1 which insert all data. This the separate query: $sql = "INSERT INTO table1(model, serial, date, time, qty) VALUES ('star', '0001', '2010-08-23', '13:49:02', '10')"; $sql2 = "INSERT INTO...

INSERT SELECT with condition

Hello, I'm trying to do a INSERT SELECT with condition but smthg seems to be wrong. I get an 1064 error for wrong syntax. Here is the query : INSERT INTO `db1`.`table`.`field` ( SELECT a.`field1` , a.`field2` FROM `db2`.`table1` a, `db2`.`table2` b WHERE a.`field1` = b.`field1` AND b.`field2` = 'value' ) WHERE a.`field1` = `...

How to get values of Dropdownlist MVC 2 for insert in DB

Hi everyone, I am beginning in this issue MVC 2 I hope you can help me. I created a basic model public class RegisterModel { public string Name { get; set; } public int idCountry { get; set; } public string Country { get; set; } } And I have in the controller the following public ActionResult Register() ViewData["c...

Possible to make this code valid/speed up?

I have an enrollment form which takes consumer information, stores it in session, passes from page to page then stores in a database when finished. Originally the table simply listed fields for up to 16 persons but after reading into relational databases, found this was foolish. I have since created a table named "members" and "manager...

Why can't I INSERT INTO?

So this might be dumb, but I can't get anything to insert into a MySQL on a certain account, and I've been staring at this for two hours. I'm a newbie to PHP, so I could very well be doing something dumb. I attached a screen shot of the DB I am trying to INSERT INTO. Find an image of what I'm talking about at http://dillondoyle.com/file...

PHP-ORACLE: take the autogenerated ID after an insert

i have a Oracle Express 10g database, i have a table with an autogenerated id, i whold like to know how can i know it in php after an insert. ...

how to insert to a identity column using sequences in DB2

Hi, how to insert to a identity column using sequences in DB2? Thanks in advacne ...

Automatically generate sql insert statement with dummy data

Possible Duplicate: Quickest way to fill SQL Table with Dummy Data I'm looking for a tool that will generate insert statement for an existing database filled with dummy data. This is meant to allow testing of the system. I'm thinking about something that reads the type of each field and generates data accordingly. If the fiel...

MERGE Command in SQL Server

Hi folks, I have been using the statement insert into target select * from source where [set of conditions] for a while. Recently found this MERGE command that will be more effective to use for my purpose so that I can change the above statement to MERGE target USING source ON [my condtion] WHEN NOT MATCHED BY TARGET THEN IN...

Mysql trigger to do an INSERT instead of an UPDATE

Hello, I would like to implement a basic versioning system in a MySQL table. Let's imagine a simple table with 2 columns: name (pk) and price. I thought I would simply add a column 'version' and add it to the primary key. Then I would catch all the UPDATE's and do an insert instead, incrementing the version number. First, is this pos...