Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

mysql - Portable SQL upsert (insert+update) solution needed -


i need perform simple operation on database - put values table key, if row exists - update it, if not - create new one. problem need in portable way - i.e. same query must work on mysql, sql server, oracle , preferably db2, postgres, etc. while use replace or insert ... on duplicate key update in mysql, i'm not sure these support such syntax. , want avoid if's database type, because unmaintainable. don't want query value before updating, because suspect slow down process (i need multiple times).

so far best came doing:

  update table set data='data' key='key';   insert table(key, data) values ('key', 'data'); 

one of succeed , fail, don't care 1 of queries fails. looks kind of inelegant though. suggestions how make better?

the database-agnostic solution, using modern databases, call update insert in 2 operations. databases not allow multiple statements sent in single operation , databases might not return number of rows affected update not rely upon that.

update mytable set data = 'data' keycol = 'key'; 

(separate call)

insert mytable(keycol, data) select 'key', 'data' ( select 1 value ) z not exists    (                     select 1                     mytable t1                     t1.keycol = 'key'                     ); 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -