Insertion of data between 2 tables ( 1 to * relationship )
Hi all, I am new to Oracle ADF, I have a problem with the insertion of data between 2 tables (Table A and Table B), I have the ratio 1 to *, and I need to insert data in table B (* Relationship) when insert in Table A all goes well, but when inserted in Table B, I need the primary key value in Table A () in the value field in table B that is as foreign key.
Ie
Value Table A
coda = 20 -> primary key
Table B values
1 set of values
val_1,
val_2,
val_3,
coda = 20 -> need this value is constant up to do a Commit.
set of values 2
val_1,
val_2,
val_3,
coda = 20 -> need this value is constant up to do a Commit.
How I can do it?
thanks
Thanks for you answers 'M.Jabr'
I was wrong, because the relationship 1 to * between tables A and B, I was writing the groovy expression in each table, in this case in Table B (A.codSolicitude), but now I notice that within the DataControls, but specifically in the control data of Table A, there is a relationship between the board B, and I thought to insert into the related table that appears as a master/detail, and first inset in table A and then in Table B in the same page master/detail, and A.CodSolicitude value is automatically filled in Table B, and performed the Commit and everything works. !
Thanks for you help.
Now if you can give me some examples with images that are on the web similar to this problem would be great:) Thanks!
Similar Messages
-
How can i open a DOC or TXT file and insert the data into table?
How can i open a DOC or TXT file and insert the data into table?
I have a doc file . the doc include some columns and some rows.(for example 'ID,Name,Date,...').
I'd like open DOC file and I'd like insert them into the table with same columns.
Thanks.Use the SQL*Loader utility or the UTL_FILE package.
-
Can not insert/update data from table which is created from view
Hi all
I'm using Oracle database 11g
I've created table from view as the following command:
Create table table_new as select * from View_Old
I can insert/update data into table_new by command line.
But I can not Insert/update data of table_new by SI Oject Browser tool or Oracle SQL Developer tool .(read only)
Anybody tell me, what's happend? cause?
Thankyou
thiensu
Edited by: user8248216 on May 5, 2011 8:54 PM
Edited by: user8248216 on May 5, 2011 8:55 PMI can insert/update data into table_new by command line.
But I can not Insert/update data of table_new by SI Oject Browser tool or Oracle SQL Developer tool .(read only)so what is wrong with the GUI tools & why posting to DATABASE forum when that works OK? -
Insert query for insert all data into table in vb6 but it insert 1 row in table
This is My insert query in vb6 but it insert 1 row in table
But i want insert all data in the table which contain the id =1.
Note that billtabsuport is blank
i want solution for this
strSQL = " select * from billtabsuport1 where StockID=" & lblid.Caption
Set DBrecordset = DBConnection.Execute(strSQL)
strSQL = " Insert into billtabsuport values('" & DBrecordset("StockID") & "','" & DBrecordset("C_Name") & "','" & DBrecordset("C_Add") & "','" & DBrecordset("C_Mobile") & "','" & DBrecordset("Invoice_No") & "','" & DBrecordset("Date") & "','" & DBrecordset("Order_No") & "','" & DBrecordset("T_Name") & "','" & DBrecordset("Dest") & "','" & DBrecordset("D_Date") & "','" & DBrecordset("Tyres_Serial_No") & "','" & DBrecordset("P_Desc") & "','" & DBrecordset("PR") & "','" & DBrecordset("Branded_NonBranded") & "','" & DBrecordset("Claim_No") & "','" & DBrecordset("Qty") & "','" & DBrecordset("U_Price") & "','" & DBrecordset("I_Value") & "','" & DBrecordset("V_Rate") & "','" & DBrecordset("V_Amt") & "','" & DBrecordset("Size") & "','" & DBrecordset("Pattern") & "','" & DBrecordset("TypesOfStock") & "','" & DBrecordset("TypesOfTube_Flap") & "','" & DBrecordset("VatAmount") & "')"
DBConnection.Execute (strSQL)The syntax for inserting from one set of tables to a new table is:
insert into newtable
(field1, field2, etc)
select somefield1, somefield2, etc
from some other tables
where whatever -
Move data between tables with INSERT-LOOP?
Greetings
I need to move all the contact information (contained in 5
fields- call it the address table) into the table (call it the main
table) that contains all the other associated information. Tables
are related via the "vendor_ID" key field.
There are about 7000 records.
I tried the attached code- with no luck- am I in the
ballpark?
Thanks!
newportriSorry- yes the tables are in the same DB because I imported
them together.
I am trying to clean this DB up for eventual porting to SQL
Server (it is in Access now) - I saw no good reason why the
designer used 2 separate tables- one with most info on each vendor,
but split the addresses off in another table?
I guess there are lumpers and splitters- but I can't see the
point of inserting/updating/deleting form 2 tables vs 1?
ERROR: The field 'Vendor1.vendor_ID' cannot contain a Null
value because the Required property for this field is set to True.
Enter a value in this field.
Thanks for your quick response. -
Using Cursor and FOR LOOP to INSERT the data into table
Hi all,
I have SELECT statement that returns 3 rows:
PROCESSNAME
PROTDATE
IMM
2013-12-18
Metrology
2013-11-18
CT
2013-12-04
SELECT processName, MAX(NVL(protStartDate, protCreateDate)) AS protDate
FROM TABLE(SEM_MATCH("{
?ipc rdf:type s:Protocol .
?ipc s:protocolNumber ?protNum .
?ipc s:protocolCreateDate ?protCreateDate .
OPTIONAL {?ipc s:protocolSchedStartDate ?protStartDate }
?ipra rdf:type s:ProcessAggregate .
?ipra s:hasProtocol ?iprot .
?iprot s:protocolNumber ?protNum .
?ipra s:processAggregateProcess ?processName.
}",sem_models("PROTS", "LINEARS"),NULL, SEM_ALIASES(SEM_ALIAS("","http://VISION/Data/SEMANTIC#"),SEM_ALIAS("s","http://VISION/DataSource/SEMANTIC#")),NULL))
Group by processName
Now I need to INSERT these values into the table along with the other values.
these other values come from different table.
INSERT INTO MODEL_CLASS_COUNTS (MODEL_NAME, CLASS_NAME, INS_COUNT, COUNT_DATETIME, PROCESS_NAME, PROT_DATE)
VALUES
("$MODEL",
"${i}",
(SELECT COUNT (DISTINCT S) FROM TABLE(SEM_MATCH(
"{?s rdf:type :${i} . }",SEM_Models("$MODEL"),NULL, SEM_ALIASES(SEM_ALIAS("","http://VISION/DataSource/SEMANTIC#")),NULL))),
SYSTIMESTAMP, %%here need to insert PROCESSNAME, PROTDATE%%
t was giving me error:
PL/SQL: ORA-22905: cannot access rows from a non-nested table item
so i enclosed sparql query into single quotes.
The code is as follows:
declare
type c_type is REF CURSOR;
cur c_type;
v_process varchar2(200);
v_pdate varchar2(200);
begin
open cur for
' SELECT processName, MAX(NVL(protStartDate, protCreateDate)) AS protDate <-- it's complaining about this being too long identifier, i think...
FROM TABLE
(SEM_MATCH (
?ipc rdf:type s:Protocol .
?ipc s:protocolNumber ?protNum .
?ipc s:protocolCreateDate ?protCreateDate .
OPTIONAL {?ipc s:protocolSchedStartDate ?protStartDate }
?ipra rdf:type s:ProcessAggregate .
?ipra s:hasProtocol ?iprot .
?iprot s:protocolNumber ?protNum .
?ipra s:processAggregateProcess ?processName.
}",SEM_Models("XCOMPASS", "XPROCESS"),NULL,
SEM_ALIASES(SEM_ALIAS("","http://VISION/Data/SEMANTIC#"),
SEM_ALIAS("s", "http://VISION/DataSource/SEMANTIC#")),NULL))
Group by processName';
loop
fetch cur into v_process, v_pdate;
exit when cur%NOTFOUND;
--here I need to insert v_process , v_pdate into my table along with other values...
dbms_output.put_line('values for process and prod_date are: ' || v_process || v_pdate );
end loop;
close cur;
end;
exit;
Now, I get an error:
ORA-00972: identifier is too long
Does anyone know way around this?Hi,
I tested something similar with insert into select and it worked fine :
insert into t_countries(ID,CITY ,POPULATION, DESCRIPTION, located, insdate )
SELECT 1 id, city, o , city||' is a nice city' description, max(nvl(locatedAt,'unknown')) as located,
SYSTIMESTAMP
FROM TABLE(SEM_MATCH(
'{GRAPH :gCH {<http://www.semwebtech.org/mondial/10/countries/CH/> :hasCity ?cityID .
?cityID :name ?city .
OPTIONAL{?cityID :locatedAt ?locatedAt .}
?cityID :population ?o .
SEM_Models('VIRT_MODEL_MONDIAL'),
SEM_Rulebases(null),
SEM_ALIASES(SEM_ALIAS('','http://www.semwebtech.org/mondial/10/meta#'),
SEM_ALIAS('prv','http://www.semwebtech.org/mondial/10/countries/CH/provinces/')
null))
group by city,o
order by city;
Or with execute immediate :
declare
v_country varchar2(200) :='http://www.semwebtech.org/mondial/10/countries/F/';
v_text varchar2(2000);
begin
v_text := 'insert into t_countries(ID,CITY ,POPULATION, DESCRIPTION, located, insdate )
SELECT 1 id, city, o , city||'' is a nice city'' description, max(nvl(locatedAt,''unknown'')) as located,
SYSTIMESTAMP
FROM TABLE(SEM_MATCH(
''{<'||v_country||'> :hasCity ?cityID .
?cityID :name ?city .
OPTIONAL{?cityID :locatedAt ?locatedAt .}
?cityID :population ?o .
SEM_Models(''VIRT_MODEL_MONDIAL''),
SEM_Rulebases(null),
SEM_ALIASES(SEM_ALIAS('''',''http://www.semwebtech.org/mondial/10/meta#'') ),
null))
group by city,o
order by city';
dbms_output.put_line(v_text);
delete from t_countries;
execute immediate v_text ;
commit;
end;
Marc -
Moving data between tables (how to find out if the 2nd table is empty)
Hi,
I have 2 tables, and I'm copying records from one table to another.
I've followed the Wiki: [https://www.sdn.sap.com/irj/sdn/wiki?path=/display/vc/movingdatabetween+tables]
So far, everything works ok.
Here is my question: how do I get the number of records passed?
I mean, how do I know the number of rows in the 2nd table? (Remember that this number is variable, because it depends on how many rows I've inserted and deleted on the 2nd table).
I've tried to achieve that using a data store with a numeric field, but I couldn't find the way to increment/decrement the numeric field on data store, and insert/delete the row on table at the same time .
All I want is to find out if the 2nd table is empty or not.
Any ideas to solve this?
Thanks in advance!
Help will be point-rewarded.
MarceloHi Ahmed
thanks for your reply, it was very helpful!! (I've assigned points to you)
However the user can add twice or more times the same row... so the counter doesn't reflect the real number of rows in the 2nd table.
I've partially solved this also using a data store with a parameter called key_list, where I add (I mean, concatenate) the key field for the selected row.
So, if I have a table with 4 rows with key fields "key1", "key2", "key3", the parameter key_list would get "key1;key2;key3".
So far, it's ok. But when I remove a row previosly added.... I can't remove the key from the key_list parameter. (I mean, from 2nd table I choose to remove the "key2" row, but I don't know how also remove the key name from the key_list)
I hope be clearly enough.
Any help will be really appreciated and point-rewarded.
Thanks again.
Best Regards
PS: is there any way of "mark" a row that has been added to the 2nd table? I mean, using (for example) a hidden boolean field named "added", that becomes true when the selected row is added to the 2nd table. -
I use SQL*Loader to load data into a interface table where I do some data cleaning.
Is there a easy way of moving the data from the interface table to a target table inside the same database, keeping in mind that the target table already contains data.
I normally export the data from the interface table, create a data and control file and use SQL*Loader again, but this seems like such a long way, surely there should be a easier way??
Thank you in advanceIt's not a problem that the target table contains more columns, you can either do ...
insert into my_target (col1, col2, col3, col4,col5)
select col_a, col_b, 'my_default_value',null, sysdate
from my_source;
... or ...
insert into my_target (col1, col2)
select co;l_a, col_b
from my_source;
The second statement will automatically put NULL into columns not listed after my_target, the first statement allows you to specify NULL explicitly or specify some static or dynamic default value.
I guess you have to find out why it's taking so long to insert the values. My guess would be that you have indexes on the table that are slowing things up. You may find it beneficial to drop the indexes, load the new data, rebuild the indexes.
You could also add the APPEND hint to the insert ...
insert /*+ append */ into my_target ...
... which might speed things up a little. Also check that your pctfree value for the table is set very low (0) and pctused is very high (99) if you are not going to be updating these rows in future -- this will pack more rows into each block.
Another option is to partition your target table, and use the EXCHANGE PARTITION mechanism to get data into it. -
Interfaces used for insert/update data in tables
for providing security the procedures are not allowed to directly insert/update the values in tables.some one suggested that use interfaces for this .i want infomation about this interfaces. how this works and how to use
An interface is an intermediate set of procedures/functions that do the job for you.
You haven't explained what it is you're trying to achieve exactly, but here's an example scenario.
We don't want to allow our developers to query, or write to the tables directly so they are set up with certain database users that have no permissions granted on the tables for such things.
Instead they have been granted permission to call procedures and functions belonging to another schema, and it is those procedures and functions that do the required table access and/or pass information/data back or write to the tables.
The developers have to write their applications to call these procedures to do any access to the tables. This means that they are limited to the functionality provided by these interface procedures so, if there is internal auditing or columns of data etc. on the tables then it may be that they can't access this data, but only the "user facing" data.
The interface can also ensure that data meets certain requirements before being written to tables, allowing for business or technical level restrictions to be implemented. -
Problem copying data between tables
Hello Members,
Its my first day using SQL queries on oracle 10g database.I used the following query to copy selected feilds of a table :
CREATE TABLE SAMPLE_TEMP as (SELECT CUSTOMER, BALANCE FROM CUSTOMER_ALL)
The CUSTOMER_ALL table has over 2 million records. I was successful in creating a table and copying data, but the new table could populate only 52978 records.
---- Sample data in my table
CUSTOMER BALANCE
6.28899273 0
6.28899274 0
6.28899275 0
6.28899289 625.12
6.28899292 2666.24
How do I go about fixing this ? Do i need to declare a structure and assign the number of records i will store to it ? Any guidance will help me get started.
Regards
newbieHello,
If the CUSTOMER_ALL table is a live table, there may have been new records INSERTed since you copied the data, therefore you will have different counts.
To check on the data difference:
SELECT CUSTOMER, BALANCE FROM CUSTOMER_ALL
MINUS
SELECT CUSTOMER, BALANCE FROM SAMPLE_ALL -
I have just completed the process of exporting my companies
main mailing database into a new database file which is setup and
structured differently. I am trying to figure out how to run a
coldfusion query that can update my contact information from one
table into another, tables are as follows:
companies table
companyid | contacttitle1 | contactname1 | contactsurname1 |
contactposition1 | mail1
autonum | text | text | text | text | text
AddxContacts table
id | contacttitle1 | contactname1 | contactsurname1 |
contactposition1 | mail1
number | text | text | text | text | text
i need to update the fields in the first table with the
fields in the second table, the companyid & id from each table
are the primary keys that match up the records, however the
AddxContacts table may contain more than one entry with the same id
no, but i only want to copy one record for each id no.
I have scoured various forums looking for an easy way to do
this but so far have come up blank, any help would be greatly
appriciated. ThanksThere is a major difference between what you say you intend
to do and what your sample code indicates you are attempting to do.
Do not store contact information in your company table. Put
it elsewhere with either a one to many or many to many relationship
set up, depending on your business requirements. -
Comparing two columns in two tables using partial text strings and copying data between tables
I have two tables:
The Vendor table is supplied by a clothing manufacturer and lists product data by row with a column that contains a unique manufacturer ID, such as T5C4. In this table is a short product description and a long product description that I need to find and copy into the second table, Inventory.
The Inventory table is an export from our Magento store. Each row contains a unique inventory number in a column that includes but does not match the unique manufacturer ID from the Vendor table. For example, the unique inventory number could be T5C4-W12, or RED-T5C4W12 or some other variation.
For each product in Inventory, I need to find the matching product in Vendor, and then copy the short description and long description from Vendor to Inventory.
Any tips? Thanks!
KarlKarl,
Here's a start, as you requested.
The formula for Our Inventory Row is:
=IFERROR(MATCH("*"&A&"*", Our Inventory :: A, 0), "n/a")
The formula for Brief Description in the inventory table is:
=IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 2), "n/a")
The formula for the Full description in the inventory table is:
=IFERROR(INDEX(ABC Products :: $A$1:$C$9,MATCH(ROW(), ABC Products :: $D, 0), 3), "n/a")
The Manufacturer's table knows the concise product numbers, so it has the ability to search the Inventory table for it's product id's using wildcards and it then displays the line number of the item in the inventory table. The Inventory table can then search the manufacturer's table for its row number and can reference the brief and full descriptions.
This approach has a serious limitation. It will only find the first occurrence in the inventory. Now, if you want to accept this, you can sort all the found descriptions and pull them out of the inventory table, and then the next product in line will display it's description too.
I wish I could do better with this, but it's all I can come up with at this point, knowing only what you have told me.
Jerry -
Hi, I have 2 tables: l_eket_obj and itab
TYPES: BEGIN OF eket_obj,
werks LIKE ekpo-werks,
matnr LIKE ekpo-matnr,
menge TYPE i,
wemng TYPE i,
objednane TYPE i,
END OF eket_obj.
DATA: l_eket_obj TYPE eket_obj OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF itab OCCURS 0,
werks like ekpo-werks,
matnr LIKE ekpo-matnr,
zamowione type i,
END OF itab.
How to move all data from field l_eket_obj-objednane into field itab-zamowione?
Thanks,
JoannaHEllo
do like this.
loop at l_eket_obj .
read table itab with key werks eq l_eket_obj-werks
matnr eq l_eket_obj-matnr.
if sy-subrc = 0.
itab-zamowione = l_eket_obj-objednane.
modify itab transporting zamowione where werks eq l_eket_obj-werks
matnr eq l_eket_obj-matnr.
endif.
endloop.
Hope this solve ur problem.
Regards,
Vasanth -
Transfering data between tables
I am creating a table to allow the user to enter data. When this is done i am transferring the data from one table and into another so that another program can work on it. This is my code:
for (i= 0; i<n; i++)
for (j=0; j<n; j++)
String obj = (String)matrix.getValueAt(i,j); // Take value out of 1st table
double ni = Double.parseDouble(obj);
table.setValueAt(""+ni,i,j); // Assign it to same location in 2nd table
//System.out.println(ni);
I am getting a nullExceptionError though each time i try this. Can any body see the problem.
ThanksEvery JTable has a table model (whether you created the model or not).
table2.setModel(table1.getModel());
should work. -
Diffrerent data between table and RSA3
Hi all,
I got one prduction order.We filled the setup tables.
Later we changed production order.We deleted and filled the setup tables again.
But in RSA3 Its showing the same dates wht we before.
In tables also its showing changed information.But in RSA3 the old ones we r getting.Krish,
Give a new run and fill the setup tables. This might be due to the validity of given before the run. Check it once.
Maybe you are looking for
-
In smartform address element ?
hi guru's. i am doing purchase order smartform in that address window displaying like this The Post Office Post Office Headquarters 33 Grosveno
-
FIM error "HRESULT: 0x80041618"
Hi, we have some an interesting problem. We have a tasks in the FIM10 to loading data from *.csv or * .xlsm files or from DB. Some users launch task in FIM but it failed with the error: "Failed to invoke service ---> Exception from HRESULT: 0x8004161
-
Flash Player Installer Is Atrocious
Flash Player Installer absolutely sucks! It is without doubt the worst program I have to interact with on a regular basis. First, you have to download the installer. 17 Mb!!! Talk about bloatware! I guess cable modem users might not complain, but
-
I am trying to figure out how to get the pre made "beats" with my garage band for my MacBook Air can u help
-
IDVD menu edges are getting clipped
I have been struggling hard to burn a 70 min DVD (movies + slideshow) to play it on my dvd player. It looks like i have to switch to some other DVD burning software (nero) because of not able to solve the problems: 1. Edges are getting clipped . I ha