Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

simple select?

396476Aug 29 2007 — edited Aug 29 2007
Hi,

I've been attempting to select (for example) the people of which all projects are older than 1 year and of which all projects also have an inactive state (state 3 and 4). I'm pretty sure this can be done in one select, but how?????? Can someone assist?

CREATE TABLE PROJECT (
id_project NUMBER(1),
person VARCHAR2(10),
id_state NUMBER(1),
last_update DATE
);

INSERT INTO PROJECT VALUES (1, 'Joe', 3, TO_DATE('08-08-2007','MM-DD-YYYY'));
INSERT INTO PROJECT VALUES (2, 'Mark', 2, TO_DATE('07-05-2007','MM-DD-YYYY'));
INSERT INTO PROJECT VALUES (3, 'Mark', 3, TO_DATE('06-27-2007','MM-DD-YYYY'));
INSERT INTO PROJECT VALUES (4, 'Mark', 4, TO_DATE('03-14-2007','MM-DD-YYYY'));
INSERT INTO PROJECT VALUES (5, 'Carl', 3, TO_DATE('12-08-2004','MM-DD-YYYY'));
INSERT INTO PROJECT VALUES (6, 'Carl', 4, TO_DATE('01-22-2005','MM-DD-YYYY'));
INSERT INTO PROJECT VALUES (7, 'Sam', 2, TO_DATE('06-15-2006','MM-DD-YYYY'));
INSERT INTO PROJECT VALUES (8, 'Paul', 1, TO_DATE('07-30-2007','MM-DD-YYYY'));
INSERT INTO PROJECT VALUES (9, 'Paul', 2, TO_DATE('06-02-2006','MM-DD-YYYY'));

So in this case the select should only return the name Carl as both his projects are inactive and both are older than one year.

All I got this far is a statement which retrieves the people of which all projects are older than one year. How do I extend this so it will limit the result to the people of which all projects are also inactive (state 3 and 4)? Being only Carl, as Sams project is still active.

SQL> SELECT person, COUNT(id_project), MAX(last_update)
2 FROM PROJECT
3 GROUP BY person
4 HAVING MAX(last_update) < ADD_MONTHS(SYSDATE,-12)
5 ORDER BY 1;

PERSON COUNT(ID_PROJECT) MAX(LAST_
---------- --------------------------------- -----------------
Carl 2 22-JAN-05
Sam 1 15-JUN-06

Comments

Anuj Dwivedi-Oracle
Answer
Hi,

Can you provide more details? Which driver are you using? Is it XA or non-XA? If you are using XA then try using non-xa.

Cross post this question in SOA suite forum as well -

3322

Regards,
Anuj
Marked as Answer by user626262 · Sep 27 2020
user626262
thanks anuj . It worked while we created a non XA db source. Any specific reason why it worked while using NON XA ?
Anuj Dwivedi-Oracle
ORA-24777: use of non-migratable database link not allowed
Cause: The transaction, which needs to be migratable between sessions, tried to access a remote database from a non-multi threaded server process.
Action: Perform the work in the local database or open a connection to the remote database from the client. If multi threaded server option is installed, connect to the Oracle instance through the dispatcher.

An XA transaction involves a coordinating transaction manager, with one or more databases (or other resources, like JMS) all involved in a single global transaction. Non-XA transactions have no transaction coordinator, and a single resource is doing all its transaction work itself (this is sometimes called local transactions).

Regards,
Anuj
596264
I really just want to use one generic adapter, with XA transaction enabled, for all of my database connections. I have a simple BPEL process that selects data - why should I have to use a non-XA datasource for this process? Are there any other workarounds for this? Some way of forcing a transaction manager for single transactions maybe?
1 - 4
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Sep 26 2007
Added on Aug 29 2007
8 comments
4,742 views