insert

MySQL stored procedure to INSERT DELAYED but CREATE TABLE first if needed?

I'm planning on doing a lot of INSERT DELAYED into MyISAM tables. But the tables might not exist yet. Let's say e.g. a new table will exist for each day. So instead of detecting absence of table in my client and creating then retrying the insert, it seems like a good case for a stored procedure ("function"). Is this possible, and wha...

SQL SELECT INSERTed data from Table

its in ASP Classic. MS-Access DB. i do: INSERT INTO Orders (userId) VALUES (123)" what i want to retrieve is orderNumber from that row. its an auto-increment number. so i did: SELECT orderNumber FROM Orders WHERE userId=123 but since it is on the same page, the SELECT returns: Either BOF or EOF is True, or the current record has bee...

PHP MySQL Insert Help

Hey I am trying to make a page that inserts some strings into a MySQL table but it just dosn't seem to be working for me. Here is the code I am using at the moment. <?php mysql_connect($address, $username, $password); @mysql_select_db($database) or die("Unable to select database"); $query = "insert INTO user (movieid, moviename)('" . $i...

Boost any usage

Hello, how can I insert my own class objects into ptr_map from boost. The objects are templated so I can't use some static typename in the map. So I did: ptr_map<string, any> someMap; My class inherits the boost::noncopyable. someMap.insert("Test", new MyClass<SomeTemplate>()); The error is: error: no matching function for call to ...

ptr_map inserting

Hello, I have some predefined type which inherits boost::noncopyable (so I have to store the pointer at these objects). I use a boost::ptr_map. As I know, the second argument in it is already a pointer. So, the code: ptr_map<string, boost::any> SomeMap; typedef %Some noncopyable class/signature% NewType; // Inserting now boost::any *te...

VB.NET How to insert text at cursor position in a different window?

Hi, I have a small application that displays a listbox under the cursor position when the user uses a shortcut key. When the user double clicks a selection from the listbox I want to insert that selected text at the curser position of that opened window. Example: user has microsoft word open. He/she uses a shortcut key that displays a...

In T-SQL, how to insert a new row with all values set by default?

Hi, In Microsoft SQL database, I have a table where every column have default values (either fixed values or stuff like identity or getdate()). I am trying to write an SQL statement which will insert a new row in which every cell will have a default value. Neither insert into MySchema.MyTable nor insert into MySchema.MyTable () va...

MySQL INSERT only if row doesn't exist, otherwise select the duplicate row.

I am looking for a statement that will try to insert a row into a table, but return the primary key of the duplicate row if one is encountered. One field in the table is the auto incrementing primary key, the other is unique. ...

Insert Only: ActiveRecord or Queries?

All that I will do is insert records into the database. However, I would definitly like the database-independence that Ruby/ActiveRecord can offer me. What would be the reccommended choice? Using simple insert queries, and rewriting them, and also maintaining my own database class for things as batch insertions; Using the power of Act...

LINQ insert related records

Hi I have a database with a "configs" table each new row in the configs table is 4 a different client which can config his environment to his liking (theme,companyname,language, culture...) one record,lets say id=-1, is the default config. all new configs should copy everything from there i want that each time i (the main admin) add a ne...

How to achieve better efficiency re-inserting into sets in C++

I need to modify an object that has already been inserted into a set. This isn't trivial because the iterator in the pair returned from an insertion of a single object is a const iterator and does not allow modifications. So, my plan was that if an insert failed I could copy that object into a temporary variable, erase it from the set, m...

Inserting data into a sql server 2008 table

Is there a relatively simple way to insert multiple rows into a table in which the data being inserted comes from both a select statement and hard-coded data? For example, insert into tblB (field1, field2, field3) values ( 950, select fieldA, fieldB from tblA ) ...where 950 is a hard-coded value and fieldA and fieldB come from...

Inserting multiple rows with loop

Code: for($i = 1; $i <= $arr['var']; $i++) { if($i == $arr['var']): $insert .= '('.$n_id.', 12)'; else: $insert .= '('.$n_id.', 12),'; endif; } $uz = mysql_query("INSERT INTO `cars` (n_id, auto_id) VALUES '$insert'") or die(mysql_error()); Why it gives me a ...

Oracle: copy row while updating one field

Please note: I am asking the question I want answered. I know this question means the database is set up poorly. So I will vote down any questions that suggest changing the way the table is set up. I need to duplicate a bunch of rows, while changing one value. name col1 col2 dave a nil sue b nil sam c 5 needs t...

How to perform a generic insert in entity framework?

I want to perform a generic insert in entity framework. This is what I wrote - static public void Insert<T>(MyEntities DataContext, T obj) where T : class { try { DataContext.AddObject(DataContext,obj); DataContext.SaveChanges(); } catch (Exception e...

PostgreSQL: dynamic row values (?)

Oh helloes! I have two tables, first one (let's call it NameTable) is preset with a set of values (id, name) and the second one (ListTable) is empty but with same columns. The question is: How can I insert into ListTable a value that comes from NameTable? So that if I change one name in the NameTable then automagically the values in List...

Insert file contents into MySQL table's column.

I know there's the LOAD DATA INFILE statement, which allows me to INSERT structured data into a table. What I'm curious about, is whether it is possible to INSERT contents of a file into single column. So, is something like this: INSERT INTO my_table (stamp, what) VALUES (NOW(), LOAD DATA INFILE 'my_file'); possible? ...

Adding data from Excel to Mysql via VBA

UPDATED QUESTION...SEE BELOW I have an excel sheet which accesses a MySQL db as a backend.... I insert new records into MySql the following way, but I am not sure if this is the best way. For rowline = 1 To 50 strSQL = myquerystring (INSERT 5 columns per excel row) rs.Open strSQL, oConn, adOpenDynamic, adLock...

Android: Inserting/Updating multiple records to SQL database

Ok, so perhaps I'm completely missing something here, but I've just started working with SQL and Android and from what I can see, updates and inserts back to the database need to be handled individually? I can retrieve a Cursor containing multiple records, but if I wanted to apply an update to each record in the cursor, I can only see ...

Linq-To-SQL Problem Inserting Multiple Objects That Are The Same

Here is my object association: Summary -> Job -> Operator -> Job -> Operator So, I have a Summary object that contains a collection of Jobs, which has an Operator object (clock #, name, etc) When creating a new summary, I go through and create the new jobs that exist and add all the properties. Then, do a single insert on the Su...