How concat string
Hi,
I've table TAB_COD
COD_ID.................NOTE
001....................OK
001....................NOT OK
001....................YES
002....................TOP
005....................X
005....................Y
005....................Z
007....................MY
007....................YOUR
008....................STOP
I'd like to get this output:
COD_ID.................NOTE
001....................OK - NOT OK - YES
002....................TOP
005....................X - Y - Z
007....................MY - YOUR
008....................STOP
How can I concat string group by COD_ID?
Thanks in advance!!
Works for me:
SQL> select banner from v$version
2 /
BANNER
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
PL/SQL Release 9.2.0.7.0 - Production
CORE 9.2.0.7.0 Production
TNS for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production
NLSRTL Version 9.2.0.7.0 - Production
SQL> select location_id
2 , concat_all(concat_expr(department_id,',')) x
3 from departments
4 group by location_id
5 /
LOCATION_ID X
1400 60
1500 50
1700 10,110,130,150,170,260,250,240,230,220,210,200,190,180,270,1
60,140,120,100,30,90
1800 20
2400 40
2500 80
2700 70
7 rows selected.
SQL>
Similar Messages
-
How many string objects - please suggest
Hi there,
Can you somebody please tell how many String objects will be created when the following method is invoked?
public String makinStrings() {
String s = Fred;
s = s + 47;
s = s.substring(2, 5);
s = s.toUpperCase();
return s.toString();
Thanks
ShanHi VShan,
This is your code
public String makinStrings() {
String s = Fred; //1
s = s + 47; //2
s = s.substring(2, 5);//3
s = s.toUpperCase(); //4
return s.toString(); //5
EXPLANATION : String is an immutable object, that means the String object cannot change it's contents.It might sound very unfamiliar but it is TRUE. In line 1: You declare a String object by assigning a a String literal "Fred" to the variable s. Now when you concat "47" with the original contents of s , a new memory space is allocated where s is assigned.+It is important to note+ that the previous reference of s i.e. "Fred" will be lost and now s refers to a new memory location where the contents are "Fred47" , so you have created another object in Line 2. Similarly you create another object in line3 & 4.As far my calculations you have created 4 objects.
I would like you to kindly note that s is already a String so you can directly return s and hence there is no need of s.toString() in Line 5.You should also note that each object is also an eligible candidate for Grabage Collection.
So as soon as Line2 gets executed , the object in Line1 becomes eligible for garbage collection.. that means when GC runs that object will be reclaimed and hence memory will be freed. -
"a"+"b"+"c", how many String objects created?
Hello everyone,
String s = "a" + "b" +"c";
How many String objects are created?
I guess 5, is it right?
regards> How many String objects are created?
>
I guess 5, is it right?
Nope. Just one. -
Concat strings for use with ternay operator
Hi,
depending on a boolean i want to output an welcome message for a user logged in or "login failed".
problem: ternary operator only acceps one expression for each argument.
so, this is ok:
<t:outputText value="#{login.loggedIn ? bundle.loginWelcome : bundle.loginFailed}" />but i want to output the username also, like:
<t:outputText value="#{login.loggedIn ? bundle.loginWelcome login.user : bundle.loginFailed}" />but this throws this:
ERROR - Servlet.service() for servlet jsp threw exception
javax.faces.el.ReferenceSyntaxException: Invalid expression: '${login.loggedIn ? (bundle.loginWelcome login.username) : bundle.loginFailed}'
Caused by: org.apache.commons.el.parser.ParseException: Encountered "? ( bundle . loginWelcome login" at line 1, column 18.
Was expecting one of:
...is there a way to concat strings in EL?
thxWhy don't you create a method on the managed bean that do that for you?
-
How many String objects will be created when this method is invoked?
public String makinStrings() {
String s = �Fred�;
s = s + �47�;
s = s.substring(2, 5);
s = s.toUpperCase();
return s.toString();
}Teachers.Obviously. Why? Is it really important?
Not in my experience. StringBuffer can be important, occasionally. Very occasionally: about 4 times in the last 10 years for me. How many Strings? not important. -
How to concate string variable?
hi,
anyone help me out in this case.
i have a prg. like this.
data: var1(20) type c.
data: var2(2) type c.
data: var3(2) type c.
data: var type string.
var1 = 'abcd'.
var2 = 'bp'.
var3 = 'bp'.
i want the output like..... abcd bpbp.
it means i want to leave 16 spaces after abcd in this case. if var1 is having content like ,
abcde than i want to leave 15 space after abcde because total length of var1 is 20.
if i simply concate output would be abcdbpbp.
so if i count the no. of spaces i need to leave after abcd and create one date object of type c at runtime , it would work out.
but how should i create.....?
plz let me know ASAP.
saurin shah.Hi Saurin...
there are 2 main keywords used with concatenate
(1) ...."SEPARATED BY"
(2) ...."RESPECTING BLANKS"
in this case if you do the code
copy the code into a test program......................
data: var1(20) type c.
data: var2(2) type c.
data: var3(2) type c.
data : var4(4) type c.
data: var type string.
var1 = 'abcd'.
var2 = 'bp'.
var3 = 'bp'.
concatenate var2 var3 into var4.
to get bpbp
concatenate var1 var4 into var separated by SPACE.
write var.
clear var.
concatenate var1 var4 into var respecting blanks.
write var.
keep changing the value of var1 in the code to see how you can use the 2 options to your advantage...and which one suits your requirement best
Output1: " using separated by space"
abcd bpbp
here there will be 1 spacce after abcd
so it is abcde
it will be
abcde bpbp
Output2: " using respecting blanks"
abcd bpbp
ie,after abcd there will be 16 more blank spaces since its total length is 16...
using this keyword the number of space is not condensed but kept intact
but if there are 20 characters in the var1 then there will be no space eg: abcdefghijklmnopqrsbpbp...for 19 characters it will be abcdefghijklmnopqr bpbp
so you can decide which layout you need once you write the code and see th output for yourself
Pls check,revert and reward if helpful
Regards
Byju -
Concat Strings to create a Resource Bundle KEY
Hello, I`m having a little problem. I need, at the same point o a JSF page to show 2 different messages depending on a String variable value inside a Bean.
Then I was thinking if a could have the 2 different keys for the 2 different messages written in the bundle file, but the first part of the key would be the same, then the second would be equal to the String variable in the bean, so I would need to do a concatenation to get the correct KEY and then retrieve the correct message. Is that possible? If so, how could I do that?
So far, I have tried: But none worked
#{messages[''+'']}
#{messages[''] + messages['']}The + is an arithmetic operator, not string-concatenation -- if you apply it to strings, the EL will attempt to coerce them to numeric values in order to apply the '+'.
There are some string manipulation functions in the JSTL standard function library. "str-concat" is not one of them, but there is a "replace" function.
Assuming your resource bundle is called 'messages' and the key suffix is in a bean called 'keysuffix', you could try something like this:
#{message[fn:replace('blah.blah.SUFFIX', 'SUFFIX', keysuffix)]} -
Xquery concat / string-join / replace
Hi, I am a newbie on Xquery.
And I need some help on a problem I been having.
My in data is three digit numbers (ex. "123" "321" "213" etc). And I need to separate this with a comma ",". The problem is how do I do this if the input is only one item?, and second how do I not
put a "," on the last item?
I have tried a for-loop where a concat my string with with "," but the result is "123, 321, 213,". I do not want the last comma. And the spaces is not real whitespaces. I don't know where this comes from, the can not be removed or be used to
replace them with a comma (which would be the simplest way to solve my problem) but doesn't work.
for $Something in $Something/ns0:Something
return
fn:concat(data($Something)," ",",").
This returns "123, 321, 213,".I have solved it.
string-join(( data($Something/SomethingElse)),",")
Thanks. -
How to string aggregate in OBIEE reports?
Hi ,
I have a requirement to string aggregate the data for a particular column in OBIEE 11g.
When Iam using the in built functions *(wmconcat)*_ it is throwing the error as ,
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 17001] Oracle Error code: 934, message: ORA-00934: group function is not allowed here at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)
How to get this requiremnet in OBIEE analytics report page while displaying?
emp_name Dept_no
Ex: Kalyan 1162 26164,26169,26183,26249,26285
Help is highly appreciated.
Regards,
KalyanHi Deepak,
Thanks for your responce.
My requirement was not that.
Ex: If a employe belongs to multiple departments
employe X belongs to department 10,20,30,40 then report should disply as comma separated values.
sol: X 10,20,30,40
As the output when we use wm_concat in built function.
Kindly waiting for the people responce.
Regards,
Kalyan -
How big strings can you insert in a document of a textpane
I hava a problem when i try to do a
insertstring on a styled Jtextpane document.
Only when the string are bigger then ~32000 iget the following error.
So is there a limit ?
How to make the stiles i have ripped from the sun example code
im using jdk 1.4.1
plz help.
javax.swing.text.StateInvariantError: infinite loop in formatting
at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:404)
at javax.swing.text.FlowView.layout(FlowView.java:182)
at javax.swing.text.BoxView.setSize(BoxView.java:379)
at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
at javax.swing.text.BoxView.layout(BoxView.java:682)
at javax.swing.text.BoxView.setSize(BoxView.java:379)
at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1598)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:800)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1272)
at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1206)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)
at java.awt.Container.layout(Container.java:1017)
at java.awt.Container.doLayout(Container.java:1007)
at java.awt.Container.validateTree(Container.java:1089)
at java.awt.Container.validate(Container.java:1064)
at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:353)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:116)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:448)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)http://developer.java.sun.com/developer/bugParade/bugs/4775730.html
-
Concat strings from different subdiagram​s of a case structures
I am using a case structure, which has about 8-10 different case and each case has a string constant. I want to show the strings in a single indicator. Suppose if 3 cases runs first then second and then third. Then the indicator should show
" first case
second case
third case"
initially indicator should be empty then as soon as the first case runs indicator should show " first case"
after finishing the first case when second case runs then the indicator should show
"first case
second case"
and so on..Please help me.
Solved!
Go to Solution.$agar wrote:
Here it is attached with 3 cases........
Well, that does not look very useful. Try to scale it to 10 booleans!
Here is a quick draft how it could be done. Modify as needed.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ConcatenateCaseStrings.vi 9 KB -
How are strings immutable in java
for e.g.
String x="abc";
x+="DEF";
x=x.toLowerCase()
System.out.println("String is "+x);
if u run the above code it prints -String is abcdef
If strings are immutable hows it possibleTry the following:
public class test
public static final void main(String args[])
final int MAXCOUNTER = 10000;
String s = new String();
long t1 = System.currentTimeMillis();
for(int i = 0;i < MAXCOUNTER;i++)
s += ".";
t1 = System.currentTimeMillis() - t1;
StringBuffer sb = new StringBuffer();
long t2 = System.currentTimeMillis();
for(int i = 0;i < MAXCOUNTER;i++)
sb.append(".");
t2 = System.currentTimeMillis() - t2;
System.out.println("String: " + s);
System.out.println("StringBuffer: " + sb.toString());
System.out.println("Time elapsed creating a String containing " + MAXCOUNTER + " dots: " + t1 + "ms");
System.out.println("Time elapsed creating a String containing " + MAXCOUNTER + " dots: " + t2 + "ms");
}You'll notice that the time elapsed when creating the string using the StringBuffer.append() method is a lot smaller than the time spent creating the string using the + String operator.
Why? Because each time the + operator is called, it returns a new String object. It can't modify the String object in which it is used. The same happens with other String operations. The StringBuffer.append() method actually really appends the dot to the end of the buffer, it doesn't create a new StringBuffer for that.
I think the constants pool is only used for the constants hard coded into the source code (the ones you write between double quotes inside the source code).
That's why it's preferred to use StringBuffers when you do many String operations. -
Concat String Values in an Update Statement
Hi,
i am having trouble with this SQL Statement. I do not understand why this is happening:
Table1 (id int, text nvarchar(max))
Data:
1 , "xxx"
1, "www"
2, "yyy"
2, "uuu"
Table2 (id int, text nvarchar(max))
1, "aaa"
2, "bbb"
The id field of table1 is not unique.
UPDATE TABLE Table2
SET text = text + Table1.text
FROM Table2 INNER JOIN Table1 ON Table2.id = Table1.id
Expected Result from Table2:
1, "aaaxxxwww"
2, "bbbyyyuuu"
But the actual result is:
1, "aaaxxx"
2, "bbbyyy"
What am I doing wrong or what am I missing?
thanx.
regards
StefanThe problem is that there is no intermediate result propagation. You simply get "aaa" + "..." where "..." is the last column value by the internal order of your statement.
You need to explicitliy concat your input strings from T1 before doing the update, e.g.
DECLARE @T1 TABLE
id INT ,
[text] NVARCHAR(MAX)
INSERT INTO @T1
VALUES ( 1, 'xxx' ),
( 1, 'www' ),
( 2, 'yyy' ),
( 2, 'uuu' );
DECLARE @T2 TABLE
id INT ,
[text] NVARCHAR(MAX)
INSERT INTO @T2
VALUES ( 1, 'aaa' ),
( 2, 'bbb' );
UPDATE T2
SET [text] = T2.[text] + ( SELECT '' + T1.[text]
FROM @T1 T1
WHERE T1.id = T2.id
FOR XML PATH('')
FROM @T2 T2;
SELECT T.id ,
T.[text]
FROM @T2 T; -
when i have the following program, the system print out at last is just "good" instead of "goodhello", do I make any mistake?
thx~
import java.io.*;
import java.lang.Object;
import java.lang.String;
public class Test{
public static void main(String[] args) throws IOException {
String c = "good";
String d ="hello";
c.concat(d);
System.out.println(c);In Java, Strings are immutable. All String manipulation functions return new Strings and leave the originals unchanged.
c.concat(d);This creates and ignores a new, separate, String object. c is left unchanged.
You could have done as the previous poster recommended and used c = c.concat(d);or c += d; c then points (yes, Java does have pointers!) to the newly-created String object.
You could also use the mutable class StringBuffer:
c = new StringBuffer(c).append(d).toString();For a simple concatenation, this offers no readability or efficiency benefits over +, but it's useful in other circumstances. -
How many String are created?
public String makinStrings() {
String s = �Fred�;
s = s + �47�;
s = s.substring(2, 5);
s = s.toUpperCase();
return s.toString();
}How many objects are created when this method is called?
My answer is 5
1. "Fred"
2. "47"
3. "Fred47"
4. "ed4"
5. "ED4"
But my friend is telling it is 3.
1. "Fred"
2. "47"
3. "Fred47"
I know that any method called on String object creates a brand new String. Please help me with the solution whether it is 3 or 5.hi,
First of all i want to thanks for all of your replies.
My friend is saying that when we say "How many objects when method is invoked" it means at runtime. String literals are not created at run time.
String s = �Fred�; // No object is creatd here
s = s + �47�; // One object created "s"
s = s.substring(2, 5); //Another object "s"
s = s.toUpperCase(); //Another object "s"
return s.toString();
Hence total 3 objects.
Now the i have got a doubt. Are String literals created at Complie time itself. Or since String s = "Fred" is a compile time constant field. And String literal "47" is also a compile time constant field.
Suppose if the code is like this
String s = new String("Fred")
String s1 = s; ---------------- Then is this String object created at Run time.
String s2 = "47" ----------- This object is created at Complie time.
Please clarify my doubt.
Maybe you are looking for
-
Need sample code using windows BitBlt() function to display image in CVI
Hello all, I need a sample code which uses windows BitBlt() function to display image in CVI Thank you. Bob.
-
How to convert html file into excel file in java
Hi EveryBody, My problem is to read some coloumns of table from html page and to keep in excel file . My Id is [email protected] Bye .
-
Skipping print cartridge check
I'd like to be able to use my ALL IN ONE, printer...for scanning. I want to be able to skip the part on boot up , where my printer checks for ink cartridges. so i can use it for scanning photos. how is this accomplished? thanks for your time
-
JSFCRUD JPA app can't be deployed to another glassfish 2.1 server
OK, my colleague wrote a JSF Crud app based on this tutorial: http://www.netbeans.org/kb/docs/web/jsf-jpa-crud-wizard.html It works fine when I build and run it on my sandbox app server, but when I try to deploy it to our company test app server, the
-
System shutting down when using slide show mode in Microsoft power point
Microsoft Power Point shutting down while clicking slide show on MacBook Air, version mid 2012. Help solicited in resolving this!