Neccessity of with SAWITH in SQL
Hi,
When I open the sesion log, I noticed the below sql.
WITH
SAWITH0 AS (
select sum(T255347.S_QTY) as c1,
avg(T255347.AMT) as c2,
T255327.BILL_NAME as c3,
T255327.P_NAME as c4,
T255326.C_CODE as c5,
T255327.C_NUM as c6
from
C_DIM T255326,
C_BILL T255327,
BUSINESS T255334 ,
I_FACT T255347
where ( T255326.C_IDN = T255347.C_IDN and T255327.B_IDN = T255347.B_IDN and T255334.BU = T255347.BU )
group by
T255327.BILL_NAME,
T255327.P_NAME ,
T255326.C_CODE ,
T255327.C_NUM
select D1.c1 as c1, D1.c2 as c2, D1.c3 as c3, D1.c4 as c4, D1.c5 as c5, D1.c6 as c6, D1.c7 as c7 from ( select distinct 0 as c1,
D1.c3 as c2,
D1.c4 as c3,
D1.c5 as c4,
D1.c6 as c5,
D1.c2 as c6,
D1.c1 as c7
from
SAWITH0 D1
order by c3, c4, c2 ) D1 where rownum <= 1000001
If I execute the piece of the belwo SQL I get the result.
select sum(T255347.S_QTY) as c1,
avg(T255347.AMT) as c2,
T255327.BILL_NAME as c3,
T255327.P_NAME as c4,
T255326.C_CODE as c5,
T255327.C_NUM as c6
from
C_DIM T255326,
C_BILL T255327,
BUSINESS T255334 ,
I_FACT T255347
where ( T255326.C_IDN = T255347.C_IDN and T255327.B_IDN = T255347.B_IDN and T255334.BU = T255347.BU )
group by
T255327.BILL_NAME,
T255327.P_NAME ,
T255326.C_CODE ,
T255327.C_NUM
what is the use of the
WITH
SAWITH0?
Please let me know why this is generated from OBIEE?
Hi ,
Not sure whether i got ur question correctly.
The sawwith is just a alias name,.According to me obiee first does all aggregations in a query then select from that view i.e. the with clause.
thanks.
Similar Messages
-
How to split numbers in a string with a single SQL on 10.2?
Is it possible to to below action with a single SQL on 10.2?
input > '3abc4de5f'
output > '3,abc,4,de,5,f'
Thank you.It might be a NLS issue. Follow the suggestion of Karthick_Arp and use [[:alpha:]] instead:Is is
SQL> with t as (select 'a' l from dual union all
select 'b' l from dual union all
select 'A' l from dual)
select * from t
order by nlssort(l, 'NLS_SORT=GERMAN')
L
a
A
b
3 rows selected.
SQL> with t as (select 'a' l from dual union all
select 'b' l from dual union all
select 'A' l from dual)
select * from t
order by nlssort(l, 'NLS_SORT=DANISH')
L
A
a
b
3 rows selected.You could also do a case insensitive match (As in TXT3)
SQL> alter session set NLS_SORT=DANISH
Session altered.
SQL> with t as (select 'aADSFF3332abc4342de5Df' txt from dual
union all
select '3abc4de5f' from dual)
select txt, regexp_replace(txt, '([0-9]{1,}|[a-z]{1,})', '\1,') txt2
,regexp_replace(txt, '([0-9]{1,}|[a-z]{1,})', '\1,', 1, 0, 'i') txt3
from t
TXT TXT2 TXT3
aADSFF3332abc4342de5Df a,ADSFF,3332,abc,4342,de,5,Df, aADSFF,3332,abc,4342,de,5,Df,
3abc4de5f 3,abc,4,de,5,f, 3,abc,4,de,5,f,
2 rows selected.
SQL> alter session set NLS_SORT=GERMAN
Session altered.
SQL> with t as (select 'aADSFF3332abc4342de5Df' txt from dual
union all
select '3abc4de5f' from dual)
select txt, regexp_replace(txt, '([0-9]{1,}|[a-z]{1,})', '\1,') txt2
from t
TXT TXT2
aADSFF3332abc4342de5Df aADSFF,3332,abc,4342,de,5,Df,
3abc4de5f 3,abc,4,de,5,f,
2 rows selected.Regards
Peter -
"[DBNETLIB] Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection"
After patches applied on patch Tuesday the database reports the above error.
All accounts are domain accounts and SQLServer uses Windows auth.
DCDIAG show no errors
All servers and DC have been restarted,
Message in db log confirms the connection is being denied due to trust.
Event log shows same rejection
Protocols enabled: named pipes, tcpip, memory
TESTS:
PortQry: "
TCP port 1433 (ms-sql-s service): LISTENING"
Connect with domain admin accounts works from multiple clients systems to DB.
Cannot connect with newly created domain admin account
Can connect if new admin account connect to server in terminal server session and uses UDL wizard or any other tool including isql.
New standard user also fails to connect.
NOTES:
I removed the SSL patch and the IE security update to see if that was an issue.
¯\_(ツ)_/¯Has someone left the company or has an account of some nature been dropped/replaced?
Please click "Mark As Answer" if my post helped. Tony C.
Hi Tony,
Srry but No. We just installed the monthly updates.
I went back and found I had missed removing a patch. I missed the rollup for Windows Server 2003:
Event Type: Information
Event Source: NtServicePack
Event Category: None
Event ID: 4382
Date: 3/12/2015
Time: 12:26:04 PM
User: NETTEST\admin
Computer: DATA1
Description:
Windows Server 2003 KB954920 was removed from your computer, and the previous Windows Server 2003 configuration was restored.
After I removed that is still didn't work but after about five minutes it started working.
I guess I ned to report that to MS after I research what might be changed to make the patch work.
Every time I get stuck and ask for help it seems to be just before I stumble on the solution.
Thanks for replying.
Well - maybe this will help someone else.
Thanks again for replying Tony
¯\_(ツ)_/¯ -
I have problem with login in sql Server give me support .pre login handshake
I have problem with login in sql Server give me support .pre login handshake
The following threads are on the same topic:
http://www.sql-server-performance.com/forum/threads/pre-login-handshake-error-when-connecting-to-db.687/
http://stackoverflow.com/questions/12308340/sql-server-2000-connection-error-pre-login-handshake
http://dbaspot.com/sqlserver-server/458011-error-occurred-during-pre-login-handshake-microsoft-sql-server-error-10054-a.html
Kalman Toth Database & OLAP Architect
IPAD SELECT Query Video Tutorial 3.5 Hours
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
XML Publisher(XDODTEXE) in EBS taking more time with the same SQL in TOAD
HI
XML Publisher(XDODTEXE) in EBS taking more time with the same SQL in TOAD.
The sql has 5 union clauses.
It takes 20-30 minutes in TOAD compared to running through Concurrent Program in XML Publisher in EBS taking around 4-5 hours.
The Scalable Flag at report level is turned on with the JVM options set to -Xmx1024m -Xmx1024m in Concurrent Program definition.
Other configurations for Data Template like XSLT, Scalable, Optimization are turned on though didn't bounce the OPP Server for these to take effect as I am not sure whether it is needed.
Thanks in advance for your help.But the question is that how come it is working in TOAD and takes only 15-20 minutes?
with initialization of session ?
what about sqlplus ?
Do I have to set up the the temp directory for the XML Publisher report to make it faster?
look at
R12: Troubleshooting Known XML Publisher and E-Business Suite (EBS) Integration Issues (Doc ID 1410160.1)
BI Publisher - Troubleshooting Oracle Business Intelligence (XML) Publisher For The Oracle E-Business Suite (Doc ID 364547.1) -
Using database link with a dynamic SQL in Forms 5
I have a Form 5 application where a database link is specified in a client version of dynamic SQL. The function that the application is designed to perform is to access data in a table in a remote database and use it to populate another table in a local database with the same structure as the source table. Dynamic SQL is used because the name of the table can only be resolved during run time.
The problem is that it gives error with code 'ORA-03113' and text 'End-of-file on communication channel' when you try to run it.
Is it not possible to use a database link with a dynamic SQL? What can I do to overcome the problem ?Try to create a local view based ao the remote table and use the view.
-
With clause in SQL query data model
Hello!
isn't it possible to use the with clause in sql query data models?
for example following query:
WITH
a_test as (
select dummy from dual
select *
from a_test
brings up a "XML Parsing Error: no element found"-error...
BR PaulI tried a slightly different query (see below) and the query worked fine and retrieved data.. I did not get any errors.
WITH
a_test as (
select 'dummy' from dual
select *
from a_test
This works as well.. retrieving the value of the parameter
WITH
a_test as (
select :Test_ID from dual
select *
from a_test
thanks,
BIPuser -
Problem with DBMS_OUTPUT and SQL statment with a function
I am using SQL Developer version 3.0.04 and I have a function that has a dbms_output statment in it. I am running the following SQL to select the output of that statment.
select A.A_FUCTION('TEST') from dual;
The output works fine but the dbms_output line does not show in the dbms_output window. I turned on the output window etc. and i can get the select to print out the output if i wrap it in a declare begin end wrapper... and then change the query to insert the return value into variable.
just wondering if there is way to get the dbms_output to flush out with just an SQL statment instead of in a begin end wrapper etc.just wondering if there is way to get the dbms_output to flush out with just an SQL statment instead of in a begin end wrapper etc.works fine in sql*plus, so I guess it must be a preference or sth. in sql*developer:
SQL> set serverout on
SQL> create or replace function f1 (r int)
2 return int
3 as
4 begin
5 dbms_output.put_line ('Hello World ' || r);
6 return r;
7 end f1;
8 /
Function created.
SQL>
SQL> select f1 (rownum) f1 from dual connect by level <= 3
2 /
F1
1
2
3
3 rows selected.
Hello World 1
Hello World 2
Hello World 3
SQL> -
Scaleability with Functions in SQL queries
Hi,
In one of our applications we have many views that use a packaged function in the where clause to filter data. This function uses a SYS_CONTEXT() to set and get values. There are couple of issues while using this approach:
1/ The deterministic function doesn't allow any scability with PQ-server.
2/ Another issue with this function and also the SYS_CONTEXT-function, they manuipulate the estimated CBO-statistics.
CREATE TABLE TAB_I
COLUMN1 NUMBER(16, 0) NOT NULL
, COLUMN2 VARCHAR2(20)
, CONSTRAINT TAB_I_PK PRIMARY KEY
COLUMN1
ENABLE
CREATE TABLE TAB_V
I_COL1 NUMBER(16,0) NOT NULL ENABLE,
VERSION_ID NUMBER(16,0) NOT NULL ENABLE,
CRE_DATIM TIMESTAMP (6) NOT NULL ENABLE,
TERM_DATIM TIMESTAMP (6) NOT NULL ENABLE,
VERSION_VALID_FROM DATE NOT NULL ENABLE,
VERSION_VALID_TILL DATE NOT NULL ENABLE,
CONSTRAINT TAB_V_PK PRIMARY KEY (I_COL1, VERSION_ID) USING INDEX NOCOMPRESS LOGGING ENABLE,
CONSTRAINT COL1_FK FOREIGN KEY (I_COL1) REFERENCES TAB_I (COLUMN1) ENABLE
CREATE OR REPLACE
PACKAGE app_bitemporal_rules IS
FUNCTION f_knowledge_time RETURN TIMESTAMP DETERMINISTIC;
END app_bitemporal_rules;
create or replace
PACKAGE BODY app_bitemporal_rules IS
FUNCTION f_knowledge_time RETURN TIMESTAMP DETERMINISTIC IS
BEGIN
RETURN TO_TIMESTAMP(SYS_CONTEXT ('APP_USR_CTX', 'KNOWLEDGE_TIME'),'DD.MM.YYYY HH24.MI.SSXFF');
END f_knowledge_time;
END app_bitemporal_rules;
explain plan for select *
FROM tab_i
JOIN tab_v
ON tab_i.column1 = tab_v.i_col1
AND app_bitemporal_rules.f_knowledge_time BETWEEN tab_v.CRE_DATIM AND tab_v.TERM_DATIM
where tab_i.column1 = 11111;
select * from table(dbms_xplan.display);
Plan hash value: 621902595
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 95 | 5 (0)| 00:00:06 |
| 1 | NESTED LOOPS | | 1 | 95 | 5 (0)| 00:00:06 |
| 2 | TABLE ACCESS BY INDEX ROWID| TAB_I | 1 | 25 | 1 (0)| 00:00:02 |
|* 3 | INDEX UNIQUE SCAN | TAB_I_PK | 1 | | 1 (0)| 00:00:02 |
|* 4 | TABLE ACCESS FULL | TAB_V | 1 | 70 | 4 (0)| 00:00:05 |
Predicate Information (identified by operation id):
3 - access("TAB_I"."COLUMN1"=11111)
4 - filter("TAB_V"."I_COL1"=11111 AND
"TAB_V"."CRE_DATIM"<="APP_BITEMPORAL_RULES"."F_KNOWLEDGE_TIME"() AND
"TAB_V"."TERM_DATIM">="APP_BITEMPORAL_RULES"."F_KNOWLEDGE_TIME"())
Note
- 'PLAN_TABLE' is old version
- dynamic sampling used for this statement (level=2)
explain plan for select *
FROM tab_i
JOIN tab_v
ON tab_i.column1 = tab_v.i_col1
AND '10-OCT-2011' BETWEEN tab_v.CRE_DATIM AND tab_v.TERM_DATIM
where tab_i.column1 = 11111;
select * from table(dbms_xplan.display);
Plan hash value: 621902595
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 256 | 24320 | 5 (0)| 00:00:06 |
| 1 | NESTED LOOPS | | 256 | 24320 | 5 (0)| 00:00:06 |
| 2 | TABLE ACCESS BY INDEX ROWID| TAB_I | 1 | 25 | 1 (0)| 00:00:02 |
|* 3 | INDEX UNIQUE SCAN | TAB_I_PK | 1 | | 1 (0)| 00:00:02 |
|* 4 | TABLE ACCESS FULL | TAB_V | 256 | 17920 | 4 (0)| 00:00:05 |
Predicate Information (identified by operation id):
3 - access("TAB_I"."COLUMN1"=11111)
4 - filter("TAB_V"."I_COL1"=11111 AND "TAB_V"."CRE_DATIM"<=TIMESTAMP'
2011-10-10 00:00:00.000000000' AND "TAB_V"."TERM_DATIM">=TIMESTAMP' 2011-10-10
00:00:00.000000000')
Note
- 'PLAN_TABLE' is old version
- dynamic sampling used for this statement (level=2) As can be seen in the second plan the cardinality has been guessed correctly, but not in the first case.
I have also tried with:
ASSOCIATE STATISTICS WITH packages app_bitemporal_rules DEFAULT COST (1000000/*246919*/,1000,0) DEFAULT SELECTIVITY 50;
But, this just leads to a increased cost, but no change in cardinality.
The (1) problem gets solved if I directly use "TO_TIMESTAMP(SYS_CONTEXT ('APP_USR_CTX', 'KNOWLEDGE_TIME'),'DD.MM.YYYY HH24.MI.SSXFF')" in the where clause. But am not able to find a solution for the (2) issue.
Can you please help.
Regards,
Vikram RHi Vikram,
On the subject of using [url http://download.oracle.com/docs/cd/E11882_01/server.112/e26088/statements_4006.htm#i2115932]ASSOCIATE STATISTICS, having done a little investigation on 11.2.0.2, I'm having trouble adjusting selectivity via "associate statististics ... default selectivity" but no problems with adjusting default cost.
I've also tried to do the same using an interface type and am running into other issues.
It's not functionality that I'm overly familiar with as I try to avoid/eliminate using functions in predicates.
Further analysis/investigation required.
Including test case of what I've done so far in case anyone else wants to chip in.
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
SQL> drop table t1;
Table dropped.
SQL>
SQL> create table t1
2 as
3 select rownum col1
4 from dual
5 connect by rownum <= 100000;
Table created.
SQL>
SQL> exec dbms_stats.gather_table_stats(USER,'T1');
PL/SQL procedure successfully completed.
SQL>
SQL> create or replace function f1
2 return number
3 as
4 begin
5 return 1;
6 end;
7 /
Function created.
SQL>
SQL> create or replace function f2 (
2 i_col1 in number
3 )
4 return number
5 as
6 begin
7 return 1;
8 end;
9 /
Function created.
SQL> Created one table with 100000 rows.
Two functions - one without arguments, one with (for later).
With no associations:
SQL> select * from user_associations;
no rows selected
SQL> Run a statement that uses the function:
SQL> select count(*) from t1 where col1 >= f1;
COUNT(*)
100000
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
SQL_ID gm7ppkbzut114, child number 0
select count(*) from t1 where col1 >= f1
Plan hash value: 3724264953
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 139 (100)| |
| 1 | SORT AGGREGATE | | 1 | 5 | | |
|* 2 | TABLE ACCESS FULL| T1 | 5000 | 25000 | 139 (62)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("COL1">="F1"())
19 rows selected.
SQL> Shows that default selectivity of 5% for an equality predicate against function.
Let's try to adjust the selectivity using associate statistics - the argument for selectivity should be a percentage between 0 and 100:
(turning off cardinality feedback for clarity/simplicity)
SQL> alter session set "_optimizer_use_feedback" = false;
Session altered.
SQL>
SQL> ASSOCIATE STATISTICS WITH FUNCTIONS f1 default selectivity 100;
Statistics associated.
SQL> select count(*) from t1 where col1 >= f1;
COUNT(*)
100000
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
SQL_ID gm7ppkbzut114, child number 1
select count(*) from t1 where col1 >= f1
Plan hash value: 3724264953
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 139 (100)| |
| 1 | SORT AGGREGATE | | 1 | 5 | | |
|* 2 | TABLE ACCESS FULL| T1 | 5000 | 25000 | 139 (62)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("COL1">="F1"())
19 rows selected.
SQL> Didn't make any difference to selectivity.
An excerpt from a 10053 trace file had the following:
** Performing dynamic sampling initial checks. **
** Dynamic sampling initial checks returning FALSE.
No statistics type defined for function F1
No default cost defined for function F1So, crucially what's missing here is a clause saying:
No default selectivity defined for function F1But there's no other information that I could see to indicate why it should be discarded.
Moving on, adjusting the cost does happen:
SQL>exec spflush;
PL/SQL procedure successfully completed.
SQL> disassociate statistics from functions f1;
Statistics disassociated.
SQL>
SQL> ASSOCIATE STATISTICS WITH FUNCTIONS f1 default selectivity 100 default cost (100,5,0);
Statistics associated.
SQL> select count(*) from t1 where col1 >= f1;
COUNT(*)
100000
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
SQL_ID gm7ppkbzut114, child number 0
select count(*) from t1 where col1 >= f1
Plan hash value: 3724264953
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 500K(100)| |
| 1 | SORT AGGREGATE | | 1 | 5 | | |
|* 2 | TABLE ACCESS FULL| T1 | 5000 | 25000 | 500K (1)| 00:41:41 |
Predicate Information (identified by operation id):
2 - filter("COL1">="F1"())
19 rows selected.
SQL> And we see the following in a 10053:
No statistics type defined for function F1
Default costs for function F1 CPU: 100, I/O: 5So, confirmation that default costs for function were found and applied but nothing else about selectivity again.
I wondered whether the lack of arguments for function F1 made any difference, hence function F2.
Didn't seem to:
Vanilla:
SQL> select count(*) from t1 where col1 >= f2(col1);
COUNT(*)
100000
SQL>
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
SQL_ID 2wxw32wadgc1v, child number 0
select count(*) from t1 where col1 >= f2(col1)
Plan hash value: 3724264953
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 139 (100)| |
| 1 | SORT AGGREGATE | | 1 | 5 | | |
|* 2 | TABLE ACCESS FULL| T1 | 5000 | 25000 | 139 (62)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("COL1">="F2"("COL1"))
19 rows selected.
SQL> Plus association:
SQL>exec spflush;
PL/SQL procedure successfully completed.
SQL>
SQL> associate statistics with functions f2 default selectivity 90 default cost (100,5,0);
Statistics associated.
SQL> select count(*) from t1 where col1 >= f2(col1);
COUNT(*)
100000
SQL>
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
SQL_ID 2wxw32wadgc1v, child number 0
select count(*) from t1 where col1 >= f2(col1)
Plan hash value: 3724264953
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 500K(100)| |
| 1 | SORT AGGREGATE | | 1 | 5 | | |
|* 2 | TABLE ACCESS FULL| T1 | 5000 | 25000 | 500K (1)| 00:41:41 |
Predicate Information (identified by operation id):
2 - filter("COL1">="F2"("COL1"))
19 rows selected.
SQL> Just to confirm associations:
SQL> select * from user_associations;
OBJECT_OWNER OBJECT_NAME COLUMN_NAME OBJECT_TY
STATSTYPE_SCHEMA STATSTYPE_NAME DEF_SELECTIVITY DEF_CPU_COST DEF_IO_COST DEF_NET_COST
INTERFACE_VERSION MAINTENANCE_TY
RIMS F2 FUNCTION
90 100 5
0 USER_MANAGED
RIMS F1 FUNCTION
100 100 5
0 USER_MANAGED
SQL> So.... started thinking about whether using an interface type would help?
SQL> CREATE OR REPLACE TYPE test_stats_ot AS OBJECT
2 (dummy_attribute NUMBER
3 ,STATIC FUNCTION ODCIGetInterfaces (
4 ifclist OUT SYS.ODCIObjectList
5 ) RETURN NUMBER
6 ,STATIC FUNCTION ODCIStatsSelectivity (
7 pred IN SYS.ODCIPredInfo,
8 sel OUT NUMBER,
9 args IN SYS.ODCIArgDescList,
10 strt IN NUMBER,
11 stop IN NUMBER,
12 --i_col1 in NUMBER,
13 env IN SYS.ODCIEnv
14 ) RETURN NUMBER
15 --,STATIC FUNCTION ODCIStatsFunctionCost (
16 -- func IN SYS.ODCIPredInfo,
17 -- cost OUT SYS.ODCICost,
18 -- args IN SYS.ODCIArgDescList,
19 -- i_col1 in NUMBER,
20 -- env IN SYS.ODCIEnv
21 -- ) RETURN NUMBER
22 );
23 /
Type created.
SQL> CREATE OR REPLACE TYPE BODY test_stats_ot
2 AS
3 STATIC FUNCTION ODCIGetInterfaces (
4 ifclist OUT SYS.ODCIObjectList
5 ) RETURN NUMBER
6 IS
7 BEGIN
8 ifclist := sys.odciobjectlist(sys.odciobject('SYS','ODCISTATS2'));
9 RETURN odciconst.success;
10 END;
11 STATIC FUNCTION ODCIStatsSelectivity
12 (pred IN SYS.ODCIPredInfo,
13 sel OUT NUMBER,
14 args IN SYS.ODCIArgDescList,
15 strt IN NUMBER,
16 stop IN NUMBER,
17 --i_col1 in NUMBER,
18 env IN SYS.ODCIEnv)
19 RETURN NUMBER
20 IS
21 BEGIN
22 sel := 90;
23 RETURN odciconst.success;
24 END;
25 -- STATIC FUNCTION ODCIStatsFunctionCost (
26 -- func IN SYS.ODCIPredInfo,
27 -- cost OUT SYS.ODCICost,
28 -- args IN SYS.ODCIArgDescList,
29 -- i_col1 in NUMBER,
30 -- env IN SYS.ODCIEnv
31 -- ) RETURN NUMBER
32 -- IS
33 -- BEGIN
34 -- cost := sys.ODCICost(10000,5,0,0);
35 -- RETURN odciconst.success;
36 -- END;
37 END;
38 /
Type body created.
SQL> But this approach is not happy - perhaps not liking the function with no arguments?
SQL> disassociate statistics from functions f1;
Statistics disassociated.
SQL> ASSOCIATE STATISTICS WITH FUNCTIONS f1 USING test_stats_ot;
Statistics associated.
SQL> select count(*) from t1 where col1 >= f1;
select count(*) from t1 where col1 >= f1
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06550: line 12, column 22:
PLS-00103: Encountered the symbol "ÀÄ" when expecting one of the following:
) , * & = - + < / > at in is mod remainder not rem =>
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset
SQL> So, back to F2 again (uncommenting argument i_col1 in ODCIStatsSelectivity):
SQL> disassociate statistics from functions f1;
Statistics disassociated.
SQL> disassociate statistics from functions f2;
Statistics disassociated.
SQL> ASSOCIATE STATISTICS WITH FUNCTIONS f2 USING test_stats_ot;
Statistics associated.
SQL> select count(*) from t1 where col1 >= f2(col1);
COUNT(*)
100000
SQL> select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
SQL_ID 2wxw32wadgc1v, child number 0
select count(*) from t1 where col1 >= f2(col1)
Plan hash value: 3724264953
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | | | 139 (100)| |
| 1 | SORT AGGREGATE | | 1 | 5 | | |
|* 2 | TABLE ACCESS FULL| T1 | 5000 | 25000 | 139 (62)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter("COL1">="F2"("COL1"))
19 rows selected.
SQL> Nothing obviously happening.
You'll note also in my interface type implementation that I commented out a declaration of ODCIStatsFunctionCost.
This post is probably already too long already so I've skipped some of the detail.
But when ODCIStatsFunctionCost was used with function F2, I presume I've made a mistake in the implementation because I had an error in the 10053 trace as follows:
Calling user-defined function cost function...
predicate: "RIMS"."F2"("T1"."COL1")
declare
cost sys.ODCICost := sys.ODCICost(NULL, NULL, NULL, NULL);
arg0 NUMBER := null;
begin
:1 := "RIMS"."TEST_STATS_OT".ODCIStatsFunctionCost(
sys.ODCIFuncInfo('RIMS',
'F2',
NULL,
1),
cost,
sys.ODCIARGDESCLIST(sys.ODCIARGDESC(2, 'T1', 'RIMS', '"COL1"', NULL, NULL, NULL))
, arg0,
sys.ODCIENV(:5,:6,:7,:8));
if cost.CPUCost IS NULL then
:2 := -1.0;
else
:2 := cost.CPUCost;
end if;
if cost.IOCost IS NULL then
:3 := -1.0;
else
:3 := cost.IOCost;
end if;
if cost.NetworkCost IS NULL then
:4 := -1.0;
else
:4 := cost.NetworkCost;
end if;
exception
when others then
raise;
end;
ODCIEnv Bind :5 Value 0
ODCIEnv Bind :6 Value 0
ODCIEnv Bind :7 Value 0
ODCIEnv Bind :8 Value 4
ORA-6550 received when calling RIMS.TEST_STATS_OT.ODCIStatsFunctionCost -- method ignoredThere was never any such feedback about ODCIStatsSelectivity.
So, in summary, more questions than answers.
I'll try to have another look later. -
Connecting SAP with an independent SQL database
Dear all,
I need to connect SAP with an independent MSSQL database.
My requirement is to transfer a set of records from my Ztable to a table in SQL database.
I have maintained the settings in DBCO transaction. I maintained DBMS as 'MSS' in DBCO.
send some sample code of how to establish the connection. Is it possible to write data in to SQL database.
How to edit the file tnsnames.ora in application server directories. I heard that for connecting to an oracle database we need to edit this , is it necessary to edit this tnsnames.ora even for connecting with SQL database?
Thanks in advance.
LakshmanThis is not possible.
My suggestion is that you create shell scripts on the unix side that copy the data to the other database.
ARD runs it's own private copy of PostGgreSQL inside the package so it won't interfer with any other SQL databases on the network or even on the machine. -
Using collections / Bind variables with a PL/SQL functio returning a query
I have this code, which is supposed to assign collection variables as column names
FOR i in 1 .. Collection_count -1
LOOP
SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
SELECT c002 into varholder FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
vQuery:= vQuery || 'SUM(decode(label, ''Aware'', product_'|| i || ', ''Expert'', product_' || i || ', ''Proficient'', product_' || i || ', ''Advanced(Demo)'', product_' || i || ' )) as ';
vQuery:=vQuery || varholder || ', ' ;
END LOOP;
I've tried &P341_M1. , :P341_M1, ':P341_M1', varholder
When I try '&P341_M1' it returns the whole SUM(decode... line as the label
Basically Im having a hard time using bind variables with the PL/SQL returning a query...anybody?Ok so working through this problem more I have realized that the problem is using the for loop i as an index value
This will get a value:
SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=2;
But this won't
SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
I'm in the for loop, and use the i variable in other places within this loop...Is there a reason why I can't compare seq_id to i?
My new code as follows:
FOR i in 1 .. Collection_count -1 --apex_application.g_f01.COUNT - 1
LOOP
varholder:=i;
SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=2;
SELECT c002 into varholder FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=4;
vQuery:= vQuery || 'SUM(decode(label, ''Aware'', product_'|| i || ', ''Expert'', product_' || i || ', ''Proficient'', product_' || i || ', ''Advanced(Demo)'', product_' || i || ' )) as f';
vQuery:=vQuery || :P341_M1 ||i||', ' ;
END LOOP; -
Help with anonymus pl/sql layout using javascript
Hi people.
i want to display some records on a region (using apex 4.2) , this anonymous pl/sql script below shows 3 records from database, but the layout only shows me the first record with it's data, the others 2 records, only show me labels.
i have verified this same query creating a report and it shows the 3 records correctly.
i guess i am doing something wrong with this javascript routine or i am surely missing something,
in this link you can see the layout i am getting. (http://sdrv.ms/Xrv0J8).
the other little help i need is to display in one row for each record. actually i am getting one row for each label and one row for each data record. i have read and found is something about /div, but i don't no how to change it to get desired results, any suggestion is welcome.
thanks in advance for any help.
i am completely new in apex and java script, but i have several years experience in pl/sql.
The Script :
Begin
Declare
Cursor Deliv Is
Select item,
To_char (Delivery, 'month dd, yyyy hh24:mi:ss') Delivery,
Current_date
From pending_items;
Begin
For A In Deliv Loop
Begin
Sys.Htp.P ('<script type="text/javascript">');
Sys.Htp.P ('function cdtd() {');
Sys.Htp.P (' var xmas = new Date("' || a.delivery || '")');
Sys.Htp.P (' var now = new Date();');
Sys.Htp.P (' var timeDiff = xmas.getTime() - now.getTime();');
Sys.Htp.P (' if (timeDiff <= 0) {');
Sys.Htp.P (' clearTimeout(timer);');
-- Sys.Htp.P (' document.write("Some Text Here!");');
Sys.Htp.P (' // Run any code needed for countdown completion here');
Sys.Htp.P (' }');
Sys.Htp.P (' var seconds = Math.floor(timeDiff / 1000);');
Sys.Htp.P (' var minutes = Math.floor(seconds / 60);');
Sys.Htp.P (' var hours = Math.floor(minutes / 60);');
Sys.Htp.P (' var days = Math.floor(hours / 24);');
Sys.Htp.P (' hours %= 24;');
Sys.Htp.P (' minutes %= 60;');
Sys.Htp.P (' seconds %= 60;');
Sys.Htp.P (' document.getElementById("daysBox").innerHTML = days;');
Sys.Htp.P (' document.getElementById("hoursBox").innerHTML = hours;');
Sys.Htp.P (' document.getElementById("minsBox").innerHTML = minutes;');
Sys.Htp.P (' document.getElementById("secsBox").innerHTML = seconds;');
Sys.Htp.P (' var timer = setTimeout("cdtd()",1000);');
Sys.Htp.P ('}');
Sys.Htp.P ('</script>');
Sys.Htp.P ('Days ');
Sys.Htp.P ('<div id="daysBox"></div>');
Sys.Htp.P ('Hours');
Sys.Htp.P ('<div id="hoursBox"></div>');
Sys.Htp.P ('Minutes');
Sys.Htp.P ('<div id="minsBox"></div>');
Sys.Htp.P ('Seconds');
Sys.Htp.P ('<div id="secsBox"></div>');
Sys.Htp.P ('<script type="text/javascript">');
Sys.Htp.P ('cdtd();</script>');
End;
End Loop;
End;
End;Let's focus on your delivery dates and javascript for now.
Why you would put your javascript in htp.p calls in a plsql region is quite beyond me. When you edit the page there is a javascript region where you can put global variables and functions, an excellent spot for this then, and a lot more maintainable than this.
Now it's also obvious that your query on pending items will return more than one record. So, using a report would serve you well in this case. However, using code like this:
document.getElementById("daysBox").innerHTML = days;
document.getElementById("hoursBox").innerHTML = hours;
document.getElementById("minsBox").innerHTML = minutes;
document.getElementById("secsBox").innerHTML = seconds;will not serve you. getElementById is meant to return one element uniquely identified by an ID. If you have a report with multiple rows, and elements on each row with the same ID, you are doing something wrong. You would need the delivery date per row, and I guess that you put out your code with htp.p because you do not know how to deal with that and passing it in to the javascript procedure.
But wouldn't it be more oppurtune for you to simply create a report with a source sql where you calculate each part of the date, and then refresh this region with a certain interval. If you'd refresh every 5 minutes, wouldn't that be more than fast enough to keep track of things? Don't forget, refreshing a region will execute the sql again.
It's not that you can't accomplish a multirecord report with a countdown per row, but are you comfortable enough with javascript and jquery to code and maintain that versus leveraging plsql and dynamic actions (there is even a dynamic action timer plugin provided by oracle)? -
How to establish a trusted connection with JDBC for SQL SERVER 2000
Hi!I am using jdk 1.4 and eclipse 3.3.
I create a servlet in eclipse with in-build tomcat.
When I run it ,it was working perfectlly has it was suppose to work.
In this servlet I connect to a sql 2000 database using jdbc-odbc bridge driver.
But when I tried to deploy the servlet on tomcat 5.5 manully on the same machine ,it gave me error saying
[Microsoft][SQLServer JDBC Driver][SQLServer]Login failed
for user 'sa'
I searched around some post and found that ok ,I need trusted connection
But I have 2 Questions
1). Why was in eclipse I was able to connect to the SQL server and why not in the servlet which I deployed manully on tomcat.
2). How do I create a trusted connection with JDBC for SQL server 2000
Thnaks for your help in advance.Hi! duffymo ,QussayNajjar ,dvohra09 .
Thank for help.
The ideas are really great.
I am trying generate reports for my company.
When I used eclipse the code worked perfectly.
below is code which I used
out.println("Calling For Class Name<br>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
out.println("Calling For Class Name success Now calling database <br>");
1). jdbcConnection = DriverManager.getConnection("jdbc:odbc:SQLJasper");
2). jdbcConnection = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=ServerName;Database=tempdb");
3). jdbcConnection = DriverManager.getConnection("jdbc:odbc:Driver={SQL Server};Server=ServerName;Database=tempdb","UID=UserName","Password=Password");
out.println("connecting to database success<br>");
I had tried to connect the database using this three way.
In 1st I tried using DSN name .
Next 2 self explainer for expert like you.
I used to 2nd variant to connect in eclipse and it worked fine.
I not an expert in java ,I just doing some research on jasperReport.
My best guest is that eclipse is using some library files of which I have no clue.
Thank's for your help,I appretiate it.
Once again thank a billion.
Sorry for the messy righting. -
DeskI report with free hand sql
Hi,
I have converted a deski report from BO 5x to BO Xi. R3. That report contains a free hand sql connection. The report run fine when running from the server. But it is not when I am trying to refresh it through Infoview; somehow I am getting the CORBA Initialization failiure.
I tested successfully the connection through Desinger. I am not sure what I need to do next.
Please help!!!!
Edited by: Brian Mangan on Sep 9, 2010 10:53 PMHi,
When a report with free hand sql converted from earlier versions (5x) to latest version (r3 I guess) then the connection parameters sholud be changed in latest version (r3). Please change ur connection parameters in r3. i.e the user name, password and connection string so that in r3 we can connect to back end and then try to refresh the report in webi.
The Corba Initialization is related to invalid connection to back end.
Cheers,
Suresh Aluri. -
How to call a stored procedure on time basis with out using sql job and GOTO
Hi,
I wanted to call a stored proc, on time basis ,
please tel me how it can be done with out using sql job , goto .
1) That is, is there any timer aviable in sqlserver.
q2) And which one is better GOTO or sql job.
yours sincerleyRaj, Check if my explanation helps you:
Your job runs every 10 seconds.
Lets say first time you are scheduling and running your job at 12:00:00 PM
Now your proc will start executing.
Say it got finished at 12:00:07.
Now the next schedule time is 12:00:10 PM.
The moment this time hits, the job will get invoked and start executing the proc.
Lets say this time it finished at 12:00:22 PM (It took 2 extra seconds)
This time the scheduled time is already gone (12:00:20 PM), thus it'll now run at the next schedule that is 12:00:30 PM.
Thus if anytime your job takes more than 10 seconds to run, it'll just miss those particular schedules overlapping with execution time. Otherwise you are good to go.
PS: A job is the best way to handle this, in your problem statement you don't need a job but that would be wrong. You have another way to do that, if you keep running your procedure all the time and the moment your timestamp hits a multiple of 10
seconds you can run your logic and then returning to the timer. But this is extremely wrong for a system. Even if your requirement is extremely transactional and complex, I would not suggest this. If the job is taking more than 10seconds (which it might if
your logics inside are complex), you should optimize your code and table architecture.
Chaos isn’t a pit. Chaos is a ladder. Many who try to climb it fail and never get to try again. The fall breaks them. And some are given a chance to climb, but they refuse. They cling to the realm, or the gods, or love. Illusions. Only the ladder is real.
The climb is all there is.
Maybe you are looking for
-
How can I transfer podcast from iMac G4 to iPad?
Hello, I used to download a radio program -- 11+MB -- to my MacBook Nothing; but it was stolen. Now, I am using an iMac G4 running Tiger; when the program is downloaded it goes to iTunes, in Music. After that, I add the date to the number of the epis
-
Why doesn't my VGA cable work after downloading iOS 8.0.2?
After downloading iOS 8.0.2, my VGA cable no longer works. Any ideas? How can I uninstall iOS 8.0.2?
-
On Windows 7 64 bit machines, we are seeing users that have Adobe Acrobat Pro installed where Firefox 18 is using the Adobe PDF as the default printer even though the print.print_printer is set to the correct system default printer.
-
PMON terminating instance due to error 472
Hello i have a database that was has crashed with the following errors : oing block recovery for file 74 block 84379 Block recovery from logseq 51144, block 137 to scn 27771463134 Fri Apr 29 18:48:24 2011 Recovery of Online Redo Log: Thread 1 Group 2
-
I purchased on-line a new Super Zoom for my iPad and iPhone. when I attached the iPhone lense to the iPhone, there seems to be a problem with the view. You can still see the outline of the lense and it is not a clear view looking through. Can you hep