Re: How to update a table with another table

From: shakespeare <whatsin_at_xs4all.nl>
Date: Wed, 23 Jan 2008 10:47:18 +0100
Message-ID: <47970d2c$0$85791$e4fe514c@news.xs4all.nl>

"nick048" <nicosia.gaetano_at_moonsoft.it> schreef in bericht news:58c09989-2361-41e1-9db9-dee2dd6cc99c_at_z17g2000hsg.googlegroups.com...
> Hi to All,
>
> I have in my 'schema' 2 tables:
>
> CREATE TABLE T_ITEMS
> (
> ITEM_GROUP VARCHAR2(10 BYTE) NOT NULL,
> ITEM_CODE VARCHAR2(25 BYTE) NOT NULL,
> ITEM_DESCRIPTION VARCHAR2(40 BYTE) NOT NULL,
> ITEM_QTA NUMBER(16,4),
> ITEM_PRICE NUMBER(18,5)
> )
> TABLESPACE DOM8DATI
> PCTUSED 0
> PCTFREE 10
> INITRANS 1
> MAXTRANS 255
> STORAGE (
> INITIAL 2M
> MINEXTENTS 1
> MAXEXTENTS 2147483645
> PCTINCREASE 0
> BUFFER_POOL DEFAULT
> )
> LOGGING
> NOCOMPRESS
> NOCACHE
> NOPARALLEL
> MONITORING;
>
> CREATE TABLE T_PRICES
> (
> ITEM_GROUP VARCHAR2(10 BYTE) NOT NULL,
> ITEM_CODE VARCHAR2(25 BYTE) NOT NULL,
> ITEM_PRICE NUMBER(18,5)
> )
> TABLESPACE DOM8DATI
> PCTUSED 0
> PCTFREE 10
> INITRANS 1
> MAXTRANS 255
> STORAGE (
> INITIAL 2M
> MINEXTENTS 1
> MAXEXTENTS 2147483645
> PCTINCREASE 0
> BUFFER_POOL DEFAULT
> )
> LOGGING
> NOCOMPRESS
> NOCACHE
> NOPARALLEL
> MONITORING;
>
> I need to create a script that for each record in T_ITEMS, read if
> exist the code (ITEM_GROUP,ITEM_CODE) in T_PRICES and update
> ITEM_PRICE in T_ITEMS.
>
> Can anyone help me?
>
> Thank You and Best Regards
> Gaetano

You don't need a script, only one sql statement (update t_items set price = select .. from t_prices where.. ), and this smells like homework. And you should normalize your model.

Shakespeare Received on Wed Jan 23 2008 - 03:47:18 CST

Original text of this message