Determine data type

Hi all,
I've got procedure for inserting data into value1 column of table1.
My need is to determine data type entered by user.
If data type is not number then user should receive error.
How do I perform it?

The easiest and most reliable way would be to declare the formal parameter as a number like:
SQL> create procedure p (p_num in number) as
  2  begin
  3     null;
  4  end;
  5  /
Procedure created.
SQL> exec p('a');
BEGIN p('a'); END;
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at line 1If you cannot do that, or want to be more "user friendly", then the only alternative is to test it and raise an error like:
SQL> create procedure p (p_str in varchar2) is
  2     l_num number;
  3  begin
  4     l_num := to_number(p_str);
  5  exception
  6     when value_error then
  7        raise_application_error(-20001, 'I know I said it was a string, but I really want a number');
  8  end;
  9  /
Procedure created.
SQL> exec p('a');
BEGIN p('a'); END;
ERROR at line 1:
ORA-20001: I know I said it was a string, but I really want a number
ORA-06512: at "OPS$ORACLE.P", line 7
ORA-06512: at line 1John

Similar Messages

  • Need to determine data type of free characteristic in multiprovider

    Hi,
    I need to determine the data type (e.g. numeric vs alpha numberic) of a free characteristic in a multiprovider.  Can this be accomplished in BEx Query Designer? 
    If not, can it be accomplished in RSA1?  How?
    Thanks,
    Kevin

    its not possible via Query designer..
    give that object name if it is infoobject then you can get via RSD1

  • Determining data type of existing column in table

    Hi
    I've done some googling on this, and I know I've done it before, but i cant find/remember how to determine the data type of a column in an existing table..... i tried select dump(column_name) from table but it didnt work.
    any suggestions?
    Thanks in advance

    Hi try this
    SQL> select data_type from user_tab_columns
      2  where COLUMN_NAME='EMPNO'
      3  and table_name='EMP';
    DATA_TYPE
    NUMBER

  • Determine data type of string field

    I am trying to determine the data type of input strings in a data flow task.  For each column in the input (all of which are strings) I want to sample X number of records, try to cast them as money, date, boolean, etc and if 100% of X records pass then
    use the first data type that passes the test.  I looked into row sample but this doesn't appear to be the right data flow task.  Can anyone point me in the right direction?
    Thanks!

    You have two tasks:  find the datatype by looking at X rows; cast all rows to the popular datatype.
    What I use is the TryParse method that occurs on several datatypes in .Net (http://msdn.microsoft.com/en-us/library/f02979c7(v=vs.110).aspx).  It returns true if it parses
    and false if it doesn't.  I have used this in a profiling package that reads a CSV and stores counts of values that can be converted to different datatypes.
    The second piece is trickier.  If you can afford, I would add a second dataflow.  The first dataflow looks at a sample of the data and determines the datatype. You assign that to a variable.  Then the second one has a derived column that has
    a set of derived columns, each with a formula like this:
    @DataType == "Int"?(DT_I4)[Column]:NULL(DT_I4)
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • How to determine data type of cell in Excel file

    I have a company standard Excel file that needs to be read to determine what tests to run.  I have no control over its format.  I need to be able to tell what the data type is in order to read it using the LabView sample code.  It is a hodge poge of numbers and strings.  Some of the numeric fields are formated as hex while some are floating point.  There does not appear to be a vi that I can call to determine info about the cell formating.  As I remember it, the Windows Active X control for accessing Excel support that.  I really was hoping to avoid dealing with the Active X control for Excel directly.
    Any help/ideas?
    Outputting it in CSV or similar is not an option.
    Solved!
    Go to Solution.

    If you have to deal with Excel directly, I don't see how you're going to get around using Active X.
    MSDN page on using ActiveX

  • How do determine data type?

     I am trying to write my own binary file saver and I need to list the data type in the custom header. How do you do this in labview?

    kameronrausch wrote:
    The data acquistion spits out data in several different formats so a priori, I do not know the data type. It can be either a 32-unsigned int, 16-bit unsigned int, 8-bit unsigned int or the signed version of each one of these. To make the program general purpose however, I would like to incorporate floating point data points as well.
    At some point you have to know what the data type is before start collecting data. If all you have is a stream of bits there is no way to determine what the data type is. What controls how the data acquistion is getting its data? If it is test specific you could use an external configuration file to store this and use that to determine how the data should be interpreted. If you have arrays of specificdata types you could use a polymorphic VI for your data writes. Based on teh wire type of the input the appropriate VI would be called. How is your data being passed from your data acquistion to the VI that will write it to a file?
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • How to determine the data type of  a text field

    hi,
    I have a text field, now i need to know what data type i have given?
    it may be numerical, string, date & boolean data type. when i write something after that it will determine the data type of the input text? is it possible in jsp? Is there anyone who can help me about this? Please help me
    With regards
    Bina

    javascript:
    function test(sample){
          if(sample==true || sample==false){
           alert('boolean')
          }else if(isNaN(sample)){
           alert('number')
          }else{
          alert('string')
        }

  • How Oracle JDBC driver determine DATE data type parameter if it is not specified

    Hello,
    Oracle JDBC driver determine the DATE data type of parameter correctly without any typecasting.
    Example:
    ps = conn.prepareStatement("SELECT ? FROM DUAL");
    ps.setObject(1, Date.valueOf("2014-01-11"));
    How Oracle JDBC driver determine the DATE data type of parameter.
    Thought?
    Regards,
    Vinayak

    Oracle JDBC driver determine the DATE data type of parameter correctly without any typecasting.
    Example:
    ps = conn.prepareStatement("SELECT ? FROM DUAL");
    ps.setObject(1, Date.valueOf("2014-01-11"));
    How Oracle JDBC driver determine the DATE data type of parameter.
    Your question isn't clear. If the driver is doing it correctly what PROBLEM are you having? What exactly do you consider 'correct'? What results are you getting? What driver name and version are  you using? What Oracle DB version are you using?
    For the code you use above the 'Date' you specify is a java.sql.Date instance
    http://docs.oracle.com/javase/8/docs/api/java/sql/Date.html#valueOf-java.lang.String-
    public static Date valueOf(String s)
    Converts a string in JDBC date escape format to a Date value.
    Parameters:
    s - a String object representing a date in in the format "yyyy-[m]m-[d]d". The leading zero for mm and dd may also be omitted.
    Returns:
    a java.sql.Date object representing the given date
    The JDBC Dev Guide shows that is mapped to an oracle.sql.DATE
    http://docs.oracle.com/cd/E11882_01/java.112/e16548/datacc.htm#g1028145
    Oracle DATE datatypes have both date and time components. Depending on the JDBC driver version and DB version you are using an Oracle date could be mapped to a Java Date (which does NOT have a time component) or, for current versions, would be considered a timestamp..

  • Determining the data type of the list item

    Hi experts,
    i have a dpop down list item in my form and from it i want
    to select some of the columns of emp table like mobile_number or address
    and send the selected field,along with name and empno to reports.
    But when i am trying to determine the data type of the selected
    item i am faceing some difficulties.
    i am trying this
    param := emp.:emp.LIST10%type;
    can you please help me.
    Regards
    rajat

    param := emp.:emp.LIST10%type;I'm not quit sure what you are trying to achieve with this.
    If have build a poplist as a block-item you know the datatype of that item. When you know want to create a local variable to take the value from that list, either define it just with the datatype taken from the item, or take it dynamically from the column from the database the item is based on, so
    DECLARE
      -- explicit
      vcParam  VARCHAR2(50);
      -- takeing datatype from db-column
      vcParam  TABLENAME.COLUMNNAME%TYPE;
    BEGIN
      -- Assignment
      vcParam:=:EMP.LIST10;
    END;

  • How do you determine a column's data type?

    Let's say I have a DB Table out there and I have NO WAY of knowing that column 1 is a CHAR, column 2 is a SMALLINT or whatever. I can write sql to select * from table and see everything, but how do I know what each column's data type is?

    I found it. Thanks, and for any other people who need the solution, here is what I found on another thread:
    int type;               try {                    type = i_metaData.getColumnType(column+1);               }               catch (SQLException e) {                    return super.getColumnClass(column);               } switch(type) {               case Types.CHAR:               case Types.VARCHAR:               case Types.LONGVARCHAR:                    return String.class;               case Types.BIT:                    return Boolean.class;               case Types.TINYINT:               case Types.SMALLINT:               case Types.INTEGER:                    return Integer.class;               case Types.BIGINT:                    return Long.class;               case Types.FLOAT:               case Types.DOUBLE:                    return Double.class;               case Types.DATE:                    return java.sql.Date.class;               case Types.TIMESTAMP: //Date Time                    return java.sql.Date.class;               case Types.DECIMAL: // Currency,Decimal                    return Float.class;               default:                    return Object.class;        } }

  • Data type determined at run time, how to provide the input type in advance

    Hi all,
    Here I have a requirement:
    on my UI, there is an inputfield which receives user's input. But the data type can't be known at design time.
    But I need to bind a context attribute to the inputfield first at design time, which data type should I use( the inputfield can recevie
    data of any type ) ?
    and how to convert the this data type into different data type( can be any type )?

    Hello Aaron,
    There can be a workaround for your requirement.
    you can assign a char data type to that field since Char can accept all characters, numbers, special symbols.
    But, you need to do validations later on the see if it is a number or all alphabets and accordingly you can assign that field to any data type  by doing little bit of manipulations.
    Hope this helps.
    Regards,
    Anand

  • Date type automatically determined when status="Closed"

    Hello Experts,
    We are using CRM 2007 Interaction Center Web Client and I would like to know how I can achieve the following:
    We need that an specific Date Type should be filled with the date and time of the moment in which the user set the status of the Service Order to "Closed" and Save the S.Order
    I hope you can help me on that.
    Many thanks in advance,
    Pablo
    Points awarded to a good answer!

    HI
      Please create the event handler function(for status change)..i.e for example zcustom_status_fm
    The function should perform the following steps and be configured in the CRMV_EVENT transaction in the option OBJECT FUNCTION/CALL BACK    for the object STATUS.
    in the above step first column entry is custom FM name and second entry is status
    Then it should be configured in the view CRMV_EVENT_CUST with the following key as Custom FM ..pls see columns and enter appropriate data there..
    after that when ever you change the status for service process it will trigger custom FM..there
    read the current dates by using CRM_DATES_READ_SINGLE_OW
    and set the current/required dates to data types by using FM 'CRM_APPT_MAINTAIN_SINGLE_OW' ...
    i Hope it will solve your problem definitely..because same req we done in our project
    Edited by: Ram Pushpala on Sep 15, 2009 1:31 PM

  • Difference b/w DATA TYPE and DATA OBJECT & differences b/w TYPE and LIKE

    hai
    can any one say the differences between Data type and Data Object.
    And also differences between TYPE and LIKE
    thanks
    Gani

    hi,
    _Data Types and Data Objects_
          Programs work with local program data – that is, with byte sequences in the working memory. Byte sequences that belong together are called fields and are characterized by a length, an identity (name), and – as a further attribute – by a data type. All programming languages have a concept that describes how the contents of a field are interpreted according to the data type.
          In the ABAP type concept, fields are called data objects. Each data object is thus an instance of an abstract data type. There are separate name spaces for data objects and data types. This means that a name can be the name of a data object as well as the name of a data type simultaneously.
    Data Types
       As well as occurring as attributes of a data object, data types can also be defined independently. You can then use them later on in conjunction with a data object. The definition of a user-defined data type is based on a set of predefined elementary data types. You can define data types either locally in the declaration part of a program using the TYPESstatement) or globally in the ABAP Dictionary. You can use your own data types to declare data objects or to check the types of parameters in generic operations.
         All programming languages distinguish between various types of data with various uses, such as ….. type data for storing or displaying values and numerical data for calculations. The attributes in question are described using data types. You can define, for example, how data is stored in the repository, and how the ABAP statements work with the data.
    Data types can be divided into elementary, reference, and complex types.
    a. Elementary Types
    These are data types of fixed or variable length that are not made up of other types.
    The difference between variable length data types and fixed length data types is that the length and the memory space required by data objects of variable length data types can change dynamically during runtime, and that these data types cannot be defined irreversibly while the data object is being declared.
    Predefined and User-Defined Elementary Data Types
    You can also define your own elementary data types in ABAP using the TYPES statement. You base these on the predefined data types. This determines all of the technical attributes of the new data type. For example, you could define a data type P_2 with two decimal places, based on the predefined data type P. You could then use this new type in your data declarations.
    b.  Reference Types
    Reference types are deep data types that describe reference variables, that is, data objects that contain references. A reference variable can be defined as a component of a complex data object such as a structure or internal table as well as a single field.
    c. Complex Data Types
    Complex data types are made up of other data types. A distinction is made here between structured types and table types.
    Data Objects
          Data objects are the physical units with which ABAP statements work at runtime. The contents of a data object occupy memory space in the program. ABAP statements access these contents by addressing the name of the data object and interpret them according to the data type.. For example, statements can write the contents of data objects in lists or in the database, they can pass them to and receive them from routines, they can change them by assigning new values, and they can compare them in logical expressions.
           Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running (field length, number of decimal places, and data type). You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures). As well as fields in the memory area of the program, the program also treats literals like data objects.
            A data object is a part of the repository whose content can be addressed and interpreted by the program. All data objects must be declared in the ABAP program and are not persistent, meaning that they only exist while the program is being executed. Before you can process persistent data (such as data from a database table or from a sequential file), you must read it into data objects first. Conversely, if you want to retain the contents of a data object beyond the end of the program, you must save it in a persistent form.
    Declaring Data Objects
          Apart from the interface parameters of procedures, you declare all of the data objects in an ABAP program or procedure in its declaration part. These declarative statements establish the data type of the object, along with any missing technical attributes. This takes place before the program is actually executed. The technical attributes can then be queried while the program is running.
         The interface parameters of procedures are generated as local data objects, but only when the procedure is actually called. You can define the technical attributes of the interface parameters in the procedure itself. If you do not, they adopt the attributes of the parameters from which they receive their values.
    ABAP contains the following kinds of data objects:
    a.  Literals
    Literals are not created by declarative statements. Instead, they exist in the program source code. Like all data objects, they have fixed technical attributes (field length, number of decimal places, data type), but no name. They are therefore referred to as unnamed data objects.
    b.  Named Data Objects
    Data objects that have a name that you can use to address the ABAP program are known as named objects. These can be objects of various types, including text symbols, variables and constants.
    Text symbols are pointers to texts in the text pool of the ABAP program. When the program starts, the corresponding data objects are generated from the texts stored in the text pool. They can be addressed using the name of the text symbol.
    Variables are data objects whose contents can be changed using ABAP statements. You declare variables using the DATA, CLASS-DATA, STATICS, PARAMETERS, SELECT-OPTIONS, and RANGESstatements.
    Constants are data objects whose contents cannot be changed. You declare constants using the CONSTANTSstatement.
    c.  Anonymous Data  Objects
    Data objects that cannot be addressed using a name are known as anonymous data objects. They are created using the CREATE DATAstatement and can be addressed using reference variables.
    d.  System-Defined Data Objects
    System-defined data objects do not have to be declared explicitly - they are always available at runtime.
    e.  Interface Work Areas
    Interface work areas are special variables that serve as interfaces between programs, screens, and logical databases. You declare interface work areas using the TABLES and NODESstatements.
    What is the difference between Type and Like?
    Answer1:
    TYPE, you assign datatype directly to the data object while declaring.
    LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.
    Answer2:
    Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.
    Answer3:
    type refers the existing data type
    like refers the existing data object
    reward if useful
    thanks and regards
    suma sailaja pvn

  • How can I read the data type of a field in an MS Access database

    I need to be able to determine if a field in an Access database is of a certain data type, and if it isn't, to change it to what it should be.
    I can't seem to find any way of reading the data type of any field in any table - can anyone give me a metod of getting this info?
    Thanks
    ..Bob

    Does <cfdbinfo> work for Access DBs?
    You might be better off asking this on a MS Access forum.  It's more of an Access issue than a CF one.
    Adam

  • Data type p

    hi all,
    i have defined a field as data type betrg which is P, but in some cases i m having arithemetic overflow error.
    "An overflow has been determined in the current arithmetical operation
    containing operands of type P. Possible causes include:
    1.  The results field of type P is to small and the result does not fit
        into it.
        places.
    2.  The result or partial result has more than 31 decimal places."
    Can someone please suggest a field that can hold higher values then betrg??
    thanks,
    HM

    Try to do it in a smalle variable on decimal places,
    ie:
    var type p decimals 7---> do not like this
    var type p decimals 4 --> correct
    Bye
    Gabriel

Maybe you are looking for

  • Display icons in Network ui element

    Hello everybody! Im trying to display some hierarchies in a Network ui element. Generally, this works fine, but I'm not able to display icons with the elements inside the applet. The examples in the JNet/JGantt Developer Documentation use <icon/>-tag

  • I can no longer log on to my bank US Bank. I have to use Safari to get there. Why?

    When I go to you www.usbank.com I can enter my username but when I hit enter that's as far as it goes. So now I have to use my other browser Safari to do my online banking.

  • Validate a column only on edit

    I have a date field that's now allowed to be >=TODAY(). But this validation should only be run IF the field have been edited. The field is present in a form with other fields. And if any of these are chagned but the datefield havent been changed the

  • I cannot download album artwork on my Mac Book Pro but it will download on a two-year old Dell Ispiron 15R.  Why?

    Whenever I insert an album into the disc drive of the Mac Book Pro (New, December 23rd 2012) it cannot find the artwork (comes up with unspecified error; 609).  But until I installed the new version of iTunes it would download artwork.  Why is this?

  • Last.fm plugin

    After yesterday's update of iTunes to 12.1.0.71,my iTunes won't connect to the Last.fm plugin. I tried reinstalling the plugin, enabled scrobbling. And i reinstalled  itunes, still not working.