SunQuest
           ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 27th, 2004, 05:04 PM
casuzen casuzen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 casuzen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 45 sec
Reputation Power: 0
How to get size of field from metadata?

I am trying to get the size of a field from a getMetaData call...
If you dump getMetaData, it says it has a method called
getColumnDisplaySize...

here is what I am doing...

gettable is a cfquery... a simple "select * from tablename"
where tablename is a table in my Oracle database....

<cfset md = gettable.getMetaData()>
<cfset fieldsize = 0>
<cfset numCols = md.getColumnCount()>
<!--- For each column in the query --->
<cfloop from="1" to="#numCols#" index="i">
<cfset fieldname = md.getColumnName(javaCast("int", i))>
<cfset fieldsize = md.getColumnDisplaySize(javaCast("int", i))>
<cfdump var="#fieldname#">
<cfdump var="#fieldsize#">
</cfloop>

it errors on the getColumDisplaySize...
error is
getColumnDisplaySize()


The error occurred in ###show_table.cfm: line 89
Called from ###show_table.cfm: line 24
Called from ###show_table.cfm: line 1

87 : <cfloop from="1" to="#numCols#" index="i">
88 : <cfset fieldname = md.getColumnName(javaCast("int", i))>
89 : <cfset fieldsize = md.getColumnDisplaySize(javaCast("int", i))>
90 : <cfdump var="#fieldname#">
91 : <cfdump var="#fieldsize#">


If I comment out the line with the getColumnDisplaySize, I get the dump for fieldname, with the correct values...


Anyway...what am I doing wrong with calling this method?
Is there a better way to find the size of a field???

TIA,
--Suze

Reply With Quote
  #2  
Old September 27th, 2004, 06:48 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
It's probably a private method so you can't call it from outside the object. I think you'll need to find another way to determine the column size.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old September 28th, 2004, 01:02 PM
casuzen casuzen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 2 casuzen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 45 sec
Reputation Power: 0
just to tie this back up in case someone else is looking to do the same thing....

I ended up using a query against the ALL_TAB_COLUMNS system table in Oracle to find the column size...

SELECT DATA_LENGTH
FROM ALL_TAB_COLUMNS
WHERE TABLE_NAME = 'TABNAME'
AND COLUMN_NAME = 'COLNAME'
AND ROWNUM = 1;

Reply With Quote
  #4  
Old September 28th, 2004, 02:36 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
That's what the system tables are for!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > How to get size of field from metadata?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway