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: Ed Prochak <prochak_at_my-dejanews.com>
Date: Mon, 19 Apr 1999 14:29:14 GMT
Message-ID: <7ffeje$arf$1@nnrp1.dejanews.com>

You may find it easiest to perform operations like this using PL/SQL. You'll need to read about using CURSORs in PL/SQL to solve this. But you can solve it in SQL. Your problem is the UPDATE.

If you do not want to update all the rows in the table, then you will need a WHERE clause in your UPDATE statement.

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
>

--
Ed Prochak
Magic Interface, Ltd.
ORACLE services
440-498-3702

-----------== 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:29:14 CDT

Original text of this message

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