A simple problem with natural join
i have 2 tables what have columns with distinct's names are referenced.
natural join not works 'cose only foreign key reference this 2 tables.
Have something to make table join in using an specific foreign key??
I'm using oracle9i
Example:
table a( a_cod number, a_name varchar2(20))
table b( b_cod number, b_month_year date, b_salary number)
ALTER TABLE b ADD ( CONSTRAINT b_a_FK FOREIGN KEY (b_cod)
REFERENCES a (a_cod));
select * from a natural join b
where trunc(b_month_year) = trunc(sysdate)
I'm not express me correctly.
We have 2 tables like this:
CREATE TABLE PPTBA001
PPA001_GROUP NUMBER(3) NOT NULL,
PPA001_PEOPLECODE VARCHAR2(20 BYTE) NOT NULL,
PPA001_NAME VARCHAR2(60 BYTE) NOT NULL,
PPA001_DATEOFBIRTHDAY DATE NOT NULL);
CREATE TABLE CLTBA001
CLA001_GROUP NUMBER(3) NOT NULL,
CLA001_CLIENTCODE VARCHAR2(20 BYTE) NOT NULL,
CLA001_SITUATION NUMBER(1) DEFAULT 1);
SELECT * FROM PPTBA001 NATURAL JOIN CLTBA001;
ALTER TABLE CLTBA001 ADD (
CONSTRAINT CLA001_PPAA001_FK1 FOREIGN KEY (CLA001_GROUP, CLA001_CLIENTCODE)
REFERENCES PPTBA001 (OFA001_GROUP,OFA001_PEOPLECODE));
the select returns without results. 'cose does not have columns like same name.
Natural join use a columns with same name. I need something use an foreign key.
Why?? Now i have a problem .. i need aggregate one more column in primary key
and i need change all selects that have join with PPTBA001 and put manualy a new column.. if have a other possibility like natural join to using a foreign key to join the selects problems is so more easy to resolve.
Message was edited by:
jonas.lima
Similar Messages
-
Hi!
I'm learning SQL and I have lot of doubts but I think with this example I can generalize them.
I have the tables:
book {idbook (PK), namebook}
auhor {idauthor (PK), nameauthor, idcountry (FK)}
authorship {idauthor (FK), idbook (FK)} (both the same constraint PK)
country {idcountry (PK), namecountry}
I want the name of the books that have authors from Canada.
I assumed that a correct query would be:
SELECT namebook FROM book NATURAL JOIN (authorship NATURAL JOIN (author NATURAL JOIN country)) WHERE country.namecountry = 'Canada';
The result that I expected was:
Book3
Book5
but this query returns me all books that have relations in authorship (with authors from any country), 2 times!! like:
book2
book3
book4
book5
book2
book3
book4
book5
the best I can do to get my correct result is:
SELECT namebook FROM book NATURAL JOIN (authorship NATURAL JOIN author) WHERE author.idcountry = 2;
But of course I can't use this one...
Does anyone can explain me what is happening?
Thanks a lot!
Edited by: user12040235 on 15/10/2009 09:37
Edited by: user12040235 on 15/10/2009 09:51Hi,
That may be a bug.
I get the correct results (2 rows) in Oracle 10.1, but I get the same bad results you do (12 rows) in Oracle 11.1.
In Oracle 11, I get the expected results if say "SELECT *" instead of "SELECT book.namebook".
I also get the correct results if I add any of the join columns to the SELECT clause. Adding a non-join column, e.g.
SELECT BOOK.namebook, author.nameauthor
FROM book
...gets the wrong results.
For the benefit of anyone who wants to try this:
DROP TABLE author;
create table author AS
SELECT 1 AS idauthor, 'Jose Luiz do Rego' AS nameauthor, 1 AS idcountry FROM dual UNION ALL
SELECT 2, 'Barbara Bela', 2 FROM dual UNION ALL
SELECT 3, 'Juan Domingues', 5 FROM dual UNION ALL
SELECT 4, 'José Mauro de Vasconcelos', 1 FROM dual UNION ALL
SELECT 5, 'Vader', 2 FROM dual UNION ALL
SELECT 6, 'navathe', 4 FROM dual UNION ALL
SELECT 7, 'Machado de Assis', 1 FROM dual
drop table AUTHORSHIP;
CREATE TABLE authorship AS
SELECT 2 AS idauthor, 5 AS idbook FROM dual UNION ALL
SELECT 1 AS idauthor, 1 AS idbook FROM dual UNION ALL
SELECT 5 AS idauthor, 3 AS idbook FROM dual UNION ALL
SELECT 6 AS idauthor, 2 AS idbook FROM dual UNION ALL
SELECT 7 AS idauthor, 4 AS idbook FROM dual UNION ALL
SELECT 7 AS idauthor, 6 AS idbook FROM dual;
drop table book;
CREATE TABLE book AS
SELECT 1 AS idbook, 'book1' AS namebook FROM dual UNION ALL
SELECT 2 AS idbook, 'book2' AS namebook FROM dual UNION ALL
SELECT 3 AS idbook, 'book3' AS namebook FROM dual UNION ALL
SELECT 4 AS idbook, 'book4' AS namebook FROM dual UNION ALL
SELECT 5 AS idbook, 'book5' AS namebook FROM dual UNION ALL
SELECT 6 AS idbook, 'book6' AS namebook FROM dual UNION ALL
SELECT 7 AS idbook, 'book7' AS namebook FROM dual;
DROP TABLE country;
CREATE TABLE country AS
SELECT 1 AS idcountry, 'Brazil' as namecountry FROM dual UNION ALL
SELECT 2 AS idcountry, 'Canada' as namecountry FROM dual UNION ALL
SELECT 3 AS idcountry, 'Chile' as namecountry FROM dual UNION ALL
SELECT 4 AS idcountry, 'Venezuela' as namecountry FROM dual UNION ALL
SELECT 5 AS idcountry, 'USA' as namecountry FROM dual UNION ALL
SELECT 6 AS idcountry, 'Argentina' as namecountry FROM dual ; -
A simple problem with sateful Session beans
Hi,
I have a really novice problem with stateful session bean in Java EE 5.
I have written a simple session bean which has a counter inside it and every time a client call this bean it must increment the count value and return it back.
I have also created a simple servlet to call this session bean.
Everything seemed fine I opened a firefox window and tried to load the page, the counter incremented from 1 to 3 for the 3 times that I reloaded the page then I opened an IE window (which I think is actually a new client) but the page counter started from 4 not 1 for the new client and it means that the new client has access to the old client session bean.
Am I missing anything here???
Isn�t it the way that a stateful session bean must react?
This is my stateful session bean source.
package test;
import javax.ejb.Stateful;
@Stateful
public class SecondSessionBean implements SecondSessionRemote
private int cnt;
/** Creates a new instance of SecondSessionBean */
public SecondSessionBean ()
cnt=1;
public int getCnt()
return cnt++;
And this is my simple client site servlet
package rezaServlets;
import java.io.*;
import java.net.*;
import javax.ejb.EJB;
import javax.servlet.*;
import javax.servlet.http.*;
import test.SecondSessionRemote;
public class main extends HttpServlet
@EJB
private SecondSessionRemote secondSessionBean;
protected void processRequest (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
response.setContentType ("text/html;charset=UTF-8");
PrintWriter out = response.getWriter ();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet main</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Our count is " + Integer.toString (secondSessionBean.getCnt ()) + "</h1>");
out.println("</body>");
out.println("</html>");
out.close ();
protected void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest (request, response);
protected void doPost (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
processRequest (request, response);
}You are injecting a reference to a stateful session bean to an instance variable in the servlet. This bean instance is shared by all servlet request, and that's why you are seeing this odd behavior.
You can use type-leve injection for the stateful bean, and then lookup the bean inside your request-processing method. You may also save this bean ref in HttpSession.
@EJB(name="ejb/foo", beanName="SecondBean", beanInterface="com.foo.foo.SecondBeanRemote")
public MyServlet extends HttpServlet {
ic.lookup("java:comp/env/ejb/foo");
} -
Select distinct problem with muliple join tables, help needed
Hi,
I have two main tables. Each has its of sub joined tables.
guest_id_for_reservation connects two major tables. This has
to be that way
because my guest may change the room status from single to
double (and the
similar exceptional requests).
guests reservation
guest_id_for_reservation
countrytable hoteltable
delegationtable roomtype
I form a query. I want to select distinct those results. But
it does not
work.
If I do not include any table related to reservation table
and its sub
joined tables (disregarding guest_id_for_reservation), it
works.
Is there a specific syntax for select distinct of this type
or any
workaround.?
Thank you
HakanHi I'm still battling with this - have connected the AX to my Imac via ethernet and it shows up fine in Airport Utility. Status light is green and it says its set up to connect to my existing wireless network using wireless connection. Security in Network Preferences is the same for both: WPA2 Personal.
So I don't think there's a problem with the AX, and my current wireless network (BT Home Hub) is working fine.
And when I restore factory settings Airport Utility can see the AX before updating settings so the wireless side of AX must work too.
I'm figuring it must be something about the settings that mean AU can't see it anymore. But I can't work out what, since security is the same.
Any ideas would be great! -
Simple problem with transitions
Hi everyone
I am having a small bit of a problem with transitions....
When I drag a clip from the viewer over the canvas to get the menu bar pop up, and select insert with transition ( cross dissolve ) it puts in a transition but its very short and too fast and when i select it and try to make adjustments it doesn't seem to let me make any changes to the cross dissolve.
I wander what i am doing wrong?
Many thanks TimHi
Just as David Harbsmeier indicates. Handles
Transitions are handled differently in iMovie resp FinalCut.
• iMovie - material that builds the transition is taken from the videoclips = the total length remains same
• FinalCut (as pro- works) . You have to set of a piece of material in each end of the video clips.
This is called In- resp. Out-points. The remaining parts are called Handles
Transitions here are using material from these = Total lenght of movie increase
per transition.
I find books/DVDs by Tom Wolsky - Very valubale - Enjoyed them very much.
• Final Cut Express 4
• Final Cut Pro 6 - DVD course (now probably version 7)
Yours Bengt W -
hi!
i've a problem with user input in my application:
Code:
BufferedReader F_reader = new BufferedReader (new InputStreamReader(System.in));
Fs_line = F_reader.readLine();
My problem is that i've to press the return key for two times, before the JDK returns the line! Does anybody know a better solution with JDK 1.4.2?
thanks for help
mikeit was a mistake of our own implementation! code ist correct! any circumstances are our eval!
thanks mike -
Simple problem with a list initialization.
hello ! i have a class Contact and i would like to make a list of lists of Contact variables .. but when i try to run my code , it says "IndexOutOfBoundsException: Index: 0, Size: 0" . I know that every list of the list must be initialized .. but i don't know how .
here is the declaration of the List
static List<List<Contact>> lolContact=new ArrayList<List<Contact>>();and i know that i should do something like :
lolContact.get(0)=new ArrayList<Contact>();to initialize every list of the list but i don't know how . please helpbadescuga wrote:
and i know that i should do something like :
lolContact.get(0)=new ArrayList<Contact>();
Couple of problems with that.
1. You can never do methodCall() = something in Java. The result of a method call is not an L-value.
2. You're trying to assign a ContactList to a Contact variable. Basically, you're trying to do
Contact c = new ArrayList<Contact>();3. Even if you changed it to
Contact c = lolContact.get(0);
c = new Contact();it would not put anything into the list. That would just copy the first reference in the list and stick it into variable c, so that both c and the first list item point to the same object (remember, the list contains references, not objects--no object or data structure ever contains an object in Java), and then assigns a completely different reference to c, forgetting about the one to the object pointed to by the list. It would not affect the list in any way.
4. You can't do get(0) until you've first put something into the list. -
Probably simple problem with while loops
I was programming something for a CS class and came across a problem I can't explain with while loops. The condition for the loop is true, but the loop doesn't continue; it terminates after executing once. The actual program was bigger than this, but I isolated my problem to a short loop:
import java.util.Scanner;
public class ok {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String antlol = "p";
while(antlol == "p" || antlol == "P"){
System.out.println("write a P so we can get this over with");
antlol = scan.nextLine();
//it terminates after this, even if I type "P", which should make the while condition true.
}Thanks, that worked.
I think my real problem with this program was my CS
teacher, who never covered how to compare strings,Here's something important.
This isn't just about comparing Strings. This applies to comparing ANY objects. When you use == that compares to see if two references refer to the same instance. equals compares objects for equality in the sense that equality means they have equal "content" as it were. -
Problem with outer join with filter on join column
Hi,
In physical layer I have one dimension and two facts, and there's an outer join between the facts.
dim_DATE ,
fact_1 ,
fact_2
Joins:
dim_DATE inner join fact_1 on dim_DATE.DATE = fact_1.DATE
fact_1 left outer join fact_2 on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
When I run a report with a date as a filter, OBIEE executes "optimized" physical SQL:
select fact1.X, fact2.Y
from
Fact_1 left outer join on fact_1.DATE = fact_2.DATE and fact_1.SOME_ID = fact_2.SOME_ID
where Fact_1.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD' )
and Fact_2.DATE = TO_DATE('2009-05-28' , 'YYYY-MM-DD')
The filter on Fact_2.DATE effectively replaces outer join with inner.
Is there a way to disable this "optimization", which is actually very good for inner joins, but doesn't allow outer joins?
Thanks in advance,
Alex
Edited by: AM_1 on Aug 11, 2009 8:20 AMIf you want to perform a Fact-based partitioning with OBIEE (two fact with the same dimension), you have to :
* create in your physical layer for each fact table the joins with the dimension
* create in the Business Model layer ONE star schema with ONE logical fact table containing the columns of your two physical fact table
In this way when you choose minimal one column of your fact1 and one column of your fact2, OBIEE will perform two query against each fact table/dimension, join them with an OUTER JOIN and your problem will disappear.
Cheers
Nico -
Hi all,
Initially I have written a trigger for testing .But im not able to write it as per the requirement.Actually I have written the trigger for a table "test" when a row is inserted into it then my trigger will insert a row in another table.In the same way if an row is UPDATED then that same field of the same row is to be updated in another table.how can I do this by modifying this trigger code.Im in a confusion of doing this.
Table: test.
Name Null? Type
ID NOT NULL NUMBER(38)
UNAME VARCHAR2(15)
PWD VARCHAR2(10)
Table : test123.
Name Null? Type
ID NUMBER
UNAME VARCHAR2(30)
PWD VARCHAR2(30)
the trigger is as follows:
CREATE OR REPLACE TRIGGER inst_trigger
AFTER INSERT OR UPDATE
ON test
FOR EACH ROW
DECLARE
id number;
uname varchar2(20);
pwd varchar2(20);
BEGIN
id := 1245;
uname :='abc';
pwd := 'xyz';
IF INSERTING THEN
INSERT INTO test123 VALUES (id,uname,pwd);
END IF;
END test_trigger;
how can i modify this for the above mentioned use.
Thanks in advance,
Trinath Somanchi,
Hyderabad.Hallo,
naturally , you have not assign values directly in trigger. They come automatically
in trigger with :new - variables.
CREATE OR REPLACE TRIGGER scott.inst_trigger
AFTER INSERT OR UPDATE
ON scott.test
FOR EACH ROW
BEGIN
IF INSERTING THEN
INSERT INTO scott.test123 VALUES (:new.id,:new.uname,:new.pwd);
ELSE
UPDATE scott.test123
set uname = :new.uname, pwd = :new.pwd
where id = :new.id;
END IF;
END inst_trigger;Nicolas, yes, merge here is very effective, but i think, that OP can starts with simpler version von "upsert".
Regards
Dmytro -
I am working with a vWLC on 7.4 code with a 3500i AP on 12.4(23c)JA code. The AP is not joining the controller automatically here is the output from the AP during a join failure,
*Jul 15 09:57:58.000: %CAPWAP-5-DTLSREQSEND: DTLS connection request sent peer_ip: 10.2.98.225 peer_port: 5246
*Jul 15 09:57:59.000: %CAPWAP-5-CHANGED: CAPWAP changed state to
*Jul 15 09:57:59.016: %LWAPP-3-CLIENTERRORLOG: Peer certificate verification failed
*Jul 15 09:57:59.016: %CAPWAP-3-ERRORLOG: Certificate verification failed!
*Jul 15 09:57:59.016: DTLS_CLIENT_ERROR: ../capwap/capwap_wtp_dtls.c:333 Certificate verified failed!
*Jul 15 09:57:59.016: %DTLS-4-BAD_CERT: Certificate verification failed. Peer IP: 10.2.98.225
*Jul 15 09:57:59.016: %DTLS-5-SEND_ALERT: Send FATAL : Bad certificate Alert to 10.2.98.225:5246
*Jul 15 09:57:59.016: %DTLS-3-BAD_RECORD: Erroneous record received from 10.2.98.225: Malformed Certificate
*Jul 15 09:57:59.016: %DTLS-5-SEND_ALERT: Send FATAL : Close notify Alert to 10.2.98.225:5246
*Jul 15 09:57:59.016: %CAPWAP-3-ERRORLOG: Invalid event 38 & state 3 combination.
*Jul 15 09:58:18.881: %CDP_PD-2-POWER_LOW: All radios disabled - NON_CISCO-NO_CDP_RECEIVED (0000.0000.0000)
From my research about this issue I should be able to do debug pm pki enable and get the SSC key hash and join the AP manually to the controller. When I do the debug I do not see the SSC key hash, I only see,
(Cisco Controller) >*sshpmLscTask: Jul 15 09:46:08.268: sshpmLscTask: LSC Task received a message 4
*spamApTask1: Jul 15 09:57:58.190: 50:3d:e5:f0:dc:f1 Discovery Request from 10.2.98.3:3536
*spamApTask1: Jul 15 09:57:58.190: 50:3d:e5:f0:dc:f1 Join Priority Processing status = 0, Incoming Ap's Priority 1, MaxLrads = 200, joined Aps =0
*spamApTask1: Jul 15 09:57:58.190: 50:3d:e5:f0:dc:f1 Discovery Response sent to 10.2.98.3:3536
*spamApTask1: Jul 15 09:57:58.190: 50:3d:e5:f0:dc:f1 Discovery Response sent to 10.2.98.3:3536
*spamApTask1: Jul 15 09:58:09.121: 50:3d:e5:f0:dc:f1 DTLS connection not found, creating new connection for 10:2:98:3 (3536) 10:2:98:225 (5246)
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: called to evaluate <cscoDefaultIdCert>
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 0, CA cert >bsnOldDefaultCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 1, CA cert >bsnDefaultRootCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 2, CA cert >bsnDefaultCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 3, CA cert >bsnDefaultBuildCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 4, CA cert >cscoDefaultNewRootCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 5, CA cert >cscoDefaultMfgCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 0, ID cert >bsnOldDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 1, ID cert >bsnDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 2, ID cert >cscoDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: called to get cert for CID 1234873a
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 0, certname >bsnOldDefaultCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 1, certname >bsnDefaultRootCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 2, certname >bsnDefaultCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 3, certname >bsnDefaultBuildCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 4, certname >cscoDefaultNewRootCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 5, certname >cscoDefaultMfgCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 0, certname >bsnOldDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 1, certname >bsnDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCertFromCID: comparing to row 2, certname >cscoDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: called to evaluate <cscoDefaultIdCert>
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 0, CA cert >bsnOldDefaultCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 1, CA cert >bsnDefaultRootCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 2, CA cert >bsnDefaultCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 3, CA cert >bsnDefaultBuildCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 4, CA cert >cscoDefaultNewRootCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 5, CA cert >cscoDefaultMfgCaCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 0, ID cert >bsnOldDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 1, ID cert >bsnDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetCID: comparing to row 2, ID cert >cscoDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetSshPrivateKeyFromCID: called to get key for CID 1234873a
*spamApTask1: Jul 15 09:58:09.121: sshpmGetSshPrivateKeyFromCID: comparing to row 0, certname >bsnOldDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetSshPrivateKeyFromCID: comparing to row 1, certname >bsnDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetSshPrivateKeyFromCID: comparing to row 2, certname >cscoDefaultIdCert<
*spamApTask1: Jul 15 09:58:09.121: sshpmGetSshPrivateKeyFromCID: match in row 2
*spamApTask3: Jul 15 09:58:09.139: 50:3d:e5:f0:dc:f1 DTLS connection closed event receivedserver (10:2:98:225/5246) client (10:2:98:3/3536)
*spamApTask3: Jul 15 09:58:09.139: 50:3d:e5:f0:dc:f1 No entry exists for AP (10:2:98:3/3536)
*spamApTask3: Jul 15 09:58:09.139: 50:3d:e5:f0:dc:f1 No AP entry exist in temporary database for 10.2.98.3:3536
What else can I try to get this AP to join the controller??
Thank you."configure certificate ssc hash validation disable" didn't help, same problems
I tried to add the AP by its MAC and MIC to the authorized APs list but it just tells me "
50:3d:e5:f0:dc:f1 No AP entry exist in temporary database for 10.2.98.3:3536"
The SSC key Hash still doesn't show in the debug output. What else can I try? -
2 problem with BITMAP JOIN INDEX and access plan
On my schema ("LSA") I have 3 tables:
AAB_VENDUTO (~4.200.000 record)
AAB_ARTICOLO (~8.200 record)
AAB_CLIENTE (~15.000 record)
AAB_ARTICOLO.MARCA has 1079 distinct values
AAB_CLIENTE.TITOLO_STUDIO has 22 distinct values
I create 2 different bitmap join index:
CREATE BITMAP INDEX lsa.AAB_V_ARTICOLO_MARCA_IDX ON LSA.AAB_VENDUTO(MARCA)
FROM LSA.AAB_VENDUTO vv, LSA.AAB_ARTICOLO aa WHERE vv.articolo_id=aa.articolo_id;
CREATE BITMAP INDEX lsa.AAB_V_CLIENTE_TIT_STUDIO_IDX ON LSA.AAB_VENDUTO(TITOLO_STUDIO)
FROM LSA.AAB_VENDUTO vv, LSA.AAB_CLIENTE cc WHERE vv.cliente_id=cc.cliente_id;(star_trasformation_enabled is TRUE)
I run (on SQL Developer 1.5.5) these similar queries:
SELECT DISTINCT VV.cliente_id FROM LSA.AAB_VENDUTO VV JOIN LSA.AAB_ARTICOLO AA on VV.articolo_id=AA.articolo_id
WHERE (MARCA='ALGIDA' OR MARCA='SAMMONTANTA');
SELECT DISTINCT VV.cliente_id FROM LSA.AAB_VENDUTO VV JOIN LSA.AAB_CLIENTE CC on VV.cliente_id=CC.cliente_id
WHERE (titolo_studio='LAUREA BREVE' OR titolo_studio='MAGISTRALE');The first one use correctly the bitmap join index, this is the access plan:
!http://bitlgs.altervista.org/_altervista_ht/marca.png!
but the second query...
!http://bitlgs.altervista.org/_altervista_ht/titolo_studio.png!
why the second query doesn't use the bitmap index?
problem #2:
I create another bitmap index:
CREATE BITMAP INDEX LSA.AAB_V_CLIENTE_SESSO_IDX ON LSA.AAB_VENDUTO(SESSO)
FROM LSA.AAB_VENDUTO vv, LSA.AAB_CLIENTE cc WHERE vv.cliente_id=cc.cliente_id;and I run this query:
SELECT VV.cliente_id, COUNT(*) FROM LSA.AAB_VENDUTO VV JOIN LSA.AAB_CLIENTE CC on VV.cliente_id=CC.cliente_id
WHERE sesso='Donna' and (titolo_studio='LAUREA BREVE' or titolo_studio='MAGISTRALE') GROUP BY VV.cliente_id;this is the access plan:
!http://bitlgs.altervista.org/_altervista_ht/terzo.png!
In my opinion, the part that I have marked as 'A' is superfluous...
why it make a join with AAB_CLIENTE table? Why it filter again the titolo_studio and sesso field?
Edited by: Nirpol on 4-set-2009 13.25Nirpol wrote:
I create 2 different bitmap join index:
CREATE BITMAP INDEX lsa.AAB_V_ARTICOLO_MARCA_IDX ON LSA.AAB_VENDUTO(MARCA)
FROM LSA.AAB_VENDUTO vv, LSA.AAB_ARTICOLO aa WHERE vv.articolo_id=aa.articolo_id;
CREATE BITMAP INDEX lsa.AAB_V_CLIENTE_TIT_STUDIO_IDX ON LSA.AAB_VENDUTO(TITOLO_STUDIO)
FROM LSA.AAB_VENDUTO vv, LSA.AAB_CLIENTE cc WHERE vv.cliente_id=cc.cliente_id;
What happens if you just create two plain bitmap indexes without the join?
CREATE BITMAP INDEX lsa.AAB_V_ARTICOLO_MARCA_IDX ON LSA.AAB_VENDUTO(MARCA);
CREATE BITMAP INDEX lsa.AAB_V_CLIENTE_TIT_STUDIO_IDX ON LSA.AAB_VENDUTO(TITOLO_STUDIO) ;You can also go with normal indexes on the FK rows (cliente_id) and the optimizer can do a bitmap conversion from normal index to bitmap index if needed. Are the column values evenly distributed? If not you might need to go for some column histogram. but I don't have the impression that this is really useful in your case. -
Problem with outer join/insert
I created a test case in scott schema that describes my problem. I use emp table, and I want to have one more table - emp_info - that will store some additional info about employees. Not every employee will have additional info. I can't add a field to emp table - this has to be in an additional table.
I want to display all the emp's in a swing table, and an info if it exists - of course, using outer join. Further more, I want users to be able to enter info in this same table. If info already exists in the emp_info it will be updated, if not a new record is created.
I hope you get the picture.
So, emp_info table is:
create table emp_info(empno number(4), info varchar2(10))
ALTER TABLE "SCOTT"."EMP_INFO"
ADD (CONSTRAINT "PK_EMP_INFO" PRIMARY KEY("EMPNO"))
ALTER TABLE "SCOTT"."EMP_INFO"
ADD (CONSTRAINT "FK_EMP_INFO_EMP" FOREIGN KEY("EMPNO")
REFERENCES "SCOTT"."EMP"("EMPNO"))
In Jdev I create entitiy objects for emp and emp_info, and create View object 'ViewOuter' using these two entities. emp is updatable and empinfo is updatable and reference.
SQL query for the view object is:
SELECT Emp.EMPNO, Emp.ENAME, Emp.JOB, Emp.MGR, Emp.HIREDATE,
Emp.SAL, Emp.COMM, Emp.DEPTNO, EmpInfo.EMPNO AS EMPNO1,
EmpInfo.INFO
FROM EMP Emp, EMP_INFO EmpInfo
WHERE Emp.EMPNO = EmpInfo.EMPNO(+)
I changed View row class of the ViewOuter view:
public void setInfo(String value) {
if (getEmpno1()==null) {
setEmpno1(getEmpno());
setAttributeInternal(INFO, value);
Now I create the table in swing. It works fine - if a user changes info, new record is created or existing updated etc. There is only one problem:
If I change info on an employee, and then requery the view without commiting to the database, I don't see this info. If I try to change it, I get error
(oracle.jbo.TooManyObjectsException) JBO-25013: Too many objects match the primary key oracle.jbo.Key[7499 ].
It seams that the new info is cached, but requerying the view didn't pick it up. And when it creates new row for info PK is violated.
How can I avoid this?I set up the primari key for emp_info like this:
public void setInfo(String value) {
if (getEmpno1()==null) {
setEmpno1(getEmpno());
setAttributeInternal(INFO, value);
It's set when the user enters info.
What is the difference between transaction.commit and transaction.postChanges?
Posting changes looks like good temp solution. How can I change view object, so it calls postchanges before executing query? Since I can do requery on multiple places in application, this should be handled by the view itself.
Is there any better way? -
Problem with outer joins and the class indicator/discriminator
Hello,
I am having a problem defining a query in toplink (10.1.3.3).
In the workbench, I have created a parent and 2 child descriptors. The parent is "AbstractValue", the children are "DefaultValue", classified by the discriminator 'DEF', and "OverrideValue", classified by 'OVR', both located in the same table.
Another descriptor (containing a one-on-one mapping to both a "DefaultValue", and a "OverrideValue") needs to be queried for its 'value'.
The way the query should act is: If an override value (row) exists, this one applies for that object. If an override doesn't exist, return the default value.
The query then comes down to (as I have it now):
builder.getAllowingNull("OverrideValue").getAllowingNull("value").ifNull(builder.get("DefaultValue").get("value")).equal(builder.getParameter(VALUE_PARAM));
The problem is that toplink adds the distinction for the different kind of "values" in the where clause WITHOUT checking for null values e.g. it performs an outer join, but then still checks for the discriminator value thus
....t1.ovr_id = t2.id(+) AND t2.discriminator = 'OVR' AND ...
instead of
... LEFT JOIN values t2 ON (t1.ovr_id = t2.id AND t2.discriminator = 'OVR') ...
This leads to the behaviour that the query returns ONLY the objects that have override and default values.
An overview of the queries (simplified)
Toplink, at the moment, returns only results if both override and default values exists:
SELECT t1.id
t1.def_id,
t1.ovr_id
FROM values t2,
parameter t1,
values t0
WHERE nvl(t2.value, t0.value) = 15 AND
t1.ovr_id = t2.id(+) AND t2.discriminator = 'OVR' AND
t1.def_id = t0.id AND t0.discriminator = 'DEF'
Situation Wanted:
SELECT t1.id
t1.def_id,
t1.ovr_id
FROM parameter t1
LEFT JOIN values t2 ON (t1.ovr_id = t2.id AND t2.discriminator = 'OVR')
JOIN values t0 ON (t1.def_id = t0.id AND t0.discriminator = 'DEF')
WHERE nvl(t2.value, t0.value) = 15
Anyone know if there is some statement I am missing to allow an actual outer join on descriptors containing class indicators/discriminators? A possible rewrite?
Thanks in advance,
RudyThis is a bug in TopLink's outer join support for Oracle. Currently the outer join is put in the where clause, instead of the from clause, as we do on other platforms. You might be able to fix it by changing your OraclePlatform to return false for shouldPrintOuterJoinInWhereClause().
Please log this bug on EclipseLink, or through Oracle technial support.
There is a workaround using,
descriptor.getInhertiancePolicy().setAlwaysUseOuterJoinForClassType(true);
James : http://www.eclipselink.org -
Simple problem with popup message before adding document on system form
Hi all,
We have an AddOn that validates price lines on system Sales Order form matrix, so that if prices fall below a certain value, a popup is show to ask to continue or not, when user presses ADD button.
The problem is that if he chooses yes (to continue), the Sales Order is not added since the button ADD keeps being selected ....
Here is my code:
[B1Listener(BoEventTypes.et_CLICK, true)]
public virtual bool OnBeforeClick(ItemEvent pVal)
int iResult = B1Connections.theAppl.MessageBox("Price lines fall bellow minimum! Continue?", 1, "NO", "YES", "");
if (iResult == 1) // NO
// Show error
B1Connections.theAppl.StatusBar.SetText("OK", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
return false;
// YES: Continue to add Sales Order
return true;
The problem is somehow related with the popup message being shown: if user says YES to continue, the system form does not continue with the standard process of adding the Sales Order (when I move the cursor above the ADD button is shows it already pressed...).
Do I have to do anything more to force the process to continue, when the user says YES?
Regards,
Manuel DiasThtas known problem. The solution for this is declare global variable as boolean, when user selects Yes, then set this variable to true and emulate click to add button again where before the message box check if its varaible sets to true - in this case dont show message box, only set variable to false.
The concept of code will be
dim continue as boolean = false
in item event
if continue = false then
x = messagebox...
if x = 1 then
continue = true
items.item("1").click
end if
else
continue = false
end if
Maybe you are looking for
-
Firefox with proxy configured keeps on asking for username and password
This was asked a while ago, but no solution every posted. I use FF at work with a proxy. When I upgraded to FF28, an "old" problem came back - FF constantly pops up a window saying the Proxy is asking for a username and password. I did nit have this
-
MacBok pro Audio line in port doesn't work for microphone input Why?
I turn line-in port on in System preferences/sound but no reaction. Using within third party applications like Hear or Amadeus the recording via head set microphone is without problem. What is wrong with the Mac os ?
-
How to install elements 11 on mac?!?
i tried to install elements 11 but it doesn't work. Always the same message. What am i doing wrong?
-
After your most recent update to Firefox, I can no longer use Roboform in your browser which renders Firefox USELESS to me as a browser...WHY?
-
Number range interval doesnot exists - error message while generating numbe
Hi Experts!, I am getting error as " Number Range interval does not exists" while generating auto number for an custom defined tr cod The prg is as followos: INCLUDE MZFIRSTPAGETOP . " global Data TABLES: