473,672 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get min_value, max_value from Table_Name/Column_Name in a table

1 New Member
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 2260

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

Similar topics

3
13554
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 and code snippets found here. It was a pain to work out so I've decided to share my work and research here. This post is just my way of saying thanks to several others here for posting with their wisdom and intelligence.
4
2591
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 looks at that field in that table and if it is not indexed, indexes it, and if it is indexed, jumps to a label. I have a query called "qryAddIndex" that will index the field, what I really need is the vba to test if the field is indexed or not. ...
7
5085
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 bigger the performance hit VBA takes. I'm wondering how to prevent or reduce this. Details: I have a database table of queries I want to run. This table contains the query name, the SQL text of the query, the name of the target table, and whether...
0
930
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 "finalize" the SQL statement I just executed? Thank you Chris Dim cn As New ADODB.Connection cn.Open("Driver={SQL Server};Server=SQLSERVER;Database=BIGDB;Trusted Connection=yes") cn.CommandTimeout = 600 cn.Execute("IF EXISTS (SELECT...
9
6369
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
2857
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 ...........( the table which recently failed loading) load from cur for cursor terminate into tablename ( the table which failed loading )
3
1266
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
3896
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 pages the table will spread over is dyanmically decided, <html> <head> <style> tHead {
0
1482
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, also import and saveTable function, any idea what is wrong, why I get error?. thanks in advance. system.sql file ========== CREATE TABLE eventLog ( component text NOT NULL,
0
1352
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 TEST_BUILDINGCODE_PROC (IN v_AppId_Ver INTEGER) BEGIN DECLARE v_ObjId,v_LayerName,v_TableName,v_ColumnName varchar(30); DECLARE v_CodeNo,v_DataCount integer; DECLARE v_Statement,v_Schema,v_Counter varchar(200); DECLARE v_stmt STATEMENT;
0
8486
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8406
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8609
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8683
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6240
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5707
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1819
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.