Insert the ROWNUM in a column of data type of NUMBER table

Hello

I have a table that has a column named "rank" of the NUMBER data type. Basically, I want to make an analysis of top-n and insert the ROWNUM with other columns in the table.

Definition of table1:

CREATE TABLE

(

col1 VARCHAR2 (10),

Col2 NUMBER,

NUMBER of col3,

rank NUMBER

);

INSERT INTO table1

SELECT col1, col2, col3, rownum

DE)

SELECT col1, col2, col3

FROM table2

ORDER BY DESC of col3

)

WHERE rownum < = 5;

I get an error ORA-01722: invalid number. I think the mistake is virtual ROWNUM is not data type of NUMBER, so I tried to cast as CAST (ROWNUM AS NUMBER), but it does not work, same error. Can can you please shed some light on how to convert a ROWNUM number or if the issue is something else.

you're right, your example worked. It is an example of table I just created just to illustrate the problem, but my real table was always showing the same problem. Weird, isn't? However when I added the column names after that insert the question but statement I resolved. Adding code

INSERT INTO TABLE1

(col1, col2, col3, rank) - added

SELECT col1, col2, col3, rownum

DE)

SELECT col1, col2, col3

FROM table2

ORDER BY DESC of col3

)

WHERE rownum<=>

So that means ROWNUM returns number; and another confusion: why the inclusion of the column has solved my problem when it is not necessary for your example. in any case thank you.

Tags: Database

