insert-update

SQL Statement for Reconciliation

爱⌒轻易说出口 提交于 2019-12-05 19:56:06
Given the schema below: create table TBL1 (ID varchar2(100) primary key not null, MATCH_CRITERIA varchar2(100)); create table TBL2 (ID varchar2(100) primary key not null, MATCH_CRITERIA varchar2(100)); create table TBL_RESULT (ID varchar2(100) primary key not null, TBL1_ID varchar2(100), TBL2_ID varchar2(100)); create unique index UK_TBL_RESULT_TBL1_ID on TBL_RESULT(TBL1_ID); create unique index UK_TBL_RESULT_TBL2_ID on TBL_RESULT(TBL2_ID); create sequence SEQ_TBL_RESULT; insert into TBL1 VALUES('1', '1'); insert into TBL1 VALUES('2', '1'); insert into TBL1 VALUES('3', '1'); insert into TBL2

Update using left join in netezza

旧时模样 提交于 2019-12-05 13:08:22
I need to perform a left join of two tables in netezza during an update. How can i achieve this ? Left join with three tables are working but not with two tables. UPDATE table_1 SET c2 = t2.c2 FROM table_1 t1 LEFT JOIN table_2.t1 ON t1.c1=t2.c1 LEFT JOIN table_3 t3 ON t2.c1=t3.c1 this works but UPDATE table_1 SET c2 = t2.c2 FROM table_1 t1 LEFT JOIN table_2.t1 ON t1.c1=t2.c1 this says like trying to update multiple columns. Thanks, Manirathinam. When performing an UPDATE TABLE with a join in Netezza, it's important to understand that the table being updated is always implicitly INNER JOINed

T-SQL Insert or update

六眼飞鱼酱① 提交于 2019-12-05 08:33:22
问题 I have a question regarding performance of SQL Server. Suppose I have a table persons with the following columns: id , name , surname . Now, I want to insert a new row in this table. The rule is the following: If id is not present in the table, then insert the row. If id is present, then update. I have two solutions here: First: update persons set id=@p_id, name=@p_name, surname=@p_surname where id=@p_id if @@ROWCOUNT = 0 insert into persons(id, name, surname) values (@p_id, @p_name, @p

MongoDB Update Array element

安稳与你 提交于 2019-12-04 03:58:53
问题 I have a document structure like { "_id" : ObjectId("52263922f5ebf05115bf550e"), "Fields" : [ { "Field" : "Lot No", "Rules" : [ ] }, { "Field" : "RMA No", "Rules" : [ ] } ] } I have tried to update by using the following code to push into the Rules Array which will hold objects. db.test.update({ "Fields.Field":{$in:["Lot No"]} }, { $addToSet: { "Fields.Field.$.Rules": { "item_name": "my_item_two", "price": 1 } } }, false, true); But I get the following error: can't append to array using

VBA to import Excel worksheet, append new rows, and update existing rows

久未见 提交于 2019-12-04 02:22:06
问题 I'm using Excel to produce reports for a support ticketing system, and I'd like to use VBA to simplify the process of updating the report data. What I want to do is import an Excel file dumped from the ticketing system into the Excel file I'm using for reporting, but with a twist. I need to use the value in one column to identify whether the ticket is new or existing. If it's new, I want to add it to the reporting file. If it's existing, I want to overwrite the matching row (based on the

T-SQL Insert or update

廉价感情. 提交于 2019-12-03 22:05:51
I have a question regarding performance of SQL Server. Suppose I have a table persons with the following columns: id , name , surname . Now, I want to insert a new row in this table. The rule is the following: If id is not present in the table, then insert the row. If id is present, then update. I have two solutions here: First: update persons set id=@p_id, name=@p_name, surname=@p_surname where id=@p_id if @@ROWCOUNT = 0 insert into persons(id, name, surname) values (@p_id, @p_name, @p_surname) Second: if exists (select id from persons where id = @p_id) update persons set id=@p_id, name=@p

how can i alter table in sqlite database through the obj c methods in iphone project

若如初见. 提交于 2019-12-03 17:27:52
hii every one I need to add one column to my existing table so how can i alter table in sqlite database through the obj c ,i am using the following code for inserting data into table in the same way how can i write updata table method - (void) InsertRecord { if(addStmt == nil) { const char *sql = "insert into tbl_Users(FirstName,MiddleName) Values(?,?)"; if(sqlite3_prepare_v2(database, sql, -1, &addStmt, NULL) != SQLITE_OK) NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database)); } sqlite3_bind_text(addStmt, 1, [strFirstName UTF8String], -1, SQLITE_TRANSIENT);

How to update elements within a heap? (priority queue)

末鹿安然 提交于 2019-12-03 12:37:34
When using a min/max-heap algorithm, priorities may change. One way to handle this is to removal and insert the element to update the queue order. For priority queues implemented using arrays, this can be a performance bottleneck that seems avoidable, especially for cases when the change to priority is small. Even if this is not a standard operation for a priority queue , this is a custom implementation which can be modified for my needs. Are there well known best-practice methods for updating elements in the min/max-heap? Background Info: I'm no expert in binary-trees, I inherited some code

How do you determine if an insert or update was successful using Java and MySQL?

耗尽温柔 提交于 2019-12-03 06:30:48
问题 I am using Java to connect to a MySQL database. I am trying to insert or update data into the database. Even though I am quite sure the insert was successful, it returns false. According to the "execute" API, the return value is "true if the first result is a ResultSet object; false if it is an update count or there are no results". How can I determine whether or not my insert or update was successful? public boolean insertSelections(String selection, String name){ String sql ="INSERT INTO

How do I Insert or Update (or overwrite) a record using NHibernate?

守給你的承諾、 提交于 2019-12-03 06:02:59
问题 I need to write a row to the database regardless of whether it already exists or not. Before using NHibernate this was done with a stored procedure. The procedure would attempt an update and if no rows were modified it would fallback to an insert. This worked well because the application doesn't care if the record exists. With NHibernate, the solutions I have found require loading the entity and modifying it, or deleting the entity so the new one can be inserted. The application does have to