About string comparision
Hi all,
Thanks in Advance.
I here i have my data in one internal table called g_t_comp. so here i need to attach a screen on which i need to add text boxes.
1) source string
2) destination string
what i need to do is from my data in the internal table. i need to replace the source string with the destination string into my internal table.
FOR EXAMPLE....
i have data in my ITAB like.
govardhan
rajesh
govarrao
rajan
rajasekhar
so
if i give source string as 1)gov
and destination as 2)hello
my ITAB shoul be filled with
helloardhan
rajesh
helloarrao
rajan
this is the situation......
please help me out......
HI,
see this code.
data:begin of itab occurs 0,
field(30),
end of itab.
PARAMETERS:source(10),dest(10).
itab = 'GOVARDHAN'.
append itab.
itab = 'RAJESH'.
append itab.
itab = 'GOVARRAO'.
append itab.
itab = 'RAJAN'.
append itab.
itab = 'RAJASEKHAR'.
append itab.
loop at itab.
write:/ itab.
endloop.
loop at itab.
replace source in itab-field with dest IGNORING CASE.
modify itab.
endloop.
SKIP.
loop at itab.
write:/ itab.
endloop.
rgds,
bharat.
Similar Messages
-
String Comparision in XSLT Mapping
HI All,
Can any one suggest me to compare the two strings in XSLT mapping.Please let me know is there any string comparision function in xslt?
Thanks
PullaraoHi Pullaro!
It depends what you want to do with the comparison
E.g. you can use a simple xsl-if Tag to compare a value
and then take action.
If your XML looks like this:
<root>
<child><b>value1</b></child>
<child>value2</child>
</root>
you can make an expression like this and take action on it:
<xsl:if test="<b>//child = 'value1'</b>">
<i>.. Do what you want to do here..</i>
</xsl:if>
With kind regards
Sebastian -
String comparision using tokens (challenging question)
Hello, everyone.
i am having a problem with string comparision.
for example, the input file is:
each line is an input line (string)
1)a x
2)b c x
3)a b x
4)a b y
5)a b c x
in above example a,b,c,x,y are strings(tokens)
in above example
line 1 ,3,5 has token "a" common and class "x" is also common
if this condition is satisfied,
line 1 should be send to general file (output file 1) and
line 3 and 5 should be send to specific file (output file 2)
rest of the lines should be send to third file.
remember in line 4, token "a" is same when compared with line1
but it has a different class (y) .this line will go the third file. this is where line 3 and 4 differs.
i have read this file into an string array.
how to proceed further.
i am new to java programming.
cheers in advance.Well, first off, I'm assuming that you keep the first string as the first token and the class name as your last token, then you tokenize everything using StringTokenizer. the code would look something like this. You could also use countTokens() to know how many tokens are in a tokenizer.
My approach would be the following:
1. Create an array of Strings to hold each line (you already did that)
2. Go through the array, one line at a time, tokenize the String, figure out the first and last tokens
3. Write it to the corresponding file.
The code would be something as follows
String ClassToLookFor, StringToLookFor; // holds which class and first string to look for
String firstToken, lastToken; //used in checking each element with first one
boolean firstFound = false; // First instance of Class name and first thread combo found
public static void main(String args[])
StringTokenizer tokenizer;
int tokenizerLength;
// read in array of Strings, store it into lines or something
int endOfRun = lines.length;
for (int i = 0; i<endOfRun; i++)
tokenizer = new StringTokenizer(lines);
tokenizerLength = tokenizer.countTokens();
if(!firstFound)
// store the information (StringToLookFor and ClassToLookFor) and write the line to the corresponding file
else
firstToken = tokenizer.next();
int runThru;
while(runThru < (tokenizerLength - 2)) {tokenizer.next();} // going to the last token
lastToken = tokenizer.next();
if (firstToken.equals(StringToLookFor) && lastToken.equals(ClassToLookFor))
{write lines[i] to second file}
else
{write lines[i] to third file}
hope that helps ... -
Doubt about string.intern()
Hello
I have a doubt about string.intern() method.
The document says
When the intern method is invoked, if the pool already contains a string equal to this String object as determined by the String.equals(Object) method, then the string from the pool is returned.
So what is the point of using this intern() method with == or != operators if it aleady calling to equals method internally?
eg:
if (studentObject.getName().intern() == "Student Name") {}cannot be better than
if (studentObject.getName().equals("Student Name")) {}Can someone please explain?Easy dude.
>
Why do you need to optimize it?>
Because i want to.
I would avoid the whole stupid 100 line if-else by doing a Map of type->object and then just clone() the object. But maybe that might not be suitable or "fast enough" for you.I cannot do above because object have it's own behaviors varying at run time
eg - class One has setOne method and class hundred has setHundred method
. Even if i use a map and clone it again i have to use above comparison for setting those behaviours.
Explain your actual problem you're trying to solve, with actual cases. What are these "one" and "Hundred" classes really? Or is your project so top secret that you can't tell us?It is not secret but big. And I need to make the question understandable. If I post the whole code no one will looking at it.
Now you asking so please have a look.
still I have cleaned up many.
My initial question was how to bit speed up the comparison? And can't i use intern() Because here if I got plenty of rectangles(it is the last) performace sucks.
for (CObject aObject : objList) {
if (aObject.getType().equals(SConstant.TEMPLATE)) { /* process Template */
Template tObj = (Template) aObject;
org.apache.velocity.Template template = VelocityTemplateManager.getInstance().getObjectTemplateFromFile(retemplateProperties.getProperty("PAGE"));
VelocityContext context = new VelocityContext();
StringWriter writer = new StringWriter();
context.put(retemplateProperties.getProperty("BAND_OBJECT"), dtmBand);
tObj.setTags(writer.toString());
} else if (aObject.getType().equals(SConstant.LINE)
&& !isInBandandBandAutoAdjust(aObject)) {
Line object = (Line) aObject;
org.apache.velocity.Template template = VelocityTemplateManager.getInstance().getObjectTemplateFromFile(retemplateProperties.getProperty("LINE"));
VelocityContext context = new VelocityContext();
StringWriter writer = new StringWriter();
updateContextWithCheckShifting(context, object);
context.put(retemplateProperties.getProperty("LINE_OBJECT"), object);
template.merge(context, writer);
object.setTags(writer.toString());
} else if (aObject.getType().equals(SConstant.IMAGE) /* process Image */
&& !isInBandandBandAutoAdjust(aObject)) {
REImage imageObject = (REImage) aObject;
org.apache.velocity.Template template = VelocityTemplateManager.getInstance().getObjectTemplateFromFile(retemplateProperties.getProperty("IMAGE"));
VelocityContext context = new VelocityContext();
updateContextWithCheckShifting(context, imageObject);
context.put(retemplateProperties.getProperty("IMAGE_OBJECT"), imageObject);
mageObject.setTags(writer.toString());
else if (aObject.getType().equals(SConstant.RECTANGLE) /* process Rectangle */
&& !isInBandandBandAutoAdjust(aObject)) {
Rectangle rectangleObject = (Rectangle) aObject;
org.apache.velocity.Template template = VelocityTemplateManager.getInstance().getObjectTemplateFromFile(retemplateProperties.getProperty("RECTANGLE"));
VelocityContext context = new VelocityContext();
StringWriter writer = new StringWriter();
updateContextWithCheckShifting(context, rectangleObject);
context.put(retemplateProperties.getProperty("RECTANGLE_OBJECT"), rectangleObject);
template.merge(context, writer);
rectangleObject.setTags(writer.toString());
}And masijade
Thank you very much for the better explanation. -
Strings comparision and get unique string in pure sql,
Dear all,
Here is two strings
S1='A,B,C,D,F';
s2='C,F,H,B,A,K';
output should be like unique string values ..
S3= A,B,C,D,F,H,K;
How to get this in pure sql..
thanks in advance,
RootsHi,
In a relational database, each column of each row should store one value, not a repleating group of values, such as a delimited list. This is so basic to database design that it is called "First Normal Form". You don't have to follow rules like this, but, if you don't, your code will be complicated, inefficient, and error-prone. It sould be best to re-design your application so that each value was on a separate row.
If you can't do that, then you can start by splitting your delimitd lists into separate rows. Then you can easily fond the distinct values, and use any String Aggregation technique to combine the results into one output row.
Here's one way to do all that:
WITH got_params AS
SELECT 'A,B,C,D,F' AS str, 1 AS str_id FROM dual UNION ALL
SELECT 'C,F,H,B,A,K', 2 FROM dual
, got_part_cnt AS
SELECT str
, 1 + LENGTH (str)
- LENGTH (REPLACE (str, ',')) AS part_cnt
FROM got_params
, cntr AS
SELECT LEVEL AS n
FROM (
SELECT MAX (part_cnt) AS max_part_cnt
FROM got_part_cnt
CONNECT BY LEVEL <= max_part_cnt
, got_substr AS
SELECT DISTINCT
REGEXP_SUBSTR ( p.str
, '[^,]+'
, 1
, c.n
) AS sub_str
FROM got_part_cnt p
JOIN cntr c ON c.n <= p.part_cnt
, got_r_num AS
SELECT sub_str
, ROW_NUMBER () OVER (ORDER BY sub_str) AS r_num
, ROWNUM AS r
FROM got_substr
SELECT MIN ( SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
, 2
) AS unique_sub_strs
FROM got_r_num
WHERE CONNECT_BY_ISLEAF = 1
-- START WITH r_num = 1
CONNECT BY r_num = 1 + PRIOR r_num
;This works in Oracle 10.2.0.2.0 Express Edition, which is the only database I can use right now. For the main query, you should be able to say:
SELECT SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
, 2
) AS unique_sub_strs
FROM got_r_num
WHERE CONNECT_BY_ISLEAF = 1
START WITH r_num = 1
CONNECT BY r_num = 1 + PRIOR r_num
;but, when I try that on my database, I only get 'A,B' as the output. CONNECT BY is very buggy in Oracle 10.2; if you have Oracle 10.1, the simpler form might work.
The query above can be shortened some, but I wrote it this way to make it easier to understand.
You can, for example, combine the sub-queries got_sub_str and got_r_num. If you do, use DENSE_RANK instead of ROW_NUMBER.
This does not assume that the sub-qtrings are all 1-character long. If they are, then the query can be simplified.
For more about string aggregation, see
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php -
Let's look at a couple of examples of how a String might be created, and let's further assume that no other String objects exist in the "String constant pool"l:
String s = "abc"; // creates one String object and one
// reference variable In this simple case, "abc" will go in the pool and s will refer to it.
String s = new String("abc"); // creates two objects,
// and one reference variable In this case, because we used the new keyword, Java will create a new String object
in normal (nonpool) memory, and s will refer to it. In addition, the literal "abc" will
be placed in the pool.
My question is this:
Then why did the sun developers created the 'public String(String str)' constructor even it uses an additional memory?Caarmel wrote:
Let's look at a couple of examples of how a String might be created, and let's further assume that no other String objects exist in the "String constant pool"l:
String s = "abc"; // creates one String object and one
// reference variable In this simple case, "abc" will go in the pool and s will refer to it.Nope. Executing that line only assigns a reference to an already existing String into the variable. The constant was put into the pool when the class was loaded. So your initial assumption of no Strings in the constant pool is invalid.
String s = new String("abc"); // creates two objects,
// and one reference variable Nope. As above, it creates one object. The other already existed.
Then why did the sun developers created the 'public String(String str)' constructor even it uses an additional memory?First, note that your question really has nothing at all to do with the constant pool. Your question is really "Why does the String(String) constructor exist, given that String is immutable, and given that we can just do s2 = s1?" That question applies even in complete absence of the constant pool.
I wasn't there when they made the decision, so I can't tell you what their thinking was. I can tell you one case where it's useful, however.
String s1 = some_very_long_string;
String s2 = s1.substring(x, x + a_small_number);
String s3 = new String(s1.substring(x, x + a_small_number);Both the s2 and s3 lines create new String objects. However, in the case of s2, the new object shares the same char array as the original, whereas in the s3 case, a new backing array of just the right size is created. If s1 is very large, AND if the substring we're extracting is very small, AND if the substring needs to live on significantly longer than the original, then without the explicit new String(), even though we only need a few characters and could get away with a very small char array, we end up stuck with a large char array that can't be GCed even when the original String is.
So in this rather unlikely scenario, we can avoid wasting a bunch of memory that can't be GCed when we only need a small fraction of it.
Or maybe the constructor came about in early versions, before other aspects of the language making it mostly useless were solidified, and then it was kept for backward compatibility.
Or maybe they didn't really have a good reason and just figured it made sense to have a copy constructor.
Or maybe the reasons that make it mostly redundant are implementation details, and they wanted to provide a copy constructor so that as Java evolved, if the implementation changed, the functionality would still be there.
Or maybe none of the above. -
Using StartsWith for String Comparision in Business rules
hi,
I need to compare whether a particular string starts with some pre-defined prefixes. These are bound to change from time to time and hence we wanted to use the business rule engine for this. We declared prefixes using "list of values" vocab and
defined the set. Now, I hoped to use the String.StartsWith() method but couldn't understand if it can be used.
As of now, we are creating a method and that will be called with 2 parameters. One the string and other is one of the list of values which we want the string to start with. Is there any better way to do this?
Praveen Behara
MCST : BizTalk Server 2006 R2, 2010Hi Murugesan,
I need to match a particular series of numbers... say 12xxx,345xxx,567xxx. I am creating a
Series as a list and the valid values would be 12, 345, 567. I intend to keep them as prefixes i.e. they are not regular expressions. So, they won't be 12.*, 345.*, 567.*. The idea is to keep the vocab close to requirement
and away from implementation (typically, for a business user). Now, if I want this setup, how will the implementation with
Match look like?
Technically, your above solution would work.. but my way of implementation / thought process is for a different purpose.
Praveen Behara
MCST : BizTalk Server 2006 R2, 2010 -
Program for string comparision in ABAP
Hi,
I require a program in abap for string comparisionComparing Strings
Similarly to the special statements for processing strings, there are special comparisons that you can apply to strings with types C, D, N, and T. You can use the following operators:
<operator>
Meaning
CO
Contains Only
CN
Contains Not only
CA
Contains Any
NA
contains Not Any
CS
Contains String
NS
contains No String
CP
Contains Pattern
NP
contains No Pattern
There are no conversions with these comparisons. Instead, the system compares the characters of the string. The operators have the following functions:
CO (Contains Only)
The logical expression
<f1> CO <f2>
is true if <f1> contains only characters from <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that does not occur in <f2> .
CN (Contains Not only)
The logical expression
<f1> CN <f2>
is true if <f1> does also contains characters other than those in <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that does not also occur in <f2>. If it is false, SY-FDPOS contains the length of <f1>.
CA (Contains Any)
The logical expression
<f1> CA <f2>
is true if <f1> contains at least one character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that also occurs in <f2> . If it is false, SY-FDPOS contains the length of <f1>.
NA (contains Not Any)
The logical expression
<f1> NA <f2>
is true if <f1> does not contain any character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that occurs in <f2> .
CS (Contains String)
The logical expression
<f1> CS <f2>
is true if <f1> contains the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
NS (contains No String)
The logical expression
<f1> NS <f2>
is true if <f1> does not contain the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
CP (Contains Pattern)
The logical expression
<f1> CP <f2>
is true if <f1> contains the pattern <f2>. If <f2> is of type C, you can use the following wildcards in <f2>:
for any character string *
for any single character +
Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
If you want to perform a comparison on a particular character in <f2>, place the escape character # in front of it. You can use the escape character # to specify
characters in upper and lower case
the wildcard character "" (enter # )
the wildcard character "" (enter # )
the escape symbol itself (enter ## )
blanks at the end of a string (enter #___ )
NP (contains No Pattern)
The logical expression
<f1> NP <f2>
is true if <f1> does not contain the pattern <f2>. In <f2>, you can use the same wildcards and escape character as for the operator CP.
Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
DATA: F1(5) TYPE C VALUE <f1>,
F2(5) TYPE C VALUE <f2>.
IF F1 <operator> F2.
WRITE: / 'Comparison true, SY-FDPOS=', SY-FDPOS.
ELSE.
WRITE: / 'Comparison false, SY-FDPOS=', SY-FDPOS.
ENDIF.
The following table shows the results of executing this program, depending on which operators and values of F1 and F2.
<f1>
<operator>
<f2>
Result
SY-FDPOS
'BD '
CO
'ABCD '
true
5
'BD '
CO
'ABCDE'
false
2
'ABC12'
CN
'ABCD '
true
3
'ABABC'
CN
'ABCD '
false
5
'ABcde'
CA
'Bd '
true
1
'ABcde'
CA
'bD '
false
5
'ABAB '
NA
'AB '
false
0
'ababa'
NA
'AB '
true
5
'ABcde'
CS
'bC '
true
1
'ABcde'
CS
'ce '
false
5
'ABcde'
NS
'bC '
false
1
'ABcde'
NS
'ce '
true
5
'ABcde'
CP
'b'
true
1
'ABcde'
CP
'#b'
false
5
'ABcde'
NP
'b'
false
1
'ABcde'
NP
'#b'
true
5
goto sap library if intsalled in ur system and check the above one.... -
HI All,
I have a requirement to compare strings.
Like this:
parameters: belnr like bkpf-belnr.
Select * from swwwihead into table t_swwwihead
where ( WI_TYPE EQ 'F' or
WI_TYPE EQ 'W' ) AND
WI_CD GE l_budat.
X2 = belnr.
Loop at t_swwwihead.
X1 = t_swwwihead-TEXT.
IF X1 byte-cs X2.
write :/ t_swwwihead-TEXT.
Endif.
Endloop.
I tried to use 'CP' but i could not compare using fields. I mean i have to compare the values in the fields.
I tried byte-cs but that i can only compare in terms of bytes and my text doesnot have zeros at the begining. and xstring pads zeros to the string to make it a full byte it seems.
how can i compare this ?Hi,
Try to concatenate * in the beginning and in the end of the to be compared string before using CP..
Example
data: X1 type string.
X1 = 'Approve Parked document 100638133 initiated by USER123'.
data: X2 type string.
X2 = '100638133'.
CONCATENATE '' X2 '' INTO X2.
IF X1 CP X2.
write: / 'True'.
ELSE.
write: / 'False'.
ENDIF.
Thanks,
Naren
Message was edited by: Narendran Muthukumaran -
String Comparision in pl/sql
Hi,
i executed the below code and found that output should be 5 but it shows 7(always else part). it is not comparing string in case. can anybody state the reason.
declare
check_in_date date;
var_day varchar2(11);
rate_id number;
begin
check_in_date := '23-mar-2013';
select to_char(check_in_date, 'DAY') into var_day from dual;
dbms_output.put_line(var_day);
select case
when VAR_DAY = 'SATURDAY' THEN
5
WHEN VAR_DAY = 'SUNDAY' THEN
6
ELSE
7
END
into rate_id
from dual;
DBMS_OUTPUT.PUT_LINE(rate_id);
end;
Thanks.
VipinChange this
select to_char(check_in_date, 'DAY') into var_day from dual;as
select to_char(check_in_date, 'fmDAY') into var_day from dual;You need to use the "fm" (format model) specificaton otherwise the value will be right padded with space for the max size.
SQL> select '"' || to_char(sysdate+level, 'DAY') || '"' without_fm,
2 '"' || to_char(sysdate+level, 'fmDAY') || '"' with_fm
3 from dual
4 connect by level <= 7;
WITHOUT_FM WITH_FM
"FRIDAY " "FRIDAY"
"SATURDAY " "SATURDAY"
"SUNDAY " "SUNDAY"
"MONDAY " "MONDAY"
"TUESDAY " "TUESDAY"
"WEDNESDAY" "WEDNESDAY"
"THURSDAY " "THURSDAY"
7 rows selected. -
String comparision in reverse order
Hi all
i want a logic in plsql which compares string and substring
and soon from last digit in the number to first digit.
If condition mets gives out put
for example my input is
INPUT = 1234567890
TO COMPARE WITH a column has list of values like
1234560000
1234567000
1234567800....soon
so now the condition is
the input 1234567890 should match with the column value
1234567890
if value is not there it should match with
123456789
if not 12345678 soon till 1 in reverse comparisionIn SQL:
SQL> ed
Wrote file afiedt.buf
1 with t as (select '123456' col1 FROM dual)
2 SELECT col1,inp,lvl FROM
3 (SELECT SUBSTR(:my_num,1,level-1) inp,level - 1 lvl FROM
4 dual CONNECT BY level <= LENGTH(:my_num)) x,t
5* WHERE t.col1 = x.inp
SQL> /
COL1 INP LVL
123456 123456 6
SQL> ed
Wrote file afiedt.buf
1 with t as (select '1234567890' col1 FROM dual)
2 SELECT col1,inp,lvl FROM
3 (SELECT SUBSTR(:my_num,1,level-1) inp,level - 1 lvl FROM
4 dual CONNECT BY level <= LENGTH(:my_num) + 1) x,t
5* WHERE t.col1 = x.inp
SQL> /
COL1 INP LVL
1234567890 1234567890 10
-- in plsql
SQL> ed
Wrote file afiedt.buf
1 declare
2 my_val VARCHAR2(100) := NULL;
3 BEGIN
4 FOR I IN REVERSE 1..LENGTH(:my_num) LOOP
5 DBMS_OUTPUt.PUT_LINE('substring value:'||SUBSTR(:my_num,1,I));
6 BEGIN
7 SELECT '123456' INTO my_Val FROM dual WHERE '123456' = SUBSTR(:my_num,1,I);
8 EXCEPTION
9 WHEN NO_DATA_FOUND THEN
10 NULL;
11 END;
12 EXIT WHEN my_Val IS NOT NULL;
13 END LOOP;
14 DBMS_OUTPUT.PUT_LINE('matched value:'||my_val);
15* END;
SQL> /
substring value:1234567890
substring value:123456789
substring value:12345678
substring value:1234567
substring value:123456
matched value:123456
PL/SQL procedure successfully completed.
SQL> print :my_num
MY_NUM
1234567890 -
String a = "alpha";
String b = "xxxxalphayyyyyyy";
is there any method that returns true, if I had to check if String b contains a, otherwise false.....What version of Java are you using?
edit: never mind, you got spoonfed in the meantime, I see
Edited by: georgemc on Jul 22, 2008 7:12 PM -
Hi
Maximum number of characters that a string data type accepts in Java.
Thanks..The next may give a rough test.
public static void main(String[] args) throws Exception{
int factor= Integer.parseInt(args[0]);
char[] data = new char[Integer.MAX_VALUE/factor];// note: integer division
for(int k=0;k<data.length;k++) data[k]=(char)0x30;
String s=new String(data);
System.out.println(Integer.toString(s.length()));
} -
Hi Experts,
in my scenario there is a value that is comming from source need to be substring depending on some condition eg: Electrical:Cable as per the req we need only Cable this could be achived by using the substring function but if there is a null value comming from the source then it should write a null at the target
but when we are using substring function to get the value eg Cable it works fine but when there is a null value it throws a error on substring function
can anyone provide the inputs as the req is critical
Thanks
SampathHi venkat,
Use the Below UDF(SubString). It works fine, even when the input given is null.
SourceField->UDF->TargetField
public static String SubString(String sInput, int iStartIndex, int iNoOfChars) {
int iLen = 0;
int iEndIndex = 0;
try {
iLen = sInput.length();
iEndIndex = iStartIndex + iNoOfChars;
if (iStartIndex > iLen)
return "";
if (iEndIndex > iLen)
iEndIndex = iLen;
} catch (Exception e) {
return "";
return sInput.substring(iStartIndex, iEndIndex);
Regards,
Swetha. -
Good morning folks,
I want to take basically month and year of sysdate and compare with month and year of field in database and compare them.
But it is not working.
select case when
(concat(TO_CHAR(sysdate, 'MM'), to_char(sysdate,'YYYY')) >
concat(to_char(max(as_of_date),'MM'), to_char(max(as_of_date),'YYYY'))) then 'Not Archived'
else 'Archived' end from historical_advs_curr_eom
can someone suggest me any other better way of doing?
May be I shouldn't convert sysdate to string?
Thanks much folks.
regards
nathanuser12131044 wrote:
May be I shouldn't convert sysdate to string?Exactly. A string is not a date. Nor a number. So comparisons using strings do not behave like comparisons using dates and numbers.
Always try and use data in its native format - do not convert it into another data type as that data type will often behave differently and not provide the expected answer.
It is also not a good idea from a performance perspective. If you have an index or a number columns, the index value is numeric. If you now do a conversion of the column to a string and compare using that, it renders that index that contains numbers and not strings, useless.
Conversion also is an overhead - especially when it needs to be applied to every single row that the SELECT statement hints.
So rather stick to the native data type of that column. It is a lot more sensible.
Maybe you are looking for
-
Itunes store not working under itunes 10.6
Is something up with the store this evening? When I go into iTunes on my win 7 laptop the store is sometimes taking a long time to show up. Just says in big letters 'iTunes store'. Eventually it loads in after a couple mins. Seems intermittent issue.
-
hi can anybody tell me how the concept of EDI works? 1)do configurations like setting logical system, partner profiles etc have to be made? 2)is there standard idocs like MATMAS or CREMAS that are sent via EDI? 3)is there a step-by-step procedure fo
-
With the new 'PODCAST' app how do I put podcasts in playlist
With the new 'PODCAST' app how do I put podcasts in playlist so they play consecutively?
-
Does anyone know how to create a binary file in Java. in C i can do an fopen("filename" , "rb") i cannot find a equivalent java binary file stream. Thanks
-
MS Document Explorer - integration with Oracle documentation
I can not properly install oracle provided documentation concerning ODP.NET and ODT (developers tools for .net) It should automaticaly integrate with documentation viewer used with MS Visual Studio. This is the same viewer that MSDN Library collectio