Search Results

Search found 23955 results on 959 pages for 'insert query'.

Page 59/959 | < Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >

  • How to insert into a table with just one IDENTITY column (SQL Server CE)

    - by Hei
    Hello I am trying to insert a value in a one IDENTITY column Table in SQL Server CE 3.5. I Tried the following: INSERT Target DEFAULT VALUES INSERT Target (ID) VALUES (DEFAULT) INSERT Target (ID) VALUES () But none of them worked. This is the SQL command I used to create the table (Using SQL Server Management Studio): CREATE TABLE Target( ID int NOT NULL IDENTITY (1, 1) PRIMARY KEY ); Microsoft help site (http://msdn.microsoft.com/en-us/library/ms174633%28SQL.90%29.aspx) mentions that DEFAULT values are not valid for identity columns however they do not mention any alternative. They mention something about uniqueidentifier and ROWGUID but I have not been able to make it work. I would appreciate any pointers on how to solve this problem or links to documentation about valid sql commands for sql server CE. Thank you

    Read the article

  • mySQL Trigger works after console insert, but not after script insert.

    - by Marcos
    Hello, I have a strange wird problem with a trigger: I set up a trigger for update other tables after an insert in a table. If i make an insert from mysql console, all works fine, but if i do inserts from external python script, trigger does nothing, as you can see bellow. When i insert from console, works fine, but insert THE SAME DATA from python script, doesn't works, i try changing the Definer to 'user'@'%' and 'root'@'%' but stills doing nothing. Any idea of what van be wrong? Regards mysql> select vid_visit,vid_money from videos where video_id=487; +-----------+-----------+ | vid_visit | vid_money | +-----------+-----------+ | 21 | 0.297 | +-----------+-----------+ 1 row in set (0,01 sec) mysql> INSERT INTO `prusland`.`validEvents` ( `id` , `campaigns_id` , `video_id` , `date` , `producer_id` , `distributor_id` , `money_producer` , `money_distributor` , `type` ) VALUES ( NULL , '30', '487', '2010-05-20 01:20:00', '1', '0', '0.009', '0.000', 'PRE' ); Query OK, 1 row affected (0,00 sec) mysql> select vid_visit,vid_money from videos where video_id=487; +-----------+-----------+ | vid_visit | vid_money | +-----------+-----------+ | 22 | 0.306 | +-----------+-----------+ DROP TRIGGER IF EXISTS `updateVisitAndMoney`// CREATE TRIGGER `updateVisitAndMoney` BEFORE INSERT ON `validEvents` FOR EACH ROW BEGIN if (NEW.type = 'PRE') THEN SET @eventcash=NEW.money_producer + NEW.money_distributor; UPDATE campaigns SET cmp_visit_distributed = cmp_visit_distributed + 1 , cmp_money_distributed = cmp_money_distributed + NEW.money_producer + NEW.money_distributor WHERE idcampaigns = NEW.campaigns_id; UPDATE offer_producer SET ofp_visit_procesed = ofp_visit_procesed + 1 , ofp_money_procesed = ofp_money_procesed + NEW. money_producer WHERE ofp_video_id = NEW.video_id AND ofp_money_procesed = NEW. campaigns_id; UPDATE videos SET vid_visit = vid_visit + 1 , vid_money = vid_money + @eventcash WHERE video_id = NEW.video_id; if (NEW.distributor_id != '') then UPDATE agreements SET visit_procesed = visit_procesed + 1, money_producer = money_producer + NEW.money_producer, money_distributor = money_distributor + NEW.money_distributor WHERE id_campaigns = NEW. campaigns_id AND id_video = NEW.video_id AND ag_distributor_id = NEW.distributor_id; UPDATE eventForDay SET visit = visit + 1, money = money + NEW. money_distributor WHERE date = SYSDATE() AND campaign_id = NEW. campaigns_id AND user_id = NEW.distributor_id; UPDATE eventForDay SET visit = visit + 1, money = money + NEW.money_producer WHERE date = SYSDATE() AND campaign_id = NEW. campaigns_id AND user_id= NEW.producer_id; ELSE UPDATE eventForDay SET visit = visit + 1, money = money + NEW. money_producer WHERE date = SYSDATE() AND campaign_id = NEW. campaigns_id AND user_id = NEW.producer_id; END IF; END IF; END //

    Read the article

  • Insert consecutive numbers

    - by Markus
    Hi. I have a table A (Acons, A1, A2, A3) in which I should insert information from another table B with columns (B1, B2, B3). The Acons is a column in which should contain some consecutive numbers (it is not an identity and I cannot make it identity). I know xmin - starting the from number the sequence has to be computed. How can I insert the rows into the table A, using a single Insert statement? I tried like the following, but it didn't work: DECLARE @i AS INT; SET @i = xmin; INSERT INTO A(Acons, A1, A2, A3) SELECT @i = (Bcons = (@i + 1)), B1, B2, B3 FROM B Unfortunatelly, the above solution does not work;

    Read the article

  • Oracle 10g multiple DELETE statements

    - by bmw0128
    I'm building a dml file that first deletes records that may be in the table, then inserts records. Example: DELETE from foo where field1='bar'; DELETE from foo where fields1='bazz'; INSERT ALL INTO foo(field1, field2) values ('bar', 'x') INTO foo(field1, field2) values ('bazz', 'y') SELECT * from DUAL; When I run the insert statement by itself, it runs fine. When I run the deletes, only the last delete runs. Also, it seems to be necessary to end the multiple insert with the select, is that so? If so, why is that necessary? In the past, when using MySQL, I could just list multiple delete and insert statements, all individually ending with a semicolon, and it would run fine.

    Read the article

  • Insert Into Two SQL Tables From XML Maintaining Relationship

    - by Thx
    I am looking to insert records from xml into two different tables. For example <Root> <A> <AValue>1</AValue> <Children> <B> <BValue>2</BValue> </B> </Children> </A> </Root> Would insert a record into table A AID AValue # 1 also insert a record into table B BID AID BValue # #(Same as AID Above) 2 I have this DECLARE @idoc INT DECLARE @doc NVARCHAR(MAX) SET @doc = ' <Root> <A> <AValue>1</AValue> <Children> <B> <BValue>2</BValue> </B> </Children> </A> </Root> ' EXEC sp_xml_preparedocument @idoc OUTPUT, @doc CREATE TABLE #A ( AID INT IDENTITY(1, 1) , AValue INT ) INSERT INTO #A SELECT * FROM OPENXML (@idoc, '/Root/A',2) WITH (AValue INT ) CREATE TABLE #B ( BID INT IDENTITY(1, 1) , AID INT , BValue INT ) INSERT INTO #B SELECT * FROM OPENXML (@idoc, '/Root/A/Children/B',2) WITH ( AID INT, BValue INT ) SELECT * FROM #A SELECT * FROM #B DROP TABLE #A DROP TABLE #B Thanks!

    Read the article

  • oracle call stored procedure inside select

    - by CC
    Hi everybody. I'm working on a query (a SELECT) and I need to insert the result of this one in a table. Before doing the insert I have some checking to do, and if all columns are valid, I will do the insert. The checking is done in a stored procedure. The same procedure is used somewhere else too. So I'm thinking using the same procedure to do my checks. The procedure does the checkings and insert the values is all OK. I tryied to call the procedure inside my SELECT but it does not works. SELECT field1, field2, myproc(field1, field2) from MYTABLE. This kind of code does not works. I think it can be done using a cursor, but I would like to avoid the cursors. I'm looking for the easiest solution. Anybody, any idea ? Thanks alot. C.C.

    Read the article

  • linked list problem (with insert)

    - by JohnWong
    The problem appears with the insert function that I wrote. 3 conditions must work, I tested b/w 1 and 2, b/w 2 and 3 and as last element, they worked. But b/w 3 and 4, it did not work. It only display up to the new added record, and did not show the fourth element. Efficiency is not my concern here (not yet). Please guide me through this debug process. Thank you very much. #include<iostream> #include<string> using namespace std; struct List // we create a structure called List { string name; string tele; List *nextAddr; }; void populate(List *); void display(List *); void insert(List *); int main() { const int MAXINPUT = 3; char ans; List * data, * current, * point; // create two pointers data = new List; current = data; for (int i = 0; i < (MAXINPUT - 1); i++) { populate(current); current->nextAddr = new List; current = current->nextAddr; } // last record we want to do it sepeartely populate(current); current->nextAddr = NULL; cout << "The current list consists of the following data records: " << endl; display(data); // now ask whether user wants to insert new record or not cout << "Do you want to add a new record (Y/N)?"; cin >> ans; if (ans == 'Y' || ans == 'y') { /* To insert b/w first and second, use point as parameter between second and third uses point->nextAddr between third and fourth uses point->nextAddr->nextAddr and insert as last element, uses current instead */ point = data; insert(()); display(data); } return 0; } void populate(List *data) { cout << "Enter a name: "; cin >> data->name; cout << "Enter a phone number: "; cin >> data->tele; return; } void display(List *content) { while (content != NULL) { cout << content->name << " " << content->tele; content = content->nextAddr; cout << endl; // we skip to next line } return; } void insert(List *last) { List * temp = last->nextAddr; //save the next address to temp last->nextAddr = new List; // now modify the address pointed to new allocation last = last->nextAddr; populate(last); last->nextAddr = temp; // now link all three together, eg 1-NEW-2 return; }

    Read the article

  • Table Adapter query Builder ASP.NET

    - by kmsony32
    I want to connect my Table adapter with the Oracle, for that I am preparing a sql query with the query builder. The query which is running fine in Oracle but makes syntax error with query builder.It shows unable to parse the query text. I am using case statement and joins within the query.

    Read the article

  • SQL Server insert performance with and without primary key

    - by Eric
    Summary: I have a table populated via the following: insert into the_table (...) select ... from some_other_table Running the above query with no primary key on the_table is ~15x faster than running it with a primary key, and I don't understand why. The details: I think this is best explained through code examples. I have a table: create table the_table ( a int not null, b smallint not null, c tinyint not null ); If I add a primary key, this insert query is terribly slow: alter table the_table add constraint PK_the_table primary key(a, b); -- Inserting ~880,000 rows insert into the_table (a,b,c) select a,b,c from some_view; Without the primary key, the same insert query is about 15x faster. However, after populating the_table without a primary key, I can add the primary key constraint and that only takes a few seconds. This one really makes no sense to me. More info: The estimated execution plan shows 0% total query time spent on the clustered index insert SQL Server 2008 R2 Developer edition, 10.50.1600 Any ideas?

    Read the article

  • Insert methode of TableAdapter not working?

    - by Stijn Leenknegt
    I'm using ADO.NET in my C# project. In my form I added a SourceBinding element from my toolbox in VS2010. I set the connection to the table of my dataset. It creates a DataAdapter automaticly for my. I want to insert a record, so I call the Insert() method of the DataAdapter. But when I view my database data, it doesn't have any new records... orderID = this.orderTableAdapter.Insert("", "", (int)OrderStatus.IN_CONSTRUCTION, DateTime.Now); Or do I need to insert it manually with the SqlCommand???

    Read the article

  • Difficulty Inserting from HTML form into MySQL (created in Workbench)

    - by Chaya Cooper
    I created a MySQL database in Workbench 5.2.35 for purposes of storing and using information submitted in html forms but I'm having difficulty inserting records from the html form. The relevant SQL script was saved as Demo2.sql, the schema is C2F, and the table is customer_info. I wasn't sure if that was the problem, so I tried replacing the database name (Demo2) with the schema name, but that didn't work either. My html file includes: form action="insert.php" method="post" The insert.php file states: ?php $con = mysql_connect("localhost","root","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("Demo2", $con); $sql="INSERT INTO customer_info(fname, lname, user, password, reminder, answer) VALUES ('$_POST[fname]','$_POST[lname]','$_POST[user]','$_POST[password]','$_POST[reminder]','$_POST[answer]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ? I've also tried INSERT INTO c2f.customer_info(fname, lname, etc. and INSERT INTO 'c2f'.'customer_info'

    Read the article

  • How to insert any string in sqlite3 in c

    - by ashishtripathi.hcu
    Hi I have to insert a string into a sqlite data base my command .. Err=sqlite_exec(DB, "create table tbl5(TEXT varchar(100));", xCallback, (void*)"First Test", &ErrMsg); Err=sqlite_exec(DB, "insert into tbl5 values ('some string');", xCallback, (void*)"First Test", &ErrMsg); works fine but when I want to put s="some string" ie Err=sqlite_exec(DB, "insert into tbl5 values (s);", xCallback, (void*)"First Test", &ErrMsg); then this is not working so how to add variable then It is not working so how to insert variable in sqlite database thank u

    Read the article

  • Oracle Merge vs Select then Insert or Update

    - by DRTauli
    What is faster? the Merge statement MERGE INTO table USING dual ON (rowid = 'some_id') WHEN MATCHED THEN UPDATE SET colname = 'some_val' WHEN NOT MATCHED THEN INSERT (rowid, colname) VALUES ('some_id', 'some_val') or querying a select statement then using an update or insert statement. SELECT * FROM table where rowid = 'some_id' if rowCount == 0 INSERT INTO table (rowid,colname) VALUES ('some_id','some_val') else UPDATE table SET colname='some_val' WHERE rowid='some_id'

    Read the article

  • Insert or update when product is present using mysql

    - by Aryan
    main_product table productid outward shopid 333 2 44//present 343 4 44//present 353 5 44//present 363 1 44//present 373 2 44//not present min_product table productid outward shopid 333 1 44 343 1 44 353 1 44 363 1 44 SELECT DISTINCT (A.productid),A.outward, B.productid,B.outward FROM main_product A INNER JOIN min_product B on B.productid=A.product_id where A.shopid='44' and B.shopid='44' my question how can i INSERT OR UPDATE in one query using mysql by checking if it is present or not if present update else insert something like this? INSERT INTO mytable (key, value) VALUES ($newkey, $newvalue) ON DUPLICATE KEY UPDATE SET value = $newvalue

    Read the article

  • MySQL: Insert into multiple tables in same query with BEGIN&COMMIT

    - by strc
    I want to insert into multiple tables in same query by using BEGIN and COMMIT. It seems the error occur at begin. here is my SQL command BEGIN INSERT INTO Product (pName, pBrand, pCategory, pSize, pQuantity, pPrice, pDetail) VALUES('$name', '$brand', '$category', '$size', '$quantity', '$price', '$detail') INSERT INTO Image (iName, iExt, iSize, pID) VALUES('$img_name', '$img_ext', '$img_size', LAST_INSERT_ID()); COMMIT;

    Read the article

  • Sqlite3 INSERT INTO Question × 377

    - by user316717
    Hi, My 1st post. I am creating an exercise app that will record the weight used and the number of "reps" the user did in 4 "Sets" per day over a period of 7 days so the user may view their progress. I have built the database table named FIELDS with 2 columns ROW and FIELD_DATA and I can use the code below to load the data into the db. But the code has a sql statement that says, INSERT OR REPLACE INTO FIELDS (ROW, FIELD_DATA)VALUES (%d, '%@'); When I change the statment to: INSERT INTO FIELDS (ROW, FIELD_DATA)VALUES (%d, '%@'); Nothing happens. That is no data is recorded in the db. Below is the code: #define kFilname @"StData.sqlite3" - (NSString *)dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:kFilname]; } -(IBAction)saveData:(id)sender; { for (int i = 1; i <= 8; i++) { NSString *fieldName = [[NSString alloc]initWithFormat:@"field%d", i]; UITextField *field = [self valueForKey:fieldName]; [fieldName release]; NSString *insert = [[NSString alloc] initWithFormat: @"INSERT OR REPLACE INTO FIELDS (ROW, FIELD_DATA) VALUES (%d, '%@');",i, field.text]; // sqlite3_stmt *stmt; char *errorMsg; if (sqlite3_exec (database, [insert UTF8String], NULL, NULL, &errorMsg) != SQLITE_OK) { // NSAssert1(0, @"Error updating table: %s", errorMsg); sqlite3_free(errorMsg); } } sqlite3_close(database); } So how do I modify the code to do what I want? It seemed like a simple sql statement change at first but obviously there must be more. I am new to Objective-C and iPhone programming. I am not new to using sql statements as I have been creating web apps in ASP for a number of years. Any help will be greatly appreciated, this is driving me nuts! Thanks in advance Dave

    Read the article

  • Why is it inserting 0's instead of blank spaces into my DB using php?

    - by zeckdude
    I have an insert: $sql = 'INSERT into orders SET fax_int_prefix = "'.$_SESSION['fax_int_prefix'].'", fax_prefix = "'.$_SESSION['fax_prefix'].'", fax_first = "'.$_SESSION['fax_first'].'", fax_last = "'.$_SESSION['fax_last']; The value of all of these fields is that they are blank right before the insert. Here is an example of one of them I echo'd out just before the insert: $_SESSION[fax_prefix] = For some reason it inserts the integer 0, instead of a blank value or null, as it should. Why is it inserting 0's instead of blank spaces into my DB?

    Read the article

  • Insert blank row on two conditions

    - by lost_my_wallet_in_el_segundo
    I have a spreadsheet with a large number of rows. There are two rows grouped together (for each customer). In column A, the first row has an account number. The second row should be blank. The spreadsheet has lots of customers listed where there is no second row. I need to insert a blank line to create a second row for each customer that doesn't have one. Here is the VBA script I cobbled together, but it gets a syntax error. Sub Macro1() ' ' Macro1 Macro ' For myrow = 1 To Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row If Cells(myrow, 1) <> "" and Cells(myrow+1, 1) <> "" Then Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove End Sub

    Read the article

  • PHP Try and Catch for SQL Insert

    - by meme
    I have a page on my website (high traffic) that does an insert on every page load. I am curious of the fastest and safest way to (catch an error) and continue if the system is not able to do the insert into MySQL. Should I use try/catch or die or something else. I want to make sure the insert happens but if for some reason it can't I want the page to continue to load anyway. ... $db = mysql_select_db('mobile', $conn); mysql_query("INSERT INTO redirects SET ua_string = '$ua_string'") or die('Error #10'); mysql_close($conn); ...

    Read the article

< Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >