The problem of function-based reuse
I read the quoted text as follows from a book authored by a Microsoft developer. I googled and found a lots of quotes of it, but did not find any explanation.
============
With languages like C, the basic unit of reuse is the function. The problem with function-based reuse is that the function is coupled to the data it manipulates. and if the data is global, a change to benefit one function in one reuse context damages another function used somewhere else.
============
C uses libraries widely,which is of function-based reuse. Can anybody kindly give me a scenario when this problem happens?
Java is typically object-based reuse, and I admit that my question is not a Java one. But I feel it would help to understand more about the concept or benefits of design of Java language. So, thank you to allow me to post this question here,
Edited by: 799160 on Sep 30, 2010 12:38 PM
Edited by: 799160 on Sep 30, 2010 12:57 PM
This is what I got out of reading the quote you posted:
I suppose something like the following could happen:
You (being a general person) have been given a class to modify. You look at the code for the first time and it has a bunch of methods and some class variables in it. Some of the methods use the class variables. How can you be sure if you change the functionality to change a class variable in one method won't affect the other methods when they are used? This problem can be solved by learning what everything does, how it interacts and the correct way to use it. But then again, if you don't think about it and just make changes...Oops!
Perhaps another abstract example would make sense:
Imagine a calculator that could be used by 2 people at the same time? I bet it'd come up with some funny answers :)
I wrote up a short example of this, hopefully it makes some sense:
public class SuperBigProgram
private int globalVar;
public static void main ( String[] args )
new SuperBigProgram();
public SuperBigProgram()
System.out.println("I'm a super big program.");
globalVar = 0;
//Let's pretend these series of events occur during the program:
doItHighChanceActivity(); //1
doItHighChanceActivity(); //2
doItHighChanceActivity(); //3
//Whoops super rare event occured!
doesNotHappenALot();
doItHighChanceActivity(); //4???? but is really 5.
* This happens A LOT!
private void doItHighChanceActivity ()
superUtilityMethod();
System.out.println("globalVar: " + globalVar);
* This utility method does some awesome utility stuff for our Super Big Program.
* This changes some global data.
private void superUtilityMethod()
globalVar++;
* This does not happen a lot, if at all.
private void doesNotHappenALot()
//Hey I don't happen a lot but I'm reusing this really cool utility method that contains global data...
//Code reuse for the win!
superUtilityMethod();
}Here is the output:
I'm a super big program.
globalVar: 1
globalVar: 2
globalVar: 3
globalVar: 5
Edited by: kilosi on Sep 30, 2010 1:22 PM
Similar Messages
-
Performance problem on function-based index
Hi guys,
I am having performance problems with the addition of new function-based indexes.
alter session set nls_comp='ANSI';
alter session set nls_sort='BINARY_CI';
* have to run this because the of case-insensitivity requirements
I have a view. for ex:
create or replace view view1
as
select * from emp1,user
where emp1.empno=user.empno
union
select * from emp2,user
where emp2.empno=user.empno
union
select * from emp3,user
where emp3.empno=user.empno and so on
When I run this it works with a full table scan. Then when i created a function-based index:
create index user_ix on
user(nlssort(empno,'NLS_SORT=BINARY_CI'));
analyze index user_ix compute statistics;
analyze table user compute statistics;
the view hangs. but when i run the individual select statements it works.
Do you guys have any idea on what's going on? Any advise is greatly appreciated.
Thanks.LC is absolutely right. Brain cramp on my part.
On the other hand, I can't seem to coerce Oracle to apply a to_binary_double conversion as part of an implicit conversion.
var bin_dbl binary_double;
select to_binary_double(14) into :bin_dbl from dual;
SCOTT @ nx102 JCAVE9420> select * from emp where empno = :bin_dbl;
no rows selected
Elapsed: 00:00:00.14
Execution Plan
Plan hash value: 2949544139
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 39 | 1 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 39 | 1 (0)| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("EMPNO"=TO_NUMBER(:BIN_DBL))I'd expect that Oracle would try to convert the binary double to a number, not the other way around.
Justin -
Problem with function-based spatial index in 10g
hi,
the document's example doesn't work anymore.
http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10826/sdo_exten.htm#sthref721
when i try to create the index i get the following error message:
create index LONG_LAT_TABLE_IDX on LONG_LAT_TABLE(get_long_lat_pt(longitude,latitude)) indextype is mdsys.spatial_index
ERROR at line 1:
ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-13249: internal error in Spatial index: [mdidxrbd]
ORA-13249: Error in Spatial index: index build failed
ORA-13249: Error in spatial index: [mdrcrtxfergm]
ORA-13249: Error in spatial index: [mdpridxtxfergm]
ORA-29400: data cartridge error
ORA-00904: "XXX"."GET_LONG_LAT_PT": invalid identifier
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10
ORA-06512: at line 1
I'm not sure, but I think this problem occured in one special version of 9i...
thanks in advance,
michael
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining optionsHi Michael,
Do you have a user named XXX on your system? Are you creating the index as XXX?
I logged in as scott, followed the example, and had no problems.
SQL> create index LONG_LAT_TABLE_IDX on
LONG_LAT_TABLE(get_long_lat_pt(longitude,latitude))
indextype is mdsys.spatial_index;
Index created.
SQL> SQL> select name from LONG_LAT_TABLE a
where sdo_filter(get_long_lat_pt(a.longitude,a.latitude),
sdo_geometry(2001, 8307,
sdo_point_type(10,10,NULL), NULL, NULL)
)='TRUE';
NAME
Place1
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options -
The problem (procedure, function, package) in object browser
we are using htmldb 2.0 in oracle DB 9.2.0.6. When we are using http server from 9.2 in the object browser for procedures, functions, packages display window show only header and all window is red, all other objects look fine. when the same DB I config with http server 10g(companion cd) it is display all objects fine.
PS we didn't forget to put
AddType text/xml xbl
AddType text/x-component htc
Is it bug in htmldb through http server 9.0.3.
MBI thought this was a browser issue. I "see red" from IE from my home PC, but I thought that's because my browser isn't up to date. Update downloads are too big for the dialup connection from home.
My IE and FF browsers work fine from work - where I update them regularly - over a nice fast connection.
Earl -
Function based indexes on CLOB storage
On a 10gR2 database, with schema-less CLOB storage for an XMLType column:
(1) Can a function based index include a wildcard in the namespace ? Or do I need a new function based index for each specific namespace ?
(2) I must create a new function based index for each different element that I want an indexed search on ?
(3) What limit is there on the number of function based indexes per table ?
(4) I believe XQuery can include a wildcard for namespaces, but XPath 1.x can't. Can I create a function based index using XQuery, rather than XPath ?
Documents conforming to different versions of an XML schema will be present (schema versioning), but I want to search across all documents irrespective of a specific namespace - e.g. "Find any document with reference = 'some Value' , and amount = 1000".
CLOB storage is proposed, due to the need to handle documents from multiple versions of an XML schema. The knowledge of the XSD is not known at development time, but is user definable, and it must be possible to change the structure without system down time. Structured storage is not suitable, due to Oracle's requirement for downtime if the schema changes (CopyEvolve drops/recreates tables), and Oracle doesn't support schema collections, so you can't bind an XML column to multiple schemas.
Here is some sample code of what I'm trying to do:
create table BulkTest
ID NUMBER(10) not null primary key,
USERFIELDS XMLTYPE
create sequence S_BulkTest;
--Document conforming to version 1 of schema
INSERT INTO BulkTest(id, Userfields) VALUES
(S_BulkTest.Nextval,
'<?xml version="1.0" encoding="utf-8" ?>
<mt395 xmlns="urn:incident:mt395-1">
<reference>FH12345678</reference>
<relatedReference>FH23456789</relatedReference>
<queries>Here is some query text.</queries>
<narrative>Here is some narrative text.</narrative>
<relatedMessageType>300</relatedMessageType>
<relatedMessageDate>2005-03-29</relatedMessageDate>
<direction>R</direction>
<sessionNumber>1234</sessionNumber>
<isn>123456</isn>
<relatedMessageDescription>This is the deal where I bought USD 1 million for GBP at 1.76.</relatedMessageDescription>
<otherParty>232332</otherParty>
</mt395>'
--Document conforming to version 2 of schema
INSERT INTO BulkTest(id, Userfields) VALUES
(S_BulkTest.Nextval,
'<?xml version="1.0" encoding="utf-8" ?>
<mt395 xmlns="urn:incident:mt395-2">
<guid>0f9a08f6-b052-4693-baba-8f7dc881e7e8</guid>
<reference>333333</reference>
<queries>Another query</queries>
<narrative>Some narrative</narrative>
<direction>R</direction>
<sessionNumber>1234</sessionNumber>
<isn>223456</isn>
</mt395>'
--It seems I need to create a new index for each field I want to search on
create index iBulkTest_REFERENCE
on BulkTest
(extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-1"'));
--And that a new index is required for each specifc namespace that is present
--Can't we include a wildcard in the namespace ?
create index iBulkTest_REFERENCE_2
on BulkTest
(extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"'));
--If I want to query, I have to explicitly specify each namespace.
--Can't I specify a wildcard ?
--This will make it "fun" querying across namespaces!
select
id,
extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"') As Reference,
t.userfields.getclobval() userfields
from bulktest t
WHERE extractValue(UserFields,'/mt395/reference', 'xmlns="urn:incident:mt395-2"') = '333333'Andy
#1. You do not have scehma versioning here. Your model is totally incorrect. You shoud not change the namespace when versioning the XML Schema. You have 2 different and totally disjoint XML Schemas. The correct was to version, as distinct from evolve an XML Schema is to change the Schema Location Hint associated with your XML...
Eg
INSERT INTO BulkTest(id, Userfields) VALUES
(S_BulkTest.Nextval,
'<?xml version="1.0" encoding="utf-8" ?>
<mt395 xmlns="urn:incident:mt395" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:incident:mt395 mt395-1.xsd">
<reference>FH12345678</reference>
<relatedReference>FH23456789</relatedReference>
<queries>Here is some query text.</queries>
<narrative>Here is some narrative text.</narrative>
<relatedMessageType>300</relatedMessageType>
<relatedMessageDate>2005-03-29</relatedMessageDate>
<direction>R</direction>
<sessionNumber>1234</sessionNumber>
<isn>123456</isn>
<relatedMessageDescription>This is the deal where I bought USD 1 million for GBP at 1.76.</relatedMessageDescription>
<otherParty>232332</otherParty>
</mt395>'
--Document conforming to version 2 of schema
INSERT INTO BulkTest(id, Userfields) VALUES
(S_BulkTest.Nextval,
'<?xml version="1.0" encoding="utf-8" ?>
<mt395 xmlns="urn:incident:mt395 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:incident:mt395 mt395-2.xsd">
<guid>0f9a08f6-b052-4693-baba-8f7dc881e7e8</guid>
<reference>333333</reference>
<queries>Another query</queries>
<narrative>Some narrative</narrative>
<direction>R</direction>
<sessionNumber>1234</sessionNumber>
<isn>223456</isn>
</mt395>'
This is the correct way of versioning an XML Schema. THe namespace stays the same, the SchemaLocationHint in the SchemaLocation tag changes.
Bear in mind that if you use the technique you are currently using you will make any path expressions you need to write absolutely unmaintaining and the processing of them very inefficient.
Some questions to consider
Node 'X' in namespace 'X' is never the same as Node 'X' in namespace 'Y'.
How would you write an Xpath or XQuery that targetted multiple versions, but not all versions ?
What happens if you have other documents that are really in a different namespace ? Using wildcards can you differentiate them..
From the problem you are describing and the terminolgy you are using it looks like you've been an early customer of Yukon. MSFT clearly didn't understand schema versioning in the early beta releases and used the 'change the namespace' schema for modelling schema versioning.
We do have some technology coming down the pipe which can address the issue, regardless of whether or not it is too late for you to correct the versioning scheme you have selected. However I cannot discuss that in a public forum. If you want to learn about these features and are prepared to enter an NDA with Oracle in order to do so please contact me directly. You can do this a number of ways...
Guess my email address @oracle.com
Post your email address here and I'll delete the post as soon as I have it..
Update your OTN Forum profile to include your email address
Open a TAR and post the tar number here. You can then softclose the tar as this is simply a method for me to get your contact info. -
Function Based Index on Date Column
Hi All,
I need to execute a query like this :
SELECT * FROM ORDERS WHERE APPROVE_DATE IS NULL
I read anywhere that this will cause unnecessary FTS so that I should create function based index.
I have tried one below , but not sure that this is correct approach :
CREATE INDEX idx_1
ON ORDERS (NVL(APPROVE_DATE, '01-JAN-1900'));
SELECT * FROM ORDERS WHERE NVL(APPROVE_DATE, '01-JAN-1900') = '01-JAN-1900'
Is this a correct approach ?
Thank you,
xtantoA SQL_TRACE output will explain clearly what Justin has stated.
I have created a table T based on all_objects.
SQL> desc t
Name Null? Type
OWNER NOT NULL VARCHAR2(30)
OBJECT_NAME NOT NULL VARCHAR2(30)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME NOT NULL DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
CASE I_
SQL> select count(1) from t
2 /
COUNT(1)
934320
SQL> select count(1) from t where created is null
2 /
COUNT(1)
2376The number of null values in CREATED column is proportionately very small.
Now i execute the query without function based index.
select *
from t
where created is null
call count cpu elapsed disk query current rows
Parse 1 0.00 0.09 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 160 0.04 0.10 0 12662 0 2376
total 162 0.04 0.19 0 12662 0 2376
Rows Execution Plan
0 SELECT STATEMENT GOAL: ALL_ROWS
2376 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'T' (TABLE)And here is the query that uses the function based index
select *
from t
where nvl(created,to_date('01-01-1900','DD-MM-YYYY')) = to_date('01-01-1900','DD-MM-YYYY')
call count cpu elapsed disk query current rows
Parse 1 0.01 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 160 0.01 0.01 0 698 0 2376
total 162 0.03 0.01 0 698 0 2376
Rows Execution Plan
0 SELECT STATEMENT GOAL: ALL_ROWS
2376 TABLE ACCESS GOAL: ANALYZED (BY INDEX ROWID) OF 'T' (TABLE)
2376 INDEX GOAL: ANALYZED (RANGE SCAN) OF 'T_FN_IDX' (INDEX)Its very obvious from the above output that the Function Based Index as increased the performance.
CASE II_
SQL> select count(1) from t
2 /
COUNT(1)
934320
SQL> select count(1) from t where created is null
2 /
COUNT(1)
202168Now the null values in the CREATED column is proportionately large than the first test case.
Now lets see without using the function based index
select *
from t
where created is null
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 13479 0.46 0.71 2 25832 0 202168
total 13481 0.46 0.71 2 25832 0 202168
Rows Execution Plan
0 SELECT STATEMENT GOAL: ALL_ROWS
202168 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'T' (TABLE)Now iam trying to use the function based index
select *
from t
where nvl(created,to_date('01-01-1900','DD-MM-YYYY')) = to_date('01-01-1900','DD-MM-YYYY')
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 13479 0.54 0.84 0 33826 0 202168
total 13481 0.54 0.84 0 33826 0 202168
Rows Execution Plan
0 SELECT STATEMENT GOAL: ALL_ROWS
202168 TABLE ACCESS GOAL: ANALYZED (FULL) OF 'T' (TABLE)Its obvious from the result that oracle has decided to go for a FULL TABLE SCAN even when an index was available.
So just having a function based index is not going to increase the query performance. There are lot of other factors to be considered as stated above.
Thanks,
Karthick. -
Segment Shrinking script erroring out due to Function based indexes, lobs,.
DB version:10gR2
Following is a script i made for freeing up(SHRINK ing and resetting HWM) the space in Tables and its indexes. Due to the existence of LOB Segments and Tables with Function based indexes, this script was erroring out. So i was wondering if there is a way to find out the segments which are eligible/not eligible for Shrinking so that i could make necessary changes to the below script.
create or replace procedure freeup_space
is
type v_segment_type is table of varchar2(30) index by binary_integer;
v_segment v_segment_type;
begin
select segment_name bulk collect into v_segment
from user_segments
where segment_type in ('TABLE')
and segment_name not like 'BIN%';
for i in v_segment.first..v_segment.last loop
execute immediate 'alter table ' || v_segment(i) ||' enable row movement';
dbms_output.put_line('Table '||v_segment(i)||'''s row movement enabled');
execute immediate 'alter table ' || v_segment(i) ||' shrink space cascade';
execute immediate 'alter table ' || v_segment(i) ||' deallocate unused';
end loop;
end;
/You can use USER_LOBS views to look for LOB columns in the segments and ALL_INDEXES.INDEX_TYPE tells if the index is function based index or not.
Message was edited by:
Pierre Forstmann -
Limit on number of function based indexes ?
What is the limit on the number of function based indexes that can exist on a table ?
I haven't been able to find this info in the Oracle docs yet . I'd RTFM, but which one ? There's so many ! :-)http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14237/limits003.htm#sthref4186
-
Reason for Macbook Pro super slow download speeds, when all other Apple devices in the house are downloading correctly. I am not attempting to use multiple devices at the same time. What could be the problem with the Macbook Pro?
Resetting SMC could solve the problem.
Intel-based Macs: Resetting the System Management Controller (SMC)
And you need to install more RAM, I think. -
How do I fix the problems with text formating functions in hotmail and other text based sites?
In a Mailing list provider site it disables the text formating functions, instead only showing a 'loading' message. The functions never appear. In Hotmail the scroll arrows on the right hand side does not work. Sometimes the email toolbar becomes 'grey' and the buttons do not work. When forwarding an email sometimes the email does not show in the new email message.
== This happened ==
Every time Firefox opened
== Firefox was reinstalled March 2010.The only possible fix was turning the phone off immediately and burying it in a bag of dry rice for a week at least. That might...just might...have worked. But you're way beyond that and I see no fixes. In fact the phone is probably going to get more problems before finally gving up the ghost. Continued use is just shorting out more and more of the circuitry. For that reason I don't think repair is much of an option. Go to an Apple Store and buy an out-of-warranty replacement.
-
Function-based index with OR in the wher-clause
We have some problems with functin-based indexes and
the or-condition in a where-clause.
--We use Oracle 8i (8.1.7)
create table TPERSON(ID number(10),NAME varchar2(20),...);
create index I_NORMAL_TPERSON_NAME on TPERSON(NAME);
create index I_FUNCTION_TPERSON_NAME on TPERSON(UPPER(NAME));
The following two statements run very fast on a large table
and the execution-plan asure the usage of the indexes
(-while the session is appropriate configured and the table is analyzed):
1) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%';
2) select count(ID) from TPERSON where NAME like 'Mil%' or (3=5);
In particular we see that a normal index is used while the where-clause contains
an OR-CONDITION.
But if we try the similarly select-statement
3) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%' or (3=5);
the CBO will not use the function-index I_FUNCTION_TPERSON_NAME and we have a full table scan in the execution-plan.
(This behavior we only expect with views but not with indexes.)
We ask for an advice like a hint, which enable the CBO-usage
of function-based indexes in connection with OR.
This problem seems to be artificial because it contains this dummy logic:
or (3=5).
This steams from an prepared statement, where this kind of boolean
flag reduce the amount of different select-statements needed for
covering the hole business-logic, while using bind-variables for the
concrete query-parameters.
A more realistic (still boild down) version of our select-statement is:
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
thank you for time..
email: [email protected]In the realistic statement you write :
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
as far as i know, NULL values are not indexed, "or (NAME is NULL)" have to generate a full table scan.
HTH
We have some problems with functin-based indexes and
the or-condition in a where-clause.
--We use Oracle 8i (8.1.7)
create table TPERSON(ID number(10),NAME varchar2(20),...);
create index I_NORMAL_TPERSON_NAME on TPERSON(NAME);
create index I_FUNCTION_TPERSON_NAME on TPERSON(UPPER(NAME));
The following two statements run very fast on a large table
and the execution-plan asure the usage of the indexes
(-while the session is appropriate configured and the table is analyzed):
1) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%';
2) select count(ID) from TPERSON where NAME like 'Mil%' or (3=5);
In particular we see that a normal index is used while the where-clause contains
an OR-CONDITION.
But if we try the similarly select-statement
3) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%' or (3=5);
the CBO will not use the function-index I_FUNCTION_TPERSON_NAME and we have a full table scan in the execution-plan.
(This behavior we only expect with views but not with indexes.)
We ask for an advice like a hint, which enable the CBO-usage
of function-based indexes in connection with OR.
This problem seems to be artificial because it contains this dummy logic:
or (3=5).
This steams from an prepared statement, where this kind of boolean
flag reduce the amount of different select-statements needed for
covering the hole business-logic, while using bind-variables for the
concrete query-parameters.
A more realistic (still boild down) version of our select-statement is:
select * FROM TPERSON
where (upper(NAME) like 'MIL%' or (NAME is null))
and (upper(FIRSTNAME) like 'MICH% or (FIRSTNAME is null))
and ...;
thank you for time..
email: [email protected] -
Conditionally executing a function based on the existance of an item value
I want to populate a field based on a function. Easy enough with a function I have created to do this.
GET_A_VALUE(:P14_ID);
This works nicely when I put that in the default value and then go and edit an existing record.
The problem is when we try and create a new value. :P14_ID does not exist
I get something like this
ORA-01403: no data found
Error ERR-9132 Error in PLSQL expression for item default code, item=P14_ID
OK
Which makes sense as P14_ID doee not exist yet.
I've tried to do something like this with no luck in the default field
begin
if :P14_ID is NOT NULL
then GET_A_VALUE(:P14_ID);
end if;
end;
Which gets me this
ORA-06550: line 3, column 6: PLS-00221: 'GET_A_VALUE' is not a procedure or is undefined ORA-06550: line 3, column 6: PL/SQL: Statement ignored
Error ERR-9131 Error in PLSQL function body for item default code, item=P14_ID
OK
Am I approaching this in the correct way? Any suggestions?I would have thought his function would look more like this:
FUNCTION get_Value(p_val IN NUMBER)
IS
l_ret VARCHAR2(1);
BEGIN
SELECT dummy INTO l_ret FROM dual WHERE 1=1;
RETURN l_ret;
ENDWhen in fact it should look something like this:
FUNCTION get_Value(p_val IN NUMBER)
IS
l_ret VARCHAR2(1);
CURSOR i IS SELECT dummy FROM dual WHERE 1=1;
BEGIN
OPEN i;
FETCH i INTO l_ret;
CLOSE i;
RETURN l_ret;
END; -
Function-based Index and an OR-condition in the WHERE-clause
We have some problems with functin-based indexes and
the or-condition in a where-clause.
(We use oracle 8i (8.1.7))
create table TPERSON(ID number(10),NAME varchar2(20),...);
create index I_NORMAL_TPERSON_NAME on TPERSON(NAME);
create index I_FUNCTION_TPERSON_NAME on TPERSON(UPPER(NAME));
The following two statements run very fast on a large table
and the execution-plan asure the usage of the indexes
(-while the session is appropriate configured and the table is analyzed):
1) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%';
2) select count(ID) from TPERSON where NAME like 'Mil%' or (3=5);
In particular we see that a normal index is used while the where-clause contains
an OR-CONDITION.
But if we try the similarly select-statement
3) select count(ID) FROM TPERSON where upper(NAME) like 'MIL%' or (3=5);
the CBO will not use the function-index.
(This behavior we only expect with views but not with indexes.)
We ask for an advice like an hint, which enable the CBO-usage
of function-based indexes in connection with OR.
This problem seems to be artificial because it contains this dummy logic:
or (3=5).
This steams from an prepared statement, where this kind of boolean
flag reduce the amount of different select-statements needed for
covering the hole business-logic, while using bind-variables for the
concrete query-parameters.
A more realistic (still boild down) version of our prepared select-statement run in
SQL Plus:
define x_name = 'MIL%';
define x_firstname = '';
select * FROM TPERSON
where (upper(NAME) like '&x_name' or ( '&x_name' = ''))
and (upper(FIRSTNAME) like '&x_firstname' or ('&x_firstname' = ''))
and ...;
In particular we dont refernce the tablecolumn , but the QUERY-Parameter
yield the second boolean value in the or-condition.
The problem is that this condition ('&x_name' = '') dont use any index.
thanks a lot for spending your time with this problemTry
SELECT /*+ RULE */
as your hint. I don't have the book with me, but this last weekend I read a section about your very problem. The book was a Oracle Press gold cover about Oracle 8i Performance tuning. If you e-mail me I can quote you the chapter when I get home Friday. -
Problem using two function based indexes at once!
Hello Oracle!
I've got problems using two function based indexes on geometries at once.
The problem occures, when I use a spatial join between two geometries both using function based indexes.
The test case:
CREATE TABLE quad (centroid NUMBER);
CREATE TABLE points (no NUMBER, point MDSYS.SDO_GEOMETRY);
CREATE OR REPLACE FUNCTION getQuad (centroid NUMBER) RETURN MDSYS.SDO_GEOMETRY DETERMINISTIC IS
BEGIN
RETURN MDSYS.SDO_GEOMETRY(2003, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1),MDSYS.SDO_ORDINATE_ARRAY(centroid-5,centroid-5,centroid+5,centroid-5,centroid+5,centroid+5,centroid-5,centroid+5,centroid-5,centroid-5));
END;
INSERT INTO USER_SDO_GEOM_METADATA VALUES('quad','tiedge.getQuad(centroid)',MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X', -100, 100, .0000001), MDSYS.SDO_DIM_ELEMENT('Y', -100, 100, .0000001)),NULL);
CREATE INDEX quad_idx on quad(getQuad(centroid)) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
INSERT INTO quad VALUES (0);
INSERT INTO quad VALUES (5);
INSERT INTO quad VALUES (10);
INSERT INTO points VALUES (1, MDSYS.SDO_GEOMETRY(1001,NULL,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1),MDSYS.SDO_ORDINATE_ARRAY(4,4)));
ALTER SESSION SET QUERY_REWRITE_INTEGRITY=TRUSTED;
ALTER SESSION SET QUERY_REWRITE_ENA[i]Long postings are being truncated to ~1 kB at this time.hi there,
For a better audience for this question, I'd look at the database forum.
guys on that will be a lot more familiar with FBIs
thanks
Barry -
Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels. Such problems never arose during two years of using LTR-4 and nothing else has changed on my computer. I have a pretty simple system with only a few plug-ins, which are usually not in operation. I have 12GB of RAM in my Windows 7 PC. I could illustrate these problems with screen shots if you would tell me how to submit screen shots. Otherwise I will try to describe the problems in words.
The problem is clearly cumulative, growing worse as usage time passes. Compare View feature gradually slows down and eventually seems to choke as my work session proceeds. If I Exit LTR and re-enter and start all over, things will work normally for maybe 30 minutes, but then the Compare View feature begins to become very slow to respond. In a recent example with my screen full of thumbnails in Library mode I highlighted two images to compare. LTR started to open the Compare View screen by first having the top row of thumbnails disappear to be replaced by the "SELECT" and "CANDIDATE" words in their spaces (but no images), but Compare View never succeeded in gaining control of the screen. After some seconds the top row of thumbnails reasserted its position and the Compare View windows disappeared. But LTR kept trying to bring them back. Again the top row of thumbnails would go away, Select and candidate would reappear, try again, and give up. This went on for at least 2-3 minutes before I tried to choose File and Exit, but even that did not initially want to respond. It doesn't like to accept other commands when it's trying to open Compare View. Finally it allowed me to exit.
To experiment I created a new catalog of 1100 images. After 30-40 minutes, the Compare View function began to operate very slowly. With left and right side panels visible and two thumbnails highlighted, hitting Compare View can take half a minute before the two mid-size images open in their respective SELECT and CANDIDATE windows. When the side panels are open and two images are in the Select/Candidate spaces, hitting the Tab button to close the side panels produces a very delayed response--25-30 seconds to close them, a few more seconds to enlarge the two images to full size. To reverse the process (i.e., to recall the two side panels), hitting Tab would make the two sides of the screen go black for up to a minute, with no words visible. Eventually the info fields in the panels would open up.
I also created a new user account and imported a folder of 160 images. After half an hour Compare View began mis-placing data. (I have a screen shot to show this.) CANDIDATE appears on the left side of SELECT, whereas it should be on the right. The accompanying camera exposure data appears almost entirely to the left of the mid-screen dividing line. Although the Candidate and Select headings were transposed, the image exposure data was not, but the data for the image on the right was almost entirely to the left of the line dividing the screen in two.
Gurus in The Lightroom Forum have examined Task Manager data showing Processes running and Performance indicators and they see nothing wrong. I could also send screen shots of this data.
At this point, the only way I can process my images is to work 30-40 minutes and then shut down everything, exit, and re-start LTR. This is not normal. I hope you can find the cause, and then the solution. If you would like to see my screen shots, tell me how to submit them.
Ollie
[email protected]Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels. Such problems never arose during two years of using LTR-4 and nothing else has changed on my computer. I have a pretty simple system with only a few plug-ins, which are usually not in operation. I have 12GB of RAM in my Windows 7 PC. I could illustrate these problems with screen shots if you would tell me how to submit screen shots. Otherwise I will try to describe the problems in words.
The problem is clearly cumulative, growing worse as usage time passes. Compare View feature gradually slows down and eventually seems to choke as my work session proceeds. If I Exit LTR and re-enter and start all over, things will work normally for maybe 30 minutes, but then the Compare View feature begins to become very slow to respond. In a recent example with my screen full of thumbnails in Library mode I highlighted two images to compare. LTR started to open the Compare View screen by first having the top row of thumbnails disappear to be replaced by the "SELECT" and "CANDIDATE" words in their spaces (but no images), but Compare View never succeeded in gaining control of the screen. After some seconds the top row of thumbnails reasserted its position and the Compare View windows disappeared. But LTR kept trying to bring them back. Again the top row of thumbnails would go away, Select and candidate would reappear, try again, and give up. This went on for at least 2-3 minutes before I tried to choose File and Exit, but even that did not initially want to respond. It doesn't like to accept other commands when it's trying to open Compare View. Finally it allowed me to exit.
To experiment I created a new catalog of 1100 images. After 30-40 minutes, the Compare View function began to operate very slowly. With left and right side panels visible and two thumbnails highlighted, hitting Compare View can take half a minute before the two mid-size images open in their respective SELECT and CANDIDATE windows. When the side panels are open and two images are in the Select/Candidate spaces, hitting the Tab button to close the side panels produces a very delayed response--25-30 seconds to close them, a few more seconds to enlarge the two images to full size. To reverse the process (i.e., to recall the two side panels), hitting Tab would make the two sides of the screen go black for up to a minute, with no words visible. Eventually the info fields in the panels would open up.
I also created a new user account and imported a folder of 160 images. After half an hour Compare View began mis-placing data. (I have a screen shot to show this.) CANDIDATE appears on the left side of SELECT, whereas it should be on the right. The accompanying camera exposure data appears almost entirely to the left of the mid-screen dividing line. Although the Candidate and Select headings were transposed, the image exposure data was not, but the data for the image on the right was almost entirely to the left of the line dividing the screen in two.
Gurus in The Lightroom Forum have examined Task Manager data showing Processes running and Performance indicators and they see nothing wrong. I could also send screen shots of this data.
At this point, the only way I can process my images is to work 30-40 minutes and then shut down everything, exit, and re-start LTR. This is not normal. I hope you can find the cause, and then the solution. If you would like to see my screen shots, tell me how to submit them.
Ollie
[email protected]
Maybe you are looking for
-
Changing ID3 tags in iTunes with Automator
I have a huge load of music, which are all named "Artist - Track". I want to edit out the Artist from the track name, and fill it in in the Artist tag with an Automator script. I have a program that does this in Finder, but can't find anything to do
-
Error while installing applications
Hi I am getting an error while installing applications in snow leopard. I got this error couple of times while I was installing different applications. Below is the details of the error. System extension cannot be used (The system extension "/System/
-
Why can't I send or receive email on iPhone?
Why ant I send or receive email?
-
I have Adobe Acrobat 5.0 installed in my PC (Windows XP) in Chinese Language. I want to change the language to English. I tried re installation but its still coming in English. Please Advise.
-
No Dock no app switching after security update 2013-001
Been running 10.6.8 very stably for a long time. Yesterday SW update found Security Update 2013-001. The first download didn't succeed, second download went and installed okay, without issue. On restart (and multiple restarts since), the desktop pa