Similar Questions

  • Removal of the custom by TestStand 4.0 data types

    Hello! I use the custom in my TestStand sequence data type. This data type is derived from my own control and is a huge cluster of clusters. It is created in a file of sequence (and not in any *.ini). By changes in the sequence, it becomes necessary to delete existing custom data type and create a new one due to changes in the custom control. How can I remove custom data types?

    I n ' found any possibility to do in Teststand menus. It was not so important, if the custom data type was not so huge.

    Thank you in advance for your answer - maybe it's a workout if no direct solution?

    Hello

    Just see the Type of data in the file in the sequence and highlight the custom data type it, then delete it.

    (Please make sure that you do not have variables defined in your file of sequence that still use the data type you want to remove).

    Concerning

    Ray Farmer

  • How (burning?) copies of your own movies on a DVD? I have only a single tray to insert the bland DVD. Is a required type of c1040 of DVD? Thank you

    How (burning?) copies of your own movies on a DVD? I have only a single tray to insert the bland DVD. Is a required type of c1040 of DVD? Thank you

    A drive and a blank DVD is all you need. Check
    the manual of your DVD burner and a DVD player to
    See the types of DVDs, they are compatible with.

    Personallty I have had success using DVD - R blanks.
    The following article offers some info about brands:

    What are the best blank DVDs?
    http://www.digitalfaq.com/reviews/DVD-media.htm If this is 'not' a commercial - protected against copying DVD...
    the following freeware can create an ISO Image
    that allows to burn copies.

    FWIW... it's always a good idea to create a system
    Restore point before installing software or updates)

    Download ImgBurn:
    http://www.Digital-Digest.com/software/download.php?sid=470&SSID=0&did=1
    (The download is: SetupImgBurn_2.5.5.0.exe)

    (During the installation there will be an option to install
    Shortcuts of UniBlue and the "Ask Toolbar"... you can
    you want to deselect those)

    The following tutorials may be worth a visit:

    How to create an image file of a disc with ImgBurn
    http://Forum.ImgBurn.com/index.php?showtopic=6379

    How to write an image file to a disc with ImgBurn
    http://Forum.ImgBurn.com/index.php?showtopic=61

  • incompatible data types: expected NUMBER got LONG

    Version 3.2.20.09

    Hello

    I use SQL Developer and want to see trigger body using as a function but unfortunately its data type is long so that I get the error message, is there a way by which I can see the bodies of trigger...

    Example query

    TRIGGER_BODY

    SELECT TRIGGER_BODY FROM user_triggers

    WHERE TRIGGER_BODY LIKE '% HEAR. "

    Error

    ORA-00932: inconsistent data types: expected NUMBER got LONG

    00932 00000 - ' incompatible data types: wait %s %s got. "

    * Cause:

    * Action:

    Error on line: column 2: 7

    This isn't a matter of SQL Developer.  Access quick, but partial, the answer is that the display of a LONG column in SQL * more / developer SQL can be done by issuing just one

    1000 long - value (or some other, more)

    You are referencing a LONG in a WHERE clause, however, is absolutely forbidden as I know.  Maybe something new (System invisible columns generated in LONG columns in the data mirrored dictionary?) are available in 12 c, but disapproval of LONG was announced in Oracle 8 in favour of the LOBs.

    Anyway, if you do not want to ask this question in the forum of PL/SQL, see solution code of Laurent Schneider in this old debate...

    Search long data type in the column

  • Conversion of the data type of a table column

    Hello

    I have a column with the varchar2 data type. I want to convert to number data type. But the data in the table are not lost. Can someone suggest me how to convert the column with the varchar2 data type to store the data in the table of number data type.

    Thanks in advance

    try something like this

    create table t(col varchar2(10));
    insert into t values('1');
    insert into t values('2');
    commit;
    select * from t;
    alter table t add  col1 number;
    update t set col1 = to_number(col);
    commit;
    alter table t drop column col;
    alter table t rename column col1 to col;
    select * from t;
    

    Published by: Karthick_Arp on April 6, 2009 12:32 AM

  • Add/change the columns of data type (scripting)

    Hello

    I am writing a script to add default columns and their values in tables. So far, for me, it is possible to add columns to an existing table in the model.

    Then, I want to add value to the data type. I discovered there is a method called getDataType(). So far, I have not found the "setter; for this property.

    Like other scripts, I started by creating a table with columns, and then using the API to read the values.

    A simplified version of my code:

    get the columns of table

    myTab var = model.getTableSet () .getByName ("T_POSITIONS");

    colArray = myTab.getElementsCollection () .toArray ();

    loop through columns

    for (i = 0; i < colArray.length; i ++) {}

    the type of var data = colArray [i] .getDataType ();

    model.getAppView () .log (colArray [i] + "a datatype" + dataType);

    colArray [i] .setDataType ("VARCHAR2 (1)");

    }

    An error occurs when I want to run this script: could not find setDataType function in the object ID.

    I can't find the right method to add/change the datatype property.

    Any information would be appreciated.

    Hi Bart,.

    Here's what's in the column in the XML file:

    
    FDB11R21
    EMPLOYEES
    FIRST_NAME
    
    2015-01-13 12:45:08 UTC
    First name of the employee. A not null column.
    HR_870
    true
    false
    1
    LOGDT024
    20 BYTE
    false
    
    

    20 BYTES

    If you need set the size in "20 BYTE" or "20 CHAR".

    Philippe

  • Change the length of a Table column (CHAR data type)

    Hi gurus,

    SQL > select * from version $ v

    BANNER

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

    Oracle Database 10g Release 10.2.0.3.0 - 64 bit Production

    PL/SQL version 10.2.0.3.0 - Production

    CORE Production 10.2.0.3.0

    AMT for Linux: release 10.2.0.3.0 - Production

    NLSRTL Version 10.2.0.3.0 - Production

    I need to increase the length of a CHAR of a table data type column (currently it's tank (3) and you want to change to char (4)). Here are more details on the table:-

    • Contains more than 20 million lines.
    • Table contains several indexes.
    • Table is referenced by several tables (about 60 tables) and it refers to several tables (about 3)
    • Table has 4 complex triggers. Triggers call procedures and packages.

    What I've tried so far


    1 disabled all triggers and ran ALTER statement to increase the length. It took hours and did not finish in a reasonable amount of time, even if no error, but it took more than 12 hours.

    2 tried DBMS_REDEFINITION package but it does not work with the standard version of Oracle 10 g.

    I think to try next

    I think same Optics:

    Say my name of the existing table is OLD_T1 where the length of column need to increase

    -Create a copy (with increased column length) table of OLD_T1, Say NEW_T1

    -Move data from in OLD_T1 to the new table NEW_T1

    -Lower OLD_T1 (or rename it to OLD_T1_TMP)

    -Rename NEW_T1 to OLD_T1

    -Create all indexes, triggers, constraints etc..

    I wish to confirm, if my approach is correct? Or someone has a better idea to do this?

    Please note: I know that the CHAR data type gives the problem but it is an old system and I don't have authority to change the design of database.

    Appreciate any comment/suggestion

    Thanks in advance

    > I mean, can any application break if it depends on fixed-length?

    Yes, because the code can be expected completed on the right areas.

  • throw ' (' and the rest of the line to a column of data)

    It's my data-

    PICL/NGJ/MP-0001/01/02012 (Export)

    PICL KWB MP-0060/002/2012 (Open)

    PICL/MRP/MP-0006/01/02012 (Inland)

    PICL/AGB/MP-0010/01/2012 (O0pen)-(co-in)

    PICL/BP/MP-0025/001/2012 (P-1)

    I want to throw the chain started from ' (' this means that the output will be)

    PICL/NGJ/MP-0001/01/02012

    PICL KWB MP-0060/002/2012

    PICL/MRP/MP-0006/01/02012

    PICL/AGB/MP-0010/01/2012

    PICL/BP/MP-0025/001/2012

    And it would be of different data type after the start of support.

    How to write a sql to get the result

    Hello

    Like this?

    DATA (col SELECT "PICL/NGJ/MP-0001/01/02012 (Export)' FROM DUAL

    UNION ALL

    SELECT 'PICL KWB MP-0060/002/2012 (Open)' DOUBLE

    UNION ALL

    SELECT "PICL/MRP/MP-0006/01/02012 (Inland)" DOUBLE

    UNION ALL

    SELECT "PICL/AGB/MP-0010/01/2012 (O0pen)-(Co-In)" DOUBLE

    UNION ALL

    SELECT "PICL/BP/MP-0025/001/2012 (P-1)" DOUBLE)

    SELECT Regexp_replace (col, ' \(.*'))

    FROM the data

  • Why the rich text editor shows unsupported data type?

    Hello

    I used the rich text editor in my application (for the message box). I used the data BLOB to the type. But, when I click on the button send it shows invalid hexadecimal number and also in back-end, it shows the data type not supported. Why is it so? Need your help.

    --

    Thank you.

    Venky_prs wrote:

    Thanks for the reply. I changed on the CLOB type. Now, the intervention process. But, in the back-end the message column contains HTML format. For this rich text editor, I used the source as the database column type. How can I get the actual message instead of the html format.

    Elements of the rich text editor are used to create HTML text. If you need/want data plain text, then use a Textarea base element.

  • Full table scan without sweeping particular column (CLOB data type column)

    I want to select the online_bank table. This table with a column of type CLOB data. I want to select all the columns in the table, except the column type of clob data. but oracle full table, including the column analysis server type CLOB data when the query is run. It took a long time to complete the table. Please give me a solution of full table scan without analysis the CLOB data type column. How to avoid the time scanning CLOB data type column... ?

    878728 wrote:
    I want to select the online_bank table. This table with a column of type CLOB data. I want to select all the columns in the table, except the column type of clob data. but oracle full table, including the column analysis server type CLOB data when the query is run. It took a long time to complete the table. Please give me a solution of full table scan without analysis the CLOB data type column. How to avoid the time scanning CLOB data type column... ?

    We do not have your table.
    We do not have your data.
    Therefore, we have no answer to your apparent mystery.

  • Change the data type of number (1) to number (3)

    Y at - it a command to change the data type for an existing column? I just need to go long number 1 to 3... or I have to delete column and then use Edit to add the new field?

    Thank you
    Mark

    Hello

    alter table  modify  NUMBER(3);
    

    Kind regards

  • 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 can I justify the difference between varchar and varchar2 data type

    Hi all

    How can I justify the difference between the data type varchar and varchar2 on any table for space management.
    Is there any query to justify this.


    Concerning
    Girish

    Published by: boujemaa on February 2, 2011 21:23

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14220/datatype.htm#sthref3780


    The VARCHAR data type

    The VARCHAR data type is synonymous with the VARCHAR2 data type. To avoid any changes in behavior, always use the VARCHAR2 data type to store strings of variable length.

  • How to record a data type float [64] table in a file?

    I have a table of type float64 [] data I want to save to a file.  I tried to use the ArrayToFile function, but he dislikes the type of data [] float64 .  I'm with LabWindows/CVI version 7.1.

    Why not use the data type double?

  • Insert the value of a column in the report in a page with JavaScript element - 2?

    Hi guys,.

    As explained here:
    http://jholoman.WordPress.com/2012/02/26/Apex-4-1-page-items-to-submit/

    We have two reports, sources of the region including:

    Select * from dept
    and
    Select * from emp where deptno =: p1_deptno

    IN report of the departments link attributes, we use this script to set the value of the point P1_deptno
    onclick = "$s ('P1_DEPTNO', #DEPTNO #); return false; "
    In the report used region, on the article Page to submit, we put: P1_DEPTNO

    Then, we use a dynamic action to refresh the report used (she should get updated when the value of P1_deptno). where it is supposed to show the employees of a specific Department:

    But I have failed to do... You can pls, take a look:

    http://theexecutivetowers.info:8282 / apex
    workspace: opener
    user: fat
    PWD: fat

    Kind regards
    I use apex 4.1 on win 2008 Server. listener 1.1.3 deployed on glassfish 3.1

    I do not have your pencil link to work. This column did not assess the value of the #DEPARTMENT_NAME column.
    Who estimated that:
    OnClick = "$s ('P1_DEPARTMENT_ID', #DEPARTMENT_ID #); return false; »

    as opposed to
    OnClick = "$s ('P1_DEPARTMENT_ID', 10); return false; »

    I got your columns Dept ID name and dept to become links by their implementation. You can see what I did there. I defined a function in the page header.

    You also had a typing mistake in your SQL for employees (p1_dempartment_id) so I've corrected it to p1_department_id.

    All together.

Maybe you are looking for

  • I cannot connect to the internet and can not find networks as well.

    Original title: a disc XP Wibdows will repair a missing msnuser file? I can't find all the networks to connect to the internet. After a router problem, I had to change the name of my network. All my other PC is connected. My Dell XP Pro has for some

  • Locked user folder

    I recently migrated an admin to a new account admin account, because the taskbar was faulty. I deleted the old admin account and the old user folder, but now the new user folder has a lock on it and it doesn't allow me to rename. I tried all the proc

  • State of the endpoint system / meaning / resolution

    Hi guys,. You know all the resources to find the following State of the endpoint system messages in MSD and their meaning and/or the corresponding resolution: State of the endpoint system Unknown- Alive- Idle- InCall- No SNMP response- Manager not av

  • High availability

    I know that HA can still run even after vCenter breaks down.My question is how long will HA will be still functional?2 data centers (with 1 cluster) is managed by a vCenter Server.The problem with one of the owners of the data center is that they wan

  • Photoshop cs6: snap a handle or other layers.

    PS CS6, Mac OS 10.6.8:It makes me crazy. During the movement of the layers, they snap to something.The only option that I found in the preferences is General-> Snap to vector tools and transformations of the pixel grid (whatever that means) I have un