|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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; |
|
#4
|
|||
|
|||
|
That's what the system tables are for!
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > How to get size of field from metadata? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|