Best way to insert two simultaneous tables.

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
  

Poston Tue, 10 Jul 2007 11:05 am

Personnel through a Java application I need to insert into two tables with the following structure: the Table without an ID field as PK and table B has a field ID as FK of the table, my main question is that the ID number must be the same for each row of both tables and how this application will run on various points I had doubts about the insert to not occur a line referencing the ID the other between the tables.
pyro
Location: Barala - TT

Poston Wed, 11 Jul 2007 12:24 am

Creates a procedure to do this for you brother!!
Places the OutPuts to the Java and já was ...
LoadingXp
Location: SP

Att.

Luciano Alvarenga M. Pires
DBA ORACLE CERTIFICADO
http://fulloracle.blogspot.com
------------------------------------
Dinheiro é o combustivel da sociedade industrial. Mas na sociedade da informática o combustivel, o poder, é o conhecimento.

Poston Wed, 11 Jul 2007 8:23 am

Otherwise, the value is the same for both: 1 Table-> sequence with NEXTVAL;
Table 2-> sequence with CURRVAL;

I believe that também kills the doubt.

qualquer thing, says ai.
Trevisolli
Location: Araraquara - SP

Abraço,

Trevisolli
OCA Oracle PL/SQL Developer Certified Associate
OCP Oracle Forms Developer Certified Professional
Araraquara-SP

Poston Thu, 19 Jul 2007 5:20 pm

Hello pyro, you can use a multiple insert:
Code: Select all
INSERT ALL
     INTO sal_history
     VALUES (empid, hiredate, sal)
     INTO dept_history
     VALUES (empid, deptid, hiredate)
SELECT employee_id empid, hire_date hiredate, salary sal, department_id deptid
FROM employees
WHERE employee_id > 40;
does this help?

Abs.
fabricio.silva
Location: Catanduva/SP

Fabricio M. Silva
Oracle Certified Associate
------------------------------
Catanduva - SP

Poston Fri, 20 Jul 2007 8:04 am

Vlw guys now running beauty.
pyro
Location: Barala - TT


  • See also
    Replies
    Views
    Last Post


Return to SQL

Who is online

Users browsing this forum: No registered users and 2 guests