Select to view content in your preferred language

Get maximum text value length of multiple text fields

505
3
10-28-2024 10:52 AM
Bud
by
Esteemed Contributor

ArcGIS Pro 2.9.5; Oracle 18c 10.7.1 EGDB:

I've imported a .CSV to an enterprise geodatabase as a standalone table using the Table to Geodatabase geoprocessing tool.

Unfortunately, the tool has made the text fields way too long: 1073741822 characters, regardless of the max value length in a given field.

Bud_0-1730137593513.png

I've deleted all rows in the table to allow me to change the field lengths using the Fields View. (I'll re-load the data afterwards.) But the question is: What lengths to use? If I could determine what the max value length in all of the fields, then I'd set the max length to, say, 255 for all fields. But I don't know what the max text value length is.

How can I determine the max text value length of multiple fields using ArcGIS Pro?


Import Table — Set text field length to input field's max text value length

0 Kudos
3 Replies
Bud
by
Esteemed Contributor

One option is to use SQL in a SQL client like SQL Developer:

select
    max(length(WONUM)),
    max(length(RECTYPE)),
    max(length(DESCRIPTION)),
    max(length(STATUS)),
    max(length(WO_CLASSIFICATION)),
    max(length(OWNERGROUP)),
    max(length(ASSET_DESCRIPTION)),
    max(length(ASSET_CLASSIFICATION)),
    max(length(LOCATION)),
    max(length(LOCATION_DESCRIPTION)),
    max(length(REPORTDATE)),
    max(length(STATUSDATE)),
    max(length(ACTSTART)),
    max(length(ACTFINISH)),
    max(length(DIVISION)),
    max(length(ASSETNUM)),
    max(length(RECUNIQUEID)),
    max(length(SA_ADDRESSLINE2)),
    max(length(SA_STADDRSTREET)),
    max(length(SA_STADDRNUMBER)),
    max(length(SA_DESCRIPTION)),
    max(length(SA_STREETADDRESS)),
    max(length(SA_FORMATTEDADDRESS)),
    max(length(SA_CODE)),
    max(length(XYSOURCE)),
    max(length(SUBZONE))
from
    infrastr.a_test_tbl

Bud_0-1730138206408.png

It would be ideal if I could pivot using Oracle SQL and then ORDER BY to find the max. I'm aware of the PIVOT clause in Oracle SQL, but I'm not sure how to use it for this.

0 Kudos
Bud
by
Esteemed Contributor

Unfortunately, changing the field lengths in the empty table using the Fields View didn't work:

"ERROR 001624: Failed to alter field length."

Bud_0-1730140290714.png

 

0 Kudos
Bud
by
Esteemed Contributor

I think the problem is the underlying Oracle field type is NCLOB.

Bud_1-1730140755531.png

That's unusual for Oracle enterprise geodatabase tables. The underlying text datatype is usually NVARCHAR2.

With that said, I think I found a fix:

In ArcGIS Pro > Fields View, change the field data type in the empty table from TEXT to SHORT INT. Save. Then change it back to TEXT. Save. The underlying datatype is now NVARCHAR2(255 CHAR). 

 

0 Kudos