Derived tables and Order by clause
Hi,
I have a query that looks as below.
The execution time of the query (10 sec) is fine when order by clause is removed from the query. But with order by clause, the execution time is 40 times more(400 sec). How to optimize this query so that it will execute within a minute, with ORDER BY clause included?
select X.a1, X.a2, X.a3, X.a4, Y.b1, Y.b2, Y.b3
from (select A.a1 a1, A.a2 a2, A.a3 a3, A.a4 a4
from A_table A
where A.a1 = 'something') X,
(select B.b1 b1, B.b2 b2, B.b3 b3
from B_table B
where B.b1 = 'some') Y
where
X.a1 = Y.a1 (+) AND (some other conditions)
order by X.a1, X.a2, Y.b1, Y.b2, X.a3, X.a4
thanks in advance,
Venkat
You do need the inline view Y if you are outer joining it because you must apply the
where B.b1 = 'some'
condition first.
However, the inline view X is not needed. Still, I'm not sure that getting rid of it is going to improve performance. Try it and see.
Incidentally, the outer join condition
where X.a1 = Y.a1 (+)
refers to Y.a1, but the inline view Y has no column named a1. Did you mean Y.b1?
What are the "some other conditions"? Do any of them involve the inline view Y alone (that is, are not join conditions)? If so, it may be that either: a) you don't need an outer join, or, b) those conditions should be moved into the inline view Y. In either case, this may improve performance.
Are you sure the execution time without the order by clause is really 10 seconds? Or, is that just the elapsed time to return the first row? With the order by clause, Oracle must identify all the rows before it can return the first row.
Similar Messages
-
How to use left outer joins ,right outer joins and order by clause for belo
Hi,
How to use left outer joins ,right outer joins and order by clause for below XML query.
The query which is red colour returns null then its not displaying any values for columns in that tables. Tried decode, nvl function hasn't worked.
SELECT XMLAGG ( XMLELEMENT( "P", XMLFOREST( P.process_id AS Ppid,
(SELECT XMLAGG( XMLELEMENT( "PI", XMLFOREST( PI.question_id AS PIqid,
PI.process_id AS PIpid,
PI.innertext AS
PItext, PI.itemtype AS PItype,
PI.linkfrom AS PIfrom,
PI.linkto AS PIto,
PI.associated AS PIas,
PI.content_id AS PIc,
PI.exitpoint1_id AS PIe1,
PI.exitpoint2_id AS PIe2,
PI.exitpoint3_id AS PIe3,
PI.followoncall AS PIfoc,
PI.userinput AS PIui,
PI.resolveidentifier AS PIri,
PI.libquestion_idfk AS PIlqid,
PI.isLocked AS PIstls,
PI.PreviousAnswer AS PIPAns,
PI.VisibleToAgent AS PIVAgent,
PI.RetryAttempt AS PIRetry,
PI.Tags AS PITag,
SELECT XMLAGG( XMLELEMENT( "PO", XMLFOREST( PO.option_id AS POoid,
PO.question_id AS POqid,
PO.process_id AS popid,
PO.opt_innertext AS POtext,
PO.opt_linkfrom AS POfrom,
PO.opt_linkto AS POto,
PO.libquestion_idfk AS POlqid,
PO.liboption_idfk AS POloid ) ) )
FROM vw_liveProcessOption_Sim_v6 PO
WHERE PI.question_id = PO.question_id (+)
AND PI.process_id = PO.process_id (+)
) "A" ) ) ) AS "PO"
FROM vw_liveProcessItem_Sim_v6 PI
WHERE P.process_id = PI.process_id
) "A" ) ) ) AS "PI"
FROM liveProcess_ec P
WHERE (P.process_id = 450)
Any help really appreciated.
Thanksuser512743 wrote:
Hi,
Here below is the scripts of tables, insert statements and Required output.
CREATE TABLE VW_LIVEPROCESSOPTION_SIM_v6
( "OPTION_ID" NUMBER,
"QUESTION_ID" NUMBER(10,0),
"PROCESS_ID" NUMBER(10,0),
"OPT_INNERTEXT" VARCHAR2(200 CHAR),
"OPT_LINKFROM" VARCHAR2(20 CHAR),
"OPT_LINKTO" VARCHAR2(20 CHAR),
"LIBQUESTION_IDFK" NUMBER,
"LIBOPTION_IDFK" NUMBER
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,2,450,'Yes',null,'5',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,3,450,'Yes',null,'5',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,5,450,'Yes',null,'6',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,6,450,'Yes',null,'7',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,8,450,'Block All',null,'9',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,9,450,'Yes',null,'10',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,11,450,'Yes',null,'12',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,12,450,'Yes',null,'13',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,14,450,'Yes',null,'16',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,2,450,'No',null,'3',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,3,450,'No',null,'4',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,5,450,'No',null,'8',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,6,450,'No',null,'8',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,8,450,'Standard',null,'11',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,9,450,'No',null,'11',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,11,450,'No',null,'14',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,12,450,'No',null,'14',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,14,450,'No',null,'15',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (3,8,450,'Disabled',null,'12',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (4,8,450,'User Defined',null,'12',null,null);
REATE TABLE "VW_LIVEPROCESSITEM_SIM_v6"
( "QUESTION_ID" NUMBER(10,0),
"PROCESS_ID" NUMBER(10,0),
"INNERTEXT" VARCHAR2(200 CHAR),
"ITEMTYPE" VARCHAR2(50 CHAR),
"LINKFROM" VARCHAR2(500 CHAR),
"LINKTO" VARCHAR2(500 CHAR),
"ASSOCIATED" VARCHAR2(200 CHAR),
"CONTENT_ID" NUMBER,
"EXITPOINT1_ID" NUMBER(10,0),
"EXITPOINT2_ID" NUMBER(10,0),
"EXITPOINT3_ID" NUMBER(10,0),
"RESOLVEIDENTIFIER" VARCHAR2(40 CHAR),
"LIBQUESTION_IDFK" NUMBER(10,0),
"FOLLOWONCALL" NUMBER(1,0),
"USERINPUT" VARCHAR2(200 CHAR),
"ISLOCKED" NUMBER(1,0),
"PREVIOUSANSWER" NUMBER(1,0),
"VISIBLETOAGENT" NUMBER(1,0),
"RETRYATTEMPT" NUMBER(10,0),
"TAGS" VARCHAR2(50 BYTE)
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (1,450,'CBB1015 - Router Firewall Settinngs Process','Title',null,'2',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (2,450,'Is the customers PC Firewall turned off?','Question','1','2.2,2.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (3,450,'Advise the customer to turn off the PC Firewall in order to continue. Has this been done?','Question','2.2','3.2,3.1',null,278,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (4,450,'Advise the customer the PC Firewall must be switched off before this process????','ExitPoint','3.2',null,null,null,14,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (5,450,'Is the customer able to access the internet now?','Question','3.1,2.1','5.2,5.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (6,450,'Is the customer having a problem with a specific website?','Question','5.1','6.2,6.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (7,450,'1536: CBB1008 - Browser Setup and Daignostics','SubProcess','6.1',null,'1536-1-0',null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (8,450,'What is the security level on the CPE Management page?','Question','6.2,5.2','8.4,8.3,8.2,8.1',null,279,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (9,450,'Change the security level to Standard. Does this resolve the customers issue?','Question','8.1','9.2,9.1',null,280,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (10,450,'Issue Resolved','ExitPoint','9.1',null,null,null,1,6,122,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (11,450,'Change the security level to Disabled. Is the customer able to browse the internet?','Question','9.2,8.2','11.2,11.1',null,281,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (12,450,'Change the security level to Standard. Is the customer able to browse the internet now?','Question','11.1,8.3,8.4','12.2,12.1',null,283,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (13,450,'Issue Resolved','ExitPoint','12.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (14,450,'Ask the customer to perform a master reset. Does this resolve their issue?','Question','12.2,11.2','14.2,14.1',null,282,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (15,450,'Faulty CPE','ExitPoint','14.2',null,null,null,1,6,124,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (16,450,'Issue Resolved','ExitPoint','14.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
CREATE TABLE "LIVEPROCESS_EC_V"
( "PROCESS_ID" NUMBER(10,0),
"USER_ID" NUMBER(10,0),
"CREATED" TIMESTAMP (6)
Insert into LIVEPROCESS_EC (PROCESS_ID,USER_ID,CREATED) values (450,7460,to_timestamp('21-APR-08 09.34.41.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'));
Required O/P in XML format
<P>
<Ppid>450</Ppid>
<PI>
<PIqid>1</PIqid>
<PIpid>450</PIpid>
<PItext>CBB1015 - Router Firewall Settinngs Process</PItext>
<PItype>Title</PItype>
<PIto>2</PIto>
<PO />
</PI>
<PI>
<PIqid>2</PIqid>
<PIpid>450</PIpid>
<PItext>Is the customers PC Firewall turned off?</PItext>
<PItype>Question</PItype>
<PIfrom>1</PIfrom>
<PIto>2.2,2.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>2</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>5</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>2</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>3</POto>
</PO>
</PI>
<PI>
<PIqid>3</PIqid>
<PIpid>450</PIpid>
<PItext>Advise the customer to turn off the PC Firewall in order to continue. Has this been done?</PItext>
<PItype>Question</PItype>
<PIfrom>2.2</PIfrom>
<PIto>3.2,3.1</PIto>
<PIc>278</PIc>
<PO>
<POoid>1</POoid>
<POqid>3</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>5</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>3</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>4</POto>
</PO>
</PI>
<PI>
<PIqid>4</PIqid>
<PIpid>450</PIpid>
<PItext>Advise the customer the PC Firewall must be switched off before this process????</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>3.2</PIfrom>
<PIe1>14</PIe1>
<PO />
</PI>
<PI>
<PIqid>5</PIqid>
<PIpid>450</PIpid>
<PItext>Is the customer able to access the internet now?</PItext>
<PItype>Question</PItype>
<PIfrom>3.1,2.1</PIfrom>
<PIto>5.2,5.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>5</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>6</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>5</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>8</POto>
</PO>
</PI>
<PI>
<PIqid>6</PIqid>
<PIpid>450</PIpid>
<PItext>Is the customer having a problem with a specific website?</PItext>
<PItype>Question</PItype>
<PIfrom>5.1</PIfrom>
<PIto>6.2,6.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>6</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>7</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>6</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>8</POto>
</PO>
</PI>
<PI>
<PIqid>7</PIqid>
<PIpid>450</PIpid>
<PItext>1536: CBB1008 - Browser Setup and Daignostics</PItext>
<PItype>SubProcess</PItype>
<PIfrom>6.1</PIfrom>
<PIas>1536-1-0</PIas>
<PO />
</PI>
<PI>
<PIqid>8</PIqid>
<PIpid>450</PIpid>
<PItext>What is the security level on the CPE Management page?</PItext>
<PItype>Question</PItype>
<PIfrom>6.2,5.2</PIfrom>
<PIto>8.4,8.3,8.2,8.1</PIto>
<PIc>279</PIc>
<PO>
<POoid>1</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POtext>Block All</POtext>
<POto>9</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POtext>Standard</POtext>
<POto>11</POto>
</PO>
<PO>
<POoid>3</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POtext>Disabled</POtext>
<POto>12</POto>
</PO>
<PO>
<POoid>4</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POtext>User Defined</POtext>
<POto>12</POto>
</PO>
</PI>
<PI>
<PIqid>9</PIqid>
<PIpid>450</PIpid>
<PItext>Change the security level to Standard. Does this resolve the customers issue?</PItext>
<PItype>Question</PItype>
<PIfrom>8.1</PIfrom>
<PIto>9.2,9.1</PIto>
<PIc>280</PIc>
<PO>
<POoid>1</POoid>
<POqid>9</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>10</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>9</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>11</POto>
</PO>
</PI>
<PI>
<PIqid>10</PIqid>
<PIpid>450</PIpid>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>9.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>122</PIe3>
<PO />
</PI>
<PI>
<PIqid>11</PIqid>
<PIpid>450</PIpid>
<PItext>Change the security level to Disabled. Is the customer able to browse the internet?</PItext>
<PItype>Question</PItype>
<PIfrom>9.2,8.2</PIfrom>
<PIto>11.2,11.1</PIto>
<PIc>281</PIc>
<PO>
<POoid>1</POoid>
<POqid>11</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>12</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>11</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>14</POto>
</PO>
</PI>
<PI>
<PIqid>12</PIqid>
<PIpid>450</PIpid>
<PItext>Change the security level to Standard. Is the customer able to browse the internet now?</PItext>
<PItype>Question</PItype>
<PIfrom>11.1,8.3,8.4</PIfrom>
<PIto>12.2,12.1</PIto>
<PIc>283</PIc>
<PO>
<POoid>1</POoid>
<POqid>12</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>13</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>12</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>14</POto>
</PO>
</PI>
<PI>
<PIqid>13</PIqid>
<PIpid>450</PIpid>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>12.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>123</PIe3>
<PO />
</PI>
<PI>
<PIqid>14</PIqid>
<PIpid>450</PIpid>
<PItext>Ask the customer to perform a master reset. Does this resolve their issue?</PItext>
<PItype>Question</PItype>
<PIfrom>12.2,11.2</PIfrom>
<PIto>14.2,14.1</PIto>
<PIc>282</PIc>
<PO>
<POoid>1</POoid>
<POqid>14</POqid>
<popid>450</popid>
<POtext>Yes</POtext>
<POto>16</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>14</POqid>
<popid>450</popid>
<POtext>No</POtext>
<POto>15</POto>
</PO>
</PI>
<PI>
<PIqid>15</PIqid>
<PIpid>450</PIpid>
<PItext>Faulty CPE</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>14.2</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>124</PIe3>
<PO />
</PI>
<PI>
<PIqid>16</PIqid>
<PIpid>450</PIpid>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>14.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>123</PIe3>
<PO />
</PI>
</P>
Thanks in advance
Edited by: user512743 on Nov 18, 2008 4:46 AM -
Hi,
I have wriiten the below query and i am using group by and order by clause....but i am not getting the required result
SELECT b.ACCOUNT_REGION,CASE WHEN b.product_reference_status='Reference' THEN 'Recruited' WHEN b.product_reference_status in ('Inactive','Declined') THEN 'Inactive' WHEN b.product_reference_status ='Nominate' THEN 'Inprogress' ELSE 'Other' END product_reference_status, COUNT(decode(b.product_quarter,'Q1FY09',b.REFERENCE_ID)) Q1FY09, COUNT(decode(b.product_quarter,'Q2FY09',b.REFERENCE_ID)) Q2FY09, COUNT(decode(b.product_quarter,'Q3FY09',b.REFERENCE_ID)) Q3FY09, COUNT(decode(b.product_quarter,'Q4FY09',b.REFERENCE_ID)) Q4FY09, COUNT(decode(b.product_quarter,'Q1FY10',b.REFERENCE_ID)) Q1FY10, COUNT(decode(b.product_quarter,'Q2FY10',b.REFERENCE_ID)) Q2FY10, COUNT(decode(b.product_quarter,'Q3FY10',b.REFERENCE_ID)) Q3FY10, COUNT(decode(b.product_quarter,'Q4FY10',b.REFERENCE_ID)) Q4FY10, COUNT(b.product_quarter) Total
FROM refdump a, ref_dh_pr b
WHERE A.REFERENCE_ID=b.REFERENCE_ID AND (b.CREATED_ON - NVL(a.REFERENCE_DATE,a.CREATED))>15 group by b.account_region,product_reference_status order by 2
output is as given below
Region Status Count
LAD Inactive 0
EMEA Inactive 21
*APAC Inactive 2
*APAC Inactive 1
EMEA Inactive 2
EMEA Inprogress 220
LAD Inprogress 19
LAD Other 2
LAD Other 0
LAD Other 5
LAD Recruited 182
APAC Recruited 191
My question is
1) Why i am geeting two APAC regions and 3 LAD (marked *) regions when i have grouped by region and status
2) How can i make the status in the following order
a) Recruited
b)Inprogress
c)Inactive
d)Other
Thanks,<i>group by b.account_region,product_reference_status</i>
Just take all the columns in the group by clause in your select segment and run the SQL, you'll come to know abt the different values in columns which group together.
*009* -
Materialized view and Order by clause
Hi all. I'd like to have some information regarding the order by clause used in a materialized view.
I'm using Oracle 9.2 and Win2003 server. I have a common view (my_common_view) on which a materialized view is based (my_materialized_view). Materialized view is built for fast refresh and is created in this way:
create materialized view my_materialized_view as
select * from my_common_view
order by 1,2,3;
My question is: if I query this materialized view without adding an order by clause in the statement, I will obtain always an ordered result set? So, is it useful to include the order by clause in the materialized view script or the order by has to be include in the statement used for quering the materialized view (for example like this: select * from my_materialized view order by ...)?
Thank you very much.
Ste.SQL> create table t
2 (x int)
3 /
Table created.
SQL> create view vw
2 as
3 select *
4 from t
5 order by x
6 /
View created.
SQL> select *
2 from v$version
3 /
BANNER
Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
PL/SQL Release 9.2.0.7.0 - Production
CORE 9.2.0.7.0 Production
TNS for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production
NLSRTL Version 9.2.0.7.0 - Production
SQL> -
PreparedStatement and order by clause
Hi all,
I'm having a strange problem, when I try to use a preparedStatement which has a parameter in the order by clause the query ignores the order by clause and returns the data in the default table order.
I'm trying to allow the enduser the ability to sort the results in any way they like.
a sample of code is:
javax.sql.DataSource dataSource;
java.sql.Connection myConnection = null;
String sort_order = null;
sort_order = request.getParameter("sort_order");
if(sort_order == null) {
sort_order = "start_date, hostname";
String sql = (String)Tokens.getInstance().getSQLProps().get(Tokens.FIND_SCHED);
try {
dataSource = getDataSource(request);
myConnection = dataSource.getConnection();
PreparedStatement pstmt = myConnection.prepareStatement(sql);
pstmt.setString(1, (Tokens.getInstance().getProps().getProperty(Tokens.CURRENT)));
pstmt.setString(2, sort_order);
ResultSet rset = pstmt.executeQuery();
thanks for any help you can provideYou cannot use bind variables for column names. In this case, what you are telling Oracle to do is to sort by the literal string 'start_date, hostname', which (since the literal string is the same for every row) has no effect. If you want Oracle to sort by the values in those columns, you would have to have different versions of the query depending on the ORDER BY clause. In this case, you would probably want to append the ORDER BY clause to your base SQL statement rather than trying to pass the ORDER BY clause in as a bind variable.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Sys_context and Order by clause
Hi All,
Im using Oracle 11g R2.
Is it somehow possible to use Context variable (to store column name) in ORDER BY clause? My ultimate aim is to construct Order by at runtime without using concatenation.
e.g. i created context as my_ctx for some pkg and its variable as v_ctx having value set as "TABLE_NAME"
so is it possible to use it as
select * from all_tables
order by sys_context('my_ctx', 'v_ctx');
if no, is there any work around??
Thanks,
VivekHi, Vivek,
Vivek wrote:
Hi All,
Im using Oracle 11g R2.
Is it somehow possible to use Context variable (to store column name) in ORDER BY clause? My ultimate aim is to construct Order by at runtime without using concatenation.Sure, you can use SYS_CONTEXT in an ORDER BY clause, but it's unclear what you're trying to do, so I don't know if SYS_CONTEXT will help you.
e.g. i created context as my_ctx for some pkg and its variable as v_ctx having value set as "TABLE_NAME"
so is it possible to use it as
select * from all_tables
order by sys_context('my_ctx', 'v_ctx');
if no, is there any work around??Post a complete test script hat people can run to re-create the problem and test their ideas. Show the output you want from the parameters an data you give.
Think about using a CASE expression in the ORDER BY clause. You can use SYS_CONTEXT in the CASE expression if you want to. -
Session Context Variable and Order by clause
Hi All,
Im using Oracle 11g R2.
Is it somehow possible to use Context variable (to store column name) in ORDER BY clause? My ultimate aim is to construct Order by at runtime without using concatenation.
e.g. i created context as my_ctx for some pkg and its variable as v_ctx having value set as "TABLE_NAME"
so is it possible to use it as
select * from all_tables
order by sys_context('my_ctx', 'v_ctx');
if no, is there any work around??
Thanks,
Vivekits better to post here
Oracle Discussion Forums » Oracle Database » SQL and PL/SQL -
3 Table Join with group by and order by clauses
I am porting from MySQL to Oracle 8i. I have a three Table Join in MySQL as follows:
select distinct TO_DAYS(l.listend)-TO_DAYS(NOW()) AS daysLeft, i.minbid, l.listend, i.itemid, i.itemtitle, l.listingid, l.lendstart, l.lendend, l.status, MAX(b.amount) AS curBid, COUNT(b.amount) AS numBids from TBL_ITEMS i, TBL_LISTING l LEFT JOIN TBL_BIDS b ON l.listingid=b.listingid where i.itemid = l.itemid AND l.status='1' AND (TO_DAYS(l.listend)-TO_DAYS(NOW()) >= 0) AND i.catcode LIKE'12__' GROUP BY listingid order by curBid DESC, daysLeft;
It performs an straight join on the first 2 tables (TBL_ITEMS and TBL_LISTING) and a LEFT JOIN between the previous result set and TBL_BIDS. TBL_BIDS uses a group by clause to obtain MAX and COUNT info. This final result set is the sorted (ORDER BY).
I have tried to reconstruct this type of call in Oracle and have failed. Several problems that I have notices: Oracle does not let me pull in additional columns when doing a GROUP BY clause.
(see below for my work around)
I have worked around the problem by creating a TABLE with the group by functionality and doing a straing 3 table join. (NOTE: I cannot create a view because use a LIKE function in the call... view dont have indexes). However, when I try to alias the column that returns DATE subtraction ("l.listend-TRUNC(SYSDATE) daysLeft" OR "l.listend-TRUNC(SYSDATE) dayLeft") I cannot use the LIKE statement.
Here is my question. How do I port the above 3-table MySQL call to Oracle. Why am I having these problems (is it the Oracle optimizer?) and how do I avaopid them in the future.
I really appreciate anyone's input. Thanks,
Inder
WORK AROUND:
FIRST STEP:
"create TABLE BIDSUM as
select l.listingid, COUNT(b.amount) numBids, MAX(b.amount) curBid from TBL_LISTING l, TBL_BIDS b where l.listingid=b.listingid(+) group by (l.listingid);"
NEXT STEP:
select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE), l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12%';
THIS ALSO WORKS (no LIKE):
"select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode='12'";
BUT THIS DOES NOT (alias the DATE arimetic)
select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12__';I am porting from MySQL to Oracle 8i. I have a three Table Join in MySQL as follows:
select distinct TO_DAYS(l.listend)-TO_DAYS(NOW()) AS daysLeft, i.minbid, l.listend, i.itemid, i.itemtitle, l.listingid, l.lendstart, l.lendend, l.status, MAX(b.amount) AS curBid, COUNT(b.amount) AS numBids from TBL_ITEMS i, TBL_LISTING l LEFT JOIN TBL_BIDS b ON l.listingid=b.listingid where i.itemid = l.itemid AND l.status='1' AND (TO_DAYS(l.listend)-TO_DAYS(NOW()) >= 0) AND i.catcode LIKE'12__' GROUP BY listingid order by curBid DESC, daysLeft;
It performs an straight join on the first 2 tables (TBL_ITEMS and TBL_LISTING) and a LEFT JOIN between the previous result set and TBL_BIDS. TBL_BIDS uses a group by clause to obtain MAX and COUNT info. This final result set is the sorted (ORDER BY).
I have tried to reconstruct this type of call in Oracle and have failed. Several problems that I have notices: Oracle does not let me pull in additional columns when doing a GROUP BY clause.
(see below for my work around)
I have worked around the problem by creating a TABLE with the group by functionality and doing a straing 3 table join. (NOTE: I cannot create a view because use a LIKE function in the call... view dont have indexes). However, when I try to alias the column that returns DATE subtraction ("l.listend-TRUNC(SYSDATE) daysLeft" OR "l.listend-TRUNC(SYSDATE) dayLeft") I cannot use the LIKE statement.
Here is my question. How do I port the above 3-table MySQL call to Oracle. Why am I having these problems (is it the Oracle optimizer?) and how do I avaopid them in the future.
I really appreciate anyone's input. Thanks,
Inder
WORK AROUND:
FIRST STEP:
"create TABLE BIDSUM as
select l.listingid, COUNT(b.amount) numBids, MAX(b.amount) curBid from TBL_LISTING l, TBL_BIDS b where l.listingid=b.listingid(+) group by (l.listingid);"
NEXT STEP:
select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE), l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12%';
THIS ALSO WORKS (no LIKE):
"select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode='12'";
BUT THIS DOES NOT (alias the DATE arimetic)
select i.minbid, i.itemtitle, l.lendstart-TRUNC(SYSDATE) daysLeft, l.lendend, l.listingid, l.status, s.numbids, s.curbid from TBL_ITEMS i, TBL_LISTING l, BIDSUM s where l.listingid=s.listingid AND i.itemid=l.itemid AND l.status='1' AND i.catcode LIKE '12__'; -
Cascading LOV - and order by clause?
Hi, I have a collection that makes use of cascading lovs.
The cascading lov works properly, but I would like the return values sorted alphabetically and cannot figure out why they are not. If I run the query in SQL, it runs perfectly.
My query is:
select......
apex_item.select_list_from_query_xl(15,c015,'select port_name, port
from valid_ports
where state = '
||nvl(c014,0)
*||'order by port_name',*
'style="width:150px;background-color:#FBEC5D;"',
'YES',
'0',
'- Select PORT -',
'f15_' || LPAD (seq_id, 4, '0'),
NULL,
'NO' ) PORT,
c014 is a state code. Order by port_name.
any thoughts? thanksHi Varad, thanks for your response. It is the child...here is the full query, it may make more sense.
thanks again!
Karen
{select apex_item.hidden (1,seq_id) checkbox,
apex_item.hidden (2,seq_id)||
*apex_item.select_list_from_query(3,c003,'select partner_name d, state_code r*
*from partners*
*where state_code is not null*
*order by partner_name',*
*'style="width:100px;background-color:#FBEC5D; "'*
*||'onchange="f_set_casc_sel_list_item_port(this,f4_'||LPAD (seq_id, 4,'0')||')"',*
*'YES',*
*'0',*
*'- Select State -',*
*'f3_' || LPAD (seq_id,4, '0'),*
*NULL,*
*'NO'*
*) STATE,*
*apex_item.select_list_from_query_xl(4,c004,'select port_name, port*
*from valid_ports*
*where fips_state = '*
*||nvl(c003,0)*
*||' order by port_name',*
*'style="width:150px;background-color:#FBEC5D;"',*
*'YES',*
*'0',*
*'- Select PORT -',*
*'f4_' || LPAD (seq_id, 4, '0'),*
*NULL,*
*'NO' ) PORT,*apex_item.POPUPKEY_FROM_LOV(5,c005,'VESSELS_DE',NULL,NULL,NULL,NULL,NULL,
'style="width:150px;background-color:#FBEC5D; "') vessel_id,
apex_item.text(7,c007,8,null,'style="background-color:#FBEC5D;"'
||'onchange="f_set_start_date(this,f7_'||LPAD(seq_id, 4,'0')||')"') trip_start_date,
apex_item.text(8,c008,5,null,'style="background-color:#FBEC5D"') trip_start_time,
apex_item.text(9,c009,null,10,'style="width:100px;background-color:#FBEC5D"') trip_end_date,
apex_item.text(10,c010,5,null,'style="background-color:#FBEC5D"') trip_end_time,
apex_item.SELECT_LIST_FROM_LOV(11,c011,'TRIP_TYPE','style="width:100px;background-color:#FBEC5D; "') trip_type,
apex_item.SELECT_LIST_FROM_LOV(12,c012,'YES_NO','onchange="setMultipleFishermen(#ROWNUM#);"','YES',0,' ','f12_#ROWNUM#') multiple_fishermen,
apex_item.text(13,c013,3,null,'style="background-color:#FBEC5D"') days_at_sea,
apex_item.text(14,c014,3,null,'style="background-color:#FBEC5D"') nbr_of_crew,
-- apex_item.hidden(15,c015) supplier_trip_id,
apex_item.hidden(16,c016,1) trip_nbr,
apex_item.text(17,c017,5) partner_vtr
from apex_collections where collection_name = 'TRIP_C'
} -
Problem with WebIntelligence and Universe Designer Derived Table
Hi people, i have an issue with a report in WebIntelligence that i want to build. Here it goes:
I created a derived table that brings every material that has or not any movement. The thing is that when I build the report using other information like Material Name, for example. The report filters by the coincidence between materials in the derived table and the SAP Standard table. I tried to modify the SQL query but, Oracle does not allow it.
So here are my questions:
1)Is any way to do a Left outer join in order to have any single material and do not allow WebIntelligence to do Inline views?
2)Do i have to modify the derived table? and use the standard tables?
3)Can i work with a derived table that does not have any join with the standard tables?
Thanks in advance,
ReynaldoIf I understand you correctly, it sounds like you are getting an inner join where you want an outer join? You have several options:
1. You can do an outer join in the universe, or even embedded in your derived table (if that is what you are trying to do)
2. You can have a derived table that is not joined with any other tables in the Universe. But you will have to merge the dimensions in the Webi report, and then be sure to put the correct dimension(s) on the report in order to reflect the outer join you want.
I hope that helps. -
Where clause and order by to DAO classes
Hi
Is it ok(I mean design wise) to pass the 'where clause' conditions and order by clause as a parameter to the method of DAO class?Well, I would suggest you write seperate methods in your dao , one to select data without the where clause and one to select data with the where clause thrown in. If you have different 'where' clauses for selecting different kinds of data, have that many dao methods. The dao methods being specific know exactly what is the data that's coming in.
Lets assume you have a list of purchase orders and each purchase order is indetified by a unique id called PURCHASE_ORDER_ID.
1. The following code would populate a purchase order's details given an id.
private statis final String QUERY_1 = "select * from PURCHASE_ORDERS where PURCHASE_ORDER_ID = ? ";
PurchaseOrderModel getPurchaseOrderData(long poId){
//get a prepared statement from your connection
PreparedStatement pst = conn.prepareStatement(QUERY_1);
//set the poId passed as params to your query
pst.setLong(1, poId);
ResultSet rs = pst.executeQuery();
if(rs.next()){
//populate data into a model
finally{
//clean up resources
return model;
}2. The following code would return a list of PurchaseOrderModel's whose shipping date falls between a set of dates selected by the user.
private statis final String QUERY_2 = "select * from PURCHASE_ORDERS where SHIPPING_DATE between ? and ? ";
PurchaseOrderModel getPurchaseOrdersBetweenDates(list bindValues){
//get a prepared statement from your connection
PreparedStatement pst = conn.prepareStatement(QUERY_1);
//set the dates passed as params to your query
//we know that the List ought to contain only 2 dates
pst.setDate(1, (Date)bindValues.get(0));
pst.setDate(2, (Date)bindValues.get(1));
ResultSet rs = pst.executeQuery();
if(rs.next()){
//iterate and populate data into a model
//add model to a list
finally{
//clean up resources
return list;
3. This is more interesting - the dao method searches a list of Purchase Orders starting with a set of specific words. The words themselves may be one or many. This means that the number of '?' in your prepared statement may be dynamic. Each element of the list is a String that contains the start substring of a purcahse order name. For example - the list may contain elements like ["a", "ab", "c", "gh"] and the dao method returns all purchase order starting with these names.
private statis final String QUERY_3 = "select * from PURCHASE_ORDERS where ";
PurchaseOrderModel getPurchaseOrderNameMatches(list bindValues){
//construct the query dynamically
StringBuffer query = new StringBuffer(QUERY_3);
int count = 0;
for(Iterator itr = bindValues.iterator(); itr.hasNext();;){
String value = (String)itr.next();
query.append ("name like 'value%' ");
if (count != 0 and (count+1 != bindValues.length)){
query.append(" or ");
count ++;
//get a prepared statement from your connection
PreparedStatement pst = conn.prepareStatement(query.toString());
ResultSet rs = pst.executeQuery();
if(rs.next()){
//iterate and populate data into a model
//add model to a list
finally{
//clean up resources
return list;
To sum up,
1. You need as many methods as you have different kinds of searches (one method for each kind of 'where' clause).
2. The ejb/business layer would examine the data and decide on which method to call.
3. Increases coding effort, but makes the code clean and readable. Each layer does it's job. Thus we dont have ejbs forming 'where' clauses and so on.
Having said that, it really is your decision - you should take into consideration the following factors -
1. How big is the project ? If its a huge codebase developed by many people, then segregate the responsibilities clearly in each layer as I have outlined. For a small scale project, you could go with your approach.
2. Whats the take on maintenance and future add-ons ? Do you see the codebase growing with time ?
3. Is your project a commercial one - is it a product that needs to be maintained or is it a one-off development - develop once and you are done with it.
4. What are the design considerations ? Is somebody going to audit code for quality ? Or is it a academic one ?
You should take into account all these before deciding to go one way or the other.
A general thumb rule should be that you should be convinced that your code readable (maintainable), scalable and efficient. Anything that you do towards these ends is good code/design despite what people/books/patterns say, IMO.
cheers,
ram. -
*Modify the LKM to add order by clause*
I had a requirement to insert the data in the asc order, So how we can modify the LKM for using the order by caluse.
Thanks in advance.
Cheers,
RajeevHi Rajeev,
It is IDEAL to change your IKM knonwledge module instead of LKM to load into the target table with order by clause.
This is because, if you add order by clause in LKM, it extracts data from source with order by clause first and loads into ODI work tables intially. From these work tables data will be loaded into target tables. In this step we are not sure if the the data is going to be loaded in the same order.
Coming to your question, follow the below steps.
1. Import IKM knowledge module depending on your technology. For example "IKM Oracle Incremental Update (MERGE)".
2. Double click on the IKM to change the definition name, to just make you aware that IKM has been customised.
3. Go to the details tab in IKM after double click, double click on the step which inserts from I$ table to final target table. In my case the step name is "Merge Rows".
4. You can modify the second line
from
using <%=odiRef.getTable("L", "INT_NAME", "A")%> S
to
using (select * from <%=odiRef.getTable("L", "INT_NAME", "A")%> order by 1) S
5. Note that above step will sort always based on the first column. You can modify depending on your requirement.
6. Save it and you can view respective sql statements generated from operator.
Let me know if it is resolved. -
Hello,
Plz Ans me-
What is Derived table, where it is using derived table? advantages& Di- advantages derived table?Hi,
Derived tables are nothing else but InLine views (with the one additional benefit of being able to use @prompt syntax in a derived table) and as such do not contain any data, everything is calculated on the fly during query execution, meaning: whenever you refresh a report.
Derived tables are tables that you define in the universe schema. You create objects on them as you do with any other table. A derived table is defined by an SQL query at the universe level that can be used as a logical table in Designer.
Derived tables have the following advantages:
u2022 Reduced amount of data returned to the document for analysis. You can include complex calculations and functions in a derived table. These operations are performed before the result set is returned to a document, which saves time and reduces the need for complex analysis of large amounts of data at the report level.
u2022 Reduced maintenance of database summary tables. Derived tables can, in some cases, replace statistical tables that hold results for complex calculations that are incorporated into the universe using aggregate awareness. These aggregrate tables are costly to maintain and refresh frequently. Derived tables can return the same data and provide real time data analysis.
Derived tables are similar to database views, with the advantage that the SQL for a derived table can include BusinessObjects prompts.
Thanks,
Amit -
Derived Table - Stored Procedure.
Hi all,
Can any tell how you call stored procedure from Derived table.
and how manage the IN parameters ?
thnx in advanceHi Reddeppa,
Could you please specify the database you are working on?
Also , BO Supports Derived Tables if and only if the underlying database supports In-line Views:
Syntax: Select tot from ( select fun(x) as tot from table) dtab ;
Ex: Select workdays from ( select workdays('10/10/2004' , '20/4/2005') as workdays from dual ) DerivedTab ;
Run the above SQL at the Database end, if it runs successfully then follow the below steps
1. Create a function at the database end.
for example :
Create or replace function testf(no number) return number
as
Begin
Return(10);
End;
2. Open the universe
3. Create a derived table using the following syntax:
for example :
Select TestF(10) from dual;
4. Click on parse and Ok.
5. Now create a report using Derived table
Note: This is tested on Oracle database.
Hope this will help you.
Regards
Sheeba -
Derived Table How can I give the results of this SQL Line an Explicit Name.
I am trying to create a derived table and I get the error
"each calculated column must have an explicit name"
I added the as shiptype to the end of the line and that did not work. Any thoughts?
shiptype = case when araddr.invno is not null then 'ADDR' else (case when arcadr.custno is not null then 'CADR' else 'CUST' end) end as shiptype,
Thanks
JeffSure,
Here is the complete query.
This query works fine is sql query analyzer but when I put it in the designer I get the error.
SELECT 'C' as tableId,
'' as StartMast,
armast.invno as invno,
armast.invdte as invdte,
armast.ponum as ponum,
armast.ordate as ordate,
armast.shipvia as shipvia,
armast.fob as fob,
armast.ornum as ornum,
armast.disc as Idisc,
armast.taxrate as Itaxrate,
armast.tax as tax,
armast.invamt as invamt,
armast.disamt as disamt,
armast.paidamt as paidamt,
armast.balance as balance,
armast.dtepaid as dtepaid,
armast.pterms as pterms,
armast.arstat as arstat,
armast.artype as artype,
armast.notes as notes,
armast.salesmn as salesmn ,
'' as StartBill,
arcust.custno,
arcust.company as billComp,
arcust.contact as billaddr1,
arcust.address1 as billaddr2,
arcust.address2 as billaddr3,
arcust.city as billcity,
arcust.addrstate as billstate,
arcust.zip as billzip,
arcust.country as billcountry,
arcust.phone as billphone,
arcust.faxno as billfaxno,
rtrim(cast(arcust.email as varchar(2000))) as billemail,
'' as StartShip,
armast.tosw,
armast.cshipno,
shiptype = case when araddr.invno is not null then 'ADDR' else (case when arcadr.custno is not null then 'CADR' else 'CUST' end) end,
shipcomp = left(case when araddr.invno is not null then araddr.company else (case when arcadr.custno is not null then arcadr.company else arcust.company end) end + space(35),35),
shipaddr1 = left(case when araddr.invno is not null then araddr.address1 else (case when arcadr.custno is not null then arcadr.contact else arcust.contact end) end + space(30),30),
shipaddr2 = left(case when araddr.invno is not null then araddr.address2 else (case when arcadr.custno is not null then arcadr.address1 else arcust.address1 end) end + space(30),30),
shipaddr3 = left(case when araddr.invno is not null then araddr.address3 else (case when arcadr.custno is not null then arcadr.address2 else arcust.address2 end) end + space(30),30),
shipcity = left(case when araddr.invno is not null then araddr.city else (case when arcadr.custno is not null then arcadr.city else arcust.city end) end + space(20),20),
shipstate = left(case when araddr.invno is not null then araddr.addrstate else (case when arcadr.custno is not null then arcadr.addrstate else arcust.addrstate end) end + space(10),10),
shipzip = left(case when araddr.invno is not null then araddr.zip else (case when arcadr.custno is not null then arcadr.zip else arcust.zip end) end + space(10),10),
shipcntry = left(case when araddr.invno is not null then araddr.country else (case when arcadr.custno is not null then arcadr.country else arcust.country end) end + space(15),15),
'' as StartCmnt,
armast.commid as commid,
arcomm.comment as CommCmnt,
arscom.comment as ScomCmnt,
invCmnt = isnull(
case
when armast.commid = 'MISC' then arcomm.comment
when len(rtrim(armast.commid)) > 0 then arscom.comment
else ''
end
'' as StartTran,
artran.tranlineno,
artran.item,
artran.loctid,
artran.Descrip,
artran.intmemo,
artran.custmemo,
artran.qtyord,
artran.qtyshp,
artran.price,
artran.disc as ldisc,
artran.taxrate as ltaxrate,
artran.extprice,
artran.taxable,
artran.arstat as linestat,
artran.artype as linetype
FROM armast
LEFT JOIN artran ON artran.invno = armast.invno
Left JOIN arcust ON arcust.custno = armast.custno
Left JOIN arcomm ON arcomm.invno = armast.invno
Left JOIN arscom ON arscom.commid = armast.commid
LEFT JOIN araddr ON araddr.invno = armast.invno
LEFT JOIN arcadr ON arcadr.custno = armast.custno AND arcadr.cshipno = armast.cshipno
WHERE (armast.invdte >= getdate() - 180 OR len(rtrim(armast.arstat)) = 0)
AND armast.invno <> '_RECEIPT'
AND len(rtrim(armast.currhist)) = 0
AND armast.custno = 'TJS-01'
Union All
SELECT 'H' as tableId,
'' as StartMast,
arymst.invno as invno,
arymst.invdte as invdte,
arymst.ponum as ponum,
arymst.ordate as ordate,
arymst.shipvia as shipvia,
arymst.fob as fob,
arymst.ornum as ornum,
arymst.disc as Idisc,
arymst.taxrate as Itaxrate,
arymst.tax as tax,
arymst.invamt as invamt,
arymst.disamt as disamt,
arymst.paidamt as paidamt,
arymst.balance as balance,
arymst.dtepaid as dtepaid,
arymst.pterms as pterms,
arymst.arstat as arstat,
arymst.artype as artype,
arymst.notes as notes,
arymst.salesmn as salesmn ,
'' as StartBill,
arcust.custno,
arcust.company as billComp,
arcust.contact as billaddr1,
arcust.address1 as billaddr2,
arcust.address2 as billaddr3,
arcust.city as billcity,
arcust.addrstate as billstate,
arcust.zip as billzip,
arcust.country as billcountry,
arcust.phone as billphone,
arcust.faxno as billfaxno,
rtrim(cast(arcust.email as varchar(2000))) as billemail,
'' as StartShip,
arymst.tosw,
arymst.cshipno,
shiptype = case when aryadr.invno is not null then 'YADR' else (case when arcadr.custno is not null then 'CADR' else 'CUST' end) end,
shipcomp = left(case when aryadr.invno is not null then aryadr.company else (case when arcadr.custno is not null then arcadr.company else arcust.company end) end + space(35),35),
shipaddr1 = left(case when aryadr.invno is not null then aryadr.address1 else (case when arcadr.custno is not null then arcadr.contact else arcust.contact end) end + space(30),30),
shipaddr2 = left(case when aryadr.invno is not null then aryadr.address2 else (case when arcadr.custno is not null then arcadr.address1 else arcust.address1 end) end + space(30),30),
shipaddr3 = left(case when aryadr.invno is not null then aryadr.address3 else (case when arcadr.custno is not null then arcadr.address2 else arcust.address2 end) end + space(30),30),
shipcity = left(case when aryadr.invno is not null then aryadr.city else (case when arcadr.custno is not null then arcadr.city else arcust.city end) end + space(20),20),
shipstate = left(case when aryadr.invno is not null then aryadr.addrstate else (case when arcadr.custno is not null then arcadr.addrstate else arcust.addrstate end) end + space(10),10),
shipzip = left(case when aryadr.invno is not null then aryadr.zip else (case when arcadr.custno is not null then arcadr.zip else arcust.zip end) end + space(10),10),
shipcntry = left(case when aryadr.invno is not null then aryadr.country else (case when arcadr.custno is not null then arcadr.country else arcust.country end) end + space(15),15),
'' as StartCmnt,
arymst.commid as commid,
arcomm.comment as CommCmnt,
arscom.comment as ScomCmnt,
invCmnt = isnull(
case
when arymst.commid = 'MISC' then arcomm.comment
when len(rtrim(arymst.commid)) > 0 then arscom.comment
else ''
end
'' as StartTran,
arytrn.tranlineno,
arytrn.item,
arytrn.loctid,
arytrn.Descrip,
arytrn.intmemo,
arytrn.custmemo,
arytrn.qtyord,
arytrn.qtyshp,
arytrn.price,
arytrn.disc as ldisc,
arytrn.taxrate as ltaxrate,
arytrn.extprice,
arytrn.taxable,
arytrn.arstat as linestat,
arytrn.artype as linetype
FROM arymst
LEFT JOIN arytrn ON arytrn.invno = arymst.invno
Left JOIN arcust ON arcust.custno = arymst.custno
Left JOIN arcomm ON arcomm.invno = arymst.invno
Left JOIN arscom ON arscom.commid = arymst.commid
LEFT JOIN aryadr ON aryadr.invno = arymst.invno
LEFT JOIN arcadr ON arcadr.custno = arymst.custno AND arcadr.cshipno = arymst.cshipno
WHERE (arymst.invdte >= getdate() - 180 OR (len(rtrim(arymst.arstat)) = 0 AND arymst.invno in (select invno FROM armast where len(rtrim(arstat)) = 0)))
AND arymst.invno <> '_RECEIPT'
AND arymst.custno = 'TJS-01'
Maybe you are looking for
-
I went to purchase an app from the app store and it said because I nev purchase them I just get the free one that I have to answer some security questions that I would of answered when I first signed up - well silly me cant even remember the answered
-
How to determine that the user/ pernr is comp cord?
Hi, In tcode pa30 i see there is Comp Cord field. so these are the HR persons right which use the three digits numbers. So my question is how to determine that the user/ pernr is comp cord? I want to create the fm and pass user id as import and want
-
Non modifiable field in Purchase Requisition
Hi, I would like to prevent users to change the material designation while creating and modifying PR, but only for few material types (all stocked material : eg ERSA materials). Only Account assigned articles should be modifiable. Item category in th
-
Quicktime converting 24 bit images to 16 bit images on paste
I am doing image processing of a QuickTime (7.1.5 pro) movie in Photoshop (CS2) using Applescript. When I copy an image (either with Applescript or manually) and paste it into a new QuickTime Player movie the image gets converted to a video depth of
-
Configure E-Mail Notification with several smtp servers
Hi all, We want to configure "reset password" and we must configure E-Mail notification.As http://help.sap.com/saphelp_nw2004s/helpdata/en/44/bf8f2069665991e10000000a422035/content.htm shown,we can "Separate multiple SMTP server entries with a se