IN clause without parentheses in 10g
I am using 10gR1 ("Why not R2?" Politics - literally), and I noticed that the following works:
SELECT a.col1
FROM some_table a, some_other_table b
WHERE a.col1 IN b.col1
I also notice that it is not documented in the SQL Referece (only IN (<list>) and IN (subquery) are mentioned).
Is this a bug, or is it part of the Oracle SQL standard - and if it is supposed to be valid, how is it supposed to function?
-- Don
Noted - thanks.
Apparenty, in 8.1.7, my code works in SQL, but when I try it in PL/SQL, it does show a compiler error that it is looking for "(" following IN.
(I've noticed this "feature" with analytic functions...)
-- Don
Similar Messages
-
Date in where clause without Trunc
Hi,
How handle a date comparision in where clause without trunc. Rightnow I am using it with 'trunc', it is very slow..
Select ColumnA, ColumnB
From Sample
Where trunc(created_date,'DD-MON-YY') = '15-NOV-2011';
CREATE TABLE SAMPLE
ColumnA NUMBER(9,0) NOT NULL,
ColumnB VARCHAR2(255) NOT NULL,
created_date DATE
);Hi,
Here's one way:
SELECT ColumnA, ColumnB
FROM Sample
WHERE created_date >= TO_DATE ('15-NOV-2011', 'DD-MON-YYYY')
AND created_date < TO_DATE ('15-NOV-2011', 'DD-MON-YYYY') + 1
;If you have an index on created_date. then this query will be able to use that index, because created_date is alone on one side of the operator.
Another reason why this will be faster is that it only has to call TO_DATE twice, regardless of how many rows are in the table. The original query had to call TRUNC for every row.
Don't compare a DATE (such as the results of TRUNC) to a string (such as '15-NOV-2011'). You're liable to get a run-time error, or, if youre not so lucky, unexpected results.
Edited by: Frank Kulash on Nov 15, 2011 5:22 PM -
How to use model clause without hard coding the values in it?
Query
select acct_no,
gl_code,
CASE
WHEN entry_type_label IN ('Earned Revenue') THEN
'Earned Revenue'
ELSE
'Deferred Revenue Credit'
END AS entry_type_label,
CASE
WHEN entry_type_label IN ('Opening Balance') THEN
'Opening Balance'
WHEN entry_type_label IN ('Deferred Revenue Credit') THEN
'Invoice Amount'
WHEN entry_type_label IN ('Earned Revenue') THEN
'Earned Revenue'
WHEN entry_type_label IN ('Closing Balance') THEN
'Closing Balance'
ELSE
'Deferred Revenue Credit'
END AS label,
entry_type_no,
orig_chg_start_date,
period_no,
-amt as amt
from revrec_test
WHERE acct_no = 1788562
AND entry_type_no IN (2, 4) model dimension by(acct_no,
gl_code,
entry_type_label,
entry_type_no,
orig_chg_start_date,
period_no) measures(amt) rules upsert
all(amt 1788562,
'UNEARNED-10011561',
'Opening Balance',
2,
'02-OCT-17 08.30.00 AM',
190 = 0,
amt 1788562,
'UNEARNED-10011561',
'Closing Balance',
2,
'02-OCT-17 08.30.00 AM',
190 = amt 1788562,
'UNEARNED-10011561',
'Deferred Revenue Credit',
2,
'02-OCT-17 08.30.00 AM',
190 - amt 1788562,
'EARNED-10011561',
'Earned Revenue',
4,
'02-OCT-17 08.30.00 AM',
190,
amt 1788562,
'UNEARNED-10011561',
'Opening Balance',
2,
'02-OCT-17 08.30.00 AM',
191 = amt 1788562,
'UNEARNED-10011561',
'Closing Balance',
2,
'02-OCT-17 08.30.00 AM',
190,
amt 1788562,
'UNEARNED-10011561',
'Deferred Revenue Credit',
2,
'02-OCT-17 08.30.00 AM',
191 = 0,
amt 1788562,
'UNEARNED-10011561',
'Closing Balance',
2,
'02-OCT-17 08.30.00 AM',
191 =
(amt 1788562, 'UNEARNED-10011561', 'Opening Balance', 2,
'02-OCT-17 08.30.00 AM', 191 + amt 1788562, 'UNEARNED-10011561',
'Deferred Revenue Credit', 2, '02-OCT-17 08.30.00 AM', 191) - amt
1788562,
'EARNED-10011561',
'Earned Revenue',
4,
'02-OCT-17 08.30.00 AM',
191,
amt 1788562,
'UNEARNED-10011561',
'Opening Balance',
2,
'02-OCT-17 08.30.00 AM',
192 = amt 1788562,
'UNEARNED-10011561',
'Closing Balance',
2,
'02-OCT-17 08.30.00 AM',
191,
amt 1788562,
'UNEARNED-10011561',
'Deferred Revenue Credit',
2,
'02-OCT-17 08.30.00 AM',
192 = 0,
amt 1788562,
'UNEARNED-10011561',
'Closing Balance',
2,
'02-OCT-17 08.30.00 AM',
192 =
(amt 1788562, 'UNEARNED-10011561', 'Opening Balance', 2,
'02-OCT-17 08.30.00 AM', 192 + amt 1788562, 'UNEARNED-10011561',
'Deferred Revenue Credit', 2, '02-OCT-17 08.30.00 AM', 192) - amt
1788562,
'EARNED-10011561',
'Earned Revenue',
4,
'02-OCT-17 08.30.00 AM',
192,
amt 1788562,
'UNEARNED-10011561',
'Opening Balance',
2,
'02-OCT-17 08.30.00 AM',
193 = amt 1788562,
'UNEARNED-10011561',
'Closing Balance',
2,
'02-OCT-17 08.30.00 AM',
192,
amt 1788562,
'UNEARNED-10011561',
'Deferred Revenue Credit',
2,
'02-OCT-17 08.30.00 AM',
193 = 0,
amt 1788562,
'UNEARNED-10011561',
'Closing Balance',
2,
'02-OCT-17 08.30.00 AM',
193 =
(amt 1788562, 'UNEARNED-10011561', 'Opening Balance', 2,
'02-OCT-17 08.30.00 AM', 193 + amt 1788562, 'UNEARNED-10011561',
'Deferred Revenue Credit', 2, '02-OCT-17 08.30.00 AM', 193) - amt
1788562,
'EARNED-10011561',
'Earned Revenue',
4,
'02-OCT-17 08.30.00 AM',
193)
ORDER BY period_no, entry_type_no;
The above query works fine. But i have hard coded the values. I want to do the same operation for different account number which is going to have different periodic no. How can I achieve it?
Thanks in advance.Create Statement
CREATE TABLE table_one(
ACCT_NO NUMBER(38),
GL_CODE VARCHAR2(300),
ENTRY_TYPE_LABEL CHAR(50),
ENTRY_TYPE_NO NUMBER,
ORIG_CHG_START_DATE TIMESTAMP(0) WITH LOCAL TIME ZONE,
ORIG_CHG_END_DATE TIMESTAMP(0) WITH LOCAL TIME ZONE,
PERIOD_NO NUMBER(38),
AMT NUMBER(38,10)
Insert Statement
INSERT ALL
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'U-11561','Deferred Revenue Debit',3,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',100,13.87)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'E-11561','Earned Revenue',4,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',102,-14.83)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'E-11561','Earned Revenue',4,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',101,-14.35)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'E-11561','Earned Revenue',4,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',100,-13.87)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'U-11561','Deferred Revenue Debit',3,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',103,0.95)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'U-11561','Deferred Revenue Debit',3,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',102,14.83)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'U-11561','Deferred Revenue Debit',3,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',101,14.35)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'E-11561','Earned Revenue',4,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',103,-0.95)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1001,'U-11561','Deferred Revenue Credit',2,'02-OCT-17 08.30.00 AM','01-JAN-18 01.30.00 PM',100,-44)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',106,44.91)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Accounts Receivable',1,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',104,60)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,3.93)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',106,11.75)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',107,6.86)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,-7.82)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',106,-23.47)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',107,-13.69)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',107,-6.86)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,7.82)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',106,23.47)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',107,13.69)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',104,-9.13)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,-44.91)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',106,-44.91)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',107,-35.91)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,-3.93)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,44.91)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',104,9.13)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Earned Revenue',4,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',106,-11.75)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Credit',2,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,38.48)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Credit',2,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,-19.24)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Credit',2,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',104,-60)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Accounts Receivable',1,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,38.48)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Accounts Receivable',1,'20-DEC-13 09.30.00 AM','16-FEB-14 09.30.00 AM',105,19.24)
INTO table_one(acct_no, gl_code, entry_type_label, entry_type_no, orig_chg_start_date, orig_chg_end_date, period_no, amt) VALUES(1002,'Recurring Flat Fees COA Code','Deferred Revenue Debit',3,'17-NOV-13 09.30.00 AM','16-FEB-14 09.30.00 AM',107,35.91)
SELECT * FROM dual;
Expected Result
S.NO
ACCT_NO
GL_CODE
ENTRY_TYPE_LABEL
ENTRY_TYPE_NO
ORIG_CHG_START_DATE
PERIOD_NO
AMT
DESCRIPTION
1
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
100
0
Opening Account
2
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
100
44
Invoice
3
1001
E-11561
Earned Revenue
4
02-OCT-17 08.30.00 AM
100
13.87
Invoice Paid
4
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
100
30.13
Closing Account
5
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
101
30.13
Opening Account
6
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
101
0
Invoice
7
1001
E-11561
Earned Revenue
4
02-OCT-17 08.30.00 AM
101
14.35
Invoice Paid
8
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
101
15.78
Closing Account
9
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
102
15.78
Opening Account
10
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
102
0
Invoice
11
1001
E-11561
Earned Revenue
4
02-OCT-17 08.30.00 AM
102
14.83
Invoice Paid
12
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
102
0.95
Closing Account
13
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
103
0.95
Opening Account
14
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
103
0
Invoice
15
1001
E-11561
Earned Revenue
4
02-OCT-17 08.30.00 AM
103
0.95
Invoice Paid
16
1001
U-11561
Deferred Revenue Credit
2
02-OCT-17 08.30.00 AM
103
0
Closing Account
Description
We must start opening account as zero and end with closing account as zero by doing manipulation with invoice and invoice paid.
Process
Initial Stage
Subsequent stage
Opening Account
0
(=closing Account)
Invoice
max value of account no which has entry type no 2
0
Invoice Paid
taken from the field amount which has entry type no 4
taken from the field amount which has entry type no 4
Closing Account
(=[opening account + invoice] - invoice paid)
(=[opening account + invoice] - invoice paid)
Note
1) Each account may have different periodic no.
2) Some account may have more than 4 distinct period no and less than 4 distinct periodic no.
3) Description column from expected result is not an part of table. It is been added for easier understanding. -
Cannot Access OpenLDAP Directory Server for Windows
Hi All,
Need urgent help for connecting to LDAP server which I installed on my Win 2000 Professional m/c. The LDAP installation was downloaded from the site www.ilex.fr/openldap. I successfully installed it. In the slapd.conf file, I have set the server suffice as dc=mycompany,dc=com and the rootdn is cn=Manager,dc-mycompany,dc=com. I have the following piece of code which tries to list the Java schema in the LDAP directory. The code was downloaded from sun's JNDI tutorial. The name of the Program is
CreateJavaSchema and it is run by giving the following options:
-l List the Java schema in the directory
-n<dn> Use <dn> as the distinguished name for authentication
-p<passwd> Use <passwd> as the password for authentication
-a<auth> Use <auth> as the authentication mechanism. Default is "simple".
I tried to run the program as java CreateJavaSchema -ncn=Manager,dc=mycompany,dc=com -psecret99
where secret99 is the root password . However I get the following exception
javax.naming.CommunicationException: localhost:389. Root exception is java.net.ConnectException: Connection refused: connect
Can somone help me with this?
ThanksThe Code ..yes
Here it is: .This code is availbale from JNDI tutorial. I run the program by specifying following command-line arguments.
java ListJavaSchema -ncn=Manager,dc=mycompany,dc=com -psecret99.
However I get the exception "javax.naming.CommunicationException: localhost:389. Root exception is java.net.ConnectException: Connection refused: connect"
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Hashtable;
public class ListJavaSchema {
protected static String dn, passwd, auth;
protected static boolean netscapebug;
// NS 4.1 has problems parsing an object class definition which contains
// a MUST clause without parentheses. The workaround is to add a
// superfluous value (objectClass) to each MUST clause.
// It also doesn't like the Octet String syntax (use Binary instead)
protected static boolean netscape41bug = false;
// AD supports auxiliary classes in a peculiar way.
protected static boolean activeDirectorySchemaBug = false;
protected static boolean traceLdap = false;
protected static final int LIST = 0;
protected static final int UPDATE = 1;
private static String[] allAttrs = {
"javaSerializedObject",
"javaFactoryLocation",
"javaReferenceAddress",
"javaFactory",
"javaClassName",
"javaClassNames",
"javaDoc",
"javaSerializedData",
"javaCodebase",
"javaFactory",
"javaReferenceAddress"};
private static String[] allOCs = {
"javaObject",
"javaNamingReference",
"javaSerializedObject",
"javaRemoteObject",
"javaMarshalledObject",
"javaContainer"};
public static void main(String[] args) {
new ListJavaSchema().run(args, allAttrs, allOCs);
ListJavaSchema() {
protected void run(String[] args, String[] attrIDs, String[] ocIDs) {
int cmd = processCommandLine(args);
try {
DirContext ctx = signOn();
System.out.println("Context: "+ctx);
switch (cmd) {
case UPDATE:
// updateSchema(ctx, attrIDs, ocIDs);
break;
default:
showSchema(ctx, attrIDs, ocIDs);
} catch (NamingException e) {
e.printStackTrace();
* Signs on to directory server using parameters supplied to program.
* @return The initial context to the server.
private DirContext signOn() throws NamingException {
if (dn != null && auth == null) {
auth = "simple"; // use simple for Netscape
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.REFERRAL, "follow");
if (auth != null) {
env.put(Context.SECURITY_AUTHENTICATION, auth);
env.put(Context.SECURITY_PRINCIPAL, dn);
env.put(Context.SECURITY_CREDENTIALS, passwd);
// Workaround for Netscape schema bugs
if (netscapebug) {
env.put("com.sun.naming.netscape.schemaBugs", "true");
// LDAP protocol tracing
if (traceLdap) {
env.put("com.sun.jndi.ldap.trace.ber", System.err);
System.out.println("HashMap: "+env);
return new InitialDirContext(env);
void showSchema(DirContext ctx, String[] attrs, String[] ocs)
throws NamingException {
DirContext attrRoot =
(DirContext)ctx.getSchema("").lookup("AttributeDefinition");
printSchema(attrRoot, attrs);
DirContext ocRoot =
(DirContext)ctx.getSchema("").lookup("ClassDefinition");
printSchema(ocRoot, ocs);
private void printSchema(DirContext ctx, String[] ids) {
for (int i = 0; i < ids.length; i++) {
try {
System.out.print(ids[i] + ": ");
System.out.print(ctx.getAttributes(ids));
} catch (NamingException e) {
} finally {
System.out.println();
private int processCommandLine(String[] args) {
String option;
boolean schema = false;
boolean list = false;
for (int i = 0; i < args.length; i++) {
option = args[i];
if (option.startsWith("-h")) {
printUsage(null);
if (option.startsWith("-s")) {
schema = true;
netscapebug = option.equals("-sn");
netscape41bug = option.equals("-sn41");
activeDirectorySchemaBug = option.equals("-sad");
} else if (option.startsWith("-l")) {
list = true;
} else if (option.startsWith("-a")) {
auth = option.substring(2);
} else if (option.startsWith("-n")) {
dn = option.substring(2);
} else if (option.startsWith("-p")) {
passwd = option.substring(2);
} else if (option.startsWith("-trace")) {
traceLdap = true;
} else {
// invalid option
printUsage("Invalid option");
if (!schema) {
return LIST;
} else {
return UPDATE;
protected void printUsage(String msg) {
printUsageAux(msg, "Java");
protected void printUsageAux(String msg, String key) {
if (msg != null) {
System.out.println(msg);
System.out.print("Usage: ");
System.out.println("java [-Djava.naming.provider.url=<ldap_server_url>] \\");
System.out.println(" Create" + key + "Schema [-h|-l|-s[n|n41|ad]] [-n<dn>] [-p<passwd>] [-a<auth>]");
System.out.println();
System.out.println(" -h\t\tPrint the usage message");
System.out.println(" -l\t\tList the " + key + " schema in the directory");
System.out.println(" -sn\tUpdate schema:");
System.out.println(
"\t\t -sn use workaround for Netscape Directory pre-4.1 schema bug");
System.out.println(
"\t\t -sn41 use workaround for Netscape Directory 4.1 schema bug");
System.out.println(
"\t\t -sad use workaround for Active Directory schema bug");
System.out.println(" -n<dn>\tUse <dn> as the distinguished name for authentication");
System.out.println(" -p<passwd>\tUse <passwd> as the password for authentication");
System.out.println(" -a<auth>\tUse <auth> as the authentication mechanism");
System.out.println("\t\t Default is 'simple' if dn specified; otherwise 'none'");
System.exit(-1); -
Where clause - parentheses versus view link
I have detail View Object DetailVO with where clause "status=1 or status=2" and I add it to AM as detail of masterVO.
Then the link doesn't work, I suppose BC4J create new where clause as "status=1 or status=2 and :1=....". But it means "status=1 or (status=2 and :1=....)"!!!
I put detail VO where clause into parentheses "(status=1 or status=2)" and everything was OK - ViewLink worked.
It is very bad feature of ViewLinks, isn't it?
JanWell, now I know I must always surround OR clauses with parenthesis.
But I was very confused about it. My ViewLink didn't work and I did't know why... I think, that if BC4J adds ViewLink condition, that it must handle the ViewObject whereClause and surround it with parenthesis. Otherwise it is very strange behaviour, isn't it? Added ViewLink condition shouldn't affect the original whereClause!
Any JDevTeam comment?
Jan -
How to Set Distinct SQL Clause on View Object without using Expert Mode.
Hi to all Actually i have a View Object usign 3 entities
if i use expert mode in my VO, it generate
QRSLT WHERE
instruction and force to include all columns on my dynamic where clause on select statement i can't include columns because get me duplicate rows
How i can include disctinct clause without usign expert mode or any other solution?
Note that in normal mode without expert mode QRSLT WHERE is not generate and all work fine
For example
select * ( select id , name from table) QRSLT WHERE loc = ..
if i use expert mode it generate QRSLT WHERE and if loc is not predicated colums get me and error :
( ORA-00904: invalid identifier )
in simple mode of View Object all work fine..
Any suggestion on It will be appreciate.....
TnxMy problem is that when use expert mode
it's change simple select statement for a select that use
select * from (select column....)
qrslt WHERE (column=somevalue)
this kind of select force me to include all where conditions of qrslt on my select columns and this get duplicate rows
thats beacuse i need include distinct without use expert mode
Anny Help on this? -
AND and OR operations in WHERE clause
Hello, Dear Oracle professionals.
In WHERE clause when I use AND or OR operations, is there any way of working ORACLE server to select rows?
For example
WHERE con1 and con2 and con3 and con4 and con5OR
WHERE con1 or con2 or con3 or con4 or con5How oracle checks this conditions ? From the begining to the end ? in order ?
May be I should put some more probable TRUE condition to the end(or to the begin).
Whant to know how oracle thinks.
Thanks in advance.Hi,
Khayyam wrote:
Hello, Dear Oracle professionals.
In WHERE clause when I use AND or OR operations, is there any way of working ORACLE server to select rows?
For example
WHERE con1 and con2 and con3 and con4 and con5OR
WHERE con1 or con2 or con3 or con4 or con5How oracle checks this conditions ? From the begining to the end ? in order ?It evalauates the one that is likely to make the most difference first. In the case of AND, that means the condition that is least likely to be true (as far as the optimizer can predict).
May be I should put some more probable TRUE condition to the end(or to the begin).It doesn't matter to the optimizer. Do whatever you find easier to read and debug.
In ancient times, using the rule-based optimizer, order did matter, but there's no reason to be using the rule-based optimizer now. Oracle 11 doesn't even have the option.
By the way, be careful not to mix AND and OR without parentheses. That is, never say:
WHERE x AND y OR z -- ***** No! Wrong! ******Instead say
WHERE (x AND y) OR z or
WHERE x AND (y OR z) depending on what you want. If you don't use partentheses, then there are rules about how the expresssion is evaluated, but it's a waste of your time to learn them. -
How can I set a variable number of values in a SQL IN clause?
Hi,
How can I set a variable number of values in a SQL IN clause without having to change the text of the SQL statement each time?
I read the link http://radio.weblogs.com/0118231/2003/06/18.html. as steve wrote.
SELECT *
FROM EMP
WHERE ENAME IN (?)
But we need the steps not to create type in the system and would there be any other solution if we would like to use variable number of values in a SQL IN clause ?
We are using JDeveloper 10.1.3.2 with Oracle Database 10.1.3.2
Thanks
RajHi,
can you please explain why the solution from steve is not the right solution for you.
regards
Peter -
I'm using the formula node and it appears that parenthesis don't work. Is this correct? What is the order of operations?
The Formula Node Syntax page in the help is extremely brief and sparse, bordering on useless for anyone that doesn't already now what is going on. Is there a more thorough description of the Syntax anywhere?Thanks Dennis,
The error is just an incorrect calculation.
I put together a simple node and parenthesis did work. So something else must be amiss. I stripped down my VI and equation and made two formula nodes implementing the same equation with and without parenthesis. One gives an exponential decreasing curve, the other a constant array. Where is the error?
Attachments:
parenth_ex.vi 49 KB -
How to use a constant defined as a concat of char values in an IN clause
Greetings,
I defined a CONSTANT as a concatenation of values and attempted to use it in an IN clause without success ...
CREATE OR REPLACE PACKAGE PKG_TEST AS
Q_IDS CONSTANT VARCHAR2(25) : = '''3'''||','||'''14'''||','||'''16'''||','||'''18'''||','||'''24''';
procedure insert_test;
END PKG_TEST;
CREATE OR REPLACE PACKAGE BODY PKG_TEST AS
PROCEDURE insert_test as
BEGIN
insert into test1
select *
from test_table
where q_id in ( Q_IDS );
END insert_test;
END PKG_TEST;
I'm guessing this doesn't work because the CONSTANT is being treated as one long string as opposed to a succession of comma separated values.
Is there a way to do this?
Any feedback would be appreciated.
Thank you.One example:
SQL> ed
Wrote file afiedt.buf
1 select *
2 from emp
3 where ename in (
4 with t as (select '&input_string' as txt from dual)
5 select REGEXP_SUBSTR (txt, '[^,]+', 1, level)
6 from t
7 connect by level <= length(regexp_replace(txt,'[^,]*'))+1
8* )
SQL> /
Enter value for input_string: SCOTT,JAMES
old 4: with t as (select '&input_string' as txt from dual)
new 4: with t as (select 'SCOTT,JAMES' as txt from dual)
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 SCOTT ANALYST 7566 19-04-1987 00:00:00 3000 20
7900 JAMES CLERK 7698 03-12-1981 00:00:00 950 30
SQL> -
Oracle 10g install dbca always in Chinese and not English language
I installed/re-installed Oracle 10g several times including removing registry entries, C:\Oracle directory, C:\Program Files\Oracle and empty c:\temp folders,
set my windows xp languages to English (Can) and u.s. only
The dbca always comes up in Chinese language and not in English no matter what I did. Is there a simple way to reset dbca to english without reinstalling Oracle 10g even though I really want to know why and how it picks up Chinese language as default ?I searched for "chinese" in oracle folder and found it in my install log where based on registry settings, it took my default language as Chinese.
I searched google, nothing until I came across how to set languages in xp.
To solve this annoying problem on xp:
Go to settings/control Panel/Regional and Language options/
under language tab, make sure both Thai and East Asian languages boxes are unchecked
under advanced tab, select language version non-unicode programs, pick English (Canada) drop down, I had Hong Kong SAR before. Clicked apply and come back in again to ensure no code page version tables for Asian languages are checked on this Advanced tab. Restart computer and that's it ! -
Sequence of tables in from clause and sequence of "where clause" conditions
Is Sequence of tables in "From Clause" and sequence of "where clause" conditions matters in 10g for performance?
Edited by: user6763079 on Jun 1, 2011 3:33 AMuser6763079 wrote:
Is Sequence of tables in "From Clause" and sequence of "where clause" conditions matters in 10g for performance?In general it does not matter.
It could matter if the Rule Based Optimizer (RBO) is used. However this RBO is only used if enforced by a hint or if no table statistics are collected. Starting from 10g the table statistics are automatically selected by a regular database job. So in general the CBO would be used.
The CBO will consider different access paths. If the number of tables is low enough, then all possible combinations are considered and the order does not make any difference.
Edited by: Sven W. on Jun 1, 2011 4:00 PM -
With clause join using ISO JOIN Sysntax
Hi,
One of my query looks like:
SELECT t2.col1,
t3.col1,
t3.col2
FROM t2
JOIN t2 ON t2.col1 = t3.col1;
Now I need to use a WITH clause to hold some values which has to be used to filter the results from the original query. Something like:
with t1 AS (Select col1
FROM tab1)
SELECT t2.col1,
t3.col1,
t3.col2
FROM t2
JOIN t3 ON t2.col1 = t3.col1
WHERE t2.col2 = t1.col1;
But the problem is I have to use t1 in the FROM clause before I can use it in the WHERE clause. My question is how do I use t1 in Where clause without joining with t2 & t3?Hi,
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
Always say which version of Oracle you're using (for example, 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Do you really need to use a WITH clause? It's hard to tell what you want to do just by looking at some code that doesn't do it, but it looks like you're trying to do this:
SELECT t2.col1,
t3.col1,
t3.col2
FROM t2
JOIN t3 ON t2.col1 = t3.col1
WHERE t2.col2 IN (
SELECT col1
FROM tab1
If you really did need a WITH clause, you could reference it like this
with t1 AS
Select col1
FROM tab1
SELECT t2.col1,
t3.col1,
t3.col2
FROM t2
JOIN t3 ON t2.col1 = t3.col1
WHERE t2.col2 IN (
SELECT col1
FROM t1
Joining t1, like Alberto suggested, is another possibility, but be careful: if t1.col1 is not unique, you may get duplicate rows. -
Non-group-by expression in select clause
Hi ya'll. I am new at writing SQL commands and am running into an error that I don't understand. I am trying to insert a simple 'GROUP BY' clause and keep getting the above error. I can insert the ORDER BY clause without any error, but when I add the GROUP BY clause it causes the error.
It is a very basic report with only two tables and one LEFT JOIN. I will insert a copy of the SQL command below.
Thank you very much for any help you can provide.
Marlene Allen
Crystal Reports Professional -FULL type
Product Version: 11.5
SELECT
sm_cntrt.scm_ctr_dt,
sm_cntrt.scm_ctr_no,
sm_cntrt.scm_cntrgrp,
sm_cntrt.div,
sm_cntrt.scm_renew_no,
sm_cstdt.scd_wo_no,
sm_cstdt.scd_fisc_dt,
sm_cstdt.scd_jc_cat,
sm_cstdt.scd_ovt_hrs,
sm_cstdt.scd_reg_hrs,
sm_cstdt.scd_ctr_empm
FROM
sm_cntrt
LEFT JOIN
sm_cstdt on sm_cntrt.scm_ctr_no = sm_cstdt.scd_ctr_no
WHERE
sm_cntrt.scm_active = 'a' and
year(sm_cstdt.scd_fisc_dt) is NULL OR
sm_cntrt.scm_active = 'a' and
year(sm_cstdt.scd_fisc_dt) = year(curdate()) and
month(sm_cstdt.scd_fisc_dt) <= month(curdate())-1 and
scd_rtype <> 2 and
scd_jc_cat = 'la'
GROUP by
sm_cntrt.scm_ctr_no
ORDER BY
sm_cntrt.scm_cntrgrp,sm_cntrt.scm_ctr_noMarlene,
Ian is correct. The GROUP BY clause is used to perform aggregate functions withing the SQL. For it to work, EVERY field in the SELECT list must be either aggregated or included in the GROUP BY list.
I'd disagree with the Ian's assertion that you don't need to use the ORDER BY clause... Database servers are typically better at sorting large record sets than a pc running CR... So while you don't NEED to sort using the ORDER BY clause, it can speed up processing time when working with larger record sets.
Jason -
Bug in apex 4.2.2.00.11, union with queries in parentheses
Hello, with apex 4.2.2.00.11 trying to build a simple report with the following query
(select 1 a from dual)
union
(select 2 a from dual)
gives: ORA-20001: Query must begin with SELECT or WITH
without parentheses it works fine
select 1 a from dual
union
select 2 a from dual
Both SQLs are perfectly valid for the DB, and such error was not raised in previous versions.
This broke some reports in our applications.I tried (SELECT ...) UNION (SELECT ...) as simple Interactive Report query in APEX 4.1.0.00.32 and received "SQL statement needs to start with SELECT".
What version are you upgrading from?
I was able to do this in a Classic Report but it complained, wanting a unique key in the Interactive Report.
select * from ((select 1, EMPNO from EMP) UNION (select 2, EMPNO from EMP))
Howard
Maybe you are looking for
-
Error while excuting WAD report on web
Hi Gurus, While excuting the Web Application Designer template, getting an error that is set parameter DATA_PROVIDER_REF in template TEST_WAD for Web item DROPDOWN_ITEM_1 to a valid data provider can any one brief me
-
AR_SYSTEM_PARAMETERS_ALL.TAX_REGISTRATION_NUMBER
This is an Oracle Receivables R12 question about an issue which is impacting our Invoice Printing programs. In Oracle Receivables R12, is there any front-end form which updates the AR_SYSTEM_PARAMETERS_ALL.TAX_REGISTRATION_NUMBER field? After introdu
-
Media Source v3.30.21 does not see "Z
I've downloaded Media Source v3.30.2 and installed it but it seems as if he does not see the Zen player. On the right screen appears the "Music bibliotheek and My computer" but not the Player itself.....to transfer music tracks to and from your Creat
-
How do I download and save the user manual as a pdf file?
where is the "divice manual icon ??? >> Branched from an earlier discussion << Message was edited by: Verizon Moderator
-
I've tried to set experiment with Socket communication in Flex, but I keep hitting problems. Approach 1: in a Flex web app, I load a crossdomain security policy from a server. I then open a socket and write a few bytes to the server. In my server, I