Posts

mysql - insert when a particular record not found -

mysql - insert when a particular record not found - i got situation need insert if record not exist. normally, i'm going utilize 2 queries conditions this: select table -> if record not found -> insert table else -> nil i sense solution not one. how can accomplish same thing single query? example: select * user status='a' , name='lewis' if record not found insert user(status,name) values('f','lewis'); you mean like: begin if not exists (select * user status='a' , name='lewis') begin insert user (status, name) values('f','lewis') end end this works in sql server, , should possible in mysql well. edit: apparently it's not working in mysql (just testd). however, utilize insert ignore : insert ignore user2 (status, name) values('f','lewis'); note that work if have unique or primary key. another way have sam...

ruby - How to regex two sets of data -

ruby - How to regex two sets of data - i have text contains description of info , ends 2 sets of data: long text - tags:(array of tags) - url i need parse text , construction data. my thought have like: a="long text. tags:[ex1,ex2,ex3]" and utilize a = a.partition("tags:") ( partition splits text on arg) long text on a[0] , tags on a[2] , split individual tags. can problem if "tags:" in long text , can create tags: unique create work. i'm having problem on how should store url. i'm guessing partitioning string on url work, believe there improve way in regex more accommodating data. how should construction info in way allow me retrieve them stored in text? update: can tell users construction info in way, needs easy. output, need text, array of strings, , url. so example, can tell users input this: "this long text, original description have , store text in database. tags:[tag1,tag 2] url:http://g...

c# - Events in BackgroundWorker thread not firing while main thread active -

c# - Events in BackgroundWorker thread not firing while main thread active - for long, have been trying run external .bat file (calls r script statistical processing), , have console redirect u.i. i think close, have gotten work have run sizable problem! is: bloody works 1 time main thread has ended (via: return;), , not during thread.sleep, or .waitone() or etc. here code in main thread. string batloc = allrg___.rscrbin_loc + "current.bat"; backgroundworker watchboxdworker1 = new backgroundworker(); watchboxdworker1.dowork += frmc.watchboxworker1_watchext; frmc.wbresetevent = new autoresetevent(false); watchboxdworker1.runworkerasync(batloc); //thread.sleep(1000*20); //frmc.wbresetevent.waitone(); return; note commented out sleep and/or waitone() instructions. if seek , utilize these backgroundworker execute, 'events' update u.i not. the code in form (frmc above) follows, public void watchboxworker1_watchext(object sender, doworkeventa...

c++ - memory alignment into structure - alignment size equal to largest member size -

c++ - memory alignment into structure - alignment size equal to largest member size - i know why must take, alignment size of structure, alignment size equal largest fellow member size structure. example : struct mixeddata { char data1; short data2; int data3; char data4; }; if take largest fellow member (int data3) , alignment 4 bytes, have do: struct mixeddata /* after compilation in 32-bit x86 machine */ { char data1; /* 1 byte */ char padding1[1]; /* 1 byte next 'short' aligned on 2 byte boundary assuming address construction begins number */ short data2; /* 2 bytes */ int data3; /* 4 bytes - largest construction fellow member */ char data4; /* 1 byte */ char padding2[3]; /* 3 bytes create total size of construction 12 bytes */ }; but why don't have, after char data1 , char padding1[3] short data2 begins @ adress(data1) + 4 instead of char data1[1] ? and, same logic, why...

visual studio - Program adaptation for Windows CE 6.0 -

visual studio - Program adaptation for Windows CE 6.0 - hello , give thanks reading post. a few years ago, developed in company barcode application "windows mobile 6.5" using "ms visual studio 2005". this application targets mobile terminal barcode scanner , makes utilize of filesystem (database). we noticed manufacturers presently sell barcode terminals ("datalogic memor x3" example) os "microsoft windows ce 6.0 core" or "ce 6.0 pro". "how adaptable" "windows mobile 6.5" application "microsoft windows ce 6.0"? (i understand might depend on application don't know info give here. please inquire , i'll give additional info if necessary). does involve minor adaptations or hard work? we couldn't seek ourselves because having hard time setting right development environment (ide, emulator). don't know ide use. heard of "ms visual studio 2008" it's old version o...

asp.net - to get asp datagrid selected rows in a session -

asp.net - to get asp datagrid selected rows in a session - i new .net technology, utilize asp datagrid loads ' n ' number of rows. have requirement add together select rows asp datagrid infragistics webdatagrid. to add together selected rows asp datagrid infragistics webdatagrid, run loop takes selected row datagrid , add together infragistics webdatagrid. i not nail database , happens on client side. when utilize grid.get_rows().add(new_row) code, @ end of loop executing see 1st selected item asp datagrid getting added infragistics webdatagrid. it has been said in infragistics forum "infragistics webdatagrid can add together 1 row , multiple rows cannot added on client side @ 1 post back ". hence selected rows in asp datagrid in session in client side (javascript) , add together rows in session infragistics webdatagid. please help me javascript code of getting selected rows asp:datagrid in session , allow me know how can add together infrag...

maven - Spring + Unable to Load Hibernate annotation jar -

maven - Spring + Unable to Load Hibernate annotation jar - i'm getting below error. java.lang.classnotfoundexception: org.springframework.orm.hibernate3.annotation.annotationsessionfactorybean here pom.xml. please allow me know if i'm missing jar or clash between jar version files. <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>myspringmvc</groupid> <artifactid>myspringmvc</artifactid> <version>0.0.1-snapshot</version> <packaging>war</packaging> <name>myspringmvc</name> <url>http://maven.apache.org</url> <properties> <java.version>...