insert

What's the best way to extract data from a database with an update if needed?

I need to insert a data into a DB using query like this one: INSERT INTO Table1 (aID) VALUES (select aID from Table2 where aID="aID")) The problem is that if Table2 doesn’t have the aID I need to update it with it and extract the newly created ID. Is there a SQL command that automatically does it? ...

How Can I Get the Identity Column Value Associated with a SubSonic 3 LinqTemplate Insert?

I am using SubSonic 3.0.0.3 along with the Linq T4 Templates. My ProjectRepository, for example, has the following two methods: public int Add(Project item) { int result = 0; ISqlQuery query = BuildInsertQuery(item); if (query != null) { result = query.Execute(); } return result; } private ISqlQuery Bui...

C# SQLite Bulk Insert or Parameterized Insert Efficenecy

I have a DataTable which I want to save to a SQLite Database Table. Here is my dilemma, I don't know which way to go. At most the DataTable would contain 65,000 rows and probably 12 columns. So, would it be faster to save the DataTable to a CSV file and then Bulk Insert it into SQLite (which I have no idea how to do) or would it be ...

PHP MySQL inserting data to multiple tables

Hi, I'm trying to make an experimental web application which minimises redundant data. I have three example tables set up like so: Table one ID | created_at (unix timestamp) | updated_at (unix timestamp) Table two ID | Foreign Key to table one | Title Table three (pages) ID | Foreign Keys to both table one and two | Content | Metadata...

SQLite INSERT Statement

I have create the following insert method by researching the internet but I know it needs some work since it quite bulky and unsightly. I have tested it and it works fairly well but I know it could work better. If possible could someone show me how to convert this method to use parameters and/or increase its efficency? public static vo...

print entire directory of text files to printer with filename as header using bash or openoffice basic script

I want to print an entire directory of text files to a printer inserting the file name at the top of the first page of each file that is printed. A bash or openoffice script would serve me well. Thanks ...

Problem with MySql INSERT MAX()+1

I have a single table containing many users. In that table I have column called user_id (INT), which I want increment separately for each person. user_id MUST start at 1 I've prepared a simple example: Showing all names +--------------+-----------------------+ | user_id | name | +--------------+-------------------...

SQL Insert with data from multiple tables.

I have four tables: Messages, MessageCategory, MessageStatus and MessageLevel. MessageCategory, MessageStatus and MessageLevel all just have three fields: Identity (primary key), Code and Description. Messages refers to these three fields and has a few other data fields, including Identity (primary key) MessageText and Order. The Identi...

my insert query is working in my localhost but not in web server

hi, I am using flex builder 3 to insert into mysql database using php and everything is working perfectly in my localhost, the problem is when I deploy the project in the web server and run it, it connect to the database but i can't insert data ( it shows nothing when i insert data ) another stupid thing is in another piece of code for r...

Failed to convert parameter value from a ListItem to a String

I am trying to insert certain values into the table using SQL server 2005. I have used textbox, label and listbox. But by doing so, I have an error that states "Failed to convert parameter value from a ListItem to a String" How do i solve this? try { //Create an insert command SqlCommand insertCmd = new...

Mark record inserted

I have table, which I am inserting records to another table. What is the best way to mark record inserted, so it will not be attemted to being inserted again? ...

add remove <li with textbox on button click. (out of ul wrap problem) and name inputs uniquely

Hi friends, I have an issue with js. I have form like below. Add button is adding li with input box and Remove button is removing... it is working very well. the issue is, it is creating the li after ul, out of ul :/ you can see it clearly at the screenshot below. any idea about solution? appreciate!!! thanks!!! * ps, how can I nam...

Linq Insert problem for Beginners

Why is this thing not working? [Database(Name="Relationships_Test")] [Table(Name = "Order")] public class Order { [Column(Name="ID", IsPrimaryKey=true)] public int ID { get; set; } [Column(Name = "OrderDate")] public DateTime OrderDate { get; set; } public void Save() { DataContext dc = new DataContext(@"Data Source=.\sqlexpre...

which sqlite statement can produce a result to indicate duplicate entries? Android

For my application, I am trying to add entries without having a duplicate entry, and if there are a duplicate notify the user and have him try again. Using SQLite, which I know very very little about, I have tried these two ways and want to know which one is better, more efficient or a better way to develop it? First way: db.execSQL("I...

Linq one to many insert when many already exists

So I'm new to linq so be warned what I'm doing may be completely stupid! I've got a table of caseStudies and a table of Services with a many to many relasionship the case studies already exist and I'm trying to insert a service whilst linking some case studies that already exist to it. I was presuming something like this would work? ...

java 1.4 -sql server 2000:not able to insert multiple records into table.

INSERT INTO UPLOAD_FILE_RECORD_FIELDS_DATA select ?,?,?,? union all select ?,?,?,? union all select ?,?,?,? I have to insert multiple records into one table.So i am using query as below.and setting parameter values. But i am getting error code 77.What is cause? No of records to be inserted are approx 70000.So i am inserting 100 ...

Select MAX(field)+1 FROM ... Concurrency issues

Hello Im afraid about concurrency on partner application cause in the last days it was having troubles with CRUDS Operations, especially with inserts. So I ran SQL Profiler and note that his insert statement dont use transaction and also he is using : INSERT INTO TABLEA VALUES ( (SELECT MAX(NUMBERFIELD) +1 FROM TABLEA), ....); How avo...

SQLLite, NOT EXISTS doesn't work

Ok, let's say from start I'm not a SQL ninja. Anyway I'm using SQLite in a tiny project of mine. I've this test table: CREATE TABLE [prova] ( [id] INTEGER PRIMARY KEY UNIQUE, [str] TEXT NOT NULL ) and this query won't work: insert into prova (id, str) select null as id, "foo" as str where not exists (select * from pr...

ActiveRecord custom insert/update query

I'm using PostGis to store some spatial data. I used ActiveRecord to retrive data from db, and I used [Property (Formula = "asbinary(shape)")] on property where geometry was stored (property type was byte[]). However this doesn't work when inserting data. So I figured out to write custom insert (and update) queries to solve the problem. ...

Sql date field is not getting saved exactly

Hi, I am trying to insert a date value '2010-03-14 02:00:00 AM'(Day light saving start time for 2010 year) in a datetime field of a table in sql server 2005. The date is saved as '2010-03-14 03:00:00 AM' The server is installed in US(EST time zone). Can anyone tell me the reason why the date is saving differently? Thanks Rupa ...