Using OR operator with string
How we can use OR operator with string in java??
Gaurav1 wrote:
its logical OR operator;how can we use it with matcher classLike its been said already. The "logical OR" is used the same everywhere.
Why don't you post the code you're having problems with. (Only the relevant areas, please. And use code tags.)
Similar Messages
-
Why not use "new" operator with strings
why we not use new when declaring a String .because in java String are treated as objects. we use new operator for creating an object in java .
and same problem wiht array when we declare array as well as initialize .here we are alse not using new for array
whyStrings aren't just treated as objects, Strings are Objects.
As for why not using new for Strings, you can, if you want.:
String str = "this is a string";
and
String str = new String("this is a string");
do the same thing (nitty-gritty low level details about literals aside). Use whatever you like, but isn't it simpler not to type new String(...) since you still need to type the actual string?
As for arrays, you can use new:
int[] ints = new int[10];
or
int[] ints = { 0, 1, 2, 3, ..., 9 };
But the difference here is you are creating an empty array in the first one, the second creates and fills the array with the specified values. But which to you often depends on what you are doing. -
Error while using between operator with sql stmts in obiee 11g analytics
Hi All,
when I try to use between operator with two select queries in OBIEE 11g analytics, I'm getting the below error:
Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
Location: saw.views.evc.activate, saw.httpserver.processrequest, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.handleConnection, saw.rpc.server.dispatch, saw.threadpool.socketrpcserver, saw.threads
Odbc driver returned an error (SQLExecDirectW).
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 27002] Near <select>: Syntax error [nQSError: 26012] . (HY000)
can anyone help me out in resolving this issue.Hi All,
Thank u all for ur replies, but I dint the exact solution for what I'm searching for.
If I use the condition as
"WHERE "Workforce Budget"."Used Budget Amount" BETWEEN MAX("Workforce Budget"."Total Eligible Salaries") AND MAX("Workforce Budget"."Published Worksheet Budget Amount"",
all the data will be grouped with the two columns which I'm considering in the condition.
my actual requirement with this query is to get the required date from a table to generate the report either as daily or weekly or monthly report. If I use repository variables, variables are not getting refreshed until I regenerate the server(which I should not do in my project). Hence I have created a table to hold weekly start and end dates and monthly start and end dates to pass the value to the actual report using between operator.
please could anyone help me on this, my release date is fast approaching. -
Using in operator with bindveriable
Dear All,
i facing proplem when i try to make SQL query using "in" operator but i send value as bind virable
example
Select emp.emp_id
from emp
where emp.emp_id in (:pEmpId)
but when i execute it and enter value for the bind i didn't get the result .
any idea how to solve this problem
Best RegardsSomething like this will work (10g onwards)
SQL> ed
Wrote file afiedt.buf
1 with req as (select '&required_empnos' as empno from dual)
2 --
3 select *
4 from emp
5 where empno in
6 (select regexp_substr(empno, '[^,]+', 1, rownum)
7 from req
8* connect by rownum <= length(regexp_replace(empno, '[^,]'))+1)
SQL> /
Enter value for required_empnos: 7839,7499,7934
old 1: with req as (select '&required_empnos' as empno from dual)
new 1: with req as (select '7839,7499,7934' as empno from dual)
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 KING PRESIDENT 17-NOV-81 5000 10
7934 MILLER CLERK 7782 23-JAN-82 1300 10
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
SQL> -
How to use LIKE operator with PreparedStatement
Hi, I need to execute a query with the LIKE operator, but using a PreparedStatement. Can I do this, and if so what must my SQL look like with the wildcard characters '%' or '_'?
normal PS example: conn.prepareStatement("select * from mytable where name like ?");
If I try: conn.prepareStatement("select * from mytable where name like ?%");
I get: ORA-00911: invalid character
If I try: conn.prepareStatement("select * from mytable where name like '?%'");
I get: ORA-01006: bind variable does not exist
I must use a PreparedStatement, as my variable may contain illegal characters (like '), and using PreparedStatement.setString(1, var) will automatically escape it for me.
I could also use a normal Statement, but I need to escape my var ... is there a utility that will safely escape a String for an Oracle VARCHAR2??
Thanks in advance,
Stu MillerHmm, it seems you are right...
when my variable contains a '%' symbol, the PreparedStatement will NOT escape it, and thus it is treated like a wildcard. Therefore, I can just do
pstmt.setString(1, var+"%");
But, that may return more results than I'm asking for, as when 'var' contains a '%' symbol it is taken as a wildcard too.
I need each character in my variable to be taken literally, and only add a wildcard at the end. Basically, I need a STARTSWITH operator ;-)
It seems to me that escaping the sensitive characters in a String (which will differ depending on which operator is used), should be possible. I could write this, but I was hoping Oracle had already done it for me in some utility class. -
Using or operator with char in a switch
Can someone please provide the syntax for an or statement that would cover this? Thanks.
substring = inputString.charAt(i);
switch(substring){
case 'a':
vowelsL++;
vowelsT++;
break;
case 'e':
vowelsL++;
vowelsT++;
break;
case 'i':
vowelsL++;
vowelsT++;
break;
case 'o':
vowelsL++;
vowelsT++;
break;
case 'u':
vowelsL++;
vowelsT++;
break;I tried this but it didnt work
case 'a'|'e'|'i'|'o'|'u':Can the or operator work this way with chars?
Thankswarnerja wrote:
uj_ wrote:
warnerja wrote:
I don't recall that syntax.How absolutely astonishing!So you're saying you think you can do this in a switch statement block?
case 'a', 'e', 'i', 'o', 'u' : // code here for all 5 cases
How absolutely astonishing!I find your desparate need to cherish this moment astonishing. You even dug out and reposted an erased post in order to triumph. Well done sheriff Warnerja. Now go back to Schmuckville were you belong.
Well, to be frank I sometimes get simple syntax wrong. It's because I've used and use many different languages so I sometimes mix them up. That's another thing I find astonishing. You cannot recall a single language with the syntax I suggested? Why don't you pull your head out of your azz on occasion. It may broaden your outlook. -
How to use filter operator with ROWNUM
I would like to add filter operator in my mapping with ROWNUM to reduce the ETL loading time during testing to ensure mapping is working, but I don't know how, please help provide me some guideline. Thank you.
what is your owb version?
Starting with Oracle Warehouse Builder 10.2.0.3, you can use the pseudocolumns ROWID and ROWNUM in mappings. The ROWNUM pseudocolumn returns a number indicating the order in which a row was selected from a table. The ROWID pseudocolumn returns the rowid (binary address) of a row in a database table.
You can use the ROWID and ROWNUM pseudocolumns in Table, View, and Materialized View operators in a mapping. These operators contain an additional column called COLUMN USAGE that is used to identify attributes used as ROWID or ROWNUM. For normal attributes, this column defaults to TABLE USAGE. To use an attribute for ROWID or ROWNUM values, set the COLUMN USAGE to ROWID or ROWNUM respectively.
You can map a ROWID column to any attribute of data type ROWID, UROWID, or VARCHAR2. You can map ROWNUM column to an attribute of data type NUMBER or to any other data type that allows implicit conversion from NUMBER.
Note that ROWID and ROWNUM pseudocolumns are not displayed in the Data Object Editor since they are not real columns.
Edited by: Darthvader-647181 on Oct 29, 2008 9:18 AM -
How to use LIKE Operator with my query requriment
HI all,
I have a requirement as follows
EMPID ENAME JOB SAL
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
30 NARENDAR GUPTA ANALYST 20000
40 ASHUTOSH GUPTA DEVELOPER 10000
50 ASHUTOSH NAYAR PROGRAMMER 15000
i am searching enames such that i need to get the whole name even if i search with just a single LETTER/WORD immaterial of the order they exist in the name for which i need to get the whole name.(INFACT WORD comparision)
ex:
1) select * from emp where ename like '%ka%'
i am getting:
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
This is not what i need i need just word camparision not letters comparision let me tell you...
select * from emp where ename like '%amal%'
Even for this query ill get the same output.. this is not my option to go..
I need just word comparision with starting letter and immaterial of the word position in the name
If it is possible to do with query please let me know..
Thanking you
Narendar VishwanathamFull example:
SQL> ed
Wrote file afiedt.buf
1 with e as (select 10 as empid, 'RAJ KAMAL' as ename, 'MANAGER' as job, 25000 as sal from dual union all
2 select 20, 'KAMAL RAJ NAYAK', 'CLERK', 4000 from dual union all
3 select 30, 'NARENDAR GUPTA', 'ANALYST', 20000 from dual union all
4 select 40, 'ASHUTOSH GUPTA', 'DEVELOPER', 10000 from dual union all
5 select 50, 'ASHUTOSH NAYAR', 'PROGRAMMER', 15000 from dual)
6 -- END OF TEST DATA
7 select *
8 from e
9* where regexp_like(ename,'(^| )KA( |$)')
SQL> /
no rows selected
SQL> ed
Wrote file afiedt.buf
1 with e as (select 10 as empid, 'RAJ KAMAL' as ename, 'MANAGER' as job, 25000 as sal from dual union all
2 select 20, 'KAMAL RAJ NAYAK', 'CLERK', 4000 from dual union all
3 select 30, 'NARENDAR GUPTA', 'ANALYST', 20000 from dual union all
4 select 40, 'ASHUTOSH GUPTA', 'DEVELOPER', 10000 from dual union all
5 select 50, 'ASHUTOSH NAYAR', 'PROGRAMMER', 15000 from dual)
6 -- END OF TEST DATA
7 select *
8 from e
9* where regexp_like(ename,'(^| )KAMAL( |$)')
SQL> /
EMPID ENAME JOB SAL
10 RAJ KAMAL MANAGER 25000
20 KAMAL RAJ NAYAK CLERK 4000
SQL> -
Using like operator with attributes in select command
Hi,
I have a table with the attributes as DID, PNO,AGE, DEPARTMENT, DATEOFADM, CHARGES, ADDRESS, DOD
I want to display the records with the months in DOD and DATEOFADM same. How can I do so? I also want to do the same with the dates in the 2 attributes.
Thanks
Edited by: 1004111 on May 23, 2013 1:51 AMHi,
Please read SQL and PL/SQL FAQ
When you put some <b>code or output</b> please enclose it between two lines starting with {noformat}<b></b>{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
You should post create table and insert statement for your requirement.
You can check if 2 dates have the same month in either way:-- this is comparing year and month
SELECT *
FROM yourtable
WHERE TRUNC(dod,'MM')=TRUNC(dateofadm,'MM');
-- or in case you want to compare only months no matter the year
SELECT *
FROM yourtable
WHERE EXTRACT(MONTH FROM dod) = EXTRACT(MONTH FROM dateofadm);
Regards.
Al -
Crash of Oracle XE when check constraint uses in-operator with desc. values
ORA-03113 and other errors in conjunction with lost of connection occur in Oracle XE under the following conditions:
/* Crash (values of check constraint in descending order) */
DROP TABLE CRASHTEST CASCADE CONSTRAINTS;
CREATE TABLE CRASHTEST
CRASHTEST_ID NUMBER(9),
CRASHTEST_OK NUMBER(1) DEFAULT 0
ALTER TABLE CRASHTEST ADD (CONSTRAINT CRASHTEST_CK CHECK (CRASHTEST_OK IN (0,-1)));
INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (1, 0);
INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (2, -1);
COMMIT;
SELECT * FROM CRASHTEST WHERE CRASHTEST_OK = 0;
If all values of the in-clause within the check constraint are entered in ascending order, no error occurs:
/* No Crash (values of check constraint in ascending order) */
DROP TABLE CRASHTEST CASCADE CONSTRAINTS;
CREATE TABLE CRASHTEST
CRASHTEST_ID NUMBER(9),
CRASHTEST_OK NUMBER(1) DEFAULT 0
ALTER TABLE CRASHTEST ADD (CONSTRAINT CRASHTEST_CK CHECK (CRASHTEST_OK IN (-1,0)));
INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (1, 0);
INSERT INTO CRASHTEST (CRASHTEST_ID, CRASHTEST_OK) VALUES (2, -1);
COMMIT;
SELECT * FROM CRASHTEST WHERE CRASHTEST_OK = 0;
Especially interesting is the fact, that the error is caused by a check constraint in conjunction with a select statement!
Hopefully, there are no other hidden bombs stealing my time...
Have a nice day,
SvenIt might be interesting to post that in the XE forum to notify Oracle developers and XE users.
Oracle Database Express Edition (XE)
C. -
Error Handling while using Batch Operation
Hi Experts,
I am trying to update document with multiple successful items using batch operation with single changeset and document is updating successfully.
But when i am trying to update document with multiple unsuccessful items, I am getting error saying " HTTP/1.1 500 Internal Server Error" .
If it is for a single unsuccessful item,i am able to get the error message as return parameter, but i am not able to get the error messages as return parameter if it is for multiple(more than one item) unsuccessful items.
Could you please let me know your thoughts on this.
Thanks,
SyamYes: I can.
Provided someone provides version information
Provided someone identifies specific API's
Provided someone defines what conversions they are referring to.
After you've defined the problem go to metalink or tahiti and look up the answer yourself. -
Why r we allowed to create String objects with & without using new operator
While creating any object, usage of the new operator is a must...but only for the string object we can create it with and also without new operator how is it possible to create an object without using new operator.
Because Mr. (Dr.?) Gosling is a kindly soul who realizes that programmers have deadlines and, when he designed Java, was not so rigid or unbending as not to realize that from time to time, certain shortcuts are warranted, even in a relatively pure language such as Java. The direct String literal assignments are a shortcut over using the new operator making Java programming (and execution; there's also a performance benefit) more streamlined.
So look not the gift horse in the mouth, but simply bask in the simplification and ease on the eyes and directly assign your little literals to your heart's content. -
Using == with String object references
Hi,
I understand that using the == operator to compare two String object references in Java will yield false for two different object references even when the contents are the same, and that you are supposed to use the method .equals() instead. However, in my program the == operator actually works for two different object references that point to the same object since it yields true! I don't understand why it works in my program when it shouldn't. Does someone know why?
Thanks!overrule. wrote:
warnerja wrote:
... unless some sneaky thread jumps in and changes the a or b reference right before the expression (a == b) were evaluated. This would also assume a or b had greater scope than simply local method variables that only one thread could access.
Just being a nitpickCould you provide an example of how that "greater scope" may look like in this case.
* Greater scope.
* @author Cynthia G.
* @see http://forums.sun.com/thread.jspa?messageID=10520796
public class ObjectAssignmentTest {
static Object a; // outer scope: class variable
static Object b; // outer scope: class variable
public static void main(String[] args) throws InterruptedException {
a = new Object();
b = a;
new Thread(new Runnable() {
public void run() { ObjectAssignmentTest.b = new Object(); }
}).start();
System.out.println(a == b ? "equal" : "not equal");
}For the record, this code is not even guaranteed to make the objects unequal with == before their equality is tested; both threads may go in parallel, the main thread first or the modifying thread first!
s -
Use Operator == for String Comparison
Hi,
I would like to know more about the impact of using operator == in String Comparison.
From the reference I get, it state this :
"Operator (==) compares two object addresses to see whether it refers to the same object."
I've tested it with 2 codes as below :
Code 1:
String Pass1 = "cosmo";
String Pass2 = "cosmo";
if (Pass1==Pass2)
System.out.println("1&2:same");
else
System.out.println("1&2:not same");
Output : 1&2:same
Code 2:
String Pass3 = new String("cosmo");
String Pass4 = new String("cosmo");
if (Pass3==Pass4)
System.out.println("3&4:same");
else
System.out.println("3&4:not same");
Output : 3&4:not same
Can anyone kindly explain why is the result so? If operator == compares the addresses, isn't it that the 1st code should also have the output :"1&2:not same".Can anyone kindly explain why is the result so?It's an implementation artifact. Strings are pooled internally and because of that any String literal will be represented by exactly one object reference.
Knowledge of this shouldn't be utilized though. It's safer to follow the basic rule: Use == to compare object references and equals to compare object values, such as String literals. -
Purchased a used macbook pro with Mountain Lion. My old Mac runs Snow Leopard is backed up to Time machine. How do I register the operating system to me and how do I use Time Machine to move my files to the new used computer?
If you look at the User Tips tab, you will find a write up on just this subject:
https://discussions.apple.com/docs/DOC-4053
The subject of buying/selling a Mac is quite complicated. Here is a guide to the steps involved. It is from the Seller's point of view, but easily read the other way too:
SELLING A MAC A
Internet Recovery, and Transferability of OS & iLife Apps
Selling an Old Mac:
• When selling an old Mac, the only OS that is legally transferable is the one that came preinstalled when the Mac was new. Selling a Mac with an upgraded OS isn't doing the new owner any favors. Attempting to do so will only result in headaches since the upgraded OS can't be registered by the new owner. If a clean install becomes necessary, they won't be able to do so and will be forced to install the original OS via Internet Recovery. Best to simply erase the drive and revert back to the original OS prior to selling any Mac.
• Additionally, upgrading the OS on a Mac you intend to sell means that you are leaving personally identifiable information on the Mac since the only way to upgrade the OS involves using your own AppleID to download the upgrade from the App Store. So there will be traces of your info and user account left behind. Again, best to erase the drive and revert to the original OS via Internet Recovery.
Internet Recovery:
• In the event that the OS has been upgraded to a newer version (i.e. Lion to Mountain Lion), Internet Recovery will offer the version of the OS that originally came with the Mac. So while booting to the Recovery Disk will show Mountain Lion as available for reinstall since that is the current version running, Internet Recovery, on the other hand, will only show Lion available since that was the OS shipped with that particular Mac.
• Though the Mac came with a particular version of Mac OS X, it appears that, when Internet Recovery is invoked, the most recent update of that version may be applied. (i.e. if the Mac originally came with 10.7.3, Internet Recovery may install a more recent update like 10.7.5)
iLife Apps:
• When the App Store is launched for the first time it will report that the iLife apps are available for the user to Accept under the Purchases section. The user will be required to enter their AppleID during the Acceptance process. From that point on the iLife apps will be tied to the AppleID used to Accept them. The user will be allowed to download the apps to other Macs they own if they wish using the same AppleID used to Accept them.
• Once Accepted on the new Mac, the iLife apps can not be transferred to any future owner when the Mac is sold. Attempting to use an AppleID after the apps have already been accepted using a different AppleID will result in the App Store reporting "These apps were already assigned to another Apple ID".
• It appears, however, that the iLife Apps do not automatically go to the first owner of the Mac. It's quite possible that the original owner, either by choice or neglect, never Accepted the iLife apps in the App Store. As a result, a future owner of the Mac may be able to successfully Accept the apps and retain them for themselves using their own AppleID. Bottom Line: Whoever Accepts the iLife apps first gets to keep them.
SELLING A MAC B
Follow these instructions step by step to prepare a Mac for sale:
Step One - Back up your data:
A. If you have any Virtual PCs shut them down. They cannot be in their "fast saved" state. They must be shut down from inside Windows.
B. Clone to an external drive using using Carbon Copy Cloner.
1. Open Carbon Copy Cloner.
2. Select the Source volume from the Select a source drop down menu on the left side.
3. Select the Destination volume from the Select a destination drop down menu on the right
side.
4. Click on the Clone button. If you are prompted about creating a clone of the Recovery HD be
sure to opt for that.
Destination means a freshly erased external backup drive. Source means the internal
startup drive.
Step Two - Prepare the machine for the new buyer:
1. De-authorize the computer in iTunes! De-authorize both iTunes and Audible accounts.
2, Remove any Open Firmware passwords or Firmware passwords.
3. Turn the brightness full up and volume nearly so.
4. Turn off File Vault, if enabled.
5. Disable iCloud, if enabled: See.What to do with iCloud before selling your computer
Step Three - Install a fresh OS:
A. Snow Leopard and earlier versions of OS X
1. Insert the original OS X install CD/DVD that came with your computer.
2. Restart the computer while holding down the C key to boot from the CD/DVD.
3. Select Disk Utility from the Utilities menu; repartition and reformat the internal hard drive.
Optionally, click on the Security button and set the Zero Data option to one-pass.
4. Install OS X.
5. Upon completion DO NOT restart the computer.
6. Shutdown the computer.
B. Lion and Mountain Lion (if pre-installed on the computer at purchase*)
Note: You will need an active Internet connection. I suggest using Ethernet if possible because
it is three times faster than wireless.
1. Restart the computer while holding down the COMMAND and R keys until the Mac OS X
Utilities window appears.
2. Select Disk Utility from the Mac OS X Utilities window and click on the Continue button.
3. After DU loads select your startup volume (usually Macintosh HD) from the left side list. Click
on the Erase tab in the DU main window.
4. Set the format type to Mac OS Extended (Journaled.) Optionally, click on the Security button
and set the Zero Data option to one-pass.
5. Click on the Erase button and wait until the process has completed.
6. Quit DU and return to the Mac OS X Utilities window.
7. Select Reinstall Lion/Mountain Lion and click on the Install button.
8. Upon completion shutdown the computer.
*If your computer came with Lion or Mountain Lion pre-installed then you are entitled to transfer your license once. If you purchased Lion or Mountain Lion from the App Store then you cannot transfer your license to another party. In the case of the latter you should install the original version of OS X that came with your computer. You need to repartition the hard drive as well as reformat it; this will assure that the Recovery HD partition is removed. See Step Three above. You may verify these requirements by reviewing your OS X Software License.
Maybe you are looking for
-
How can I sign out of cloud and sign in as another ID?
My Main Mac and Iphone are both under my iTunes ID but my MacAir would only let me use my MobileMe ID - how can I sign out on my Air, and sign in under the iTunes ID?
-
When I create a new project I get a metadata error
Could not read metadata for 'C:\Users\Darrin Kay\Application Data\Adobe\Flash Catalyst CS5.5\workspace\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes\properties.i ndex'. Unexpected version: 0. I just downloaded and install the CS 5.5 We
-
Date format conversion in Business Server pages
Hi Floks i am working Business server pages i got some problem in the date format. Igetting date as dd.mm.yyyy and i want to change this to MM/DD/YYYY format . i tried to change this in like in ABAP coding . it s not working can give how can fixthis
-
i want to post the document using zprogram instead of FBCJ standared program. i use one BAPI FCJ_POST_ALL in my report i use hot spot after clicking on hot spot this bapi is excute and that document is post. but it will ask me for Amount and acc
-
¿Como puedo volver a instalar la aplicacion Mail para que funcione con esta versión?