Changing column datatype value

Can any body forward me the SQL for changing the datatype value from
Varchar2(64) to Varchar2(2)
Arif

You can do that if the column is empty, or its contents size is not bigger than the new size :
SQL> create table test_tab(a varchar2(100));
Table created.
SQL> alter table test_tab modify a varchar2(50);
Table altered.
SQL> insert into test_tab values('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
1 row created.
SQL> alter table test_tab modify a varchar2(40);
Table altered.
SQL> ed
Wrote file afiedt.buf
  1* alter table test_tab modify a varchar2(20)
SQL> /
alter table test_tab modify a varchar2(20)
ERROR at line 1:
ORA-01441: cannot decrease column length because some value is too big
SQL>

Similar Messages

  • Change column datatype from varchar2 to number(10) and keep existing data

    Hi,
    I need to change the datatype on a column that already has data in it from a varchar2 to number(10). The data that is already there is not necessarily number data, however I must be able to keep the old data to. We are running 10g. Does anyone have any ideas? Thanks. Here's the current data.
    Current Values for From_Value
    T
    U
    T2
    K
    M
    A
    T
    T1
    O
    E
    S
    NSTU
    4

    Example of keeping the data in the current column and adding a new numeric column for numeric data:
    SQL> drop table t purge;
    Table dropped.
    SQL> create table t(i int, x varchar2(10));
    Table created.
    SQL> insert into t values(1, 'T1');
    1 row created.
    SQL> insert into t values(2, 2);
    1 row created.
    SQL> --
    SQL> alter table t add (xn number);
    Table altered.
    SQL> --
    SQL> begin
      2  for c in (select i, x from t)
      3  loop
      4   begin
      5   update t set xn = to_number(c.x) where i = c.i;
      6   exception
      7    when invalid_number then null;
      8   end;
      9  end loop;
    10  end;
    11  /
    PL/SQL procedure successfully completed.
    SQL> show errors
    No errors.
    SQL> select * from t;
             I X                  XN
             1 T1
             2 2                   2

  • How can i change column header value dynamically in IR report

    HI,
    I have created report with the help of collections. Report query has been changing dynamically but i got problem with report header names and headers names has not been changing dynamically it is always showing like c001,c002....etc so, i have created global item(G_ITEM) in shared components--->Applications items after that
    I have created process(before headers) and assigning some value to G_ITEM and used &G_ITEM to column headres in IR Report but here &G_ITEM is not showing any value.
    How can i achieve dynamic headers names by using *&G_ITEM(global items)* Please guide me to achieve this.
    Thanks in advance.
    Regards
    Narender B

    Narender wrote:
    HI,
    I have created report with the help of collections. Report query has been changing dynamically but i got problem with report header names and headers names has not been changing dynamically it is always showing like c001,c002....etc so, i have created global item(G_ITEM) in shared components--->Applications items after thatWhy didn't you answer the questions in the other thread to see if there was a better approach than this?
    I have created process(before headers) and assigning some value to G_ITEM and used &G_ITEM to column headres in IR Report but here &G_ITEM is not showing any value.
    How can i achieve dynamic headers names by using *&G_ITEM(global items)* Please guide me to achieve this.The static text exact substitution method of referencing the value of an APEX item requires a terminating dot ("."):
    &G_ITEM.

  • How to Sort Dimension in Pivot Table via Order Column which is changing like Factual values

    Hi,
    Recently in of our product offerings we got stuck on this following question:
    How to Sort Dimension based on the Order Value which Keeps Changing with Factual Values??
    We have a data source laid out as (example)
    In the above the “Order” columns are changing per
    Company/(DimensionA) for DimesnsionB.
    Instead what we want is: (But only if we can get the following result without putting the “Order” Column in the “Values” Section. 
    If there are any configurations that we can make to our power pivot model for the similar data set so that the
    DimesnionB in this case can be sorted by the Order column, would be greatly helpful to us. 
    Sample File:
    http://tms.managility.com.au/query_example.xlsx
    Thanks
    Amol 

    Hi Amol,
    According to your description, you need to sort dimension members in Pivot Table via order column, and you don't want the order column show on the Pivot table, right?
    Based on my research, we can sort the data on the Pivot table based on one of the columns in that table, and we cannot sort the data based on the columns that not existed on the Pivot table. So in your scenario, to achieve your requirement, you can
    add the column to pivot table and hide it.
    https://support.office.com/en-gb/article/Sort-data-in-a-PivotTable-or-a-PivotChart-report-49efc50a-c8d9-4d34-a254-632794ff1e6e
    Regards,
    Charlie Liao
    TechNet Community Support

  • OBIEE - changing imported column datatypes

    Hi All,
    I am trying to join 2 tables in physical layer but the columns on which I am making join condition have different datatypes defined(one is datetime,another is timestamp).Hence, I am getting error incompatible datatypes can't be joined.
    I don't want to change the columns datatypes in ohysical layer bcz I am not sure if some other report using this rpd might be using the join conditions based on existing datatypes.Is there any alternative to this?
    Please suggest.
    Thanks,
    Neha

    Please try to use this function. it is good if we have sample data for both columns.Please provide if you have issues using following function
    Evaluate( 'to_date(%1,%2)',Evaluate( 'TO_CHAR(%1)' as char,20090101) , 'yyyymmdd')
    Thanks
    NK

  • Column Datatype Change

    Hi,
    I created a table with some 10 columns earlier, now one of the column datatype needs to be changed to varchar2(2), which actually in the database it is number.
    The thing the table now contains 10 records. Its not allowing me to modify the column datatype, because it has rows in it. How to change the column datatype with data in the table. Pl reply ASAP.
    Thanks

    See the following example.
    Let's modify deptno column from number to varchar2 :
    SCOTT@demo102> desc emp2
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO NUMBER(2)
    SCOTT@demo102> select count(*) from emp2;
      COUNT(*)
            14
    SCOTT@demo102> alter table emp2 modify deptno varchar2(2);
    alter table emp2 modify deptno varchar2(2)
    ERROR at line 1:
    ORA-01439: column to be modified must be empty to change datatype
    SCOTT@demo102> alter table emp2[b] add deptno2 varchar2(2);
    Table altered.
    SCOTT@demo102> update emp2 set deptno2=deptno;
    14 rows updated.
    SCOTT@demo102> commit;
    Commit complete.
    SCOTT@demo102> alter table emp2 drop column deptno
    SCOTT@demo102> /
    Table altered.
    SCOTT@demo102> alter table emp2 rename column deptno2 to deptno
    SCOTT@demo102> /
    Table altered.
    SCOTT@demo102> desc emp2
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO VARCHAR2(2)
    SCOTT@demo102>
    Pl reply ASAP.Since this is saturday, and saturday is an unworked day in most of countries, and since this forum is based on volunteers, you cannot ask ASAP...
    Nicolas.

  • Change the datatype of all the columns

    Oracle version 10g.
    I have a table with 150 columns.
    I'd like to change the datatype of all the columns in my table to varchar.
    Do we have a query for this task?
    Thanks.

    Not knowing yet what you'll answer to John:
    If your table is empty, you can use the datadictionary to generate a statement and execute it using dynamic SQL or spool the query to a file that does the DDL and run that...
    Example:
    MHO%xe> create table bla (col1 number, col2 number);
    Tabel is aangemaakt.
    MHO%xe> select column_name, data_type from user_tab_columns where table_name = 'BLA';
    COLUMN_NAME                    DATA_TYPE
    COL1                           NUMBER
    COL2                           NUMBER
    MHO%xe> declare
      2    l_sql varchar2(4000);
      3    l_sep varchar2(1);
      4  begin
      5    l_sql := 'alter table BLA modify ('||chr(10);
      6    for rec in ( select column_name from user_tab_columns where table_name = 'BLA')
      7    loop
      8      l_sql := l_sql||l_sep||' '||rec.column_name||' varchar2(50)'||chr(10);
      9      l_sep := ',';
    10    end loop;
    11    --
    12    dbms_output.put_line(l_sql||' )');
    13    --
    14    execute immediate l_sql||' )';
    15    --
    16  end;
    17  /
    alter table BLA modify (
    COL1 varchar2(50)
    , COL2 varchar2(50)
    PL/SQL-procedure is geslaagd.
    MHO%xe> select column_name, data_type from user_tab_columns where table_name = 'BLA';
    COLUMN_NAME                    DATA_TYPE
    COL1                           VARCHAR2
    COL2                           VARCHAR2

  • Change column value based on another

    Hi, everyone.
    my version 11.1.2.2.0.
    i wanna change 1 column's value based on another column's value that be selected.
    ex: select 2rd column to 'A' , then the 1rd should be 'New Start'.
    i used EL like #{row.bindings.MacdType.inputValue eq 1 ? 'New Start' :  row.bindings.CircuitId.inputValue}.
    But it does not set the inputvalue which should binding with the DataSource.
    what's the best way to do these logic?
    pls help. thx

    Hi,Abhijit;
    ex: the frist column is a LOV, the user select "A" for the first column, so the value of the second column should be changed to 'New Start'.
    And the value should be binding to the DC, when save, the value of the 2rd column should be saved to DB.
    thx

  • How to catch changed column values in alv oops using grid

    My requirement needs to catch changed column values in alv oops using grid .any method to do this.
    please help me out ,
    Tks in advance

    Have a look into the SAP standarad Programs those programs have the edit option on the ALV output.
    BCALV_EDIT_01
    BCALV_EDIT_02
    BCALV_EDIT_10.
    Regards,
    Gopi ,
    Reward points if helpfull.

  • Dynamic changing column using one calumn values

    Dear All,
    I have one Column having values in single row as Zones|1,Zones|2,Zones|3,Zones4,Venue|Ind,Venue|eng,Country|india,Country|africa......
    In report we have to take Zones, venue, country dynamically and correponding values has to be shown in the column area. Pls provide me any solution .

    Hi Shyamal,
    The closest thing to doing this dynamically would be with a Crosstab report but it won't show you the details, only summarize on the column. 
    Unless you know all the possible columns you may have, you can create something like:
    If {TABLE.FIELD} = "Zones" Then
    Else If {TABLE.FIELD} = "1,Zones" Then
    And so forth.  But you will have to know each and every possible value for that column. 
    Good luck,
    Brian

  • Need to change color of one column's value depending on the other column

    Hi,
    i have a search form which displays two column values
    First column value's colour should be based on second column's value
    For example, if second column has values 'Active', 'Inactive' and 'Pending'
    If 'Active' , the first column value's color sholud be 'red'
    If 'inacitve, another color ....
    Thanks in advance,

    Hi!
    What we did was we added a column on the VO that returns kind of a css part (for example if a column value is 'Active' the value of this column should be "background-color:rgb(255,0,0);")
    Than you use something like this on your column:
    inlineStyle="#{row.StatusStyle}"where StatusStyle is the name of the column with "background-color:rgb(255,0,0);" value.
    The problem here can be that the background color doesn't cover the whole column but only the text in it (so if it is null, the color is default).
    If you want the whole column to be of this color you use something like this:
                                        <af:column ...>
                                          <afh:tableLayout ...>
                                            <afh:rowLayout ...>
                                              <afh:cellFormat inlineStyle="#{row.StatusStyle}" ...>
                                                <af:outputText ...>
                                                </af:outputText>
                                              </afh:cellFormat>
                                            </afh:rowLayout>
                                          </afh:tableLayout>
                                        </af:column>Basically you put another table layout inside a column instead just a outputText (or whatever control you use)
    Hope this is understandable and it helps :)
    It works for us.
    BB

  • Changing DataColumn DataType in the same DataTable

    hi,
    I have following requirement.
    In a DataTable, I have a DataColumn with String as DataType (This has dateTime data in String format). I want to change this DataType to DateTimeStamp and then sort it in ASC order.
    Could someone please share sample code to do this?
    Appreciate for your help.
    Many Thanks,
    Alex
    AC

    Hi Alex,
    >> In a DataTable, I have a DataColumn with String as DataType (This has dateTime data in String format). I want to change this DataType to DateTimeStamp and then sort it in ASC order. Could someone please share sample code to do this?
    As far as I know, the DateTimeStamp is an element in Exchange Server, there is “System.DateTime” in C#. Do you want to covert the string to System.DateTime, and sort it in ASC order? If so, I will recommend you add a new column, convert the string to DateTime,
    add the value of the DateTime to the new column, and then sort by the new column.
    For information about adding new column, you could refer the link below:
    # DataTable Class
    https://msdn.microsoft.com/en-us/library/system.data.datatable(v=vs.110).aspx
    For information about converting the string to DateTime, you could refer the link below:
    # How to: Convert a String to a DateTime (C# Programming Guide)
    https://msdn.microsoft.com/en-us/library/cc165448.aspx?f=255&MSPPError=-2147217396
    For information about sorting by the new column, you could refer the link below:
    # Dataset sorting in c#
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/adbd95cd-49d1-483d-b2b2-4b696a66e9a6/dataset-sorting-in-c?forum=netfxbcl
    If I misunderstand you, please feel free to let me know.
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Under the column firld value new variable needs to be displayed in

    hi
    i ahve a query
    presently in sap script output in main window
    these three fields are coming i want to add a new line ie bar code for the field value which is coming below it
    example
    present output
    number  item    total amount       unitvalue
    001       dxs     22222                 3456
    002     tcg       44545               45464
    desired output change needed
    number  item    total amount       unitvalue
    001       dxs     22222                 3456
                                                  bar code for 3456
    002     tcg       44545               45464
    my question is kindly let me know how to increase the space next line how to get below the earlier value coming
    what is code for next line and if i put it below that field in the column unit value will it be displayed and automatically space created for whole line??? and output as above comes
    pls suggest
    regards
    Arora

    closed
    duplicate thread

  • How to change defauled field value in Appraisal OSA

    Hi,
    We hav implemented OSA Appraisal Model and it's working fine both in R/3 and from EP.In form template We hav set the column 'Value Input' to Required Entry.
    In the HAP Document the field values of that column are never null coz the field value is defaulted to the first entry '1'. How to change the defaulted value in the drop dwn boxes.
    Any help will be much appreciated .
    Rgds,
    Jothi.
    Message was edited by: Jothivenkatachalam.P

    Hello Jothi,
    Defaulting can be achieved with a value determination, BAdI definition HRHAP00_VAL_DET.
    Regards and Groetjes,
    Maurice

Maybe you are looking for

  • Data Federator authentication modes

    In Data Federator (3.0 SP1 or previous), Is there any authentication mode similar to AD/LDAP in BOE? What are the options available for dynamic logon, while connecting to a database via JDBC in the DF Data source definition screen? Thanks Tiji

  • Add Customer_PO number to SQR Invoice

    I need to add customer po number to our invoice.I am very new to PeopleSoft and SQR when I look at biivcpn.sqr and bisubp00.sqc I can't tell where(What Table) it pulls from How do I tell that? How do I need to add the Customer PO line to bisubp00.sqc

  • Need help using wifi on my iPad for computer

    Hi guys sorry if this question has been asked before but i wasn't able to find my answer anywhere so here goes :) I just bought an iPad mini and it's awesome i love it. But due to some problems my wired internet connection to my computer is not worki

  • ITunes Launches whenever I plug in my Ipod,  How to stop it???

    This is amazingly annoying. There are times when I want to plug in my ipod to my PC just to charge it. But for the last month or so, ITunes launches automatically. This is a real problem because Itunes dominates the PC during its long load time. HOW

  • Storage locations as storage areas

    We do not use Warehouse Management module. We are thinking of creating many storage locations (100+) to represent storage areas within a warehouse. This way, we will be able to locate stocks by referencing their SAP storage location against physicall