How to declare the data type of a column in a select query?

How can we give the data type of each column on the fly during the selection of rows in a query?

the cast function converts one data type to another.

The syntax of the cast function is:

Cast ({expr |}) (subquery) | (MULTISET (subquery)} AS type_name)

Select cast (22 August 2003 ' AS varchar2 (30))
Double;

Published by: b_ * August 12, 2011 10:08

Tags: Database

Similar Questions

  • How to recover the data type of a column in a table?

    Hello

    I want to retrieve the data type of a column in a table. At the moment I'm querying attribute 'OCI_ATTR_DATA_TYPE', but it is SQLT_CHR varchar2 and nvarchar2 data type columns. I need to make a distinction between these columns of two separate data types. Y at - it all API through which I could get the exact data type of a column, i.e. "nvarchar2?

    Thanks in advance.

    Hashim

    Hello

    It is not a very direct way to do it. What you can do is to call OCIDescribeAny on the table that you want to get information. You can then get the OCI_ATTR_CHARSET_FORM attribute for the column. If the value of the attribute that you get is SQLCS_IMPLICIT, that would mean its a varchar/char/varchar2 column regular. If you get SQLCS_NCHAR, this means that the column is NCHAR. You can get the example of it here:

    http://download.Oracle.com/docs/CD/B14117_01/AppDev.101/b10779/oci06des.htm#446491

    Just look for the section "Recovering for a Table column Datatypes".

    Thank you
    Sumit

  • How to change the data type of a column after the creation of the table

    It comes to my table desc

    SQL > desc job1

    Name                                      Null?    Type

    ----------------------------------------- -------- ----------------------------

    JOB_CODE NOT NULL VARCHAR2 (3)

    JOB_CLASS VARCHAR2 (30)

    CHG_HOUR NUMBER (5.2)

    OVERTIMECHARGE NOT NULL NUMBER

    I want to change column CHG_HOUR to store numbers up to 12 digits in length (including the decimal points).

    I tried the following and it did not help

    SQL > alter table job1 change column chg_hour number (6.6);

    ALTER table job1 change column chg_hour number (6.6)

    *

    ERROR on line 1:

    ORA-01735: invalid option of ALTER TABLE

    SQL > alter table job1 change chg_hour number (6.6);

    ALTER table job1 change chg_hour number (6.6)

    *

    ERROR on line 1:

    ORA-01438: value larger than the precision specified for the column

    where I'm going wrong?

    Hello

    I want to change the CHG_HOUR column to store numbers up to 12 digits in length (including the decimal points).

    I tried the following and it did not help

    ALTER table job1 change chg_hour number (12.6);

  • change the data type of a column

    Since the previous post: how to change the data type of column number to varchar2 in oracle10g

    Measures may be:
    create table TestTable (ColA varchar2 (5));
    Insert into TestTable values('12345');

    ALTER table TestTable Add (ColATemp number (5));
    setting a day of TestTable set ColATemp = ColA;

    ALTER table TestTable remove column ColA;
    change the column in table TestTable rename ColATemp CLC;

    My question is:
    If the table half million records

    setting a day of TestTable set ColATemp = ColA;

    will it be a good solution? Any performance issues? There is no index on this column.

    Sort while you do DDL, you will not be able to do any operation on the table. You the best suites you. It's a time operation, you can change the table to change the data type, but it may not work if some of the data in the table confirms no new data type of column.

    Concerning

  • How to get the data type of an object?

    I have some custom classes, and I would like to make conditional function that behaves differently depending on the data type of the object. How can I do this?

    you could do something like

    var obj:CustomObject = new CustomObject();

    If (obj is Objetpersonnalise)

    {

    do something

    }

    or you could look at using getQualifiedClassName() or getDefinitionByName()

  • How to set the date type date of work

    This is perhaps a silly question, but I can't seem to get the data type date to work for a member account. When I go to the planning application and choose an account I want to put in a date entry account, the web form seems to show that the setting of the date works for the account. I even put my account type to be saved hypothesis. For example, I expect to see the date formatted in 10/20/2009 when I enter this value in the web form under my account "Hire Date". I also checked the display options in the preferences of planning. If anyone knows if this function works even on 9.3 or 11.1?

    Hello

    Looks like you have not defined the order of evaluation of Auditors. Administration > Dimensions > evaluation order > select plan type > moving accounts to another window, apply.
    Try the form again.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Display the data type of a column in the status bar

    Hi all

    n pl/sql developer, when I select a column in a table.

    If I clicked with the mouse on the column in the query results box, it shows me the type of data and the size of the column in the status bar

    Developer SQL does not by default,

    is there an option I can change to do the same task?

    Thank you

    No, you will need to open a popup DESC of the query to see the data types of the data returned.

  • length of the data type of a column

    Hello

    I would like to know if it is possible to find the length of the
    data type in a create table stmt.

    For example:
    create employee table (empno number (3), empname varchar (10));


    in the DDL above I mentioned the size of my 3 number data type.
    is there a way to retrieve this info. ?
    outside desc < table_name >?


    Thanks in advance
    SQL> create table employee(empno number(3),empname varchar(10))
      2  /
    
    Table created.
    
    SQL> select column_name
      2       , data_length
      3       , data_precision
      4       , data_scale
      5    from user_tab_columns
      6   where table_name = 'EMPLOYEE'
      7  /
    
    COLUMN_NAME                    DATA_LENGTH DATA_PRECISION DATA_SCALE
    ------------------------------ ----------- -------------- ----------
    EMPNO                                   22              3          0
    EMPNAME                                 10
    
    2 rows selected.
    

    Details on the columns can be found in the documentation: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_2094.htm#I1020277

    Kind regards
    Rob.

  • How can I find what is the data type of a column of a Table in oracle or SQL?

    (a) what happens if I want to know the type of data in a specific column in the Table.

    (b) how to find the column data types?

    Can someone help me please. I am new to oracle and try to learn a few tricks

    Hello

    How to do

    SQL > desc

    SQL> desc emp
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     EMPNO                                     NOT NULL NUMBER(4)
     ENAME                                              VARCHAR2(10)
     JOB                                                VARCHAR2(9)
     MGR                                                NUMBER(4)
     HIREDATE                                           DATE
     SAL                                                NUMBER(7,2)
     COMM                                               NUMBER(7,2)
     DEPTNO                                             NUMBER(2)
    
  • How to return the data type complex of a synchronous BPEL process

    Hi all
    I have created a synchronous BPEL process, so a partner customer link was automatically created in the project. Now the link partner of this client is to have input and output variable of type normal string where as my BPEL process finally returns a complex data type.
    In order to solve this problem, I took a processing activity and mapped the collection [variable returned by my BPEL process] to the chain of production of the customer but in this way I just get a single string to store the entire collection but I want that they separately.

    Can someone tell me, how to manage this scenario.

    Concerning
    Lokesh

    After creating the partner link and the invoke (to create the variables), change the element type of the response message to the complex type definition of your collection that appears in the XSD. You can do the same thing if you want to change the element type of the payload of the request message as well.

  • How to force the data type in create table field?

    Hi all

    I need to force my table to create as follows

    Create table XYZ

    (Test varchar2 (10 CHAR)

    ...

    );

    When I run my Interface the script is

    Create table XYZ

    (Test varchar2 (10))

    ...

    );

    and the DBMS translated into

    Create table XYZ

    (Test varchar2 (10 BYTE),

    ...

    );

    I have the same problem with I$, C$, and so on.

    Best regards

    Marco

    Hi all

    I fix my problem:

    In Phisical Tecnology, under ORACLE Tecnology, data TYPE, I modified the definition of VARCHAR2 in VARCHAR2(%L CHAR).

    (Before it was VARCHAR2 (%)).

    Thank you all.

    Marco

  • How to handle the data type DECIMAL MySQL converted to DOUBLE in OBIEE 10 gR 3?

    Hi all

    I have a problem in OBIEE 10g to I use the MySQL database as datasource direct to the server of the OBI and I have a column in a MySQL table which was designed as the DECIMAL data type (18.0).
    This column is used to measure a length, and values are included in seconds (without decimals), in the form as:
    "1200"
    in the MySQL database.

    After the import of the MySQL table associated with the repository of the OBI, the OBIEE converts the DECIMAL data type column to the DOUBLE PRECISION data type automatically.

    My goal is to reach the values in this form, certainly in the sense of the term (not at the time!):
    hh mm ss

    In order to accomplish, I tried to change the format of column with the ROUND function:
    ROUND (db.table.column / * 3600 * 2)

    The problem is that it doesn't work well if values can be divided with no rest for example
    original value: 7200
    new value (ROUND): 2

    In the case of my example:
    original value: 1200
    new value (ROUND): 0
    It's false, because 1200 seconds are not equal to 0 hours, I want to see two hours of _0.33333_ OR I much prefer more _0 hour 20 m_

    Anyone have any ideas?
    I tried to make a view of database and importing that type of CHAR data in the database, but is not the solution too, because if I filter BI app or try to make a SUM the BI would drop errors...

    Kind regards
    Laszlo

    Hello
    SE refer to this link, it is exactly will meet your need.

    OBIEE 11 g - change seconds in the format hh: mm: DD
    OBIEE functions

    Share updates... :)

    check if useful/correct...

  • How to refresh the report region change which column of report selection list

    Hello
    I worked with apex 4.2 and I create a classic report with list (named loved) select a column in the list change in report, update the table with the new value via JavaScript (change) call and woke up very well, and I change the color of the line was updated to make it different from the other lines now I want to update to the report after doing update without submitting the page to show the new color of line update.
    I called javascript:apex.submit() in the update function, but

    My Question
    1. How do I refresh the report after change report column list without sending page
    2-can we enter column name selection list report to submit the Page to refresh the report area


    Thank you
    Ahmed

    See my answer above!

    Here's what I did:

    • Created two hidden page items

    • Created a dynamic action on the page with three real actions. (1) set the item values page. (2) to execute code to update the plsql table. (3) update the region report

    Thank you
    Vikram

  • How to detect the data type is?

    Hello!

    I built a function of VI. But I want to make it safe - function could detect what type of data is connected to the inputs and only allow certain types of data cabling. How can I do this?

    Thank you

    You could look in polymorphic VI.  They will allow you to connect different types of data.  However, it is not really an option to "do not allow" it.

    If someone creates their own s VI in LabVIEW, then they should pay attention to details like the stress points.  Other than provide good documentation describing the function, inputs and outputs of a Subvi, it's not really necessary for the creator of the Subvi to prevent another programmer to use this Subvi wrongly.

  • How to display the data type long using the select statement

    Hai All

    I have to select the text of a view. But the text is declared as long and I need to see full view

    When I use this

    Select the text in all_views where view_name = "DAILY_ATTEND_VIEW";

    I have got only half of a select statement

    Concerning

    Srikkanth.M

    Hello

    SQL> SET LONG 100000
    SQL> select text from user_views
      2   where view_name='MVIEW';
    
    TEXT
    ------------------------------------------
    select e.empno,e.deptno,d.dname
    from emp@sdblink e,dept@sdblink d
    where e.deptno=d.deptno
    

    But it is limited to sql alone. If you use the double click TOAD on the text column in the grid will show you the entire SQL views.
    Unfortunately, there is limitation to consider,
    The largest value that you return from the function would be 32 k (RETURN VARCHAR2), both.

    Twinkle

