473,411 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

PL/SQL code

Hi,

I have a piece of code (attached bellow) that grabs the names of
several tables in my schema. I now want to grab a maximum value of one
of the columns from these tables (same column name in all the tables).
Is there any way other then spooling the output (as shown below) into
a file and running that file?

As you can see from the code I'm a beginner at this so any help will
be much appreciated.

Thanks,
Doron



Declare

CURSOR SITE_BASE_CUR IS select tdm_base_obj_id from tdm_db_site_ranges
where object_id = (select object_id from tdm_db_site where tdm_name =
(select global_name from
global_name));

site_base tdm_db_site_ranges.tdm_base_obj_id%type ;

cursor up_tab is select table_name from tdm_class where class_id in
(select class_id from tdm_last_object_id where object_id>0);

update_table tdm_class.table_name%type ;

begin
open site_base_cur;
fetch site_base_cur into site_base;

open up_tab;
loop
fetch up_tab into update_table;
exit when up_tab%notfound;
dbms_output.put_line(‘select max(column_1) from' update_table);
end loop;
end ;
Jul 19 '05 #1
2 5381
you probably want to use dynamic SQL -- check out EXECUTE IMMEDIATE in the
PL/SQL docs

++ mcs

"Doron" <do*********@msn.com> wrote in message
news:99**************************@posting.google.c om...
| Hi,
|
| I have a piece of code (attached bellow) that grabs the names of
| several tables in my schema. I now want to grab a maximum value of one
| of the columns from these tables (same column name in all the tables).
| Is there any way other then spooling the output (as shown below) into
| a file and running that file?
|
| As you can see from the code I'm a beginner at this so any help will
| be much appreciated.
|
| Thanks,
| Doron
|
|
|
|
|
|
|
| Declare
|
| CURSOR SITE_BASE_CUR IS select tdm_base_obj_id from tdm_db_site_ranges
| where object_id = (select object_id from tdm_db_site where tdm_name =
| (select global_name from
| global_name));
|
| site_base tdm_db_site_ranges.tdm_base_obj_id%type ;
|
| cursor up_tab is select table_name from tdm_class where class_id in
| (select class_id from tdm_last_object_id where object_id>0);
|
| update_table tdm_class.table_name%type ;
|
|
|
|
|
| begin
|
|
| open site_base_cur;
| fetch site_base_cur into site_base;
|
| open up_tab;
| loop
| fetch up_tab into update_table;
|
|
| exit when up_tab%notfound;
| dbms_output.put_line('select max(column_1) from' update_table);
| end loop;
| end ;
Jul 19 '05 #2
Hi Doron,

You can use dynamic sql. It will let you build the sql statement and
execute it.
The following link has good examples.

http://www.cise.ufl.edu/help/databas...ynam.htm#13131

Padma
do*********@msn.com (Doron) wrote in message hnews:<99**************************@posting.google .com>...
Hi,

I have a piece of code (attached bellow) that grabs the names of
several tables in my schema. I now want to grab a maximum value of one
of the columns from these tables (same column name in all the tables).
Is there any way other then spooling the output (as shown below) into
a file and running that file?

As you can see from the code I'm a beginner at this so any help will
be much appreciated.

Thanks,
Doron



Declare

CURSOR SITE_BASE_CUR IS select tdm_base_obj_id from tdm_db_site_ranges
where object_id = (select object_id from tdm_db_site where tdm_name =
(select global_name from
global_name));

site_base tdm_db_site_ranges.tdm_base_obj_id%type ;

cursor up_tab is select table_name from tdm_class where class_id in
(select class_id from tdm_last_object_id where object_id>0);

update_table tdm_class.table_name%type ;

begin
open site_base_cur;
fetch site_base_cur into site_base;

open up_tab;
loop
fetch up_tab into update_table;
exit when up_tab%notfound;
dbms_output.put_line(?select max(column_1) from' update_table);
end loop;
end ;

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
4
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
109
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
5
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
18
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
37
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.