473,396 Members | 1,827 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,396 software developers and data experts.

get min_value, max_value from Table_Name/Column_Name in a table

I try to get Minimum and Maximum Values for columns/tables with names are in a table. Table name is CAMPOS_DATE and TABLE_NAME, COLUMN_NAME have table and column names.
I try to get MIN and MAX values for columns and I have created next procesure
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PROCEDURE "NA_PRC_MIN_MAX_DATES_CHM" IS
  2.  
  3.     -- ------------------------------------------------------------------ --
  4.     -- Cursores                                                           --
  5.     -- ------------------------------------------------------------------ --
  6.  
  7.  
  8.     CURSOR cColumnas IS
  9.     SELECT 
  10.         TABLE_NAME,
  11.         COLUMN_NAME
  12.     FROM CAMPOS_DATE;
  13.     -- ------------------------------------------------------------------ --
  14.     -- Variables                                                          --
  15.     -- ------------------------------------------------------------------ --
  16.     vdMinValue      DATE;
  17.     vdMaxValue      DATE;
  18.  
  19. BEGIN
  20.  
  21.   FOR rcCol IN cColumnas LOOP
  22.  
  23.     vdMinValue := NULL;
  24.     vdMaxValue := NULL;
  25.     SELECT MIN(rcCol.COLUMN_NAME), max(rcCol.COLUM_NAME)
  26.     INTO vdMinValue, vdMaxValue
  27.     FROM rcCol.TABLE_NAME;
  28.  
  29.     UPDATE CAMPOS_DATE
  30.     SET MIN_VALUE = vdMinValue,
  31.         MAX_VALUE = vdMaxValue
  32.     WHERE TABLE_NAME = rcCol.TABLE_NAME
  33.     AND COLUMN_NAME = rcCol.COLUMN_NAME;
  34.  
  35.     COMMIT;
  36.  
  37.   END LOOP;
  38.  
  39. EXCEPTION
  40.     WHEN OTHERS THEN
  41.       ROLLBACK;
  42. END;
  43. /
  44.  
It doesn´t work. What am I doing wrong?

Thanks in advance
May 14 '15 #1
0 2240

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: M Simpson | last post by:
/* for the google index */ ALTER TABLE DEFAULT COLUMN DEFAULT VALUE I've worked out several stored procedures for altering the default column values in a table. They were compiled from books...
4
by: dixie | last post by:
I have a table called "tblParticipants" with a field called "ID", which must be indexed with No duplicates allowed. I am looking for a way of doing in vba a small if ..then ..else .. routine that...
7
by: rednexgfx_k | last post by:
All, Problem Summary: I've running about 30 make table queries via VBA in Access 2000, and my database goes from 14,000k to over 2,000,000k. In addition, the longer the procedure runs, the...
0
by: Chris Blue | last post by:
When I am debugging this code and I step through it, after I run through to the cn.Close() statement, the table TABLENAME should be dropped...but it is not. Is there some other command I must run to...
9
by: Mike | last post by:
Hi, How can I pls get the maxvalue and the minvalue in a specific colunm in a dataset or datareader. thanks -- Regads, Rochdi
1
by: technocrat | last post by:
I wanted to know if i always have to use 1..load from /dev/null/ of del terminate into tablename nonrecoverable or can i do something like 2...declare cur cursor for select * from tablename...
3
by: smitashirole | last post by:
can we create table with tablename as TABLE eg. create table TABLE(no int ,name varchar(20)); like this.
2
by: Albin | last post by:
Hi, I have a html page where in the table spans for two pages the first page's last row doesn end properly and the 2nd page's first row also isnt proper.The code i use is given below,the no of...
0
by: tvnaidu | last post by:
database file gets created using below sql file, then lua script calls "db.import config_ascc", then I get errors says "insert table failed for eventLog", below are my sql file entry, config file,...
0
by: KarthikaKKD | last post by:
Im passing table name & column name which im selecting from cursor.But its inserting correctly and also showing error like cursor is not open . my proc is as: CREATE OR REPLACE PROCEDURE...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.