Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SCRIPT: FIX ME PLEASEEEE!!!!!!!! :(

Re: SCRIPT: FIX ME PLEASEEEE!!!!!!!! :(

From: James <james_lorenzen_at_allianzlife.com>
Date: Mon, 19 Apr 1999 14:48:25 GMT
Message-ID: <7fffnm$bub$1@nnrp1.dejanews.com>


You need to have a where clause on the update statement. Your SQL is updating all rows in "mytable" for each row found in user_tables.

BTW: You do not need to script this, an update with a subselect will work. I.E. update mytable tm set "num_of_rows"= (select a.num_rows from user_tables a where a.table_name = tm.table_name);

This will update all matches with the num_row column and __NULL__ out the num_of_rows column where there is not a match. NOTE: newly added tables will not be placed on "mytable" automatically.

HTH
    James

In article <3717E73B.B15EE131_at_YAHOO.COM>,   Jonus <Jonus123_at_YAHOO.COM> wrote:
> Hi everyone
> Below is a script that needs attention.
>
> select 'update mytable tm
> set num_of_rows"= (select num_rows from user_tables a
> where table_name = ' ||''''||table_name||''''||'
> and a.table_name =
> '||''''||table_name||''''||'
> and a.'||'table_name'||' = tm.'||'table_name'||')'||';'
> from sys.user_tables;
>
> UNSCRIPTED VERSION on a single table **
>
> update mytable tm
> set "num_of_rows"= (select count(a.num_rows)
> from user_tables a, user_tables b
> where a.table_name = b.table_name
> and a.table_name = 'USER_PROFILE'
> and a.table_name = tm.table_name);
>
> The script works, but it doesn't transfer the num_rows to each table.
> It insteads updates all rows with the same numeric value for every
> table updated. Any
> sugesstions on what I'm doing wrong??????? to get an INDIVIDUAL
> COUNT..
>
> I'm getting this when i should be getting
> this
> XXXX XXX
> ____ _____
> 5 6
> 5 54
> 5 456
> 5 5
> 5 88
> 5 87
> 5 76
> 5 34
> 5 22
> 5 5
>
> Can some help me to fix this.. I tried it using: select
> Count(num_rows) and select num_rows
>
> Jonus
>

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Mon Apr 19 1999 - 09:48:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US