简体   繁体   中英

How do I get column datatype in Oracle with PL-SQL

I created an apex application which uses jquery, package, function and procedure to check if aa value in enter in a field can be store in a table.

At the moment It tell you "character too long", "incorrect date", etc but what I want to do now is return the datatype for an example

table: information 
name      datatype
ID        number
info1    varchar2(100)
.
.
.
.

now lets say i type some values that is over 100 characters long. I will get "character too long" which is good but I want to return "varchar2(100)" along with the message.

Is, this possible with pl/sql to return the datatype?

Look at the columns of the user_tab_columns data dictionary view. They have all the data type and length information you need.

with sql your query would look something like: select data_type||'('||data_length||')' from user_tab_columns where table_name = 'MY_TABLE' and column_name = 'MY_COLUMN'

You can put that in your function where you do the rest of your validations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM