APEX_APPLICATION. G_F0x tables in the query
HelloIs it possible to use APEX_APPLICATION. G_F0x tables in the query and select it at the table?
I like to select values from table bunch I have on the table.
Of course I can loop table, but I like to select at once as
SELECT e.*
FROM emp e
WHERE EXISTS(
SELECT 1
FROM TABLE(APEX_APPLICATION.G_F01 AS empno) a
WHERE e.empno = a.empno
)
I don't know is it still possible.Thanks in advance.
Kind regards
Jari
Jari
No, you cannot use the TABLE operator on a PL/SQL associative array as apex_application.g_f01: it requires a nested table or a table variable declared as an object database. You can access apex_application.g_f01 by using a function in the pipeline in this way.
Tags: Database
Similar Questions
-
Select from another table, when the query returns no result
Hello
I have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.
SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid
Any help will be greatly appreciated.
Thank you.user10407139 wrote:
HelloI have a question where I'm supposed to retrieve the address of an account id-based billing. However, the table of billing may not have an address. There is a table of addresses that always has an address for an account. If the billing address exists, it should be used, so I can't use the address table. Is it possible in a select statement to query to the billing address and if it does not exist, use the address table.
SELECT * FROM accounts a, b billings WHERE a.accountid = b.accountid
Any help will be greatly appreciated.
I think you need to explain more clearly if
-you only have a couple of "billing" columns which is empty and in this case, you want to use the columns from the table 'accounts '.
- or you have a join with another table that doesn't return data, for example a foreign key "address_id" "billing" is zero and therefore the join to other tables 'address' will return all the data
In the first case, you have already been provided with some examples here, how to use NVL or similar functions to achieve, even if the first post first evaluates the information of 'accounts' and if it is white using information from "billing". According to your description you need the other way around. The second post a subquery recursive useless in my opinion.
In the latter case, you should probably use an "outer" join so that the data in your table "bills" are returned, even if the join to another table is not at all the lines.
SELECT NVL(AD1.ADDRESS_ATTR1, AD2.ADDRESS_ATTR1) as ADDRESS_ATTR1, NVL(AD1.ADDRESS_ATTR2, AD2.ADDRESS_ATTR2) as ADDRESS_ATTR2, NVL(AD1.ADDRESS_STREET, AD2.ADDRESS_STREET) as ADDRESS_STREET, ... FROM accounts a INNER JOIN billings b ON a.accountid = b.accountid LEFT OUTER JOIN address ad1 ON b.address_id = ad1.address_id INNER JOIN address ad2 ON a.address_id = ad2.address_id;
In this way you pick up the address stored in the "invoices" table, if it existed, otherwise you pick up the address assigned to the "accounts" table I used an inner for the second address join join because you said that the account always has an assigned address.
Kind regards
RandolfOracle related blog stuff:
http://Oracle-Randolf.blogspot.com/SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676 /.
http://sourceforge.NET/projects/SQLT-pp/ -
Pagination of the table in a query with table Panel
Hello
I need to implement paging in a table as long as the results of a query which makes the user, the table that the query is run has several records, 40000 or more.
I searched but I can't find a way to apply what I, some links show me how to insert the pagination on the part of the table, but if I only do when I want to see a different page, let's say 500 or 1000, it takes too long to display the data of that specific page. I'm guessing it will retrieve all the data from the query and read it all so it can show what I want.
Another way is to control the amount of data to be returned from the view object (VO), but I am unable to perform paging efect component table in my file jspx somehow.
I think I should change my VO both my component so I can get the effect I want, but I don't know how. Properties that I need to change to achieve this.
THK
If I set the af: non paginated table mode the number of pages do not appear.
Then maybe you can use the code from this blog to do it manually:
http://www.Ateam-Oracle.com/adventures-in-WebCenter-skinning-aftable-with-custom-pagination/
The only optimization that I think is missing is somehow when I select the page from the list of results, will retrieve only the data on this page.
Yes and for this you must range Paging in VO (so the result of the query may be limited by the size of the range).
But, as I mentioned in my first reply, range of paging is bug in 12.1.3 then maybe the same applies to 11.1.1.7
Dario
-
query MySQL (search multiple tables in the database)
I have 12 tables in a database - January to December.
I need to find all the tables 'keyworrd' 12 phrases submitted by the user via a search form.
Need to create a simpler way to do as below with 'UNION '. I have incorporated 2 tables in the query below, but I need a query more "condensed" for all tables of 12?
$sql = (' SELECT * FROM January WHERE tourTitle = "'.") $keyword. "' UNION SELECT * FROM February WHERE tourTitle = ' '. '" $keyword.' » ") ;
See you soon
Operating system
Booth wrote:
> That's what I did last year, but thought I would break down this year in 12 easier to work with tables.
No, Ben is correct. 1 using table for each month is absolutely the wrong way. It violates the basic rules of standardization and causes all sorts of problems.
> Breaking down appealed to be more so I can keep all these months
> together instead of potentially become scattered across a table.
That's what you use the Order By clause for.
> If by chance the customer says they want to update x, y or z, I can go
> straight for the month in question, without the need to browse
> dozens of pages in phpMyAdmin, because there are no real management CMS in place for this process.
Don't know what you're saying. Performing inserts, updates and queries is much easier using a single table.
Whenever someone asks for a way to search through more than one table, he told me that the data structure is not well designed.
When I did this job last year there were about 60 pages created in phpMyAdmin. Records of January could be anywhere on these 60 pages I might add on additional folders much later in the process.
My thought behind this was to combine all entries of the month so I could view them easily in phpMyAdmin.
Now, due to my lack of knowledge on phpMyAdmin, it would be possible to create a query to show only entries from January, I suspect that she can do.
I agree it is much simpler using 1 table to select and browse BUT I need if the opportunity presents itself to be able to view all entries January or February etc. one after another, not 10 on page 2 and 3 on page 7 and 5 more to page 47 of phpMyAdmin.
So I quess what I really need, it is write a select query in phpMyAdmin that shows only the entries selected for the requested month. I did not much research into what phpMyAdmin can do... so I guess I have to.
PUBLISHED:
Arrgh, you see it WAS so SIMPLE:
SELECT * FROM 'towers' months WHERE = "March".
It's because I'm afraid of the bloody thing in case I mess up something!
-
Select a table returned in the result of the query
Hi, I'm trying to find a way to query a table name that I'm back to a different query. I am doing this in pure SQL and PL/SQL, if I can.
Here's the situation. I have a table called FILES, a table called TYPE and an unknown number of different reference tables with different names.
Each entry in the FILE has a reference to a TYPE id, and each entry type is a varchar that contains the name of a table reference, such as PHOTO_INFORMATION, PDF_INFORMATION or XML_INFORMATION.
I want to be able to extract the data from the reference table for any data file. So with a file id, I question TYPE to get the name of the reference table (IE, "PHOTO_INFORMATION" back) then the request it is at this table for all of its columns, using the reference id in the FILE table.
The thing is that I wish it were generic, so that I can just add an entry to AA_TYPE and a new table for this type, and then I can ask her but I want, through the FILE table. The reason is that there are some data that is common for all files, and I would like to that data in one place.
Here is my paintings, I have two reference tables of the sample to the bottom "AA_FILETYPE1" and "AA_FILETYPE_PHOTO".
Here's an example query I would use:CREATE TABLE "AA_FILES" ( "FILE_ID" NUMBER, "FILE_NAME" VARCHAR2(4000), "FILE_TYPE" NUMBER, "REFERENCE_ID" NUMBER, CONSTRAINT "AA_TEST_FILE_PK" PRIMARY KEY ("FILE_ID") ENABLE ) / CREATE TABLE "AA_TYPE" ( "TYPE_ID" NUMBER NOT NULL ENABLE, "REFERENCE_TABLE" VARCHAR2(4000), CONSTRAINT "AA_TYPE_PK" PRIMARY KEY ("TYPE_ID") ENABLE ) / CREATE TABLE "AA_FILETYPE1" ( "REFERENCE_ID" NUMBER, "DATE_MODIFIED" DATE, "SUMMARY" VARCHAR2(4000), "TOTAL_VALUE" NUMBER(5,2), CONSTRAINT "AA_FILETYPE1_PK" PRIMARY KEY ("REFERENCE_ID") ENABLE ) / CREATE TABLE "AA_FILETYPE_PHOTO" ( "REFERENCE_ID" NUMBER NOT NULL ENABLE, "DATE_TAKEN" DATE, "CAMERA_NUMBER" VARCHAR2(4000), "WEATHER_CONDITIONS" VARCHAR2(4000), "CONSULTANT_NAME" VARCHAR2(4000), CONSTRAINT "AA_FILETYPE_PHOTO_PK" PRIMARY KEY ("REFERENCE_ID") ENABLE ) /
So who withdrew all the columns in the reference given in AA_TYPE table based on an entry in AA_FILES.select * from (select REFERENCE_TABLE from AA_TYPE where TYPE_ID = AA_FILES.FILE_TYPE) where REFERENCE_ID = AA_FILES.REFERENCE_ID;
I'm not entirely sure how to do this, or if this is possible even without using PL/SQL.
I'm open to suggestions on how to achieve what I want with a different design of table, I am a student and I'm not really experienced in database design. (My first design of database class isn't until next year!)
Thank you very much!Hello
[email protected] wrote:
Sorry about the confusion about file_id = 3, I meant the insert in the third I've included. I did not indicate the id_fichier in my inserts since it is the main key and it auto increments.It is important to post of the CREATE TABLE and INSERT statements that work. All those who want to help you to will want to recreate the problem and test solutions. Also, do not use strings for all entries. If the column is a NUMBER, use a NUMBER in the INSERT statement. If the column is a DATE, use a DATE or a function that returns a DATE.
So you should post something like:insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (1, 'test-photo-1.jpg', 1, 1); insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (2, 'test-xml-1.jpg', 2, 2); insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (3, 'test-photo-2.jpg', 1, 2); -- The value file_type=1 immediately above was not in your original data, but seems to be what you meant. prompt ===== AA_TYPE Table: ===== insert into AA_TYPE(TYPE_ID, REFERENCE_TABLE) values (1, 'AA_FILETYPE_PHOTO'); insert into AA_TYPE(TYPE_ID, REFERENCE_TABLE) values (2, 'AA_FILETYPE1'); prompt ===== AA_FILETYPE1 Table: ===== insert into AA_FILETYPE1 (REFERENCE_ID, DATE_MODIFIED, SUMMARY, TOTAL_VALUE) values (1, TO_DATE ('01-01-02', 'MM-DD-RR'), 'An XML file that has some information about something', '14'); prompt ===== AA_FILETYPE_PHOTO Table: ===== insert into AA_FILETYPE_PHOTO (REFERENCE_ID, DATE_TAKEN, CAMERA_NUMBER, WEATHER_CONDITIONS, CONSULTANT_NAME) values (1, TO_DATE ('01-01-01', 'MM-DD/RR'), 'abc123', 'rainy!', 'John Smith'); insert into AA_FILETYPE_PHOTO (REFERENCE_ID, DATE_TAKEN, CAMERA_NUMBER, WEATHER_CONDITIONS, CONSULTANT_NAME) values (2, TO_DATE ('01-01-02', 'MM-DD/RR'), 'def456', 'slightly cloudy', 'Jane Jones'); commit;
To give you my workplace, I'm applying in Application Express. A user has entered the number '3' the file_id (I'm not worried about the distinction between passing in the id_fichier and the name of the file, I just my application one application or the other).
Now, run a query that will get related data which table it is stored in. I don't know the name of the table at design time, as that particular file may be of any type (each of which has a different table name). However, with a the file_id, I have a file_type (in aa_files) which refers to an entry in aa_type.
I see. You could add even add new tables after this query is written. As long as the new table has a column named reference_id, and there is a line for the new table in aa_files, the following query should work.
>
select FILE_TYPE from AA_FILES where FILE_ID = 3
I stored the name of the table, I need to ask for the rest of the data in aa_type at design time, so using the file_type value, I can get the name of reference_table:
select REFERENCE_TABLE from AA_TYPE where FILE_TYPE = 1
In the sample data, you have validated, Type_de_fichier = 2 on the 3rd row. I've changed that in my example 1 revised data.
Be very careful that your explanation fits your data. You talk to people who know about your application, and it is very easy for them to be induced in error or confusion.Now the '1' is here that the first query would return. I would like to use a subquery to combine these two queries into a single (I think?). This second query would return "AA_FILETYPE_PHOTO", which is the reference table.
So I have the reference table, which is a name of table to another table in my database. It contains the data that I'm actually looking for. I want it for this particular file (file_id 3), and in aa_files, I have a value of "reference_id", which refers to the respective line in the reference table. File_id 3, the reference_id is 2.
select * from AA_FILETYPE_PHOTO where reference_id = 2
If the above query gets me my final data.
Now, I've been watching substitution values and bind variables, here's another way to explain what I want:
Explanation step by step below is very useful. It would be more useful if each step uniquely and gavce movement results given the sample data and an example of setting (3 in this case)
-- get the file_type from aa_files for the desired file EXEC :file_type := (select file_type from aa_files where file_id = 3);
That we will call the step step (a) above.
Step (a) sets: Type_de_fichier 1 (given my corrected sample data)-- get the reference table from aa_types using the file_type EXEC :reference_table := (select reference_table from aa_type where type_id = :file_type);
That we will call the step step (b) above.
(B) sets the stage: reference_table to 'AA_FILETYPE_PHOTO '.-- get the reference_id from aa_files for the desired file EXEC :reference_id := (select reference_id from aa_files where file_id = 3);
That we will call the step step (c) above.
(C) sets the stage: reference_id 2-- using the reference table and reference id for the desired file, get the rest of the data select * from :reference_table where reference_id = :reference_id;
Not sure if this makes it more clear or not.
Yes, it helps a lot.
Basically I have a table full of table names. How do I write a query that pulls one of these table names and it then queries?
You need SQL dynamic, because you can't hardcode a table name in the query that you normally would be.
How dynamic SQL works normally (and the functioning of this example) are that the query is built by using a variable. In SQL * more (as shown below), you can simply use a variable substitution instead an identifier hardcoded, and that's what it takes to make the dynamic query from SQL * more resolves the substitution variables before sending the code for the compiler. I don't know much on the Apex, but I bet there's some way to do dynamic SQL in the Apex, too.
So the dynamic part here should include step d, since you can't hardcode the name of the table in the query.
Until we can step (d), then, did they to us to do the steps (a) and (b) to obtain this file name. In the example blelow, I used a separate, preliminary request to get the & table_name...
Step (c) could be made in the main query, using a subquery or a join. However, I chose to step (c) in the preliminary motion, as well as steps (a) and (b), since it's the same table same step (a). In this way, step (d) must refer to a table.Here's (finally) how to make this work in SQL * more:
ACCEPT file_id PROMPT "Enter the file_id (a number, e.g. 3): " -- Preliminary Query, to set table_name COLUMN reference_id_col NEW_VALUE reference_id COLUMN table_name_col NEW_VALUE table_name SELECT f.reference_id AS reference_id_col , t.reference_table AS table_name_col FROM aa_files f JOIN aa_type t ON f.file_type = t.type_id WHERE f.file_id = &file_id ; -- Main Query SELECT * FROM &table_name WHERE reference_id = &reference_id ;
The results, account required to the data from the sample I posted above, and the & file_id 3, are:
` CAMERA_ WEATHER_ CONSULTANT_ REFERENCE_ID DATE_TAKE NUMBER CONDITIONS NAME ------------ --------- ---------- --------------- --------------- 2 01-JAN-02 def456 slightly cloudy Jane Jones
-
Slow index by using the query. Fast with full table Scan.
Salvation;
(Thanks for the links)
Here's my question correctly formatted.
The query:
Works on 32 seconds!SELECT count(1) from ehgeoconstru ec where ec.TYPE='BAR' AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) and deathdate is null and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
Same query, but with an extra where clause:
This is 400 seconds.SELECT count(1) from ehgeoconstru ec where ec.TYPE='BAR' and ( (ec.contextVersion = 'REALWORLD') --- ADDED HERE AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) ) and deathdate is null and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText'
It should return data from a table, given the conditions.
The database version is Oracle9i Release 9.2.0.7.0
These are the parameters relevant for the optimizer:
Here is the output of the PLAN to EXPLAIN for the first quick query:SQL> show parameter optimizer NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ optimizer_dynamic_sampling integer 1 optimizer_features_enable string 9.2.0 optimizer_index_caching integer 99 optimizer_index_cost_adj integer 10 optimizer_max_permutations integer 2000 optimizer_mode string CHOOSE SQL>
Here is the output of the EXPLAIN of PLAN for slow queries:PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost | -------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | SORT AGGREGATE | | | | | |* 2 | TABLE ACCESS FULL | EHCONS | | | | -------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- 2 - filter(SUBSTR("EC"."strgfd",1,8)<>'[CIMText' AND "EC"."DEATHDATE" IS NULL AND "EC"."BIRTHDATE"<=TO_DATE('2009-10-06 11:52:12', 'yyyy -mm-dd hh24:mi:ss') AND "EC"."TYPE"='BAR') Note: rule based optimization
The TKPROF output for this slow statement is:PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- | | | 1 | SORT AGGREGATE | | | | | |* 2 | TABLE ACCESS BY INDEX ROWID| ehgeoconstru | | | | |* 3 | INDEX RANGE SCAN | ehgeoconstru_VSN | | | | PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter(SUBSTR("EC"."strgfd",1,8)<>'[CIMText' AND "EC"."DEATHDATE" IS NULL AND "EC"."TYPE"='BAR') PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- 3 - access("EC"."CONTEXTVERSION"='REALWORLD' AND "EC"."BIRTHDATE"<=TO_DATE('2 009-10-06 11:52:12', 'yyyy-mm-dd hh24:mi:ss')) filter("EC"."BIRTHDATE"<=TO_DATE('2009-10-06 11:52:12', 'yyyy-mm-dd hh24: mi:ss')) Note: rule based optimization
Published by: PauloSMO on November 17, 2009 04:21TKPROF: Release 9.2.0.7.0 - Production on Tue Nov 17 14:46:32 2009 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Trace file: gen_ora_3120.trc Sort options: prsela exeela fchela ******************************************************************************** count = number of times OCI procedure was executed cpu = cpu time in seconds executing elapsed = elapsed time in seconds executing disk = number of physical reads of buffers from disk query = number of buffers gotten for consistent read current = number of buffers gotten in current mode (usually for update) rows = number of rows processed by the fetch or execute call ******************************************************************************** SELECT count(1) from ehgeoconstru ec where ec.TYPE='BAR' and ( (ec.contextVersion = 'REALWORLD') AND ( ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') ) ) and deathdate is null and substr(ec.strgfd, 1, length('[CIMText')) <> '[CIMText' 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 2 0.00 538.12 162221 1355323 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 4 0.00 538.12 162221 1355323 0 1 Misses in library cache during parse: 0 Optimizer goal: CHOOSE Parsing user id: 153 Rows Row Source Operation ------- --------------------------------------------------- 1 SORT AGGREGATE 27747 TABLE ACCESS BY INDEX ROWID OBJ#(73959) 2134955 INDEX RANGE SCAN OBJ#(73962) (object id 73962) ******************************************************************************** alter session set sql_trace=true call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 0 0.00 0.00 0 0 0 0 Execute 1 0.00 0.02 0 0 0 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 1 0.00 0.02 0 0 0 0 Misses in library cache during parse: 0 Misses in library cache during execute: 1 Optimizer goal: CHOOSE Parsing user id: 153 ******************************************************************************** OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 2 0.00 0.02 0 0 0 0 Fetch 2 0.00 538.12 162221 1355323 0 1 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 5 0.00 538.15 162221 1355323 0 1 Misses in library cache during parse: 0 Misses in library cache during execute: 1 OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 0 0.00 0.00 0 0 0 0 Execute 0 0.00 0.00 0 0 0 0 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 0 0.00 0.00 0 0 0 0 Misses in library cache during parse: 0 2 user SQL statements in session. 0 internal SQL statements in session. 2 SQL statements in session. ******************************************************************************** Trace file: gen_ora_3120.trc Trace file compatibility: 9.02.00 Sort options: prsela exeela fchela 2 sessions in tracefile. 2 user SQL statements in trace file. 0 internal SQL statements in trace file. 2 SQL statements in trace file. 2 unique SQL statements in trace file. 94 lines in trace file.
Published by: PauloSMO on November 17, 2009 07:07
Published by: PauloSMO on November 17, 2009 07:38 - title changed to be more correct.Although your optimizer_mode is choosing, it seems that there are no statistics collected on ehgeoconstru. The absence of estimated costs and estimated row counts of each of the stages of the plan and the "Note: optimization based on rules" at the end of these two plans would tend to confirm this.
Optimizer_mode choose means that if statistics are collected then it will use the CBO, but if no statistic is present in any of the tables in the query, the optimizer to rule will be used. The RBO tends to be happy in the best of the index case. I guess the index ehgeoconstru_VSN contextversion as the main column and also includes the date of birth.
You can either gather statistics on the table (if all other tables have statistics) using dbms_stats.gather_table_stats, or suggest the query to use a full scan instead of index. Another solution would be to apply a function or an operation against the contextversion to prevent the use of the index. something like this:
SELECT COUNT(*) FROM ehgeoconstru ec WHERE ec.type='BAR' and ec.contextVersion||'' = 'REALWORLD' ec.birthDate <= TO_DATE('2009-10-06 11:52:12', 'YYYY-MM-DD HH24:MI:SS') and deathdate is null and SUBSTR(ec.strgfd, 1, LENGTH('[CIMText')) <> '[CIMText'
or maybe UPPER (ec.contextVersion) so that would not change the rows returned.
John
-
Impossible to activate the rewrite of the query, no error
Hello
I created a simple MV with activated query rewrite, and it works well. The MV is very simple:
Mv_sales CREATE MATERIALIZED VIEW
NOLOGGING
REFRESH THE STRENGTH TO DEMAND
ACTIVATE THE QUERY REWRITING
AS
SELECT
s.cust_id,
Sum (s.QUANTITY_SOLD) sold_qty,
Sum (s.AMOUNT_SOLD) sold_amt
S SALES
GROUP BY s.cust_id
;
I tested the mechanism of query rewriting, and everything works as expected.
Now, I created an another MV with a motion very similar to the one above, but with several tables.
An excerpt from the new query:
SELECT...
Of
FACT_SALES_AND_MARKDOWNS FSM
DIM_PRODUCT DP
DIM_LOCATION DL
DIM_DATE DD
WHERE WSF. DIM_PRODUCT_KEY = DP. DIM_PRODUCT_KEY
AND WSF. DIM_LOCATION_KEY = DL. DIM_LOCATION_KEY
AND WSF. DIM_SALE_DATE_KEY = DD. DIM_DATE_KEY
GROUP BY
DD MERCH_YEAR_ID.
DD. MERCH_YEAR_START_DATE...
I can create the MV, but the query rewriting will not activate!
If I execute ALTER materialized view mv_test ALLOW to REWRITE the QUERY. It runs without giving me an error, but the MV is not always activate the rewrite of the query.
Am I missing something? Can we not have Query Rewrite on a MV with several tables in the query?
Thank you
Joao Moreira
Hello
Please provide the results of these queries:
Select MVIEW_NAME, REWRITE_ENABLED
of DBA_MVIEWS
where MVIEW_NAME = '
'; Kind regards.
-
How to disable autojoins in the query designer
Hello
When I add several tables to the query generator window graphic in SQL Developer I get automatically all possible variants of joins between them. Tables in the database have multiple foreign keys, and even with a few tables, the net of the linkages between them become quite incomprehensible. The only way to work around that I have found is to manually remove all the links after each addition to the table. It's still very painful and embarrassing, and of course with each new table there are a greater number of links to delete. It is possible to add a table to the query generator without automatically creates links?
Best regards
Vladimir.Hi Vladimir,.
There is no preferences to control the Query Builder, but rather than leave a request it via drag & drop of tables/views of the tree of the browser, why not start instead with the spreadsheet by typing in something very minimal as:
SELECT * FROM JOB_HISTORY, JOBS, EMPLOYEES, LOCATIONS
Then, switch to the Query Builder tab (just not joined tables will appear) and add the joints as you wish. The completion feature Insight can help speed up by typing the name of the table/view and can also avoid a performance problem with Query Builder drag & drop.
Hope this helps,
Gary -
Using the QUERY parameter in exp/expdp
Hi, I've faced a nite last question.
IM currently using Oracle 10 g (10.2.0.4) OS - MS Windows Server 2003
I want a dump of tables to export multiple schemas. say (acb.m1, pqr.b2, xyz.b1)
Each table has a minimum lines of 2,000,000,
And I want to just the initials 10 rows in each table of export
Is it possible that I can do this...
Please answer.
Thanks in advanceExport tables in multiple schemas is not supported in Data Pump until 11.1.0.7. So if you're on 10g, you will need to run multiple commands expdp. For only 10 lines of each table, use the query parameter
Query = "where rownum"<>
This will apply to all the tables you export.
I hope this helps.
Dean
Published by: Dean WINS January 30, 2012 08:42
-
Join the query - confused behavior
Hello.. I need to make a join on four tables and select one data tables. The query is as below,
SELECT THE VIRTUAL MACHINE. SEGMENT, VM.CA, VM. PR, VM. BP, VM. TERM_ID, VM. TL v_mlr_cable VM, v_neicode NEI, v_mlr MLR, v_fibre_ntwk_type FIBER WHERE MLR.master_key = 62 AND MLR.dslam_tid = NEI.id AND NEI.type = 'OLT' AND MLR.ntwk_type = FIBRE.id AND MLR.master_key = VM.master_key;
This query works very well. I want to change the query to have an OR condition by combining certain conditions in the WHERE clause as below,
SELECT THE VIRTUAL MACHINE. SEGMENT, VM.CA, VM. PR, VM. BP, VM. TERM_ID, VM. TL v_mlr_cable VM, v_neicode NEI, v_mlr MLR, v_fibre_ntwk_type FIBER WHERE MLR.master_key = 62 AND ((MLR.dslam_tid = NEI.id ET NEI.type = 'OLT') or MLR.ntwk_type = FIBRE.id) AND MLR.master_key = VM.master_key;
This translates into several duplicates of the correct result lines (about 93 272 rows).
I suspect this is a unwanted Cartesian product.
I am limited to use a 'different' because my application performs custom, so 'distinct' query analysis is out of the option.
I struggle to understand the result of this query. You can help... ! Thanks in advance.
My database: Oracle Enterprise Edition 10.2.0.2.0
Published by: vanessa on June 9, 2011 12:49 AMHello
Can hide you the SELECT DISTINCT in a subquery, like this:
SELECT * FROM ( SELECT DISTINCT VM.SEGMENT, ... );
or in a view?
If this is not the case, use GROUP BY. The GROUP BY clause contains all the columns in the SELECT clause.
You could also re - write the query to use EXISTS or IN, instead of a jon.
For example:SELECT SEGMENT , CA , PR , BP , TERM_ID , TL FROM v_mlr_cable vm WHERE master_key = 62 AND EXISTS ( SELECT 0 FROM v_neicode NEI , v_mlr MLR , v_fibre_ntwk_type FIBRE WHERE MLR.master_key = vm.master_key AND ( ( MLR.dslam_tid = NEI.id AND NEI.type = 'OLT' ) OR MLR.ntwk_type = FIBRE.id ) ) ;
Do you think it is easier to read and understand the code formatted, as the query above, or unformatted, as what you posted?
Who do you think will encourage people to read your question and provide accurate responses?
Never write, not to mention NPA, not formatted.I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) of all the tables and the results desired from these data.
Explain how you get these results from these data.
Always tell what version of Oracle you are using. -
Problem in the export using the QUERY functionality
Problem in the export using the QUERY functionality
I'm trying to export some rows in a table using the query functionality
and I have some errors... I'm using the syntax is
system@orcl QUERY = scott.emp expdp: '"WHERE emp_no = 123455" '
DIRECTORY = data_pump_dir DUMPFILE = data_pump.dmp
LOGFILE = data_pump_12345.log INDEX = n
Can someone tell me please the problem with that statement
I also tried to use the simple export
exp file system@orcl = orcl_export.dmp log = orcl_export.log
tables = Scott.EMP index = QUERY = n------"WHERE emp_no\ = 123455\"
and this error
EXP-00008: ORACLE error 904
ORA-00904: identify invalid
My os is Solaris
Please let me know what the problemHello
Try to create parfile and use that, otherwise, you will need to escape each clause correctly to run exp or expdp successfully.
test.par
tables=emp query="WHERE emp_no=123455" or tables=myobjects query="WHERE owner='SYS'" $> exp username/password parfile=test.par Export: Release 10.2.0.1.0 - Production on Thu Mar 19 10:17:48 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining Scoring Engine options Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set About to export specified tables via Conventional Path ... . . exporting table MYOBJECTS 22650 rows exported Export terminated successfully without warnings.
Concerning
Published by: OrionNet on March 19, 2009 10:21
-
Hi all
I need to export a table with the query clause = "" where rownum < 100 ' "
His works well, but the extraction of all columns.
But I need only selective columns.
Is it possible to export the follwing recordsSelect some_columns from table where rownum < 100
how with exp util?
DB version 10.2.0.4
AIX OPERATING SYSTEM
Thank youYou can not specify columns, only where clause may be specified with exp/expdp.
generate instructions insert with the help of select instead then.
Or if you need to import this data into another database - create link db and just do insert by it. -
Tuning for sql join key table no consumer of the heavy use of the query processor
Obligation comes to tunne prod of the query in
high use of the query processor
sql_id: fp79wb32h7a6t
Module: AHC, P_PatientDQ()
Cost: 7
Elapsed time: hung
Status: Hung, 35,253,460 day at 30 minute intervals
-Create table
create table ahc. PATIENTVISITS
(
ahcid NUMBER,
visitId NUMBER,
visitstatus NVARCHAR2 (100),
visitdate DATE,
visitintime DATE,
visitouttime DATE
)
-Create/recreate the index
create indexes ahc. F1_PATIENTVISIT_AHCID on ahc. PATIENTVISITS (AHCID, VISITID);
create indexes ahc. VISITDATE_IDX on ahc. PATIENTVISITS (TRUNC (VISITDATE));
First total number of table
Select count (1) of
Pvs AHC.patientvisits
-Save County 1387485
create table ahc. PATIENTDEPENDENTVISITS
(
ahcid NUMBER (19) not null,
IDPack NUMBER (10) not null,
visitId NUMBER (19) not null,
dependentvisitid NUMBER (19) not null,
isdiabetic NUMBER (2)
)
-Create/recreate the index
create indexes ahc. K1_PATIENTDEPENDENT_AHCID on ahc. PATIENTDEPENDENTVISITS (AHCID);
Total number of second table
Select count (1) of
AHC.patientdependentvisits POS
-Save County 774599
Original request:
SELECT count (*)
ACH. PVS PATIENTVISITS
WHERE PVS. VISITID IN (SELECT POS. DEPENDENTVISITID
ACH. PATIENTDEPENDENTVISITS POS
WHERE POS. AHCID = 37
AND POS. VISITID = 218
AND POS. ISDIABETIC = 0)
AND SUPERIOR (PVS. VISITSTATUS) = 'PENDING'
AND PVS. AHCID = 37
Count (1)
-----------
1
PL/sql Developer explain plan for the original query
Owner of description Objects_name cost cardin bytes cpucost cost of e/s
SELECT STATEMENT, GOAL = ALL_ROWS 7 1 41 63669 7 AGGREGATION OF TRI 1 41 SEMI OF THE NESTED LOOPS 7 1 41 63669 7 TABLE ACCESS BY INDEX ROWID AHC PATIENTVISITS 4 1 25 33295 4 INDEX RANGE SCAN AHC F1_PATIENTVISIT_AHCID 3 9 23164 3 TABLE ACCESS BY INDEX ROWID AHC PATIENTDEPENDENTVISITS 3 1 16 30375 3 INDEX RANGE SCAN AHC K1_PATIENTDEPENDENT_AHCID 2 14 18093 2 After editing the query
SELECT / * + FIRST_ROWS * / COUNT (1)
ACH. PVS PATIENTVISITS
JOIN THE AHC. PATIENTDEPENDENTVISITS POS ON PVS. VISITID = POS. DEPENDENTVISITID
WHERE PVS. AHCID = POS. AHCID
AND POS. AHCID = 37
AND POS. VISITID = 218
AND POS. ISDIABETIC = 0
AND SUPERIOR (PVS. VISITSTATUS) = 'PENDING'
Count (1)
-----------
1
PL/sql Developer explain plan for change request
Owner of description Objects_name cost cardin bytes cpucost cost of e/s
SELECT STATEMENT, TARGET = TIP: FIRST_ROWS 7 1 41 59257 7 AGGREGATION OF TRI 1 41 NESTED LOOPS NESTED LOOPS 7 1 41 59257 7 TABLE ACCESS BY INDEX ROWID AHC PATIENTDEPENDENTVISITS 4 1 16 36646 4 INDEX RANGE SCAN AHC K1_PATIENTDEPENDENT_AHCID 3 14 24364 3 INDEX RANGE SCAN AHC F1_PATIENTVISIT_AHCID 2 1 15293 2 TABLE ACCESS BY INDEX ROWID AHC PATIENTVISITS 3 1 25 22611 3 here after I changed the query no display cost = 7 io wait = improvement also 7 can someone please help these
How to adjust or rewrite lots of join not keys to multiple records on table table
Thank you
VSM
you have not answered my question. Are you really calling it 35 million times in 30 minutes?
If so, why?
-
How can I set the default value of a selection in the Query Panel with table.
Hi Experts,
JDev 12.1.3.0.0
I have a view Criteria (contains a attribute with LOV). and the named criteria is dragged as a query with Table Panel.
In the user interface, the LOV is now visible in the query Panel. Suppose that the LOV has 3 values: 'Manual', 'Other' and 'portfolio '.
How can I set a default value for the choice of a select. ?
Thank you
Roy
refer to:
Andrejus Baranovskis Blog: Dynamic value by default for the field in query ADF search
but rather to express as in the bellows of the image, choose literal and let 2
-
Refresh the result table or rerun the query
I have a requirement, simple but stuck somewhere.
Jdev 11.1.1.17 Expert level: Mid-Senior
I have a form of application and the associated result table. It works great and no problems.
My requirement is that I have a commandlink on one of the column. Clicking on that will open a popup with an editable filed. OK will commit and Cancel will close the pop-up window.
After that the popup is dismissed with partial trigger, my table refreshes but data is identical to the front. But if I click the Find (Search) button on the query, it shows the data with the results updated which are changed in the pop-up window above.
How do I update table which re - runs the query and then refreshes the table after the popup is dismissed, or when the user clicks the OK button in the pop-up window.
Get on the viewObject of this table and call the executeQuery method that
Write this method in the method AMImpl and then call it in bean managed using the OperationBinding at the click on the Ok button of the dialog box
ViewObject vo = this.getViewObjectName ();
vo.executeQuery ();
Ashish
Maybe you are looking for
-
I recently bought my new laptop and updated operating system of Windows 8.1 for Windows (64-bit) 10. I received a message saying that Realtek RTL8723BE Bluetooth Driver and Documentation HP had been turned off because they were incompatible with wind
-
Can someone check if this "processor Intel E8400 Core 2 Duo - 3.00 GHz, 6MB L2 Cache, 1333 MHz FSB, Socket LGA775" processor is compatible with the T60?
-
Driver update has a seal saying that it is certified by Microsoft, is that true?
Since I downloaded it my audio died and my screen flickers when playing my game of chess. What is going on? I wanted to have some knowledge before interacting with the driver update that I paid the money on my credit card for this program (Fix clea
-
Problem downloading program practical driving test success
Problems with the installation an error message and the program says d3drm.dll is missing on my computer. What this mean and how can I fix this please?
-
Sound with no video in Windows Media Player or any other software I've tried.
I have no video when I play all the files on my computer no matter what program I use. I updated my driver for video card, re-installed the software. Verified that both we are up-to-date. The files are files simple .wmv and .mpg. They have worked in