sql - R language sqldf package update table not working -
i exported data csv file r. using sqldf package udpate data. below query runs. can provide csv file dont know how attach files here :(
> sqldf("select * + ( + + select disposition dummy_disposition, case disposition + when 'disposition' 'unknown' + when 'donate' 'eol' + when 'resale' 'eol' + when 'harvest' 'eol' + when 'intelspinoff' 'eol' + when 'scrap' 'eol' + when 'bufferfeedforward' 'active' + when 'fb' 'unknown' + when 'unknown' 'unkown' + when 'harvestresale' 'eol' + when 'returntosupplier' 'eol' + when 'icapresale' 'eol' + when 'nonemsmanaged' 'eol' + when 'buffereol' 'eol' + when 'resalescrap' 'eol' + when 'st' 'unknown' + when 'as' 'unknown' + else null end new_status, + + * floorstatus null , disposition not null + + + ) table1 + new_status null") [1] dummy_disposition new_status ueid date enddate [6] site cfd type scheduleid eventtype [11] floorstatus entitycode ceid process supplier [16] fa mfgtype disposition comments extra1 [21] extra2 extra3 <0 rows> (or 0-length row.names)
but when run below query doesnt run :( interesting because except update table part rest of query part of above query.
> sqldf("update set floorstatus = case disposition + when 'disposition' 'unknown' + when 'donate' 'eol' + when 'resale' 'eol' + when 'harvest' 'eol' + when 'intelspinoff' 'eol' + when 'scrap' 'eol' + when 'bufferfeedforward' 'active' + when 'fb' 'unknown' + when 'unknown' 'unknown' + when 'harvestresale' 'eol' + when 'returntosupplier' 'eol' + when 'icapresale' 'eol' + when 'nonemsmanaged' 'eol' + when 'buffereol' 'eol' + when 'resalescrap' 'eol' + when 'st' 'unknown' + when 'as' 'unknown' + else null end + floorstatus null , disposition not null") error in sqliteexecstatement(con, statement, bind.data) : rs-dbi driver: (error in statement: near "from": syntax error)
what wrong update table command? when run code in sql development studio runs fine...but prefer if code runs in r
update:
what changes need make below code????
declare @outputs table ([day] datetime, floorstatus varchar, quantity int) declare @date datetime; declare dates_cursor cursor select clndr_dt epsd.dbo.t_calendar clndr_dt between '2008-01-01' , '2013-08-13' order clndr_dt open dates_cursor fetch next dates_cursor @date while @@fetch_status = 0 begin insert @outputs select @date [day], floorstatus, count(floorstatus) quantity graph_data @date between [date] , enddate group floorstatus fetch next dates_cursor @date end close dates_cursor deallocate dates_cursor select * @outputs
update not have from
clause (see update syntax on sqlite site) , see sqldf faq #8 commonly made error of updating table in sqlite not returning table r.