insert-update

Correctly inserting and/or updating many datasets to MongoDB (using mongoose)?

泪湿孤枕 提交于 2019-12-24 18:57:28
问题 So from time to time I get new exports of a cities database of POIs and info about them and I want to have all that data in my MongoDB with a Loopback-API on it. Therefore I reduce the data to my desired structure and try to import it. For the first time I receive such an export, I can simply insert the data with insertMany(). When I get a new export, it means that it includes updated POIs which I actually want my existing POIs to be replaced with that new data. So I thought I'd use

SQL Server Trigger to fill in value based off File Name on Import

随声附和 提交于 2019-12-24 11:37:20
问题 I need to create a trigger that fills in a project name for table based off the filename. Currently, I am able to fill in the first project name on import based off the first hostname. Example after Current import: Now I need to fill in the rest of the Null Project Names where Project name is Not Null for the corresponding Filename. Example for Goal Import How do I get this to work dynamically for each time new data is entered? I also want to make sure it is done by filename to make sure no

Data are missing after updating

放肆的年华 提交于 2019-12-24 08:00:04
问题 Okay I'll discuss my problem with images so we can solve it easily. Hoping. First, The image below shows the PersonalInfo gridview under PersonalInfo.aspx Second, The image below shows the MobileInfo gridview under MobileINfo.aspx Third, now we are going to edit the record in this page MobileInfo.aspx Fourth, Image below I thought everything works perfectly because the data has been updated. But... Fifth and last, I went back in PersonalInfo.aspx but it gives me this...Data has been deleted

How to implement INSERT ON DUPLICATE KEY UPDATE aka upsert in CakePHP 3?

核能气质少年 提交于 2019-12-24 03:38:06
问题 I am using CakePHP 3 and MySQL. I would like to implement a INSERT on DUPLICATE KEY UPDATE aka upsert query via CakePHP 3 model. Given the following table: +----+----------+-----+ | id | username | age | +----+----------+-----+ | 1 | admin | 33 | | 2 | Timmy | 17 | | 3 | Sally | 23 | +----+----------+-----+ where id is Primary Key and username is unique index When I have the following values awaiting to be upserted: Felicia, 27 Timmy, 71 I expect the following result after the upsert: +----+-

JPA merge does not appear to work

[亡魂溺海] 提交于 2019-12-23 22:26:39
问题 I'm running the following code to update the database according to the data I read from CSV file. I've tried to debug, and check the console and it's running through the whole 800 records. I don't get any error, but only the first record is inserted. If I'm using persist instead of merge, I got "Cannot persist detached object" error. for (String[] data : dataList) { log.debug("Reading data no " + (i++)); EntityManager em = PersistenceUtil.getAgisDbEntityManager(); EntityTransaction tr = em

How can the INSERT … ON CONFLICT (id) DO UPDATE… syntax be used with a sequence ID?

房东的猫 提交于 2019-12-23 17:25:58
问题 In postgresql 9.5 how can the INSERT ... ON CONFLICT (id) DO UPDATE... syntax be used with a sequence ID? In a table tbltest that has the following columns: tbltest_ID tbltest_Name tbltest_Description Where tbltest_ID has a sequence in the db that does auto increment. The following works fine for updates, eg; updating the record with an ID of 4: INSERT INTO tbltest ( tbltest_ID, tbltest_Name, tbltest_Description) VALUES (4, 'test name','test description') ON CONFLICT (tbltest_ID) DO UPDATE

How to pass string with ' ' (timestamp) in prepared statement?

心不动则不痛 提交于 2019-12-23 10:29:11
问题 I am trying to execute the following query INSERT INTO hotspot(timestamp) VALUES (timestamp with time zone '2012-10-25 14:00:00 +05:00' at time zone 'EET'); and i want to pass the timestamp as a variable. My timestamp column is type of timestamp with time zone. Do you have any idea how this can be done? When i do... (Java, Postgresql) String stm= "INSERT INTO hotspot(timestamp) VALUES(timestamp with time zone ? at time zone 'EET')"; pst = con.prepareStatement(stm); pst.setString(1, "2012-08

How to pass string with ' ' (timestamp) in prepared statement?

拜拜、爱过 提交于 2019-12-23 10:28:26
问题 I am trying to execute the following query INSERT INTO hotspot(timestamp) VALUES (timestamp with time zone '2012-10-25 14:00:00 +05:00' at time zone 'EET'); and i want to pass the timestamp as a variable. My timestamp column is type of timestamp with time zone. Do you have any idea how this can be done? When i do... (Java, Postgresql) String stm= "INSERT INTO hotspot(timestamp) VALUES(timestamp with time zone ? at time zone 'EET')"; pst = con.prepareStatement(stm); pst.setString(1, "2012-08

insert …select … count … on duplicate key update error

喜你入骨 提交于 2019-12-23 03:04:46
问题 I created a table to hold counts of work orders by asset tag. I have 2 fields, asset_tag (which is unique) and the wo_count. I am trying to write a query that will insert/update the counts in the table. Through research on ON DUPLICATE KEY UPDATE , I have come up with this, but am getting unknown column errors. INSERT INTO mod_workorder_counts (asset_tag, wo_count) (SELECT t.asset_tag, count(*) AS cnt FROM mod_workorder_data t WHERE t.asset_tag IS NOT NULL GROUP BY t.asset_tag) ON DUPLICATE

Update Existing Access Records from CSV Import , native to MS Access or in VB.NET

风流意气都作罢 提交于 2019-12-20 04:56:22
问题 I am the application administrator for a ticketing system at my organization. We're adding a new client, and need to import their customer records into our system. However, we have been denied access to simply grab these records from a direct database connection. We are limited to entering their ticketing system, and running an export of the existing records to a CSV file. In order to make this work with our system, I'm taking these CSV's and entering them into an MS Access database, which