mercredi 1 avril 2015

Comparing two values in java that fetched from MSSQL

Hi i'm new to talend tool. While practicing i came through this. Its one of our previous project. I know how to compare two rows using NOT EQUAL in java, but this looks pretty different..


For example Comparison of two strings in java



(!row1.nts_vcr.equals(row2.nts_vcr))


and comparison of two integer in java



(row1.SOC!=row2.SOC)


I dunno what the below statement means



(!(row1.cntnr_id==row2.cntnr_id ))||
(!(row1.cntnr_sz_id==row2.cntnr_sz_id))||
(!(row1.cntnr_typ_id==row2.cntnr_typ_id))||
(!(row1.cntnr_stts_id==row2.cntnr_stts_id))

SQL Check if a text contains a word

I have a Text,



'Me and you against the world' // false
'Can i have an email address' // true


I want to check whether the word an is inside my String.


How do I check if a text contains a specific word in SQL? I can't add a full-text catalog. Otherwies i could



SELECT * FROM TABLE WHERE CONTAINS(Text, 'an')

Replace the " character with a space

I have a CSV file, where each comma delimited field is enclosed in " - eg. "fred", "bert", "blah". I am trying to use the replace function but can't seem to have it recognize the " character. example, if the record is in a string called buffer:



buffer.replace('\"','')

How to make a string uppercase (extended ASCII)?

I wrote this function to make a string all uppercase. Unfortunately, it does not work with the extended ASCII characters, like ä, ö, ü, é, è and so on. How can I convert the string to uppercase and convert these characters also (Ä, Ö, Ü, É, È)?



void toUppercase1(string & strInOut)
{
std::locale loc;
for (std::string::size_type i=0; i<strInput.length(); ++i)
{
strInput.at(i) = std::toupper(strInput.at(i),loc);
}
return;
}


This is the new version.



#include <clocale>
void toUppercase2(string& strInput)
{
setlocale(LC_CTYPE, "sv_SE");

for (std::string::size_type i=0; i<strInput.length(); ++i) {
strInput.at(i) = toupper(strInput.at(i));
}

// reset locale
setlocale(LC_ALL, "");

return;
}


Unfortunately, the above method toUppercase2(string&) is very slow. It seems that changing the locale globally requires some effort. I assume that using a locale object from C++ which is initialized once and then used by toupper is much faster, but I cannot find an example of how to use it properly.


Any hints to where I can find more information about locales and their use is appreciated.


Remove prefix from name python


names = [
'LIC. SEBASTIÁN LASTIRI',
'ING. AGR. ROBERTO DANIEL RODRÍGUEZ',
'C.P.N. JULIO DOMINGO BURAK',
'INGENIERO HIDRÁULICO VÍCTOR AGUSTÍN PORRINO'
]


I have such list with names, i need to remove prefix like ('lic', 'c.p.n' etc) from name (this is just sample there is a lot of prefixes in such format)


output shell be like this :



'SEBASTIÁN LASTIRI'



I have tried to :



for i in names:
if '.' in i:
i.split('.')[1]


But it works only when there is one dot in prefix How to solve this


scanning a 128 bit input represented in 32 hex values

I need to scan the 32 hex number from command line and populated it into a uint8_t [16] array, I tried scanning the string and convert it to hex but its really a hassle since i cant find a function that does that, whats the best way to do this?


I want to pass list of String say userIds. So solr document containing these ids must be neglected from search.



public FacetPage<SolrDocument> facetSearch(String searchTerm,String city,String category,Pageable page) {
SimpleFacetQuery facetQuery=null;
if(getCriteria(city,category)==null)
{
facetQuery = new SimpleFacetQuery(new SimpleStringCriteria(searchTerm));
}
else
{
facetQuery = new SimpleFacetQuery(new SimpleStringCriteria(searchTerm)).addCriteria(getCriteria(city, category));
}
FacetOptions options = new FacetOptions();
options.addFacetOnFlieldnames(getFacetFields());
facetQuery.setFacetOptions(options);
facetQuery.setPageRequest(page);
return hspTemplate.queryForFacetPage(facetQuery, SolrHspDocument.class);
}