concatenation

SQL Server: Concatenating WHERE Clauses. Seeking Appropriate Pattern

I want to take a poorly designed SQL statement that's embedded in C# code and rewrite it as a stored procedure (presumably), and am looking for an appropriate means to address the following pattern: sql = "SELECT <whatever> FROM <table> WHERE 1=1"; if ( someCodition.HasValue ) { sql += " AND <some-field> = " + someCondition.Value; ...

Benefits of MessageFormat in Java

In a certain Java class for a Struts2 web application, I have this line of code: try { user = findByUsername(username); } catch (NoResultException e) { throw new UsernameNotFoundException("Username '" + username + "' not found!"); } My teacher wants me to change the throw statement into something like this: static final Strin...

Get specific data from a string? C#

I have a string named group. string group="|17|11|"; So my issue is that I want my output to be something like this: 17 11 so these 2 numbers should be stored in the database as two records. and another case if the string group = "|17|11|05|"; it will store 3 values in the database. The number of groups always differs in differe...

How to concatenate multple python source files into single file

(Assume that: application start-up time is absolutely critical; my application is started a lot; my application runs in an environment in which importing is slower than usual; many file need to be imported; and compilation to .pyc files is not available.) I would like to concatenate all the python source files that define a collection o...

Paste two text lists (one list a file) into one list separated by commas

An example of the process/output would be: File1: hello world File2: foo bar Resulting file after concatenation: File3: hello;foo world;bar For a large list of non-predictive text (no-wild cards - but lines are aligned as above). I cannot figure out how to do this with the paste command under Ubuntu. ...

Creating C macro with ## and __LINE__ (token concatenation with positioning macro)

I want to create a C macro that creates a function with a name based on the line number. I thought I could do something like (the real function would have statements within the braces): #define UNIQUE static void Unique_##__LINE__(void) {} Which I hoped would expand to something like: static void Unique_23(void) {} That doesn't wor...

Oracle SQL, concatenate multiple columns + add text

So I basically wanna display this (whole row in ONE column): I like [type column] cake with [icing column] and a [fruit column]. The result should be: Cake_Column I like chocolate cake with whipped_cream and a cherry. I like strawberry cake with vanilla_cream and a lemon_slice. etc. etc. I need some sort of TO_CHAR statement tha...

Concat field value to string in SQL Server

I need a similar function to Oracle WM_CONCAT in SQL Server, which returns a comma separated list of whatever field you pass it as argument. For example, in Oracle, select WM_CONCAT(first_name) from employee where state='CA' returns "John, Jim, Bob". How can I do this in SQL Server? Thanks ...

Combining registers in vim

Is it possible to combine registers in vim? For example, if I have registers "a, "b, "c, can I easily create register "d which is a concatenation of all three? That is, without pasting them all and then selecting the whole thing. ...

How many different ways are there to concatenate two files line by line using Perl?

Suppose file1 looks like this: bye bye hello thank you And file2 looks like this: chao hola gracias The desired output is this: bye bye chao hello hola thank you gracias I myself have already come up with five different approaches to solve this problem. But I think there must be more ways, probably more concise and more elega...

PHP Concatenation becomes NULL

When I run this code, About half-way through the concatenation loop, $xml becomes null and remains null throughout the rest of the concatenation loop. Has anyone else ran into this? Or see why this is happening? $xml = ''; foreach($this->currentColumns['unknown'] as $column => $value) { $xml .= "<columnName>"; $xml .= $column; ...

Concatenating 2 2D arrays in java?

I've got 2 2D arrays, one int and one String, and I want them to appear one next to the other since they have the same number of rows. Is there a way to do this? I've thought about concatenating but that requires that they be the same type of array, so in that case, is there a way I could make my int array a String array? ...

How can I concatenate two arrays in C?

How do I concatenate two arrays to get a single array containing the elements of both original arrays? ...

How can I concatenate set of results in MySQL?

I would like to join results returned in the set in MySQL with a comma as a separator string. For example, set returned contains: COLUMN_X john jerry maria joseph gugla I would like to receive the result as: COLUMN_X-concat john,jerry,maria,joseph,gugla is that possible? thanks. SELECT CONCAT(rooms.ID,",") FROM rooms AS rooms LEF...

Concatenating strings in macros - C++

What's the easiest way to concatenate strings defined in macros. i.e. The pseudo code I'm looking for would be like: #define ROOT_PATH "/home/david/" #define INPUT_FILE_A ROOT_PATH+"data/inputA.bin" #define INPUT_FILE_B ROOT_PATH+"data/inputB.bin" ... #define INPUT_FILE_Z ROOT_PATH+"data/inputZ.bin" The only way I know of is to use st...

Oracle: Way to aggregate concatenate an ungrouped column in grouped results

Hi, I have a query with several aggregate functions and then a few grouped columns. I want to take one of the grouped columns out of the group and perform some sort of aggregate "concatenating" of all the VARCHAR values it has. (Ideally in a new carriage separated list). Here is my query and I note where I'd like to do this: SELECT r...

How to concatenate multiple rows, where fieldnames are duplicated?

I am using SQL. Here is an example of my table: (There are actually thousands of rows like these, with varying course numbers.) Course No | Meeting Day | Course Name | Instructor 123 | M | English | Smith 123 | W | English | Smith 123 | F | English | Smith I need to...

how to concatenate two dictionaries to create a new one in Python?

Say I have three dicts d1={1:2,3:4}, d2={5:6,7:9}, d3={10:8,13:22}, how do I create a new d4 that combines these three dictionaries. i.e d4={1:2,3:4,5:6,7:9,10:8,13:22}? ...

Duplicates without using While or Cursor in T-SQL

ID Name 1 A 1 B 1 C 2 X 2 Y 3 P 3 Q 3 R These are the columns in a table. I want to get output like ID Company 1 A,B,C 2 X, Y 3 P,Q,R Restriction is that I cannot use WHILE or CURSOR. Please write a query for the same. ...

values of diff keys to concatenate from a resource file, how?

I want to concatenate the values of two or more keys from a resource file, while assigning value to a control, somthing like <%$ Resources:LocalizedText, LeadTitle%>" but, getting an error.Is it possible some way to concatenate the value of different keys from a resource file? ...