Home » SQL & PL/SQL » SQL & PL/SQL » how to determine the data type of a variable (Oracle 10g)
- how to determine the data type of a variable [message #475579] Wed, 15 September 2010 18:27 Go to next message
francismarinus
Messages: 3
Registered: September 2010
Location: United States
Junior Member
Can anyone give me the code to determine the data type of a variable in oracle 10g
- Re: how to determine the data type of a variable [message #475580 is a reply to message #475579] Wed, 15 September 2010 18:29 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>Can anyone give me the code to determine the data type of a variable in oracle 10g
HUH?

It would be helpful if you followed Posting Guidelines - http://www.orafaq.com/forum/t/88153/0/
- Re: how to determine the data type of a variable [message #475582 is a reply to message #475580] Wed, 15 September 2010 19:10 Go to previous messageGo to next message
cookiemonster
Messages: 13967
Registered: September 2008
Location: Rainy Manchester
Senior Member
The type is whatever it's declared as.
So why would you need code to determine that?
- Re: how to determine the data type of a variable [message #475598 is a reply to message #475582] Thu, 16 September 2010 01:23 Go to previous messageGo to next message
Michel Cadot
Messages: 68758
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
There is no code for this, it is not programmatically available.

Regards
Michel
- Re: how to determine the data type of a variable [message #475649 is a reply to message #475579] Thu, 16 September 2010 08:17 Go to previous messageGo to next message
S.Rajaram
Messages: 1027
Registered: October 2006
Location: United Kingdom
Senior Member
I assume you want to find out the datatype of a variable in pl/sql. I really don't know why you want to do that. But this is one way of doing it. It will work only when the variable is not null.

  1  declare
  2  numb number;
  3  character varchar2(100);
  4  text varchar2(100);
  5  begin
  6  numb := 123;
  7  character := 'Hello World';
  8  select dump(numb) into text from dual;
  9  dbms_output.put_line(text);
 10  select dump(character) into text from dual;
 11  dbms_output.put_line(text);
 12* end;
SQL> /
Typ=2 Len=3: 194,2,24
Typ=1 Len=11: 72,101,108,108,111,32,87,111,114,108,100


You have to decipher the Typ=<value>.

Regards

Raj
- Re: how to determine the data type of a variable [message #475677 is a reply to message #475649] Thu, 16 September 2010 10:41 Go to previous message
Michel Cadot
Messages: 68758
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
And if it is a user defined type, the type is always 121, not very useful, in addition it does not work for collection types.

Regards
Michel
Previous Topic: PL/SQL Order By
Next Topic: how to get count on executing a dynamic query?
Goto Forum:
  


Current Time: Thu Jun 12 11:45:11 CDT 2025