Function Index to another Table
Hello developers,Here is sample to exist when the clause, reason why I'll give you a quick explanation... the company wants.
Select blah blah blah
view bla
where blah_date decode the interval ((«Aujourd'hui», «Aujourd'hui», (select a.date from update_table, dont le processus = 'remplir'), to_date (< < entered_date > >, ' dd/mm/yyyy')))
My question is, that it will be possible (recommended) to create indexes of function that refers to another table? I tried, but it is not created successfully, put: 1 where I reference the subselect.
As many of you know, the query runs much faster and does not full table scan or scan limited complete index if the decoding function is removed from the equation. However, as mentioned at the beginning, the company asked it, so we try to answer. ' Executing the query * horrible "with the decode function, so any help/advice you can give would be much appreciated.
Thank you
Mike
* After all of my research and testing (at least two weeks now), the F.B.I path is probably the only solution available that will increase performance.
I'm not, in general. a big fan of views on views, including such that it appears, based on the names of your sample, that there is an environment of DW. It seems to me that you try to answer view2 a qquestion isn't really designed to answer.
I am tempted to re - write the thing using base tables instead of views which would give you a better chance of using the index on the date column. It would also probably you can eliminate a lot of unnecessary things, lines or columns or both that could affect the choice of paths optimizer.
John
Tags: Database
Similar Questions
-
Creating Index on another table in schema stored in my table
Hello
I want to create indexes on a table column that is in another schema of my schema and index will be stored in my diagram.
ex: the current user 'hr '.
SQL > create index idx1 on scott.emp (eno);
Does the above query?
Thank you
SriSQL> conn Enter user-name: hr@**** Enter password: Connected. SQL> create index ndx on scott.emp(sal); Index created. SQL> show user USER is "HR" SQL> select index_name from user_indexes where index_name = 'NDX'; INDEX_NAME ------------------------------ NDX
-
Check a functional index on a table and its metadata
Hello
I have a functional base normal index (unique) defined on a table that uses a function of decoding and a combination of the columns of a table.
For example: decode (status, 'A', column1 | column 2, column1 | Column2 | Column3)
Now my question is, how do we ask these functional indices of the database to see what exactly is the function...
On the database when I run a query: -.
Select in all_indexes where index-name =: index_name, *.
She retrieves the name of the stored index code as ncs $00025 (don't remember the exact value).
How will I know what exactly is the function? (from table)
and is it possible that I can query the data that has been indexed by this unique index, so that I can check why unique constraint is violated in some cases?
Thank you and best regards,
SylvainHow, we ask these functional indices of the database to see what exactly is the function...
select * from user_ind_expressions
-
Another key or a function Index Question
Hello
I have the following sample tables:
CREATE THE TABLE1 TABLE:
(
NUMBER OF RESOURCE_KEY
CONSTRAINT TABLE_PK
KEY ELEMENTARY SCHOOL
(RESOURCE_KEY)
)
/
CREATE THE TABLE2 TABLE
(
RESOURCE2_KEY INTEGER NOT NULL,
RESOURCE1_KEY INTEGER NOT NULL,
CONSTRAINT TABLE2_PK
UNIQUE (RESOURCE2_KEY, RESOURCE1_KEY)
USING INDEX
TABLESPACE TRACERT_DATA,
CONSTRAINT TABLE1_FK1
FOREIGN KEY (RESOURCE1_KEY)
REFERENCES TABLE1 (RESOURCE_KEY)
ON DELETE CASCADE,
CONSTRAINT TABLE1_FK2
FOREIGN KEY (RESOURCE2_KEY)
REFERENCES TABLE1 (RESOURCE_KEY)
ON DELETE CASCADE
)
/
Insert into TABLE1
(RESOURCE_KEY)
Values
(1) ;
Insert into TABLE1
(RESOURCE_KEY)
Values
(2) ;
COMMIT;
Now comes the tricky part. I want only one of the following inserts to work:
Insert into TABLE2
(RESOURCE2_KEY, RESOURCE1_KEY)
Values
(1, 2);
Insert into TABLE2
(RESOURCE2_KEY, RESOURCE1_KEY)
Values
(2: 1);
COMMIT;
Any suggestions?You can use a single function index based.
SQL> create table t (x number, y number); Table created. SQL> create unique index t_idx on t (greatest(x, y), least(x,y)); Index created. SQL> insert into t values (2, 1); 1 row created. SQL> insert into t values (1, 2); insert into t values (1, 2) * ERROR at line 1: ORA-00001: unique constraint (TEST.T_IDX) violated SQL> rollback; Rollback complete. SQL> insert into t values (1, 2); 1 row created. SQL> insert into t values (2, 1); insert into t values (2, 1) * ERROR at line 1: ORA-00001: unique constraint (TEST.T_IDX) violated
-
Inserting data from one table to another table
Hello
I have the following SQL where I am updating a table by adding new data from another table, but without success.
INSERT INTO
() TOP_PROSPECTS
COMMON_ID
DATE_ADDED
REVIEW_RANK
EVAL_DATE
PM_ASSIGN
WHY_NOTES)
SELECT
t.COMMON_ID
t.DATE_ADDED
t.REVIEW_RANK
t.EVAL_DATE
t.PM_ASSIGN
t.WHY_NOTES
Of
TEMP_IVAN_MARY t
WHERE
COMMON_ID <>t.COMMON_ID
Any suggestions?
Thank you.
Published by: user13822709 on August 14, 2012 09:14
Published by: user13822709 on August 14, 2012 09:15Is that what you're trying to do with the insert. I think there may be a sign {noformat}<{noformat}{noformat}>{noformat} missing in the where clause. This site eat those, so you need to use the equivalent! = post here.
If I'm wrong about the missing trader, then it looks like you want to insert rows in temp_ivan_mary that are not already in top_prospects. If Yes, then you need something like:
insert into top_prospects (common_id, date_added, review_rank, eval_date, pm_assign, why_notes) select t.common_id, t.date_added, t.review_rank, t.eval_date, t.pm_assign, t.why_notes from temp_ivan_mary t where t.common_id not in (select common_id from top_prospects where common_id is not null)
Function index and data available volumnes etc. then a mergr can be more effective. Something like:
merge into top_prospects p using (select common_id, date_added, review_rank, eval_date, pm_assign, why_notes from temp_ivan_mary) t on (p.common_id = t.common_id) when not matched then insert (common_id, date_added, review_rank, eval_date, pm_assign, why_notes) values (t.common_id, t.date_added, t.review_rank, t.eval_date, t.pm_assign, t.why_notes) from temp_ivan_mary t
John
{noformat}{noformat}> -
function index() in LabWindows 2013 of the compiler
LabWindows CVI 2013 compiler complains about the use of the variable global 'index', even if 2010 LabWindows is OK with that. The error is an error that is redefined as LabWindows 2013 confused with an old C library string index function.
Is there a simple solution for that, instead of rename my variable global 'index' in another name?
Hello nhd973!
The behavior that you are experiencing is unfortunately a known issue in CVI 2013 (see section incompatibilities):
http://www.NI.com/product-documentation/51877/en/
Around that, the simplest method is to rename your global variable.
However, there is a back door that you can use, which forces the compiler to LabWindows/CVI to ignore the internal controls. You can change the following configuration for these built-ins registry key:
HKEY_CURRENT_USER\Software\National Instruments\CVI\13.0\Environment\DisableBuiltIns
By default, this key value is
False
. Setting its value onTrue
allows the compiler to LabWindows/CVI ignore builtins, so you should not encounter the error again.Best regards!
-Johannes
-
change the order of a table with another table
I want to change the order of a 1 d table based on another table 1 d that specifies the order. For example, I have a table including the following items: 12, 13, 14, 15, 16. And I have another 1 d array that specifies the order of 3, 4, 0, 1, 2. I want the table resulting in 15, 16, 12, 13, 14. How can I do this? It must be really easy. Another example, I give myself a table in the order following 1,2,3,4,5,6,7 and I an order specifying the array containing the 0,6,1,5,2,3,4. Therefore, the resulting table must be 1,7,2,6,3,4,5. ???
It is, in fact, quite easy. Put an "Array Index" inside a loop and thread the two tables in it. Disabled automatic indexing on the input array. Wire of the array element located on the border of the for loop, and you'll have the desired table.
-
I'm reviewing an existing table in a database Oracle 11g and I do not understand a function based index that was created. The syntax is less than
CREATE INDEX abc. Orders_Date on abc. ORDERS
(CASE WHERE "ORDER_DATE" IS NOT NULL THEN "ORDER_DATE" ELSE NULL END)
LOGGING;
This table has about 90 000 lines with 32 000 values distinct order_date, 3000 lines have order_dates null. When you run a query on this table using the order_date column it makes a full table scan.
What does this function index based? because I do not see how it adds all the required features
Thank you
As others have said, this index is actually right on order_date, however, is a core function so it cannot be used in queries that use CASES WHEN "ORDER_DATE" IS NOT NULL THEN END NO OTHER "ORDER_DATE."
It is assumed that it might be possible that there is an index on (order_date) but it was found that it was used in the sql queries, which would have preferred to use other indexes. Some queries benefits so maybe that option based function was created as the sql must refer to the phrase exactly, requests that have received have been rewritten and others were left so that they could avoid the new index of the index.
Of course, if this were the case then maybe you can take a look at your stats.
-
Hello
I have a small question. I want to get a tabelname on another table.
I have a question 'P1_xyz' (selection list). This select list returns a name of a table in my database.
Now, I want to create a report (select * from...) where the part behind the keyword 'FROM' is in the item "P1_xyz". But it dosent work... The selection of the report do not show the two column...
Can someone help me?
Workspace: TEST_OA5
Username: [email protected]password: Hund123
There is a single application, you can find it, really!
THX René
Hi RWErene81,
RWErene81 wrote:
There is only one thing, that I need too. I need the original titles in the columns of the tables / views. How can I do that. in your SQL query all columns that are named by col01, col02...
Can you explain or show me, how can I get the real column names?
See the 586 page of your application. I've implemented the dynamic report headers depending on the selected table.
That's what I did:
- Page 586 - "Guard" report - column attributes - headers of Type-> set it to PL/SQL
- Page 586 - "guard" report attributes - attributes of column - Type headers-> function of the sections of the colon delimited:
DECLARE L_LABEL_STR VARCHAR2(32000); BEGIN -- get the column names if the table exists FOR REC IN ( SELECT COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME = UPPER(TRIM(:P586_TIERAUSWAHL)) ORDER BY COLUMN_ID ) LOOP IF L_LABEL_STR IS NULL THEN L_LABEL_STR := REC.COLUMN_NAME; ELSE L_LABEL_STR := L_LABEL_STR ||':'|| REC.COLUMN_NAME; END IF; END LOOP; RETURN L_LABEL_STR; END;
NOTE: in an opinion, here to show that I wrote directly the code into anonymous blocks for the dynamic query, as well as for the labels. You could make a formula with two functions and replace the anonymous by function calls as blocks:
For the query:
RETURN APP_REPORTS_PKG.FNC_GET_TIERE_QUERY (:P586_TIERAUSWAHL);
Label:
RETURN APP_REPORTS_PKG.FNC_GET_TIERE_LABEL (:P586_TIERAUSWAHL);
I hope this helps!
Kind regards
Kiran
-
Function Index problem.
Hello
I have a problem regarding a function function index.
example:
TableName: Test
Column: A, B, C, D
I create the index on the table, column, a test using a user-defined function.
If I do a select on the column, he'll be fine. In other words, I'll get the results you want.
However, if I insert in the table and validation, and I do a query using the 'A' column in the where clause. I don't have any query hits. Its really weird.
Have you ever experienced this problem? and is there an index of function according to back and donts w.r.t.?
Thank you.
MichaelR
If you use a deterministic function really, it works:
create or replace function test_fn (p_number number) return number deterministic is vreturn number := 0; begin if p_number = 1 then vreturn := 55; end if; if p_number = 2 then vreturn := 89; end if; return vreturn; end;
Or, if you reverse the order of your second inserts (insert the folder before the recording of test1 test2) - it works fine.
The reason why you get no results is when you insert the file test1 with a = 2, Oracle executes the function and gets no data, so it assumes that the result is NULL and puts in the index. You said Oracle function is deterministic, so he starts from the principle that any time test_fn (2) is called, it retrieves a null response.
-
Drag N Drop table lines do not move a table to another Table
Hello
I use 11.1.7 to develop the drag N drop rows in one table to another
1. I create a table in the schema hr as a student (sName, brands, sId, grade) & inserting values.
2. I create EO & three your based on Student table... only three your from wise rank as (GroupAVO, GroupBVO, GroupCVO)
3. I create page & panelgridLayout (3 columns, 1 row), I drop these three instances of VO tabular...
4 drag the component Source and Drop target in these 3 tables...
Run the page... page contains perfectly with the wise group of 3 tables...
but when I drag a line a table to another table, lines do not move...
I check my DB too... changes there too...
No error and exceptions in my journal...
What is the problem? Can someone help me?
Thank you
-
Hello experts. I was told that I need to add indexes to my table, even if I'm just doing a select * from tbl_one. The index is actually justified in this case
Hello
user13328581 wrote:
Hello experts. I was told that I need to add indexes to my table, even if I'm just doing a select * from tbl_one. The index is actually justified in this case
No, if
Select *.
of tbl_one;
is exactly what you do, then any index on tbl_one will do everything (faster or slower).
If you have a WHERE clause, or an ORDER BY clause, or join you, or only some of the columns, then it's another story.
Ask the one who told you to explain. Maybe you didn't understand what you were told correctly.
-
[I ask nicely for a few comments for this question.
Someone else can reproduce it with the test below?
Is my code invalid or false?
Or what is the problem here?
-Thank you
Frank
]
Hello
Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE Production 11.2.0.3.0
AMT for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
Trigger Before Insert or Update to a table, I invoke a PL/SQL package function to check the size of an xmltype column (passing as IN OUT NOCOPY).
PL/SQL functions retrieves the xmltype. GetClobVal(), check its size, and when it is beyond a limit, he tries to insert the data into another table (GTT - global temporary table).
Finally, it changes the value of the value of the column of xmltype to the shorter XML (just by referring to the corresponding record in the TWG).
But the Insert SQL in the TWG operation strike ORA-22993: specified input is greater than the amount actual source.
I don't know why this happens. In the internet I only find references on importing files in lob/clob.
Anyone have the same problem?
I know that you prefer to have a sample program to demonstrate the problem - I'll try to post one, but it will take time.
But maybe someone can help me based on the information above already.
-Thanks a lot!
Best regards
Frank
I have reproduced the issue.
It must be a bug.
-
Validation form column against the value of another Table
Hello
I'm new to this forum, so please bear with me a bit! I only have a small amount of writing PL/SQL experience, and I've never written Javascript or JQuery before. I am an Oracle DBA and I coding experience C and PERL, so I have a strong technical background. But I need some advice on the best way to approach a problem.
I have an application of data base in Oracle Apex (version 4.2) with a tabular form on a table: Let's say that #1 with the conditions of licence 1 a, 1 b, and1C. I have to make sure that the value entered in col B is not greater than the value of a column in another table (for example table #2 pass 2 (a). From a conceptual point of view, the amount of money available is in the #2 table, and my tabular form lines are an act of spending money (such as orders or invoices), so I have to make sure that we spend more that we have. Who is?
Does anyone have tips for the best way to do it? I'm figuring that the biggest problem here is perhaps to account for people who enter multiple lines in the form of tables at the same time, right? So, if a person is entered 3/invoices, I need a total to ensure that they do not have spend more than we have in the #2 table.
I really appreciate your help!
Best regards
Laurie Baublitz
Ah, I was not totally with you on this charge then. My validation works overall, but it totals the amount for each line, regardless of the task. Okay - who was not totally my solution but more a demonstration of the technique that you can use to validate your tabular presentation in this way.
You could solve this issue with a safe collection, or with a table plsql where you add an entry for each task name and keep the amount stored in there.
Anyway, it would be better for you to spend a little time on playback on the plsql collections or collections apex!
Remember, this is a sample and you will need to take stock of it. The best solutions are those where you need to experiment with 8)
DECLARE TYPE tt_taskamount IS TABLE OF NUMBER INDEX BY VARCHAR2(20); t_taskamount tt_taskamount; l_task VARCHAR2(20); l_amount NUMBER; l_max NUMBER; BEGIN -- F02 is the taskname -- F03 is the amount -- adapt to your situation! FOR i IN 1..apex_application.g_f02.count LOOP l_task := apex_application.g_f02(i); l_amount := apex_application.g_f03(i); IF NOT t_taskamount.exists(l_task) THEN t_taskamount(l_task) := l_amount; ELSE t_taskamount(l_task) := t_taskamount(l_task) + l_amount; END IF; -- it's not the best idea to perform a select each time and could be -- done better but for the sake of the example it's fine -- not too bad either if the rowcount is small. SELECT maxamount INTO l_max FROM table2 WHERE taskname = l_task; IF t_taskamount(l_task) > l_max THEN -- returning will stop further processing and throw an error message as soon as a budget has been overrun -- it might or might not be required behaviour but that's up to you RETURN 'The max amount ('||l_max||') for task ' || l_task ||' has been exceeded. Reduce the total amount on associated tasks!'; END IF; END LOOP; END;
-
How to insert data into the table of plain text stored as a CLOB in another table
Hi people,
Maybe it's an easy question for someone who is more frequently used files and CLOB.
I have a table that stores text files in the CLOB column. Files text includes some basic data that I want to load in the other - a text line = a new insert for me. Is there a "trick" how to do it effectively?
Here is my model:
Table OS_IMPORT_DOCS, stores the complete files as CLOB
Sample data from OS_IMPORT_DOCSSQL> desc OS_IMPORT_DOCS Name Type Nullable Default Comments ------------- -------------- -------- ------- -------- OBJECT_ID NUMBER DATUM_ZMENY DATE sysdate FILE_PATH VARCHAR2(4000) Y FILE_NAME VARCHAR2(4000) Y FILE_SIZE NUMBER Y LAST_MODIFIED DATE Y DOCUMENT CLOB Y STATUS VARCHAR2(15) Y 'NEW'
Example of file CLOB - stored text data (select d.document from os_import_docs d where d.object_id = 1815042 ;)SQL> select * 2 from os_import_docs d 3 order by d.last_modified desc 4 ; OBJECT_ID DATUM_ZMENY FILE_PATH FILE_NAME FILE_SIZE LAST_MODIFIED DOCUMENT STATUS ---------- ----------- ------------------------------ --------------- ---------- ------------- ----------- --------------- 1815043 13.8.2012 1 d:\data\C120813.DAT C120813.DAT 16800 13.8.2012 16: <<CLOB>> NEW 1815042 13.8.2012 1 d:\data\C120812.DAT C120812.DAT 3600 12.8.2012 22: <<CLOB>> NEW 1815041 13.8.2012 1 d:\data\C120811.DAT C120811.DAT 1800 11.8.2012 13: <<CLOB>> NEW
Above the example text includes "columns" in plain text:061053120820120000AGT000002Osoby 0000000042301000000017210632 062322120820120000AGT000002Osoby 0000000012301000000017197566 063526120820120001AGT000002Osoby 0000000012301000000017197566 064234120820120001AGT000002Osoby 0000000103301000000162218777
timestamp - 1-14, SSMIHH24DDMMYYYY position format
flag - post 15-18
company code - position 19-27
etc...
How can I query data stored within the OS_IMPORT_DOCS. The DOCUMENT column, divide it into columns and insert into another table?
I have to read this method of 'online' file?
Thank you very much
TomasFor the first three columns:
SQL> create type TRecord is object ( 2 ts timestamp 3 , flag varchar2(4) 4 , company_code varchar2(9) 5 ); 6 / Type created SQL> SQL> create type TRecordTable is table of TRecord; 2 / Type created SQL> SQL> create or replace function parse_clob (p_doc in clob) 2 return TRecordTable pipelined 3 is 4 lf number; 5 eol varchar2(2) := chr(10); 6 eollen number := length(eol); 7 line varchar2(32767); 8 offs number := 1; 9 begin 10 loop 11 lf := dbms_lob.instr(p_doc, eol, offs); 12 if lf != 0 then 13 line := dbms_lob.substr(p_doc, lf - offs + 1 - eollen, offs); 14 offs := lf + eollen; 15 else 16 line := dbms_lob.substr(p_doc, dbms_lob.getlength(p_doc) - offs + 1, offs); 17 end if; 18 pipe row ( 19 TRecord( 20 to_timestamp(substr(line, 1, 14), 'HH24MISSDDMMYYYY') 21 , substr(line, 15, 4) 22 , substr(line, 19, 9) 23 ) 24 ); 25 exit when lf = 0; 26 end loop; 27 end; 28 / Function created SQL> SQL> select t.* 2 from os_import_docs d 3 , table(parse_clob(d.document)) t 4 where d.object_id = 1815042; TS FLAG COMPANY_CODE -------------------------------------- ---- ------------ 12/08/12 06:10:53,000000 0000 AGT000002 12/08/12 06:23:22,000000 0000 AGT000002 12/08/12 06:35:26,000000 0001 AGT000002 12/08/12 06:42:34,000000 0001 AGT000002
Maybe you are looking for
-
How can I program the machine of the time's up
How can I program the machine of the time's up
-
U100: Where to connect the Kensington lock?
Hello my book is brand new, but I can't find the place to connect the Kensington lock. My book "at work" got a so I have an idea of what it should look like, but I can't find on the booklet.Clues? concerning
-
I recently installed Windows 7 on my laptop HP 15-AD129DS. In the Device Manager miss me the driver for PC Data Acquisition and Signal Processing controller. There is also an unknown device without driver right below in the section "other devices.
-
Unable to clear the attach photos in my out look express, my computer is Microsoft XP
Please help me remove attach photos in my outlook express mail. I tried to send to my children and cannot send maybe because he had a lot of pictures, that I sent you.
-
Went to Device Manager. It shows my laptop integrated webcam and shows my printer/scanner "cameras". But it does not show the built-in webcam of the independent monitor, and I can't find how to get the Device Manager to see the device. Help!