Table Partitionining - Insert on primary select from previous partition
Hello,
I have a large table storing log data from the application. I want to query this table <TABLEA> and insert the result data to another table <TABLEB>.
At the same time another query is running selecting only from <TABLEB>.
I want to create 2 partitions on the TABLEB where the insert query will use one partition and the select query the second partition.
How can i do that ?
alekons wrote:
Hello,
I have a large table storing log data from the application. I want to query this table <TABLEA> and insert the result data to another table <TABLEB>.
At the same time another query is running selecting only from <TABLEB>.
I want to create 2 partitions on the TABLEB where the insert query will use one partition and the select query the second partition.
How can i do that ?what type of partitioning was used?
Oracle support the following partitioning methods:
Range partitioning - data is mapped to partitions based on a range of column values (usually a date column)
Hash partitioning - data is mapped to partitions based on a hashing algorithm, evenly distributing data between the partitions.
List partitioning - data is mapped to partitions based on a list of discrete values.
Interval partitioning - data is mapped to partitions based on an interval
Composite partitioning - combinations of the above methods
Range-Hash partitioning - data is partitioned by range, then hashed to sub-partitions.
Range-List partitioning - data is partitioned by range, then to sub-partitions based on a value list.
Range-range partitioning
List-range partitioning
List-hash partitioning
List-list partitioning
Interval partitioning, an extension of range partitioning. New partitions are automatically added.
System partitioning, application controlled partitioning.
Reference partitioning, partitioned like a parent table (referenced in a referential constraint).
Similar Messages
-
How to populate a table based on a row selection from another table.
Hi, i just started to use ADF BC and Faces. Could some one help me or point me a solution on the following scenario .
By using a search component , a table is being displayed as a search result. If i select any row in the resulted table , i need to populate an another table at the bottom of the same page from another view. These two tables are related by primary key . May i know how to populate a table based on a row selection from another table. Thanks
ganeshI understand your requirement and the tutorial doesn't talk about Association between the views so that you can create a Master-Detail or in DB parlance, a Parent-Child relationship.
I will assume that we are dealing with two entities here: Department and Employees where a particular Department has many Employees and hence a Parent-Child relationship.
Firstly, you need to create an Association between the two Entities - Department and Employees. You can do that by right clicking on the model's entity and then associating the two entities with the appropriate key say, DepartmentId.
Once you have done that, you need to link the two entities in the View section with this Association that you created. Then go to AppModule and make sure that in the Available View Objects: 'EmployeesView' appears under 'DepartmentView' as "EmployeesView via <link you created>". Shuttle the 'DepartmentView' to the right, Data Model and then shuttle
"EmployeesView via <link you created>" to the right, Data Model under 'DepartmentView'.
This will then be reflected in your Data Controls. After that, you simply would have to drag this View into your page as a Master-Detail form...and then when you run this page, any row selected in the Master table, would display the data in the Detail table.
Also, refer to this link: [Master-Detail|http://baigsorcl.blogspot.com/2010/03/creating-master-detail-form-in-adf.html]
Hope this helps. -
A select from internal partition crashes Oracle
I have the following INTERNAL partitioned table and local index by BUREAU_CODE:
CREATE TABLE fin_mea (
fin_mea_uid NUMBER NOT NULL,
fiscal_month_uid NUMBER NOT NULL,
fiscal_year_uid NUMBER NOT NULL,
bureau_code VARCHAR2(3) NOT NULL,
main_acct_code VARCHAR2(4),
sub_acct_code VARCHAR2(3),
net_amt NUMBER(23,2))
PARTITION BY RANGE (fiscal_month_uid)
INTERVAL (1)
(PARTITION fmea_initial VALUES LESS THAN (200501) );
CREATE INDEX fin_mea_bureau_idx ON fin_mea (bureau_code ASC) LOCAL;
When I try to select rows from non-existing partition with a condition which uses indexed column Oracle crashes with 'End of communication channel' error:
SELECT * FROM fin_mea partition for (201301) a where a.bureau_code = 'ZZZ'
The following one works even no rows selected:
select * from (SELECT * FROM fin_mea partition for (201301)) a where a.bureau_code = 'ZZZ';
If I delete index then first query works with no problem:
SELECT * FROM fin_mea partition for (201301) a where a.bureau_code = 'ZZZ'
Is this a bug or am I doing something wrong?
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0The following is the full script. I renamed field names and removed tablespace section.
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jul 19 18:23:38 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> drop table fin_mea;
Table dropped.
SQL> CREATE TABLE tfs.fin_mea (
2 fin_mea_uid NUMBER NOT NULL,
3 field2 NUMBER NOT NULL,
4 fiscal_month_uid NUMBER NOT NULL,
5 field4 NUMBER NOT NULL,
6 field5 NUMBER NOT NULL,
7 field6 NUMBER NOT NULL,
8 field7 NUMBER NOT NULL,
9 field8 VARCHAR2(24) NOT NULL,
10 field9 NUMBER NOT NULL,
11 bureau_code VARCHAR2(3) NOT NULL,
12 field11 VARCHAR2(3),
13 field12 VARCHAR2(3),
14 field13 NUMBER(4),
15 field14 NUMBER(4),
16 field15 VARCHAR2(1),
17 field16 VARCHAR2(4),
18 field17 VARCHAR2(3),
19 field18 NUMBER(4),
20 field19 NUMBER(4),
21 field20 NUMBER(5),
22 field21 VARCHAR2(3),
23 field22 VARCHAR2(2),
24 field23 NUMBER(4),
25 net_amt NUMBER(23,2))
26 PARTITION BY RANGE (fiscal_month_uid)
27 INTERVAL (1)
28 (PARTITION fmea_initial VALUES LESS THAN (200501) )
29 PCTFREE 10
30 INITRANS 1
31 MAXTRANS 255
32 NOCACHE
33 MONITORING
34 NOPARALLEL
35 LOGGING
36 /
Table created.
SQL>
SQL> CREATE INDEX tfs.fin_mea_org_idx ON tfs.fin_mea LOCAL
2 (bureau_code ASC
3 )
4 PCTFREE 10
5 INITRANS 2
6 MAXTRANS 255
7 NOPARALLEL
8 LOGGING
9 /
Index created.
SQL>
SQL> SELECT * FROM fin_mea partition for (201301) a where a.bureau_code = 'ZZZ';
SELECT * FROM fin_mea partition for (201301) a where a.bureau_code = 'ZZZ'
ERROR at line 1:
ORA-03113: end-of-file on communication channel -
Hi All,
I am having one query as below:
There is a master table named: MSTR_TABLE (It's having partitions on a month column [YYYYMM] )
I am having 4 temp Tables As: Temp1, Temp2, temp3, Temp4 (These tables are not having any index, no partitions)
Scenario 1: I am trying to insert data into MSTR_TABLE from Temp1, Temp2, temp3, Temp4 tables (Select data from temp tables by Outer Join), which i taking lot's of time. Coming to no of records in temp tables are Temp1: 5 Million Records,
Temp2: 3 Million Records,
Temp3: 0.5 Million records,
Temp4: 5000 Records
Scenario 2: Creating a new Table as TEMP_MASTER using Temp1, Temp2, temp3, Temp4 tables. This is executing much faster and the table is getting created in less than 10 mins.
Scenario 3: Now i am inserting data from TEMP_MASTER to MSTR_TABLE. This is is also getting executed in less than 5 mins.
I tried following methods:
1) Creating a table with partitions and tried Inserting Data - No Luck
2) Disabled Logging on table and tried Inserting data - No Luck
3) used /*+ append nologging*/ and tried inserting data - No Luck
4) Altered Next Extent to 8MB and tried - No Luck
Please let me know, why while inserting into main table (Scenario 1) from query is not working and running long time (More than 2 hrs).
Thanks in Advance,
Venu Gopal KHi Sudhakar,
Thanks for your reply. Please find the detailed description of situation as below:
MSTR_TABLE: Existing Number of columns : 120
Indexes: NO
Partitions: On Month Column (Datatype: Number, format (YYYYMM, Ex: 201205))
Inserting Data for every month
I added 18 new columns to MSTR_TABLE and the requirement is to populate data for 18 columns. These 18 columns data i am fetching from multiple tables and storing in temp tables as below, and creating a new table by joining PRNT_TABLE, TEMP1,TEMP2,TEMP3,TEMP4 and fetching 120+18 columns data and storing in MSTR_TABLE.
PRNT_TABLE: Existing Number of columns : 120
Indexes: NO
Partitions: On Month Column (Datatype: Number, format (YYYYMM, Ex: 201205))
Data : more than 100 Million records
TEMP1: No Index, No Partitions (No Of Rows: 5 million)
TEMP2: No Index, No Partitions (No Of Rows: 4 million)
TEMP3: No Index, No Partitions (No Of Rows: 30000)
TEMP4: No Index, No Partitions (No Of Rows: 5000)
Queries are as follows:
Scenario 1:
Insert into MSTR_TABLE
(col1,
col2,
col3,
col119,
col120,
New_col121,
New_col122,
New_col138)
select col1, col2, col3 ...............col119, col120, New_col121, New_col122.................New_col138
from PRNT_TABLE, TEMP1,TEMP2,TEMP3,TEMP4
where PRNT_TABLE.Col1 = TEMP1.Col1(+)
AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
AND PRNT_TABLE.Month = 201102
Execution Plan Statistics: INSERT STATEMENT ALL_ROWSCost: 19,451,465 Bytes: 2,472,327,442 Cardinality: 5,593,501
Scenario 1:
Create table NEW_TABLE
as
select col1, col2, col3 ...............col119, col120, New_col121, New_col122.................New_col138
from PRNT_TABLE, TEMP1,TEMP2,TEMP3,TEMP4
where PRNT_TABLE.Col1 = TEMP1.Col1(+)
AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
AND PRNT_TABLE.Month = 201102
Execution Plan Statistics: CREATE TABLE STATEMENT ALL_ROWSCost: 19,500,277 Bytes: 2,472,327,442 Cardinality: 5,593,501
Thanks,
Venu Gopal K. -
Can ResultSetMetaData() return the table name if it is selected from a view
hi all
can anyone tell me if ResultSetMetaData() can return the name of the table if it is selected from a view? thanks, i tried and it didn't return nothing. is it because the view is treated differently than table in ResultSetMetaData?hi all
can anyone tell me if ResultSetMetaData() can return
the name of the table if it is selected from a view?
thanks, i tried and it didn't return nothing. is it
because the view is treated differently than table in
ResultSetMetaData?I would say "no". A view could be a multi-table join query, or maybe even a no-table query. The bigger picture I think though, is that you shouldn't need to know what the underlying table(s) were for this query - smells of a mis-design. -
I am trying to import data characters from a tab delimited file into a table in labview. After I import the strings, I want to be able to select individual strings from the table and put into another table. I want the item that I am selecting to appear in a text box labeled 'selected step'. After I put all of the selected data in the new table, I want to be able to save that table in another tab delimited file (spreadsheet). This is what I have so far. Any help given will be GREATLY appreciated.
Attachments:
Selector.zip 30 KBHi,
Here are modifications to your vi to do what you are describing. It helps, when trying to work through issues like these on this forum to not start a new thread with each iteration of your question. Those of us that are trying to help can follow it better if you just "Reply" to your previous thread with the new, related question. If the question is for a totally new issue then a new thread is best, but when you are working through the details of essentially the same problem it really helps us follow it if you stay in one thread, and that usually means faster answers.
We also like it if, when an answer helps, you give us a rating (the more stars the better) as it is about all we get out of it!
P.M.
Putnam
Certified LabVIEW Developer
Senior Test Engineer
Currently using LV 6.1-LabVIEW 2012, RT8.5
LabVIEW Champion
Attachments:
SelectorV2.zip 30 KB -
Can I do an Insert using two selects from different tables?
Hi,
I have three tables, Course (CID, NAME, TIME)
Teacher (TID, NAME, DESCRIPTION) and OfferedBy(CID, TID) to match a course to a teacher.
After I do an insert on Course, I want to be able to do an insert on OfferedBy using the CID of the course I inserted, and the TID of the teacher that's offering it.
I tried this after doing inserts on Course and Teacher:
INSERT INTO OfferedBy values (SELECT CID FROM Course where courseName = 'name' , SELECT TID FROM Teacher WHERE LastName = 'teacherName').
I get an ORA 00907 error.
What am I doing wrong? Can this actually be done?
Thank you
IHi,
How would you relate the TID with CID?
I tried this after doing inserts on Course and Teacher:
INSERT INTO OfferedBy values (SELECT CID FROM Course where courseName >= 'name' , SELECT TID FROM Teacher WHERE LastName = 'teacherName').
I get an ORA 00907 error.You can use the query in this way:
SQL> SELECT ( ( SELECT dummy FROM DUAL), (SELECT DUMMY FROM DUAL)) FROM DUAL;
SELECT ( ( SELECT dummy FROM DUAL), (SELECT DUMMY FROM DUAL)) FROM DUAL
ERROR at line 1:
ORA-00907: missing right parenthesis
SQL> SELECT 'AA',(SELECT dummy FROM DUAL) FROM DUAL;
'A (
AA X
SQL>Regards -
Back button on IE 11 does not load the dropdown selections from previous form
We have a site in clasic ASP. There is a search criteria form with a few drop downs and a few radio buttons. While working in IE 11, When this form filled and submitted, the results show up. When the back button is hit, the previous form loads but the selections
are lost. This works perfectly fine in IE 9. What has changed in IE 11 that this does not work.
Is there some setting that can get this feature back.
ArunHi,
your question would be better answered in a developers forum. Include with your question a link to your website so that it can be tested.
usually the query parameters from a get request are used to populate a form with previously entered values. You may have coded your page to always refresh from the server.
IE documentation for developers can be found here -
http://msdn.microsoft.com/en-us/ie/ - there are no MSDN support forums for classic asp.
Questions regarding Internet Explorer 8, 9 and 10 and Internet Explorer 11 for the IT Pro Audience. Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions. If you are a consumer looking for answers or to
raise a question, it's highly recommended you head on over to http://answers.microsoft.com/en-us
Rob^_^ -
The source tables are having crores of data (growing tables). Tables with 4crores, 17cr. We want these tables to be copied frequently to our local database. Previously it was done by export-import through windows scheduled task. but now we are planning to do it as database jobs. We are fetching the datas with query
insert into dest_tablee( select * from source_table@dblink) when we tried with this it was throwing exception like enough table space is not there. And also it was found that frequent commits has to be used while populating datas from big tables. So tried with cursor But it was very slow and again we got the exception like 'the table space unable to extend segment by 16 in undo tablespace 'UNDOTBS1'.
After that we tried with the group by. In this case we got the exception like unable to extend table and also index in the table space. For this the solution is to add datafile. Again we have increase the table space. Now the procedure is running very slow(taking much time. It might be because of the conditions used in the query).
Is there any other option to copy the datas from such a big tables? can we use the same sort of query?
Friends please help me to sort it out.
Thanks in AdvanceHi,
you have lot of data DONT use cursor, did you try using the COPY command.
How frequently you will be doing the COPYING of the data ?
If you have any constraints you can disable and enable after all the records have been copied.
Please look at this link this should help.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5280714813869
Thanks
Message was edited by:
hkandpal
Link added -
4.0 EA1 - Cannot select from table with xmltype
Hi,
I have the following table. When doing a select * from horus_owner.horus_objects nothing is shown. This could be reproduced with both 10g and 11g on the database-side.
Regards,
Johannes
-- Wiedergabe von TABLE DDL für Objekt HORUS_OWNER.HORUS_OBJECTS nicht möglich, da DBMS_METADATA internen Generator versucht.
CREATE TABLE HORUS_OWNER.HORUS_OBJECTS
ID NUMBER(32, 0) NOT NULL
, TRE_ID NUMBER(32, 0) NOT NULL
, WRK_ID NUMBER(32, 0) NOT NULL
, NAME VARCHAR2(200 BYTE) NOT NULL
, MOD_TYPE VARCHAR2(10 BYTE) NOT NULL
, LOCKED_BY VARCHAR2(30 BYTE)
, PETRI_XML SYS.XMLTYPE
, AOM_XML SYS.XMLTYPE
, SHM_XML SYS.XMLTYPE
, ORG_XML SYS.XMLTYPE
, ROLE_XML SYS.XMLTYPE
, MIT_XML SYS.XMLTYPE
, RUL_XML SYS.XMLTYPE
, TXT_DATA CLOB
, CREATED DATE NOT NULL
, CREATED_BY VARCHAR2(30 BYTE) NOT NULL
, UPDATED_BY VARCHAR2(30 BYTE)
, UPDATED DATE
, SIM_XML SYS.XMLTYPE
, GLOSSARY_XML SYS.XMLTYPE
, CONSTRAINT OBJ_PK PRIMARY KEY
ID
ENABLE
LOGGING
TABLESPACE HORUS_OWNER_DATA
PCTFREE 10
INITRANS 1
STORAGE
INITIAL 65536
NEXT 1048576
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
) NOCOMPRESS
XMLTYPE PETRI_XML STORE AS CLOB
XMLTYPE AOM_XML STORE AS CLOB
XMLTYPE SHM_XML STORE AS CLOB
XMLTYPE ORG_XML STORE AS CLOB
XMLTYPE ROLE_XML STORE AS CLOB
XMLTYPE MIT_XML STORE AS CLOB
XMLTYPE RUL_XML STORE AS CLOB
LOB (TXT_DATA) STORE AS SYS_LOB0000024538C00021$$
ENABLE STORAGE IN ROW
CHUNK 8192
RETENTION
NOCACHE
LOGGING
XMLTYPE SIM_XML STORE AS CLOB
XMLTYPE GLOSSARY_XML STORE AS CLOBALTER TABLE HORUS_OWNER.HORUS_OBJECTS
ADD CONSTRAINT OBJ_UK UNIQUE
WRK_ID
, NAME
, TRE_ID
ENABLEALTER TABLE HORUS_OWNER.HORUS_OBJECTS
ADD CONSTRAINT OBJ_TRE_FK FOREIGN KEY
TRE_ID
REFERENCES HORUS_OWNER.HORUS_TREE_NODES
ID
ENABLEALTER TABLE HORUS_OWNER.HORUS_OBJECTS
ADD CONSTRAINT AVCON_1243352806_MOD_T_000 CHECK
(MOD_TYPE
IN ('EMP', 'ROL', 'ENT', 'OCH', 'XML', 'SHM', 'OSM', 'BUM', 'BOM',
'BEH', 'KPI', 'RIS', 'SER', 'STR', 'SWO', 'AOM', 'CON', 'GOA', 'BUR'
, 'BPA', 'RES', 'SIM', 'GLO','TEM', 'SAR'))
ENABLECREATE UNIQUE INDEX HORUS_OWNER.OBJ_PK ON HORUS_OWNER.HORUS_OBJECTS (ID ASC)
LOGGING
TABLESPACE HORUS_OWNER_IDX
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
NEXT 1048576
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
NOPARALLEL
CREATE INDEX HORUS_OWNER.OBJ_TRE_FK_I ON HORUS_OWNER.HORUS_OBJECTS (TRE_ID ASC)
LOGGING
TABLESPACE HORUS_OWNER_IDX
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
NEXT 1048576
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
NOPARALLEL
CREATE UNIQUE INDEX HORUS_OWNER.OBJ_UK ON HORUS_OWNER.HORUS_OBJECTS (WRK_ID ASC, NAME ASC, TRE_ID ASC)
LOGGING
TABLESPACE HORUS_OWNER_IDX
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
NEXT 1048576
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
NOPARALLEL
CREATE INDEX HORUS_OWNER.OBJ_WRK_FK_I ON HORUS_OWNER.HORUS_OBJECTS (WRK_ID ASC)
LOGGING
TABLESPACE HORUS_OWNER_IDX
PCTFREE 10
INITRANS 2
STORAGE
INITIAL 65536
NEXT 1048576
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
NOPARALLELNot sure if this helps, but I was trying to come up with some test cases myself and I noticed some strange behavior. 4 simple test cases:
SELECT XMLTYPE('<OUTER><INNER>TEST</INNER></OUTER>') FROM DUAL;
SELECT XMLELEMENT("OUTER", XMLELEMENT("INNER", 'TEST')) FROM DUAL;
SELECT XMLELEMENT("OUTER", XMLAGG(XMLFOREST('TEST' "INNER"))) FROM DUAL;
SELECT XMLQUERY('/OUTER' PASSING XMLTYPE('<OUTER><INNER>TEST</INNER></OUTER>') RETURNING CONTENT) FROM DUAL;
1 and 2 return the xml string in the result grid column. 3 and 4 return (XMLTYPE) with no data in the pop-up editor when double clicking the result. I changed #3 to:
SELECT XMLELEMENT("OUTER", XMLFOREST('TEST' "INNER")) FROM DUAL;
and it returns the XML string.
I used undo to revert back to my original #3 and it started showing the XML string instead of (XMLTYPE) previously observed.
I changed my connection to another schema, ran #3 again, and it went back to (XMLTYPE). I tried to recreate the same behavior using the 2nd schema, but I was unable to get to show the XML string.
In any test case where I was getting the (XMLTYPE), I was not able to see data in the pop-up editor.
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for HPUX: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production -
Using combination of insert into and select to create a new record in the table
Hello:
I'm trying to write a stored procedure that receives a record locator parameter
and then uses this parameter to locate the record and then copy this record
into the table with a few columns changed.
I'll use a sample to clarify my question a bit further
-- Create New Amendment
function create_amendment(p_mipr_number in mipr.mipr_number%TYPE, p_new_amendment_number in mipr.amendment_number%TYPE)
return integer is
new_mipr_id integer;
begin
THIS is causing me grief See comments after this block of code
insert into mipr
(select mipr_id from mipr where mipr_number=p_mipr_number),
(select fsc from mipr where mipr_number=p_mipr_number),
45,
(select price from mipr where mipr_number=p_mipr_number),
practical,
(select part_number from mipr where mipr_number=p_mipr_number);
THe above will work if I say the following
insert into mipr
(select * from mipr where mipr_number=p_mipr_number);
BUt, Of course this isn't what I want to do... I want to duplicate a record and change about 3 or 4 fields .
How do I use a combination of more than one select and hard coded values to insert a new record into the table.
/** Ignore below this is fine... I just put a snippet of a function in here ** The above insert statement is what I need help with
select (mipr_id) into new_mipr_id from mipr where mipr_number=p_mipr_number + amendment_number=(select max(amendment_number) + 1);
return new_mipr_id;
end;
THANK YOU IN ADVANCE!
KTfunction create_amendment(p_mipr_number in mipr.mipr_number%TYPE)
return integer is
new_mipr_id integer;
tmp_number number;
tmp_mipr_id integer;
begin
tmp_number :=(select max(amendment_number) from mipr where mipr_number=p_mipr_number);
Question:
tmp_number :=1; works..
tmp_number doesn't work with the select statement?
Obviously I'm a novice! I can't find anything in my book regarding tmp variables... What should I look under is tmp_number a
variable or what? In my Oracle book, variable means something different.
Thanks!
KT
I have the following code in my stored procedure:
Good luck,
Eric Kamradt -
Html form for select * from table a
Hi all,
I m looking for report on header/footer part from one apex pages
which will display context from table a, like sql statement
select * from table a, written in html.
Is any examples in java script/html select from tables
(and same insert into table A (...) select * from table b)
thanks,
GordanHello Gordan,
Do you want to show the whole report or just some data of it?
If it's for ex just the name and address you could create two items and have a process or computation to fill it with your select statement.
If it's the whole report, just create the report and put it in for ex. Region 1. In your page template you can specify that Region 1 needs to come into the footer.
Regards,
Dimitri
-- http://dgielis.blogspot.com/
-- http://apex-evangelists.com/
-- http://apexblogs.info/ -
DB Trigger: select from and into current table
I'm running 8.0.5 and facing a table looking like MYTAB(RECID,RECLABEL,..., PARENTRECID, PARENTRECLABEL) where:
. RECID = current record UID (say: employee number)
. RECLABEL = current record label (say: employee name)
. PARENTRECID = RECID of another record in table MYTAB (say: employee ID of the manager of the current employee)
. PARENTRECLABEL = must be made to hold automatically the contents of RECLABEL in the parent record (say: the name of the manager of the current employee)
I know an easy way to get this info would be to use a view like CREATE VIEW MYVIEW AS SELECT A.RECID, A.RECLABEL, A.PARENTRECID, B.RECLABEL "PARENTRECLABEL" FROM MYTAB A, MYTAB B WHERE A.PARENTRECID=B.RECID but for various reasons I would really love to denormalize that info into column PARENTRECLABEL using a database trigger.
Obviously, table MYTAB itself cannot be selected from during the execution of the dB trigger: mutating table error !
I tried:
. to select from a view defined as "SELECT * FROM MYTAB" as suggested in another thread, but this trick didn't seem to be sufficient to lure Oracle (it still says I'm trying to select from a mutating table !)
. to use a package within which a PL/SQL table variable is filled with the list of affected RECID on a FOR EACH ROW basis, and to issue updates in a after statement (thus: not AFTER EACH ROW) AFTER UPDATE trigger - but it's too late already and those updates are apparently not taken into account by the database.
Any other suggestions?
Thx - DidierHere's the code, if the formatting in unpreserved please do let me I'll mail the same.
The Package
CREATE OR REPLACE PACKAGE save_table_package
AS
TYPE saved_test2_type
IS TABLE OF test2%ROWTYPE
INDEX BY BINARY_INTEGER;
saved_test2 saved_test2_type;
saved_test2_num NUMBER:= 1;
PROCEDURE save_test2_row(i_id NUMBER
,i_ename VARCHAR2
,i_mgr_id NUMBER
,i_mgr_ename VARCHAR2
PROCEDURE clear_rows;
END save_table_package;
show err
CREATE OR REPLACE PACKAGE BODY save_table_package AS
PROCEDURE save_test2_row(i_id NUMBER
,i_ename VARCHAR2
,i_mgr_id NUMBER
,i_mgr_ename VARCHAR2
IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Enter pkg.save_test2_row:'| |TO_CHAR(save_table_package.saved_test2_num,'099999'));
save_table_package.saved_test2(saved_test2_num).id := i_id;
save_table_package.saved_test2(saved_test2_num).ename := i_ename;
save_table_package.saved_test2(saved_test2_num).mgr_id := i_mgr_id;
save_table_package.saved_test2(saved_test2_num).mgr_ename := i_mgr_ename;
DBMS_OUTPUT.PUT_LINE('Saved Details Of Row ###:' | |
TO_CHAR(save_table_package.saved_test2_num,'099999') | |'('| |
TO_CHAR(save_table_package.saved_test2(saved_test2_num).id,'099') | |','| |
save_table_package.saved_test2(saved_test2_num).ename | |','| |
save_table_package.saved_test2(saved_test2_num).mgr_id | |','| |
save_table_package.saved_test2(saved_test2_num).mgr_ename | |')'
save_table_package.saved_test2_num := save_table_package.saved_test2_num + 1;
DBMS_OUTPUT.PUT_LINE('Leave pkg.save_test2_row:'| |TO_CHAR(save_table_package.saved_test2_num,'099999'));
END save_test2_row;
PROCEDURE clear_rows IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Enter pkg.clear_rows :'| |TO_CHAR(save_table_package.saved_test2_num,'099999'));
save_table_package.saved_test2_num := 1;
DBMS_OUTPUT.PUT_LINE(' Leave pkg.clear_rows :'| |TO_CHAR(save_table_package.saved_test2_num,'099999'));
END clear_rows;
END save_table_package;
show err
The Triggers
CREATE OR REPLACE TRIGGER trig_bfr_iup_test2_fer
BEFORE INSERT OR UPDATE OF mgr_id ON test2 FOR EACH ROW
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('Enter before insupd:'| |TO_CHAR(save_table_package.saved_test2_num,'099999'));
save_table_package.save_test2_row(:new.id
,:new.ename
,:new.mgr_id
,:new.mgr_ename);
DBMS_OUTPUT.PUT_LINE('Leave before insupd:'| |TO_CHAR(save_table_package.saved_test2_num,'099999'));
END;
show err
CREATE OR REPLACE TRIGGER trig_aft_iup_test2_stm
AFTER INSERT OR UPDATE OF mgr_id ON test2
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('Enter after insupd:'| |TO_CHAR(save_table_package.saved_test2_num,'099999'));
FOR i IN 1 .. save_table_package.saved_test2_num - 1
LOOP
UPDATE test2 eme
SET mgr_ename = (SELECT mgr.ename
FROM test2 mgr
WHERE mgr.id = eme.mgr_id)
WHERE eme.id = save_table_package.saved_test2(i).id
DBMS_OUTPUT.PUT_LINE('MGR_ENAME Set Row#:'| |TO_CHAR(i,'099999'));
END LOOP;
save_table_package.clear_rows;
DBMS_OUTPUT.PUT_LINE('Leave after insupd:'| |TO_CHAR(save_table_package.saved_test2_num,'099999'));
END;
show err
null
Maybe you are looking for
-
CF MX and Daylight Savings Time Change
Next year 2007, the Daylight Saving day (chaning the clocks for spring and fall) will be changing. The Spring date will be a month earlier and the fall date a month later then it has been for years. How will the Cold Fusion Server for MX 7+ handle th
-
Managing several project configurations
Hi! Being a newbie with Sun Studio, but not exactly with programming, I have a question regarding project configurations. Currently, I have a group of projects configured as dynamic libraries, the number may grow up to between 10 and 20. I want to be
-
Hi Gurus, Can any one of you please guide me in picking up the total tax value for a PO with the help of the PO number? I have the Invoive number and then i can get a PO number from that, I have been trying to find a way to get the Path to pick up th
-
[SOLVED] ruby-panelapplet2 won't compile (i686 & x86_64)
Hi! I already wrote forum post in 64 bit section, but today I got to i686 machine and the error is the same, that damned package won't compile Can anyone help getting this compiled? Any hints? Errors are as follows: Package 'glipper' has no Name: fie
-
Create id, update id with date for each record
Hi, Please give me brief idea or document for this concept: I need create id, create date, update id, update date for each record inserted or updated in database (in few tables). 1) how user id can be obtained? 2) Is it better if i use views instead