Unix Technical Forum

2 scripts in one, possible???

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, ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 11:42 AM
valigula
 
Posts: n/a
Default 2 scripts in one, possible???

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 11:42 AM
Michel Cadot
 
Posts: n/a
Default Re: 2 scripts in one, possible???


"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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 11:42 AM
DA Morgan
 
Posts: n/a
Default Re: 2 scripts in one, possible???

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2008, 11:42 AM
Thorsten Kettner
 
Posts: n/a
Default Re: 2 scripts in one, possible???

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)?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:31 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com