How to trunck the string
hi
one string is there of length 45 character, i want to do display upto 35 character on the window how we can do this?
substr(your_string, 1, 35)
Similar Messages
-
How to capture the string values
Hi Gurus,
Could you plz suggest me how to capture the string value.
My requirement is.
I have a structure field called cnj_stat-sttxt_int and it is storing a value like "REL CDRT AVAC". AND the moddile value CDRT will change according to condtions. now i required to write a logic like if cnj_stat-sttxt_int field contain 'REL' and 'AVAC'. I HAVE TO THROW SOME ERROR.
SO please give some idea about on it...
Its urgent..
points will be rewarded...
Thanks in advance!!!!
Thanks & regards,
Kranthi.if cnj_stat-sttxt_int field contain 'REL' and 'AVAC'. I HAVE TO THROW SOME ERROR.
if cnj_stat-sttxt_int CS 'REL' and cnj_stat-sttxt_int CS 'AVAC'.
THROW SOME ERROR.
endif. -
How to split the string by datetime in sql
Hi,
How to split the string by datetime in sql, I've a table with comments column stores comments by datetime, while selecting I want to split and show as in rows by each jobref.
can anyone help me in this please.
Thanks,declare @callcentre table (comments varchar(max),lbiref varchar(200))
insert into @callcentre
select '(28/10/2014 14:56:14) xyz ..... call logged (28/10/2014 14:56:58) xyz ..... call updated (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
insert into @callcentre
select '(29/10/2014 14:56:14) xyz ..... call logged (29/10/2014 14:56:58) xyz ..... call updated (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
insert into @callcentre
select '(30/10/2014 14:56:14) xyz ..... call logged (30/10/2014 14:56:58) xyz ..... call updated
output:
1) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call logged ,'Vi2910201'
2) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910201'
3) 28/10/2014 14:57:41, (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910201'
4) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call logged ,'Vi2910202'
5) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910202'
6) 28/10/2014 14:57:41, (28/10/2014 14:57:41)xyz ..... call updated,'Vi2910202'
7) 28/10/2014 14:56:14, (28/10/2014 14:56:14) xyz ..... call logged ,'Vi2910203'
8) 28/10/2014 14:56:58 ,(28/10/2014 14:56:58) xyz ..... call updated ,'Vi2910203'
Thanks,
See this illustration
declare @callcentre table (comments varchar(max),lbiref varchar(200))
insert into @callcentre
select '(28/10/2014 14:56:14) xyz ..... call logged (28/10/2014 14:56:58) xyz ..... call updated (28/10/2014 14:57:41)xyz ..... call updated','Vi2910201'
insert into @callcentre
select '(29/10/2014 14:56:14) xyz ..... call logged (29/10/2014 14:56:58) xyz ..... call updated (29/10/2014 14:57:41)xyz ..... call updated','Vi2910202'
insert into @callcentre
select '(30/10/2014 14:56:14) xyz ..... call logged (30/10/2014 14:56:58) xyz ..... call updated','Vi2910203'
SELECT LEFT(p.u.value('.[1]','varchar(max)'),CHARINDEX(')',p.u.value('.[1]','varchar(max)'))-1) AS [Date],
'(' + p.u.value('.[1]','varchar(max)') AS comments,
lbiref
FROM
SELECT lbiref,CAST('<Root>' + STUFF(REPLACE(comments,'(','</Data><Data>'),1,7,'') + '</Data></Root>' AS XML) AS x
FROM @callcentre c
)t
CROSS APPLY x.nodes('/Root/Data')p(u)
and the output
Date comments lbiref
28/10/2014 14:56:14 (28/10/2014 14:56:14) xyz ..... call logged Vi2910201
28/10/2014 14:56:58 (28/10/2014 14:56:58) xyz ..... call updated Vi2910201
28/10/2014 14:57:41 (28/10/2014 14:57:41)xyz ..... call updated Vi2910201
29/10/2014 14:56:14 (29/10/2014 14:56:14) xyz ..... call logged Vi2910202
29/10/2014 14:56:58 (29/10/2014 14:56:58) xyz ..... call updated Vi2910202
29/10/2014 14:57:41 (29/10/2014 14:57:41)xyz ..... call updated Vi2910202
30/10/2014 14:56:14 (30/10/2014 14:56:14) xyz ..... call logged Vi2910203
30/10/2014 14:56:58 (30/10/2014 14:56:58) xyz ..... call updated Vi2910203
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
How To Split the String for "."
Hi Friends
I am Using Following Code to Split one String.
String str = "Jeetendra.choudhary";
String[] sp_str = str.split(".");
wdComponentApi.getMessageManager.reportSuccess(str[0]);
wdComponentApi.getMessageManager.reportSuccess(str[1]);
but its throwing null pointer exception.
when i am using following code its working fine.
String str = "Jeetendra/choudhary";
String[] sp_str = str.split("/");
wdComponentApi.getMessageManager.reportSuccess(str[0]);
wdComponentApi.getMessageManager.reportSuccess(str[1]);
what may be the issue and how to split the string with "." ?
Thanks & Regards
Jeetendra"." is a special character.
Use
str.split("\\.");
Regards
Benjamin
Edited by: Benjamin Hansen on Dec 29, 2009 7:52 AM -
How to Splilit The String Into Single Column using Comma As Delimiter ?
How to Splilit The String Into Single Column using Comma As Delimiter ?
using Functionrefer my thread ,code is also available see if that helps you
error while executing the sp ORA-21779: duration not active -
How to increase the string length of an uploaded file
Hi,
i use a abap webser where i've uploaded some JAR files into the mime repository.
Unfortunately the string length is limited by 40 characters and so longer file names are cut.
How can I increase the default string length? Does somebody know a workaround?
Thanks.
Edited by: Martin Gardyan on Oct 22, 2008 9:48 AMwhat i guess copying those jars should not create this problem.U just try in db using
"ALTER TABLE <table_name> MODIFY <column_name> VARCHAR2(<new, larger length>)"
may be it works.
Regards,
Anu -
How to Split the string using Substr and instr using loop condition
Hi every body,
I have below requirement.
I need to split the string and append with single quotes('') followed by , (comma) and reassign entire values into another variable. so that i can use it where clause of update statement
for example I am reciveing value as follows
ALN varchar2(2000):=(12ERE-3MT-4Y,4IT-5O-SD,OP-K5-456,P04-SFS9-098,90P-SSF-334,3434-KJ4-O28,AS3-SFS0-J33,989-3KL-3434);
Note: In the above variable i see 8 transactions, where as in real scenario i donot how many transaction i may recive.
after modification i need above transactions should in below format
ALTR Varchar2(2000):=('12ERE-3MT-4Y','4IT-5O-SD','OP-K5-456','P04-SFS9-098','90P-SSF-334','3434-KJ4-O28','AS3-SFS0-J33','989-3KL-3434');
kindly help how to use substr and instr in normal loop or for loop or while loop while modifying the above transactions.
Please help me to sort out this issue.
Many Thanks.
Edited by: user627525 on Dec 15, 2011 11:49 AMTry this - may not be the best way but...:
create or replace type myTableType as table of varchar2(255)
declare
v_array mytabletype;
v_new_str varchar2(4000);
function str2tbl
(p_str in varchar2,
p_delim in varchar2 default '.')
return myTableType
as
l_str long default p_str || p_delim;
l_n number;
l_data myTableType := myTabletype();
begin
loop
l_n := instr( l_str, p_delim );
exit when (nvl(l_n,0) = 0);
l_data.extend;
l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
l_str := substr( l_str, l_n+length(p_delim) );
end loop;
return l_data;
end;
begin
v_array := str2tbl ('12ERE-3MT-4Y,4IT-5O-SD,OP-K5-456,P04-SFS9-098,90P-SSF-334,3434-KJ4-O28,AS3-SFS0-J33,989-3KL-3434', ',');
FOR i IN 1 .. v_array.COUNT LOOP
v_new_str := v_new_str || ''''||v_array(i)||'''' || ',';
END LOOP;
dbms_output.put_line(RTRIM(v_new_str, ','));
end;
OUTPUT:
=======
'12ERE-3MT-4Y','4IT-5O-SD','OP-K5-456','P04-SFS9-098','90P-SSF-334','3434-KJ4-O28','AS3-SFS0-J33','989-3KL-3434'HTH
Edited by: user130038 on Dec 15, 2011 12:11 PM -
How to validate the string object for alphabet input
Hi,
I want to check for alphabet (a-z,A-Z), in String object. I need to check the object, whether its contain numerals or special character, in that case, I want to throw an error stating that "value is not valid". It should accept only the a-z or A-Z.
how to do this.
Thanks in advance
Karthi> I want to check for alphabet (a-z,A-Z), in String
object. I need to check the object, whether its
contain numerals or special character, in that case,
I want to throw an error stating that "value is not
valid". It should accept only the a-z or A-Z.
how to do this.
As Rene suggested, you can do this using the Pattern class:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
You can do it also by looping through your String and check with String's charAt(index) method (which returns a char) to see if every char from the String is >= A AND <= z.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
Good luck. -
Help on how to treat the \' string ?
Hi,
i have a string which i have to save it to a file. It happens that the string can contains \' (2 chars = \ and ' )
I save it to a file performing:
try {
FileOutputStream fos = new FileOutputStream(aFileName);
Writer out = new OutputStreamWriter(fos, "UTF8");
out.write(cadena);
out.close();
catch (IOException eIO){
eIO.printStackTrace();
And i read it from the file:
StringBuffer buffer = new StringBuffer();
try {
FileInputStream fis = new FileInputStream(aFileName);
InputStreamReader isr = new InputStreamReader(fis,"UTF8");
Reader in = new BufferedReader(isr);
int ch;
while ((ch = in.read()) > -1) {
buffer.append((char)ch);
in.close();
return buffer.toString();
} catch (IOException e) {
e.printStackTrace();
return null;
After reading the file the contents does not include the \' string just ' only. The \ is missing and obviously
it is not the same string previously saved.
How can i solve this problem? Early I suspected the problem was saving to the file with out.write(cadena); so i replace the code with another which saves char by char the string but with the same final result.
Many thanks in advance,
Marla.Escape characters. Okey.
This is the string R\'U*��� how can i do to insert a \ before the one in the string ?
That is my problem?
Thanks. -
How to analyze the String input??
The program should accept integers but not the sentences for example
the user enters "Hi how are you"
the program should say"Sorry, please enter the integers"
if the user enters "123454545"
the program should work normally
The main aim is to differentiate between sentences and integersYou can use Exception handling to do this
for example
String userInput;
int number;
try
number = Integer.parseInt(userInput);
catch(NumberFormatException nex)
System.err.println("please enter integer");
} -
How to split the string?
Hi Experts,
Can anyone explain me with code how to separate the single character from the given input string?
For Example: Input String str = 'RAGHU'
Output should be:
R
RA
RAGH
RAGHU
RAGH
RAG
RA
R
Can anyone help me with code for above required output?
Thanks in Advance,
Regards,
Raghu.HI,
sy-index will give u the iteration number.
first of all in this program u are counting the length of the string and it was in variable LEN.
we are always printing the string from 0 index(1st character) to POS number of characters.
length is 5 so LNG = 5 * 2 = 10 and LNG = 10 - 1 = 9.and first sy-index = 1.so,1 <= 5 so POS = 0 + 1 = 1. it is printing the first char
second sy-index = 2.so,2 <= 5 so POS = 1 + 1 = 2. it is printing the first two chars
third sy-index = 3.so,3 <= 5 so POS = 2 + 1 = 3. it is printing the first three chars
forth sy-index = 4.so,4 <= 5 so POS = 3 + 1 = 4. it is printing the first four chars
fifth sy-index = 5.so,5 <= 5 so POS = 4 + 1 = 5. it is printing the first five chars
sixth sy-index = 6.so,6 > 5 so POS = 5 - 1 = 4. it is printing the first four chars
seventh sy-index = 7.so,7 > 5 so POS = 4 - 1 = 3. it is printing the first three chars
eighth sy-index = 8.so,8 > 5 so POS = 3 - 1 = 2. it is printing the first two chars
ninth sy-index = 9.so,9 > 5 so POS = 2 - 1 = 1. it is printing the first char
rgds,
bharat. -
How to split the string from character position.
HI ALL,
I need to split the string like this.
example:
String = "HelloWorld"
mid("HelloWorld", 2, 5);
it should print "ello"
menas mid is functiuon it will split "HelloWorld" from 2nd character to 5th character and prints "ello".
This one how to do in labview.
Regards
PunithString Subset is the function you are looking for.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines -
How to save the string from JTextFied to database?
can i know how to save the data from JTextFied to databse. Is it using update?
The most straightforward way would be something like:
String myKey=myKeyField.getText();
String foo=fooField.getText();
String sql="update mytable set foo='"+foo+"' where mykey='"+myKey+"'";
connection.createStatement().executeUpdate(sql);
This example assumes that the input fields cannot possibly contain quotes or the string won't be built correctly. Which by the way brings up a question I'd be interested in hearing others answer: What do you do about this? Sometimes I use PreparedStatement which handles that problem, other times I write my own little function to escape the string properly.
You can also read the record into a ResultSet and use ResultSet.update(). I'm mostly using mySql and I found that in mySql ResultSet.update just creates a SQL update statement like I did above and executes it, so the only real advantage would be if you find the syntax more convenient. Perhaps other database drivers do something different that would give other pros and cons. -
How to convert the String "1+1==2" into the boolean true?
Hi folks!
I need your help...
In a Java program, I have a String such as
String str="1+1==2";
and I want to know if the content of this String is true or not.
How to get the answer in a boolean b?
I already know that
boolean b=Boolean.valueOf(str).booleanValue();
doesn't work (b contains false);
whereas when I try
boolean b=Boolean.valueOf("true").booleanValue();
it perfectly works (b is true).
Would you be so kind as to solve my problem?
Thanks ;)
Tropoufreferring to the original poster...
Hi folks!
I need your help...
In a Java program, I have a String such as
String str="1+1==2";
and I want to know if the content of this String is true or not.
How to get the answer in a boolean b?How can the content of a String ever be a boolean ? and we all know that one...
If he were to revise his orginal requirement things would not be so
difficult for him.
"1+1==2" and "2*12-2*10==2" have one thing in common. They both check if the
RHS is equal to 2 or not...and THAT is a boolean.
And if that is a String it takes no genius to figure out how to
get a number out of them.
What's the problem with getting his boolean result. -
How to prevent the String Tokenizer filter more than one character
I am wrinting a simple program to cut the long string into small piece of data with the delimiters "#####" by using StringTokenizer
For example:
String output ="Apple Company #####APPLECOMPANY48877 #####2005-01-01 #####TESTING1 ##### ##### ##### ##### #####MR.Apple Wong #####[email protected] #####0-852-34183741 #####0-852- #####XYZ #####Apple in the tree road #####ROOM 3T099, LEVEL 9, All WIN BLDC ##### ##### #####NT #####34KJFG45 |||||0.0000 |||||1 |||||3 |||||3";
StringTokenizer st = new StringTokenizer(output,"#####");
int i=0;
while(st.hasMoreTokens()){
System.out.println("The number is: " i" "+st.nextToken());
i++;
The result is
The number is: 0 Apple Company
The number is: 1 APPLECOMPANY48877
The number is: 2 2005-01-01
The number is: 3 TESTING1
The number is: 4
The number is: 5
The number is: 6
The number is: 7
The number is: 8 MR.Apple Wong
The number is: 9 [email protected]
The number is: 10 0-852-34183741
The number is: 11 0-852-
The number is: 12 XYZ
The number is: 13 Apple in the tree road
The number is: 14 ROOM 3T099, LEVEL 9, All WIN BLDC
The number is: 15
The number is: 16
The number is: 17 NT
The number is: 18 34KJFG45 |||||0.0000 |||||1 |||||3 |||||3----->
It is correct!!!!!!
But, if the one of the small string in the long string contain the character "#", I found the "#####" and "#" also trace as delimiters by StringTokenizers to filter the String such as following example:
I only add one more "#" in String "ROOM 3T099, LEVEL 9," from the above example:
String output ="Apple Company #####APPLECOMPANY48877 #####2005-01-01 #####TESTING1 ##### ##### ##### ##### #####MR.Apple Wong #####[email protected] #####0-852-34183741 #####0-852- #####XYZ #####Apple in the tree road #####ROOM #3T099, LEVEL 9, All WIN BLDC ##### ##### #####NT #####34KJFG45 |||||0.0000 |||||1 |||||3 |||||3";
StringTokenizer st = new StringTokenizer(output,"#####");
int i=0;
while(st.hasMoreTokens()){
System.out.println("The number is: " i" "+st.nextToken());
i++;
But the result is:
The number is: 0 Apple Company
The number is: 1 APPLECOMPANY48877
The number is: 2 2005-01-01
The number is: 3 TESTING1
The number is: 4
The number is: 5
The number is: 6
The number is: 7
The number is: 8 MR.Apple Wong
The number is: 9 [email protected]
The number is: 10 0-852-34183741
The number is: 11 0-852-
The number is: 12 XYZ
The number is: 13 Apple in the tree road
The number is: 14 ROOM
The number is: 15 3T099, LEVEL 9, All WIN BLDC
The number is: 16
The number is: 17
The number is: 18 NT
The number is: 19 34KJFG45 |||||0.0000 |||||1 |||||3 |||||3
I have found that the StringTokenizer trace "#####" and "#" to be delimiters to filter the String, I only want to filter the String by StringTokenizer with "#####" not include "#"
So What Can I Do? Is it
StringTokenizer st = new StringTokenizer(output,"#####");
not Correct?
It is thank a lot if anyone can help me! thx!!If I must use StringTokenizer, How can I do it? You completely misunderstand how StringTokenizer works.
StringTokenizer st = new StringTokenizer(output,"#####");Each character is used as a delimiter. So you have specified the same delimiter 5 times.
As suggested above you would need to rewrite the entire code, to treat the String as a delimiter, intead of each character as a delimiter.
Maybe you are looking for
-
Hellow everyone, Wondering if some genius out there can help me come up with a solution, or whether this is just too pie in the sky!! So, I'm exhibiting at a huge conference at the end of the month and want the following set up: MacBook Pro Retina sh
-
A fresh Arch installation - from VirtualBox?
Hey, My dad's laptop is about 2-year old LG. It runs Vista, and it runs like shit.. I wanna install Arch on the laptop for him, for a much better user experience. Since I am only gonna see him on the weekend for only several hours, I wanna make a fre
-
30EA4 - Command Line Exporting Fails (ututil -exp)
I'm using SQL Developer Version 3.0.03 Build MAIN-03.97 and i'm attempting to export unit tests from SQL Developer to my local file system (windows XP Professional 2002 service pack 3). I've written a .bat file to accomplish this (scary i know, much
-
Non-Global Zones and startup scripts
Created a non-global zone on a Solaris 10 box. Boots up ok and I can login with zlogin. It doesn't seem to run any of the scripts in /etc/rc2.d or /etc/rc3.d I know Solaris 10 uses "Service Management Facility" for most services now, but could still
-
Hello, My client requires customer trail balance like opening balance, sales, receipts and closing balanes format. please suggest me the table to get the exact information as per my client requirement. now i am refereing the tables namely BSAD, BSI