This is a discussion on 2 scripts in one, possible??? within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hi update table1 r set (c1, c2, c3, c4, c5, c6, c7)= ( SELECT c1, c2, c3, c4, c5, ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi update table1 r set (c1, c2, c3, c4, c5, c6, c7)= ( SELECT c1, c2, c3, c4, c5, c6, c7 from table2 i where i.c8 =c8) I´m doing an insert first to load the pk (c8) into table1 (that is the pk for table1). table2 has not pk so there are many c8. I was wondering if is possible to do both scripts in one go? Thanks in advance ... A |
| |||
| "valigula" <valigula@gmail.com> a écrit dans le message de news: 1178548090.183737.13880@e51g2000hsg.googlegroups.c om... Hi update table1 r set (c1, c2, c3, c4, c5, c6, c7)= ( SELECT c1, c2, c3, c4, c5, c6, c7 from table2 i where i.c8 =c8) I´m doing an insert first to load the pk (c8) into table1 (that is the pk for table1). table2 has not pk so there are many c8. I was wondering if is possible to do both scripts in one go? Thanks in advance ... A ------------------------------ Use MERGE. Regards Michel Cadot |
| |||
| valigula wrote: > Hi > > > update table1 r set > (c1, c2, c3, c4, > c5, c6, c7)= > ( SELECT c1, c2, c3, c4, > c5, c6, c7 > from table2 i > where i.c8 =c8) > > I´m doing an insert first to load the pk (c8) into table1 (that is the > pk for table1). > table2 has not pk so there are many c8. > I was wondering if is possible to do both scripts in one go? > > Thanks in advance ... > > A No version and no idea what you are actually doing but look at the MERGE command. www.psoug.org click on Morgan's Library Scroll down to MERGE -- Daniel A. Morgan University of Washington damorgan@x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Group www.psoug.org |
| ||||
| On 7 Mai, 16:28, valigula <valig...@gmail.com> wrote: > Hi > > update table1 r set > (c1, c2, c3, c4, > c5, c6, c7)= > ( SELECT c1, c2, c3, c4, > c5, c6, c7 > from table2 i > where i.c8 =c8) > > I´m doing an insert first to load the pk (c8) into table1 (that is the > pk for table1). > table2 has not pk so there are many c8. > I was wondering if is possible to do both scripts in one go? I don't understand what you are trying to do and I daresay others fail to understand as well. Just in case your actual question hasn't been answered yet, please elaborate: What is the relation between tabele1 and table2? Why does table2 have no pk? Why, if there are many records of table2 matching one record of table1, is there no aggregation in your select (say max, min, sum or whatever)? |