insert

Excel OleConnection Insert Statements

How would insert a row into an excel document. This is what I have. String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + file_path + ";Extended Properties=Excel 8.0;"; DataTable dt = new DataTable(); DataSet ds = new DataSet(); OleDbConnection conn = new OleDbConnection(connString); ...

SQL: What is INSERT INTO #table?

I wanted to know what does the # symbol mean? Why is it being used? Example: INSERT INTO #tmpContracts (sym, contractCount) SELECT sym, COUNT(DISTINCT(fulloptionsym)) AS contractCount ...

PostgreSQL, Foreign Keys, Insert speed & Django

A few days ago, I ran into an unexpected performance problem with a pretty standard Django setup. For an upcoming feature, we have to regenerate a table hourly, containing about 100k rows of data, 9M on the disk, 10M indexes according to pgAdmin. The problem is that inserting them by whatever method literally takes ages, up to 3 minutes...

Easier way to insert a long array into an INSERT query?

I'm trying to insert this array into a database: Array ( [0] => 1 [1] => 2376 [2] => 1804229942 53 [3] => 99 [4] => 120510105 5525 [5] => 99 [6] => 21581237 622 [7] => 99 [8] => 46612404 3 [9] => 99 [10] => 174284497 8 [11] => 99 [12] => 200000000 922 [13] => 99 [14] => 13641206 5 [15] => 99 [16] => 118438707 15 [17] => 99 [18] => 20000...

SQL Server Insert Query problem

I want to execute this query : INSERT INTO [Order] (FactorId, ProductId, Entity) VALUES((SELECT Top 1 FactorId FROM Factor WHERE UserId = @UserId AND Status = -1), @ProductId, @Entity) but the following error occurs : Subqueries are not allowed in this context. Only scalar expressions are allowed. ...

How to set initial value + auto increment in mysql?

How to set the initial value (for example for "id" column) that start from 1001?? I do a insert "INSERT INTO users (name, email) VALUES ('{$name}', '{$email}')"; Without specify the initial value. ...

Design pattern for element validation

I have a system where users insert many types of things ("incidences") and all of them have to be approved by an admin. Which pattern will be useful for this case? Maybe validation is not the word for this. Update: The problem is that the db where the data resides can't be changed. All the moderation things will be done in another db an...

How do I insert a lot of whitespace in Perl?

I need to buff out a line of text with a varying but large number of whitespace. I can figure out a janky way of doing a loop and adding whitespace to $foo, then splicing that into the text, but it is not an elegant solution. ...

How to get individual identity in an XML Insert?

I haven't worked much with XML in SQL so I'll try to ask the question the best I can. Say I receive some structured XML in SQL for insertion. The structure might be: <Team> <Player> <Name>Player1</Name> <Games> <Game> <Date>9/7/2009</Date> <MinutesPlayed>90</MinutesPlayed> </Game> </Ga...

Tinymce - insert html code

Hello folks, I would appreciate if there is someone who can help me solve this problem, I've been trying to resolve it for few days, but with no success. I made custom button that inserts image into code, and here is textual version: <a href="javascript:;" onmousedown="tinyMCE.execCommand('mceInsertContent',false,'<br><img alt=$img_titl...

Help with ON DUPLICATE KEY UPDATE implementation/design

I have a table, sessionBasket, that holds a list of the items in the shopping baskets of visitors to my site. It looks like: id INT NOT NULL AUTO_INCREMENT PRIMARY KEY usersessid VARCHAR date_added DATETIME product_id INT qty INT My add to basket script first checks for the presence of an item with the current product_id in this table ...

Grouped UITableView Footer Sometimes Hidden On Quick Scroll

OK, this one is a puzzler. There is one similar post but it's not similar enough to count, so I'm posting this one. :) I've got a grouped UITableView with a header and footer. The footer includes two UIButton views, side-by-side. Nothing major. Now … there is a toggle button in a UIToolbar at the bottom for more/less info in this table...

Is there a way to emulate auto_increment on a second column in MySQL?

I think this is more clear than my last version: I have a table that already has a PK field starting with 1 that is already set for auto-increment. I would like to add a new field that does not start with 1, instead starting with an arbitrary number (think invoice number) and also automatically increments. Apparently, you can only have ...

Using OPENROWSET in an INSERT statement while specifying the values of another column?

I'm using OPENROWSET(BULK ...) to insert the contents of a file into my table. The problem is that I also need to specify the value of another column in the same INSERT statement. I have something like this: INSERT INTO MyTable SELECT * FROM OPENROWSET(BULK 'c:\foo.bin', SINGLE_BLOB) I'm sure there's a way to also specify the value ...

Entity Framework - inserting new entity via objectcontext does not use existing entity properties

I have an insert method on my repository like so: public T Insert(T entity) { _ctx.AddObject(EntityName, entity); _ctx.SaveChanges(); return entity; } If I execute the below code, the values assigned to my entity do not propagate to the SQL that is executed. Category c = new Category(); c.Name = CLEARANCE; c = categoryMa...

mySQL/PHP to update if the row exists or else insert when column to check is not unique

I have read about REPLACE and INSERT ON DUPLICATE key queries, and while I can see how useful they are, they don't appear to work for my purposes. Perhaps my database design is off from how it should be, but either way I hope I can get this working. I am trying to mock up an online store to teach myself mysql and php, and I am recording...

Inserting Record into database using Javascript!

Hi Is it possible to insert data in a database using javascript only. if yes then please post a simple example of it. Since javascript is a client side language and not a server side,i think its not possible. But then how to do it. ...

SQLPlus removes trailing spaces in clob field on insert

Hi, I'm using SQL Plus 11.1.0.6.0 to run a script that performs batch inserts into an Oracle 10g db. The problem i noticed is when inserting some code string into a clob field that has some lines with trailing spaces such as: ....public void myMethod().... --trailing space here ....{ ........int myVar = 1; ........ -- empty line with t...

Insert HTML into iframe

Hey Guys, I am creating a in browser HTML editor. I am using the syntax highlighter called Code Mirror which is very good. My setup is an iframe that holds a view of the page which is being edited and a textarea which the plain text HTML sits which the user edits. I am trying to insert the edited HTML from the textarea into the ifram...

How to insert a row, but on duplicate; update it instead?

I have a table which contains the items the users of my game owns. If a user buys a new item, it should be inserted, but if he already got it, it should be increased instead. I understand I can use INSERT ... ON DUPLICATE KEY UPDATE, but I don't understand how in my problem. The item_id isn't unique, because many players can own the s...