Select into another table
Hello -
I'm running Oracle 8.1.7.4. Is there a way to run a query and automatically load the results into a newly created table? For example, my secondary table currently does not exist. I want to run a query, and at the same time, create and load the secondary table with the query results.
Thanks.
A utilização da clausula storage (initial value integer) pode melhorar o desempenho no momento da criação da tabela, pois evita a extensão automática do segmento no momento da carga, segue um exemplo:
create table teste
storage (initial 2048 k) /*para ser mais preciso verifique o tamanho do segmento tabela1 e substitua o valor initial da clausula storage */
as select * from tabela1 nologging
Similar Messages
-
Copy selected values from a table control into another table control
hi there,
as seen in the subject i need to copy selected values from a table control into another table control in the same screen. as i dont know much about table controls i made 2 table controls with the wizard and started to change the code... right now im totally messed up. nothing works anymore and i don't know where to start over.
i looked up the forums and google, but there is nothing to help me with this problem (or i suck in searching the internet for solutions)
i have 2 buttons. one to push the selected data from the top table control into the bottom tc and the other button is to push selected data from the bottom tc into the top tc. does somebody has a sample code to do this?you're funny
i still don't get it... can't believe, there is no tutorial or sample code around how to copy multiple selected rows from a tc.
here's my code, maybe you can tell me exactly were i have to change it:
tc1 = upper table control
tc2 = lower table control
SCREEN 0100:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE get_nfo. --> gets data from the dictionary table
MODULE tc1_change_tc_attr.
LOOP AT it_roles_tc1
INTO wa_roles_tc1
WITH CONTROL tc1
CURSOR tc1-current_line.
ENDLOOP.
MODULE tc2_change_tc_attr.
LOOP AT it_roles_tc2
INTO wa_roles_tc2l
WITH CONTROL tc2
CURSOR tc2-current_line.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT it_roles_tc1.
CHAIN.
FIELD wa_roles_tc1-agr_name.
FIELD wa_roles_tc1-text.
ENDCHAIN.
FIELD wa_roles_tc1-mark
MODULE tc1_mark ON REQUEST.
ENDLOOP.
LOOP AT it_roles_tc2.
CHAIN.
FIELD wa_roles_tc2-agr_name.
FIELD wa_roles_tc2-text.
ENDCHAIN.
FIELD wa_roles_tc2-mark
MODULE tc2_mark ON REQUEST.
ENDLOOP.
MODULE ok_code.
MODULE user_command_0100.
INCLUDE PAI:
MODULE tc1_mark INPUT.
IF tc1-line_sel_mode = 2
AND wa_roles_tc1-mark = 'X'.
LOOP AT it_roles_tc1 INTO g_tc1_wa2
WHERE mark = 'X'. -
> big problem here is, that no entry has an 'X' there
g_tc1_wa2-mark = ''.
MODIFY it_roles_tc1
FROM g_tc1_wa2
TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc1
FROM wa_roles_tc1
INDEX tc1-current_line
TRANSPORTING mark.
ENDMODULE. "TC1_MARK INPUT
MODULE tc2_mark INPUT.
IF tc2-line_sel_mode = 2
AND wa_roles_tc2-mark = 'X'.
LOOP AT it_roles_tc2 INTO g_tc2_wa2
WHERE mark = 'X'. -
> same here, it doesn't gets any data
g_tc2_wa2-mark = ''.
MODIFY it_roles_tc2
FROM g_tc2_wa2
TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc2
FROM wa_roles_tc2
INDEX tc2-current_line
TRANSPORTING mark.
ENDMODULE.
thx for anybody who can help with this! -
Inserting results from select query into another table
Hi: Is there a way to insert results returned from a SQL query into another table within the same SQL statement.
For example
SELECT a.SRCID,
SUM(DECODE(a.CLASS_ID,91147,1,0)) BLOCK,
SUM(DECODE(a.CLASS_ID,91126,1,0)) ALLOW,
FROM EVENT_DATA a
where
a.class_id in (91147,91126)
GROUP BY SRCID
order by TOTAL DESC;The columns returned SRCID, BLOCK and ALLOW need to go into another table called AGGREGATE_COUNT. This table has fields SRCID, BLOCK and ALLOW. Or is the only way this can be done from outside of SQL like using perl or C.
Thanks
RayINSERT INTO aggregate_count
( chart_id
, srcid
, block
, allow
SELECT 2234 chart_id
, srcid
, SUM(DECODE(class_id, 91147, 1, 0))
, SUM(DECODE(class_id, 91126, 1, 0))
FROM event_data
WHERE class_id IN (91147, 91126)
GROUP BY chart_id, srcid
ORDER BY total DESC; -
Inserting data from one table into another table using PL/SQL
HI,
I am trying to insert values from one table into another using PL procedure, the values I want to retrieve from the table riverside1 are charac_id and charac_type and insert these values into another table called riverside2 , the stored procedure zorgs_gorfs(x,y) accepts two parameters which are 2 charac_id's of d characters in riverside1 then using insert statements inserts these characters from riverside1 into riverside2.
CREATE OR REPLACE PROCEDURE zorgs_gorfs(x IN NUMBER, y IN NUMBER) AS
BEGIN
INSERT INTO riverside2
(charac_id)
VALUES
(x);
INSERT INTO riverside2
(charac_id)
VALUES
(y);
END zorgs_gorfs;
/This works but the problem im having is that when I also try to insert the charac_type as well as the charac_id it doesnt work below is the code:
CREATE OR REPLACE PROCEDURE zorgs_gorfs(x IN NUMBER, y IN NUMBER) AS
BEGIN
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id = x);
END zorgs_gorfs;
/can someone kindly sort me outmodify this sql
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id = x);as
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id in ( x,y));But my suggestion would be consider revising your approach. It does not look that good.
Thanks,
karthick. -
How can I get a count at the same time I am inserting into another table
I have a requirement where I have to find out the count(number of records inserted into another table) at the same time I insert into the table:
Like
I am copying records from table B to A, while doing this I have to find out how many records I've inserted since I need this count in subsequent steps
INSERT INTO A
SELECT * FROM B
how can I store the count into any variable while doing above statement
Please adviceNo, Warren that doesn't work!
SQL> set serveroutput on
SQL> declare
2 vCtr number := 0;
3 begin
4 insert into emp2
5 select * from emp;
6
7 select count(*)
8 into vCtr
9 from emp2;
10
11 dbms_output.put_line('rows created '||to_char(vCtr));
12 end;
13 /
rows created 15
PL/SQL procedure successfully completed.
SQL> declare
2 vCtr number := 0;
3 begin
4 insert into emp2
5 select * from emp;
6
7 select count(*)
8 into vCtr
9 from emp2;
10
11 dbms_output.put_line('rows created '||to_char(vCtr));
12 end;
13 /
rows created 30
PL/SQL procedure successfully completed.
SQL> -
Need help in SQL Query: Update a row in a table & insert the same row into another table
I want to update a row in a table say Table A and the updated row should be inserted into another table say Table B. I need to do it in a single SQL query and i don't want to do it in PL/SQL with triggers. And i tried with MERGE statement but its working with this scenario. (Note: I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0).
Thanks in Advance.Using Sven's code as an example, you could save the updated row in a sql plus variable. (also untested):
SQL> var v_id number
update tableA
set colB='ABC'
where colC='XYZ'
returning id into :v_id;
insert into table A_History (ID, colA, colB, ColC)
select id, ColA, ColB, ColC
from tableA
where id = :v_id; -
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. -
Insert values to one table based on a value inserted into another table
Hi,
I've got a form based off a report which creates a new project. I've added an additional process to this form to insert four new values into another table as soon as the new project is created and the PK for that project is generated. This was working last week (of course!) and now seems to not work at all. It's complaining that the PK I was getting from my first insert was null. Here is one the the statements in my process I'm trying to run:
insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER);
The complaint I get that it's getting null where :P45_PROJECT_SEQ should be.
Thoughts?
Thanks,
JonHi Andy,
Thanks for the tip. Those two values didn't match and I updated them so they do and I'm still getting a "cannot insert NULL..." error.
When I turn on debug I see that I'm getting the PK and I see the value. Here's my debug output:
0.24: ...Process "Get PK": PLSQL (AFTER_SUBMIT) declare function get_pk return varchar2 is begin for c1 in (select PROJECT_SEQ.nextval next_val from dual) loop return c1.next_val; end loop; end; begin :P45_PROJECT_SEQ := get_pk; end;
0.25: ...Session State: Saved Item "P45_PROJECT_SEQ" New Value="252"
0.25: ...Process "Process Row of PROJECT": DML_PROCESS_ROW (AFTER_SUBMIT) #OWNER#:PROJECT:P45_PROJECT_SEQ:PROJECT_SEQ|IUD
0.26: ...Session State: Save "P45_PROJECT_SEQ" - saving same value: "252"
0.26: ...Process "reset page": CLEAR_CACHE_FOR_PAGES (AFTER_SUBMIT) 45
0.27: Nulling cache for application "120" page: 45
0.27: ...Process "Add Week Groups": PLSQL (AFTER_SUBMIT) insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER); insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY') +
0.28: Encountered unhandled exception in process type PLSQL
0.28: Show ERROR page...
0.28: Performing rollback...
I notice that when it runs my process "Add Week Groups" it's not displaying all of the SQL. But the SQL is fine, it's right here:
insert into week_group values(week_group_seq.nextval, (SELECT trunc(NEXT_DAY(SYSDATE, 'FRIDAY')) FROM dual), 0, '', :P45_PROJECT_SEQ, sysdate, :APP_USER);
Hmmm....what about the "reset page" action in the last of the 0.26 lines?
Thanks,
Jon -
How to retrive one table records into another table by multiple records
how to retrive table X records into another table Y by multiple records (means at once i want display 10 records) in form 6i .
when i am written cursor it is ftching only one record.But i want to display all records at once.
Declare
Cursor cur_name is
select PROTOCOL_NO,DOCNUM,SUBSETSN,REPEATSN,AESEQ,AETERM from coding_ae WHERE PROTOCOL_NO='KP229';
Begin
open cur_name;
loop
fetch cur_name into :PROTOCOL_NO,:DOCNUM,:SUBSETSN,:REPEATSN,:AESEQ,:AETERM;
exit when cur_name%notfound;
next_record;
end loop;
close cur_name;
End;Hi,
Make sure the cursor is in the detailed block. For that use 8GO_BLOCK* built-in. So the code will be
Declare
Cursor cur_name is
select PROTOCOL_NO,DOCNUM,SUBSETSN,REPEATSN,AESEQ,AETERM from coding_ae;
Begin
GO_BLOCK('<detailed_block_name>');
open cur_name;
loop
fetch cur_name into :PROTOCOL_NO,:DOCNUM,:SUBSETSN,:REPEATSN,:AESEQ,:AETERM;
exit when cur_name%notfound;
next_record;
end loop;
close cur_name;
End;Regards,
Manu.
If my response or the response of another was helpful or Correct, please mark it accordingly -
Multi-row uipdate with an insert into another table [I think]
Folks,
I'm trying to get a multi row region with a checkbox against each row. When a user checks a box I want to insert a corresponding row into another table. So I've tried to simplify the questions and distill the problem down using the EMP table.
So, here goes:
I have table EMPS, which looks like this:
EMPNO Number
FIRSTNAME Varchar2(9)
LASTNAME Varchar2(10)
HIREDATE Date
I have table EMP_CANDIDATES, which looks like this:
EMPNO Number
SELECTION_DATE Date
NOTES Varchar2(53)
- I want to create a multi-row region based on EMPS, with a checkbox on each employee row.
- The user should be able to select any number of employees in the region and then press submit.
- on-submit there needs to be a process, which inserts a record into EMP_CANDIDATES for each checked employee.
I've tried pre-populating a collection with the EMPS records and using apex_item.checkbox to produce a checkbox, using this code:
=============
if apex_collection.collection_exists(p_collection_name=>'EMPS') then
apex_collection.delete_collection(p_collection_name=>'EMPS');
end if;
apex_collection.create_collection_from_query(
p_collection_name=>'EMPS',
p_query=>'select
p.empno,
p.hiredate,
p.firstname,
p.lastname,
null selection
from emps p');
=========
I can create a report region on this using tthe following SQL:
select c001 empno
, c002 hiredate
, c003 firstname
, c004 lastname
,apex_item.checkbox(1,c005) selection
from apex_collections
where collection_name ='EMPS'
======
So how do I now get a MRU that will insert a row into EMP_CANDIDATES for each checked row in my region? Or have I gone about this the wrong way?
TFH
DerekHi Derek,
Firstly, your checkbox should be on the c001 field as this is the one that contains your empno.
Then, you need a page process that can be triggered by a button. The process should be set to run "On submit (After computations and validations)" and the PL/SQL code would be something like:
DECLARE
v_empno NUMBER;
BEGIN
IF HTMLDB_APPLICATION.G_F01.COUNT = 0 THEN
raise_application_error(-20001, 'Please select at least one employee!');
END IF;
FOR i IN 1.. HTMLDB_APPLICATION.G_F01.COUNT LOOP
v_empno := TO_NUMBER(HTMLDB_APPLICATION.G_F01(i));
INSERT INTO EMP_CANDIDATES VALUES (v_empno, whateverdate, whatevernotes);
END LOOP;
END;
This will firstly count the items that have been ticked - if there aren't any, the user gets an error message. If there is at least one item ticked, the code will loop through these, get the empno relating to the ticked box and insert a record into the emp_candidates table. Please note that no account is taken here of any validation on this second table - if you need to ensure, for example, uniqueness of records in this table, you will have to update the above to perform this validation.
Regards
Andy -
Generate xml from a table and insert the xml into another table
I want to generate an xml file from a table and insert it into another table all in one tsql
insert into table B(xmlfile)
select * from tableA
FOR
XML
PATH('ac'),TYPE,ELEMENTS
XSINIL,ROOT('Accum')
Is not working any helpI have solved my issue all I did was to change my column datatype to xml
-
How could I insert the deleted row into another table within a trigger?
Hi,
How could I insert the deleted row into another table within a trigger? The destination table has the same columns as the source table. Since the statements are in the trigger, it is not allowed to query the source table named 'test'. Thanks! The trigger is as follows, uncompleted:
CREATE TRIGGER delete_trigger
AFTER DELETE
ON test
FOR EACH ROW
BEGIN
-- How could I insert the deleted row into another table
END delete_trigger;
Message was edited by:
user569548Hi,
I'm not sure what's wrong there.
I read the oracle docs about ANALYZE and ALL_TAB_COLUMNS, and did the following:
ANALYZE TABLE my_tab VALIDATE STRUCTURE; //went ok.
SELECT column_name
FROM all_tab_columns
WHERE table_name = 'my_tab'; //but no rows selected?
This topic might not be what this thread should be about. Here I posted a new thread:
How to get colum names of the newly created table?
Thanks.
Message was edited by:
user569548 -
How to dynamically display the data from a table base on row selection of another table in ADF
Hi ,
I have a requirement in ADF. I need to change the data of a table based on row selection of another Table . Both the table have a Parent Child relationship between them. They have a common attribute say department_id.
For this I created bind variable in view object of employees table and wrote a where clause in the sql query using that bind variable. Then I created method for selection listener of department Table in java bean.
My method is following
public void onrowselection(SelectionEvent selectionEvent) {
RichTable richTable = (RichTable)selectionEvent.getSource();
CollectionModel tableModel = (CollectionModel)richTable.getValue();
JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
Object selectedRowData = richTable.getSelectedRowData();
JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
Number pallet = newVal.bigDecimalValue();
System.out.println("Selected values " + pallet);
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
ViewObject vo =dciter.getViewObject();
vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
vo.executeQuery();
It is printing the selected value of department id from department table in the log. But it is not able to pass the value to employees view. It is showing the following error in the log
"Definition DepartmentId of type Variable is not found in EmployeesView1."
I will be very thankful if someone helps me to solve this errror or is there any other way to achieve the same requirement.
Thanks
NileshNote quite sure why you simply wont create a viewlink for the viewobject the tables are based on..
The viewlink attribute will be based on the departmentId and it's a simple master detail relationship which automatically uses ppr.
However, if both tables are on the same page; using your hack about;
On the underlying viewobject, define a viewcriteria e.g. "listById" and set your bind variable here.
I would bind table two to a RichTable component:
RichTable t2;
public void onrowselection(SelectionEvent selectionEvent) {
RichTable richTable = (RichTable)selectionEvent.getSource();
CollectionModel tableModel = (CollectionModel)richTable.getValue();
JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
Object selectedRowData = richTable.getSelectedRowData();
JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
Number pallet = newVal.bigDecimalValue();
System.out.println("Selected values " + pallet);
refreshTable2(pallet);
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
ViewObject vo =dciter.getViewObject();
vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
vo.executeQuery();
private void refreshTable2(Number pallet){
RichTable x=getT2();
CollectionModel cm=(CollectionModel)x.getValue();
JUCtrlHierBinding jcb=(JUCtrlHierBinding)cm.getWrappedData();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(jcb.getName()+"Iterator");
ViewObject vo =dciter.getViewObject();
ViewCriteriaManager vcm=vo.getViewCriteriaManager();
ViewCriteria vc=vcm.getViewCriteria("listById");
vo.applyViewCriteria(vc);
vo.setNamedWhereClauseParam("DepartmentId",pallet);
vo.executeQuery();
AdfFacesContext.getCurrentInstance().addPartialTarget(getT2()); -
How to get the data from one table and insert into another table
Hi,
We have requirement to build OA page with the data needs to be populated from one table and on save data into another table.
For the above requirement what the best way to implement in OAF.
I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
ThanksYou can achieve this in many different ways, one is
1. Create another VO based on the EO which is based on the dest table.
2. At save, copy the contents of the source VO into the dest VO (see copy routine in dev guide).
3. commiting the transaction will push the data into the dest table on which the dest VO is based.
I understand that if we attach VO object instance to region/page, we only can pull and put data in to only one table.
if by table you mean a DB table, then no, you can have a VO based on multiple EOs which will do DMLs accordingly.Thanks
Tapash -
How to move a selection into another selection in elements 12
how to move a selection into another selection in elements 12
Open picture B, the one you wish to select something from to add to another picture.
Use one of the selection tools, e.g. selection brush, lasso tool, to select the object. You will see an outline ("marching ants") once the selection is complete
Go to Edit menu>copy to copy the selection to the clipboard
Open picture A, then go to Edit>paste
Use the move tool to position object from picture B.
In the layers palette you should see picture A as the background layer, and object B on a separate layer
Maybe you are looking for
-
IMovie '08: Built-in iSight camera not recognized in Yosemite
On this page http://support.apple.com/en-us/TS2472 iMovie '08: Built-in iSight camera not recognized it says: In Finder, navigate to /System/Library/LaunchDaemons/ Select the file com.apple.mio.VDCAssistant.plist and delete. Restart your system. You
-
PowerBook G4 boots to Open Firmware without keyboard access
Summary: Let me provide a little backstory. According to the [DARPA Visitor Guidelines|http://www.darpa.mil/body/visitor_guidelines.html] wireless network technology is prohibited from DARPA facilities. Laptops with a wireless card are required to be
-
Form initialisation problem QMS-00100
I am NOT succeeding in generating a form with the right pre-form tigger code: The following code should be in the PRE-FORM trigger: /* CGNV$PRE_FORM_NAVCUR */ DECLARE rg_id RECORDGROUP; gc_wnd GROUPCOLUMN; gc_item GROUPCOLUMN; BEGIN CGNV$.nav_opening
-
I'm getting an error code 9 when trying to restore apple tv 2 thru iTunes any suggestions?
I'm getting an error code 9 when trying to restore apple tv 2 thru iTunes any suggestions? the error comes up when itunes tries to verify the update. I hook the apple tv back to tv and says I need to connect to itunes. the original problem was the
-
[locked] how to handle Machii_config_mode
Hi experts... can u pls help its very urgent.... can u pls tell me how to work with MACHII_CONFIG_MODE