Maybe you are looking for

  • .sparsebundle vs .dmg

    Its the there is a difference between a file encrypted with a .sparsebundle file name extension and a file encrypted with a .dmg file name extension. A few years ago, I created an encrypted folder and got a .sparsebundle file name extension. I still

  • Graphics driver for my ThinkPad L412

    I recently bought a Lenovo ThinkPad L412 laptop. I have Windows 7 Professional with it. The graphics driver that I got in reinstall drive does not work. So, I uninstalled this driver and Windows automatically installed driver "Ati Mobility Radeon HD

  • How can I analyze the flow on SF302 - 08 p

    Hello I have a SF302 switch - 08 p and I'm looking for an option to analyze all streams on it. I tried to enable netflow, but it seems that the product does not support because I can't access the stream ip like here: http://www.cisco.com/c/en/us/td/d

  • devices & printers fails to tell [play anything

    When "devices and printers" are selected in the Control Panel, there is no evidence that installed; devices or printers. Printers are selectable from software such as Excel or Word. However, I can't access any printer to make the default. Have remove

  • Yet of the Smartphone blackBerry cannot find SIM Application Toolkit in 6.0.0.246

    Dear Sir I have recently updated my torch using a device AT & T. I searched through everything and found nothing. Can someone provide explanations on this subject, or maybe RIM doesn't want this feature in their device more? Thank you Andy