user input windows OS when loading data using sql loader

Hello
I have the oracle 11g Linux database.
I have excel sheets with data that must be loaded into the database.
I have oracle running on my windows client11g.

When I or anyone else is running the load sql script to load the data, I need to capture the user OS (the one that runs the script of their windows login) and pass it via the sql loader and insert into the table as a column value outside the columns in the excel sheet.

I think that this could be a very simple solution, I did some research but not just anywhere.
Can someone guide me on this.

Thanks in advance.
Philip.

Well, I built this example on the fly to show the answer. But it is based on documentation and previous experience with sql * loader or sys_context.

SQL * Loader Control File Reference
http://download.Oracle.com/docs/CD/E11882_01/server.112/e16536/ldr_control_file.htm#SUTIL005

SQL * Loader field list reference
http://download.Oracle.com/docs/CD/E11882_01/server.112/e16536/ldr_field_list.htm

SQL - SYS_CONTEXT language reference
http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions184.htm#SQLRF06117

This forum is a good source of examples, as well as asktom.oracle.com

Tags: Database

Similar Questions

  • How to view clob data using sql

    Hello

    In our database we have a table that is to have a column of type CLOB but now I want to display the data using sql select query but it throws error: "unsupported data Type.

    Could someone let me know how to view the clob data using the select query.

    Oracle DB version: 10.2.0.3

    Thank you

    user562223 wrote:
    Hello

    In our database we have a table that is to have a column of type CLOB but now I want to display the data using sql select query but it throws error: "unsupported data Type.

    Could someone let me know how to view the clob data using the select query.

    Oracle DB version: 10.2.0.3

    Thank you

    Usually a to_char (CLOBDFIELD) circled

    HTH,

    FJFranken

  • Re: Satellite A200 Windows crash when loading according to the decision

    Hello

    Recently, I had problems with my laptop during booting. Whenever I start my laptop after a stop, my laptop goes down while windows tries to load. However, when I try to start it up for the 2nd time, windows works perfectly. I tried to do the repair start several times but each time the laptop hangs on the window to the loading screen when I try to start it after the next stop.

    You are able to help me please because I don't think it's good to have it down whenever I turn it on my laptop.

    Thank you for your time and help,
    skyryan

    NOTE: I have the Satellite A200, running Windows Vista. Oh and recently I posted a problem with my computer laptop freeze after awakening from a sleep. I don't know if the two are related: S

    Hello

    You see, the windows repair is a fairly complicated procedure. I don't know if reinstalling the operating system is acceptable to you, but I would recommend.
    You can use image disk or hard drive recovery. And don't forget to save all the necessary staff.
    Even though I know that a lot of things about windows troubleshooting, I prefer reinstall problems rather fixing that can take a long time.

    Post edited by: Jeka-HE

  • Question to load data using sql loader in staging table, and then in the main tables!

    Hello

    I'm trying to load data into our main database table using SQL LOADER. data will be provided in separate pipes csv files.

    I have develop a shell script to load the data and it works fine except one thing.

    Here are the details of a data to re-create the problem.

    Staging of the structure of the table in which data will be filled using sql loader

    create table stg_cmts_data (cmts_token varchar2 (30), CMTS_IP varchar2 (20));

    create table stg_link_data (dhcp_token varchar2 (30), cmts_to_add varchar2 (200));

    create table stg_dhcp_data (dhcp_token varchar2 (30), DHCP_IP varchar2 (20));

    DATA in the csv file-

    for stg_cmts_data-

    cmts_map_03092015_1.csv

    WNLB-CMTS-01-1. 10.15.0.1

    WNLB-CMTS-02-2 | 10.15.16.1

    WNLB-CMTS-03-3. 10.15.48.1

    WNLB-CMTS-04-4. 10.15.80.1

    WNLB-CMTS-05-5. 10.15.96.1

    for stg_dhcp_data-

    dhcp_map_03092015_1.csv

    DHCP-1-1-1. 10.25.23.10, 25.26.14.01

    DHCP-1-1-2. 56.25.111.25, 100.25.2.01

    DHCP-1-1-3. 25.255.3.01, 89.20.147.258

    DHCP-1-1-4. 10.25.26.36, 200.32.58.69

    DHCP-1-1-5 | 80.25.47.369, 60.258.14.10

    for stg_link_data

    cmts_dhcp_link_map_0309151623_1.csv

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5

    DHCP-1-1-3. WNLB-CMTS-01-1

    DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3

    DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7

    WNLB-DHCP-1-13 | WNLB-CMTS-02-2

    Now, after loading these data in the staging of table I have to fill the main database table

    create table subntwk (subntwk_nm varchar2 (20), subntwk_ip varchar2 (30));

    create table link (link_nm varchar2 (50));

    SQL scripts that I created to load data is like.

    coil load_cmts.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_cmts IS SELECT *.

    OF stg_cmts_data;

    TYPE t_stg_cmts IS TABLE OF stg_cmts_data % ROWTYPE INDEX BY pls_integer;

    l_stg_cmts t_stg_cmts;

    l_cmts_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_cmts.

    Get the c_stg_cmts COLLECT in BULK IN l_stg_cmts;

    BECAUSE me IN l_stg_cmts. FIRST... l_stg_cmts. LAST

    LOOP

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_cmts (i) .cmts_token;

    IF l_cmts_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_cmts (i) .cmts_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_cmts (i) .cmts_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_cmts EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for dhcp


    coil load_dhcp.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_dhcp IS SELECT *.

    OF stg_dhcp_data;

    TYPE t_stg_dhcp IS TABLE OF stg_dhcp_data % ROWTYPE INDEX BY pls_integer;

    l_stg_dhcp t_stg_dhcp;

    l_dhcp_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_dhcp.

    Get the c_stg_dhcp COLLECT in BULK IN l_stg_dhcp;

    BECAUSE me IN l_stg_dhcp. FIRST... l_stg_dhcp. LAST

    LOOP

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_dhcp (i) .dhcp_token;

    IF l_dhcp_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_dhcp (i) .dhcp_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_dhcp (i) .dhcp_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_dhcp EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for link -.

    coil load_link.log

    Set serveroutput on

    DECLARE

    l_cmts_1 VARCHAR2 (4000 CHAR);

    l_cmts_add VARCHAR2 (200 CHAR);

    l_dhcp_cnt NUMBER;

    l_cmts_cnt NUMBER;

    l_link_cnt NUMBER;

    l_add_link_nm VARCHAR2 (200 CHAR);

    BEGIN

    FOR (IN) r

    SELECT dhcp_token, cmts_to_add | ',' cmts_add

    OF stg_link_data

    )

    LOOP

    l_cmts_1: = r.cmts_add;

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = r.dhcp_token;

    IF l_dhcp_cnt = 0 THEN

    DBMS_OUTPUT. Put_line ("device not found: ' |") r.dhcp_token);

    ON THE OTHER

    While l_cmts_add IS NOT NULL

    LOOP

    l_add_link_nm: = r.dhcp_token |' _TO_' | l_cmts_add;

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = TRIM (l_cmts_add);

    SELECT COUNT (1)

    IN l_link_cnt

    LINK

    WHERE link_nm = l_add_link_nm;

    IF l_cmts_cnt > 0 AND l_link_cnt = 0 THEN

    INSERT INTO link (link_nm)

    VALUES (l_add_link_nm);

    DBMS_OUTPUT. Put_line (l_add_link_nm |) » '||' Has been added. ") ;

    ELSIF l_link_cnt > 0 THEN

    DBMS_OUTPUT. Put_line (' link is already present: ' | l_add_link_nm);

    ELSIF l_cmts_cnt = 0 then

    DBMS_OUTPUT. Put_line (' no. CMTS FOUND for device to create the link: ' | l_cmts_add);

    END IF;

    l_cmts_1: = TRIM (SUBSTR (l_cmts_1, INSTR (l_cmts_1, ',') + 1));

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    END LOOP;

    END IF;

    END LOOP;

    COMMIT;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    control files -

    DOWNLOAD THE DATA

    INFILE 'cmts_data.csv '.

    ADD

    IN THE STG_CMTS_DATA TABLE

    When (cmts_token! = ") AND (cmts_token! = 'NULL') AND (cmts_token! = 'null')

    and (cmts_ip! = ") AND (cmts_ip! = 'NULL') AND (cmts_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:cmts_token))' cmts_token,

    cmts_ip ' RTRIM (LTRIM(:cmts_ip)) ")". "

    for dhcp.


    DOWNLOAD THE DATA

    INFILE 'dhcp_data.csv '.

    ADD

    IN THE STG_DHCP_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (dhcp_ip! = ") AND (dhcp_ip! = 'NULL') AND (dhcp_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    dhcp_ip ' RTRIM (LTRIM(:dhcp_ip)) ")". "

    for link -.

    DOWNLOAD THE DATA

    INFILE 'link_data.csv '.

    ADD

    IN THE STG_LINK_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (cmts_to_add! = ") AND (cmts_to_add! = 'NULL') AND (cmts_to_add! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    cmts_to_add TANK (4000) RTRIM (LTRIM(:cmts_to_add)) ")" ""

    SHELL SCRIPT-

    If [!-d / log]

    then

    Mkdir log

    FI

    If [!-d / finished]

    then

    mkdir makes

    FI

    If [!-d / bad]

    then

    bad mkdir

    FI

    nohup time sqlldr username/password@SID CONTROL = load_cmts_data.ctl LOG = log/ldr_cmts_data.log = log/ldr_cmts_data.bad DISCARD log/ldr_cmts_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    nohup time username/password@SID @load_cmts.sql

    nohup time sqlldr username/password@SID CONTROL = load_dhcp_data.ctl LOG = log/ldr_dhcp_data.log = log/ldr_dhcp_data.bad DISCARD log/ldr_dhcp_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_dhcp.sql

    nohup time sqlldr username/password@SID CONTROL = load_link_data.ctl LOG = log/ldr_link_data.log = log/ldr_link_data.bad DISCARD log/ldr_link_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_link.sql

    MV *.log. / log

    If the problem I encounter is here for loading data in the link table that I check if DHCP is present in the subntwk table, then continue to another mistake of the newspaper. If CMTS then left create link to another error in the newspaper.

    Now that we can here multiple CMTS are associated with unique DHCP.

    So here in the table links to create the link, but for the last iteration of the loop, where I get separated by commas separate CMTS table stg_link_data it gives me log as not found CMTS.

    for example

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    Here, I guess to link the dhcp-1-1-1 with balancing-CMTS-01-1 and wnlb-CMTS-02-2

    Theses all the data present in the subntwk table, but still it gives me journal wnlb-CMTS-02-2 could not be FOUND, but we have already loaded into the subntwk table.

    same thing is happening with all the CMTS table stg_link_data who are in the last (I think here you got what I'm trying to explain).

    But when I run the SQL scripts in the SQL Developer separately then it inserts all valid links in the table of links.

    Here, she should create 9 lines in the table of links, whereas now he creates only 5 rows.

    I use COMMIT in my script also but it only does not help me.

    Run these scripts in your machine let me know if you also get the same behavior I get.

    and please give me a solution I tried many thing from yesterday, but it's always the same.

    It is the table of link log

    link is already present: dhcp-1-1-1_TO_wnlb-cmts-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-02-2

    link is already present: dhcp-1-1-2_TO_wnlb-cmts-03-3
    link is already present: dhcp-1-1-2_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-5

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-8
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-6
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-0

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-03-3

    link is already present: dhcp-1-1-5_TO_wnlb-cmts-02-2
    link is already present: dhcp-1-1-5_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-7

    Device not found: wnlb-dhcp-1-13

    IF NEED MORE INFORMATION PLEASE LET ME KNOW

    Thank you

    I felt later in the night that during the loading in the staging table using UNIX machine he created the new line for each line. That is why the last CMTS is not found, for this I use the UNIX 2 BACK conversion and it starts to work perfectly.

    It was the dos2unix error!

    Thank you all for your interest and I may learn new things, as I have almost 10 months of experience in (PLSQL, SQL)

  • Error loading data using SQL loader

    I get an error message like "SQL * Loader - 350 combination illegal syntax of non-alphanumeriques characters error during loading of a file using SQL loader in RHEL." The command used to run SQL * Loader is:

    Sqlldr userid = < user name > / < password > control = data.ctl

    The control file is data.ctl:

    DOWNLOAD the data

    INFILE ' / home/oraprod/data.txt'

    Add in the table test

    {

    EmpID completed by «,»,

    fname completed by «,»,

    lname completed by «,»,

    treatment is completed with a white space

    }

    The data.txt file is:

    1, Kaushal, Hamad, 5000

    2, Chetan, Hamad, 1000

    Hopefully, my question is clear.

    Please get back with the answer to my query.

    Concerning

    Replace "{" by "("dans votre fichier de contrôle) "

    DOWNLOAD the data

    INFILE 'c:\data.txt.

    Add the emp_t table

    (

    EmpID completed by «,»,

    fname completed by «,»,

    lname completed by «,»,

    treatment is completed with a white space

    )

    C:\>sqlldr user/pwd@database control = c.ctl

    SQL * Loader: release 10.2.0.3.0 - Production on Wed Nov 13 10:10:24 2013

    Copyright (c) 1982, 2005, Oracle.  All rights reserved.

    Commit the point reached - the number of logical records 1

    Commit the point reached - the number of logical records 2

    SQL > select * from emp_t;

    EMPID, FNAME LNAME SALARY

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

    1 kone hamadi 5000

    2 Chetan Hamad 1000

    Best regards

    Mohamed Houri

  • Select quarterly data using SQL

    All-

    The database version that I use is 10.2.0.4.0

    This is probably simple, but for the life of me, I can't understand it. I have a table of approximately 200 Codes and a table that contains millions of records that are obliterated (data are from 1995 to sysdate). I need a query for a view to be used in a report that will show you the different codes used by the employee for specific areas based on a date parameter. If they have no data for this quarter I want to still show the quarter show 0 for the number.

    I created this simple example. If I see someone how I can integrate this logic in what I do.

    SQL for the test data:
    create the table bunch_of_codes
    (id_code number (12) primary key,)
    Description varchar2 (10));

    insert into bunch_of_codes
    values (1, 'APPLE');

    insert into bunch_of_codes
    values (2, 'ORANGE');

    insert into bunch_of_codes
    values (3, 'GRAPE');

    create the table bunch_of_data
    (id_code, number (12),)
    date of activity_date,
    CONSTRAINT data_id_code
    FOREIGN KEY (id_code) REFERENCES bunch_of_codes (id_code));

    INSERT INTO bunch_of_data
    VALUES (1, to_date('4/12/2011','MM/DD/YYYY'));

    INSERT INTO bunch_of_data
    VALUES (1, to_date('6/1/2011','MM/DD/YYYY'));

    INSERT INTO bunch_of_data
    VALUES (3, to_date('1/15/2011','MM/DD/YYYY'));

    INSERT INTO bunch_of_data
    VALUES (3, to_date('4/17/2011','MM/DD/YYYY'));

    INSERT INTO bunch_of_data
    VALUES (3, to_date('11/11/2011','MM/DD/YYYY'));

    COMMIT;

    What I see when I run the SQL statement is:
    DESCRIPTION QUARTER COUNTY
    ----------- ------- -----
    APPLE 1 0
    2 2 APPLE
    APPLE 3 0
    APPLE 4 0
    1 1 GRAPE
    1 2 GRAPES
    GRAPES 3 0
    4 1 GRAPE
    ORANGE 1 0
    ORANGE 2-0
    ORANGE 3 0
    ORANGE 4 0

    I need each printed code without worrying if it was not used. If it has not been used, I want to still see each quarter but show 0 for count.

    For this example, I can run this SQL to join the data:
    Select c.description,
    to_char(d.activity_date,'Q') quarter,
    Count County (d.id_code)
    of bunch_of_codes c,.
    bunch_of_data d
    where c.id_code = d.id_code
    C.description group, to_char(d.activity_date,'Q')
    order of description, quarter

    But if it is not no matter how much detail for the quarter then I don't get a row of data. I tried all sorts of things, but nothing seems to work.

    Please help if you have any ideas.

    Hi MLBrown,

    Here's a query that gives what you asked.
    Note: My table bunch_of_data has three lines that you have published, more a fourth line (the activity_date of this row is April 12, 2010, in the format DD-MON-YYYY).
    To account for the response you gave to the question of Etbin, a column Y (for data year) is included in the output. In this output, there is for the year, Q for the quarter and the total for the count.

    SQL> select * from bunch_of_codes;
    
       ID_CODE DESCRIPTION
    ---------- -----------
             1 APPLE
             2 ORANGE
             3 GRAPE
    
    SQL> select * from bunch_of_data;
    
       ID_CODE ACTIVITY_DATE
    ---------- ---------------
             1 12-APR-2010
             1 12-APR-2011
             1 01-JUN-2011
             3 15-JAN-2011
             3 17-APR-2011
             3 11-NOV-2011
    
    6 rows selected.
    
    SQL> with a as(select mi + level - 1 as y
      2            from (select min(extract(year from activity_date)) mi,
      3                         max(extract(year from activity_date)) ma
      4                         from bunch_of_data
      5                 )
      6           connect by level <= ma - mi + 1
      7            ),
      8       qt as(select '1' q from   dual
      9            union all
     10            select '2' from dual
     11            union all
     12            select '3' from dual
     13            union all
     14            select '4' from dual),
     15       allt as(select b.id_code,b.description,a.y, qt.q  as q
     16              from   bunch_of_codes b,a,qt
     17              ),
     18       temp as(select id_code,y,q,count(1) co
     19      from (select bd.id_code,extract(year from bd.activity_date) y,
     20                   to_char(bd.activity_date,'Q') q
     21      from   bunch_of_data bd)
     22      group by id_code, y,q)
     23      select allt.id_code,allt.description,allt.y,allt.q,nvl(co,0) total
     24      from allt,temp
     25      where allt.id_code =temp.id_code(+)
     26            and  allt.y=temp.y(+)
     27            and allt.q=temp.q(+)
     28      order by allt.id_code, allt.y, allt.q;
    
       ID_CODE DESCRIPTION          Y Q      TOTAL
    ---------- ----------- ---------- - ----------
             1 APPLE             2010 1          0
             1 APPLE             2010 2          1
             1 APPLE             2010 3          0
             1 APPLE             2010 4          0
             1 APPLE             2011 1          0
             1 APPLE             2011 2          2
             1 APPLE             2011 3          0
             1 APPLE             2011 4          0
             2 ORANGE            2010 1          0
             2 ORANGE            2010 2          0
             2 ORANGE            2010 3          0
    
       ID_CODE DESCRIPTION          Y Q      TOTAL
    ---------- ----------- ---------- - ----------
             2 ORANGE            2010 4          0
             2 ORANGE            2011 1          0
             2 ORANGE            2011 2          0
             2 ORANGE            2011 3          0
             2 ORANGE            2011 4          0
             3 GRAPE             2010 1          0
             3 GRAPE             2010 2          0
             3 GRAPE             2010 3          0
             3 GRAPE             2010 4          0
             3 GRAPE             2011 1          1
             3 GRAPE             2011 2          1
    
       ID_CODE DESCRIPTION          Y Q      TOTAL
    ---------- ----------- ---------- - ----------
             3 GRAPE             2011 3          0
             3 GRAPE             2011 4          1
    
    24 rows selected.
    
    SQL>
    

    Edited by: Manguilibe Jan 28 KAO. 2012 01:06

  • Logic to find particular weekdays after a given date, using SQL

    Hello Experts,

    Version: Oracle 11G

    Could you please help me with logic to find a day of special week after a date in SQL
    For example, I need to know the first Friday after today's date.

    Thank you for your help.

    I hope that under query will be useful for you.

    SELECT NEXT_DAY(SYSDATE,'FRIDAY') "NEXT DAY"
    FROM DUAL
    
    Output:
    
            NEXT DAY
         2/24/2012 12:06:48 PM
    
  • To change the way of afficherdans the data using SQL

    I have data as follows:

    Name age
    Tom 24
    Harry 45
    Mona 30


    I want to convert these data in the way below

    Name1, name2 Age1 Age2 Name3 3
    24 45 30 Mona Harry Tom



    How can I do the same thing using SQL?

    Why not try to search this forum of 'PIVOT' to make this small change yourself?

    SQL> set line 1000
    SQL> WITH t AS (SELECT 101 empid,45 marks,8 rank FROM dual UNION ALL
      2             SELECT 101 empid,62 marks,7 FROM dual UNION ALL
      3             SELECT 101 empid,80 marks,2 FROM dual UNION ALL
      4             SELECT 102 empid,67 marks,5 FROM dual UNION ALL
      5             SELECT 102 empid,56 marks,6 FROM dual UNION ALL
      6             SELECT 103 empid,87 marks,7 FROM dual UNION ALL
      7             SELECT 103 empid,55 marks,9 FROM dual UNION ALL
      8             SELECT 103 empid,60 marks,6 FROM dual UNION ALL
      9             SELECT 103 empid,70 marks,3 FROM dual
     10             )
     11  ---End of Sample Data
     12  ---Now the original query.
     13  SELECT empid, MAX(DECODE(rn1,1,marks)) Marks1,MAX(DECODE(rn1,1,rank)) Rank1
     14              , MAX(DECODE(rn1,2,marks)) Marks2,MAX(DECODE(rn1,2,rank)) Rank2
     15              , MAX(DECODE(rn1,3,marks)) Marks3,MAX(DECODE(rn1,3,rank)) Rank3
     16              , MAX(DECODE(rn1,4,marks)) Marks4,MAX(DECODE(rn1,4,rank)) Rank4
     17  FROM
     18     (SELECT empid,marks,rank,
     19      ROW_NUMBER() OVER(PARTITION BY empid ORDER BY marks) rn1
     20      FROM t)
     21  GROUP BY empid;
    
         EMPID     MARKS1      RANK1     MARKS2      RANK2     MARKS3      RANK3     MARKS4      RANK4
    ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
           101         45          8         62          7         80          2
           102         56          6         67          5
           103         55          9         60          6         70          3         87          7
    
    SQL> 
    
  • can I install windows vista when I currently use Server 2003?

    I am currently using windows 2003 server.  Being computer illiterate, I did not understand what I was installing.  I have windows vista and need to know if there is anything I should do before installing vista?  Thanks in advance.

    Save a copy of your data that you have to do a clean install (format).  You have to reinstall your applications.

  • How can I add a user in Windows XP when all users with administrative rights have been deleted?

    All administrative users have been deleted.

    All administrative users have been deleted.

    Windows XP family or Professional Edition?

    (The built-in Administrator account cannot be deleted in native mode.  Probably it is still there.)

    http://support.Microsoft.com/kb/321305

  • Importing data using SQL loader.

    Hi all

    I'm trying to import data from a txt file. I have created a CTL and the bat which I include below.

    CTL file
    LOAD DATA
    TRUNCATE
    INTO TABLE danint.VOIP
    FIELDS TERMINATED BY ','
    TRAILING NULLCOLS
    ( destination             INTEGER EXTERNAL
      destination_group       INTEGER EXTERNAL
      country                 CHAR,
      description             CHAR,
      off_peak_period         INTEGER EXTERNAL
      first_interval          INTEGER EXTERNAL
      next_interval           FLOAT EXTERNAL,
      first_price             DECIMAL EXTERNAL
      next_price              DECIMAL EXTERNAL
      off_peak_first_interval DECIMAL EXTERNAL
      off_peak_next_interval  DECIMAL EXTERNAL
      off_peak_first_price    DECIMAL EXTERNAL
      payback_rate            DECIMAL EXTERNAL
      forbidden               INTEGER EXTERNAL
      hidden                  INTEGER EXTERNAL
      discontinued            INTEGER EXTERNAL
      effective_from          DATE 'DD/MM/YYYY',
      formula                 INTEGER EXTERNAL
      report_date             DATE 'DD/MM/YYYY'
    )
    DATA
    995,,GEORGIA,Proper,,1,1,0.0795,0.0795,1,1,0.0795,0.0795
    995122,,GEORGIA,Sukhumi proper,,1,1,0.0795,0.0795,1,1,0.0795,0.0795
    9953,,GEORGIA,proper other,,1,1,0.0795,0.0795,1,1,0.0795,0.0795
    99532,,GEORGIA,Tblisi,,1,1,0.0668,0.0668,1,1,0.0668,0.0668
    9953226,,GEORGIA,Mobile Others,,1,1,0.0795,0.0795,1,1,0.0795,0.0795
    9953297,,GEORGIA,Tbilisi city,,1,1,0.0795,0.0795,1,1,0.0795,0.0795
    99544,,GEORGIA,Abkhazia,,1,1,0.3,0.3,1,1,0.3,0.3
    99555,,GEORGIA,Mobile Geocell,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99557,,GEORGIA,Mobile Geocell,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99558,,GEORGIA,Mobile Geocell,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99571,,GEORGIA,Mobile Others,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99574,,GEORGIA,Mobile Others,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99577,,GEORGIA,Mobile,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99577,,GEORGIA,Mobile,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99579,,GEORGIA,Mobile Others,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    9959,,GEORGIA,Mobile,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99593,,GEORGIA,Mobile,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99597,,GEORGIA,Mobile,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    99599,,GEORGIA,Mobile,,1,1,0.1528,0.1528,1,1,0.1528,0.1528
    30,,GREECE,Proper,,1,1,0.019,0.019,1,1,0.019,0.019
    BAT FILE
    REM LOADING VOIP Prices
    sqlldr system/manager@test control=C:\Library\Control\VOIP.CTL data=C:\Library\Data\VOIP.txt log=C:\Library\Log\VOIP.log rows=10000
    PAUSE
    TABLE
    -- Create table
    create table VOIP
    (
      destination             NUMBER,
      destination_group       NUMBER,
      country                 VARCHAR2(65),
      description             VARCHAR2(60),
      off_peak_period         NUMBER,
      first_interval          NUMBER,
      next_interval           NUMBER,
      first_price             NUMBER,
      next_price              NUMBER,
      off_peak_first_interval NUMBER,
      off_peak_next_interval  NUMBER,
      off_peak_first_price    NUMBER,
      off_peak_next_price     NUMBER,
      payback_rate            NUMBER,
      forbidden               NUMBER,
      hidden                  NUMBER,
      discontinued            NUMBER,
      effective_from          DATE,
      formula                 NUMBER,
      report_date             DATE
    )
    tablespace TEST
      pctfree 10
      initrans 1
      maxtrans 255
      storage
      (
        initial 560M
        next 1M
        minextents 1
        maxextents unlimited
      );
    I get the following error message, but the message seems meaningless, as the comma are in fact. Any ideas?


    ORA-28002: the password will expire in 6 days
    SQL * Loader-350: error of syntax in line 7.
    Expected ', 'or') ', found 'destination_group '.
    destination_group INTEGER EXTERNAL

    You are missing commas in the CTL file

    HTH
    Srini

  • Recovering data using SQL SERVER

    Hello
    We migrated an environment where Oracle has been store relational data, to one where it is SQLSERVER. I'm trying to load the relational source data into Essbase using rule files. (Nothing fancy) We are on 11.1.2.1

    My rule file Essbase, which in SQL embedded in it, returns the numeric columns apparently valid, but rejects essbase each records as if the numerical value was a value of text, for example, he says "Member 12345.67890' not found.


    View SQL SERVER sets the numeric columns (Numeric (38.5), null).

    Someone at - he met before & can help?

    Thank you

    You must validate your definition of the rule of load, something pushed and charge State treats the data as members of a dimension column.

  • Extract data using SQL Expression

    Hello, I created an intermediate table and just realized that I need some new additional fields.
    Should I create them in the scene or in the target table?

    I want to use the SQL COUNT expression to fill these new data sources published, fields
    but do not know exactly how do. I'm a little amateur.

    Thank you.

    You should check the analytical functions:

    http://www.orafaq.com/node/55

  • Support for copying data using sql

    Hello
    I want to fill the data in a table in a way
    EID     ENAME     EADDRESS     ESALARY     EDEPARTMENT     MANAGER_ID
    
    101     Pankaj Saxena     New Delhi     2000     IT     
    102     Sanjay Singh     New Delhi     2000     IT     101
    103     Dhiraj Tuteja     Kanpur     3000     NONIT     101
    104     Nitin Grover     New Delhi     4000     IT     102
    105     Juhi Agarwal     Itawa     5000     NONIT     103
    106     Siddharth     Itawa     5000     NONIT     103
    107     Kalyan     Itawa     7000     IT     104
    Now I want to fill the same data 10 times but the IDS must be incremented
    What should I do?
    I use oracle 9i
    insert into demo_1
    select eid,ename,eaddress,esalary,edepartment,manager_id from demo_1
    I have eid necessary to increase sequencially

    Create a sequence.

    insert into demo_1
    Select sq.nextval, ename, eaddress, esalary, edepartment, manager_id demo_1

  • How to choose the following data using sql?

    Hi people,

    I use oracle 10g.i have two tables as follows.

    PROGRAMMER
    PNAME                          DOB       DOJ       SEX   PROF1                          PROF2                             SALARY
    ------------------------------ --------- --------- ----- ------------------------------ ------------
    ALIAF                          02-JUL-64 02-JUL-90 M     CLIPPER                        COBOL                               2800
    JULIANA                        31-JAN-68 31-JAN-60 F     COBOL                          DBASE                               3000
    KAMALA                         30-OCT-68 30-OCT-92 F     C                              DBASE                               2900
    MARY                           24-JUN-78 24-JUN-91 F     C++                            ORACLE                              4500
    NELSON                         11-SEP-65 11-SEP-89 M     COBOL                          DBASE                               2500
    PARTICK                        10-NOV-65 10-NOV-90 M     PASCAL                         CLIPPER                             2800
    QADIR                          31-AUG-65 31-AUG-91 M     ASSEMBLY                       C                                   3000
    RAMESH                         03-MAR-67 03-MAR-91 M     PASCAL                         DBASE                               3200
    REBECCA                        01-JAN-67 01-JAN-90 F     BASIC                          COBOL                               2500
    REMITHA                        02-DEC-69 02-DEC-92 F     PASCAL                         BASIC                               3600
    REVATHI                        02-DEC-69 02-DEC-92 F     PASCAL                         BASIC                               3700
    VIJAYA                         14-DEC-65 14-DEC-92 F     FOXPRO                         C                                   3500
    ANAND                          21-APR-66 21-APR-92 M     PASCAL                         BASIC                               3200
    SOFTWARE
    PNAME                          TITLE                          DEV_IN                   DCOST     SCOST      SOLD
    ------------------------------ ------------------------------ -------------------- --------- -------
    ANAND                          PHARACHUTES                    BASIC                     6000       400        43
    ANAND                          VIDEO TITLLING PACK            PASCAL                   16000      7500         9
    JULIANA                        INVENTORY CONTROL              COBOL                     3500      3000         0
    KAMALA                         PAYROLL PACKAGE                DBASE                    20000      9000         7
    MARY                           FINANCIAL ACCOUNT              ORACLE                   85000     18000         4
    MARY                           CODE GENERATOR                 C                        20000      4500        23
    PARTICK                        READ ME                        C++                        900      2000        84
    QADIR                          BOMBAS AWAY                    ASSEMBLY                  5000       750        11
    QADIR                          VACCINES                       C                         3400      1900        21
    RAMESH                         HOTEL MANAGEMENT               DBASE                    35000     12000         4
    RAMESH                         DEAD LEE                       PASCAL                    4500       600        73
    REMITHA                        PC UTILITIES                   C                         5000       725        51
    REMITHA                        TRS HELP PACKAGE               ASSEMBLY                  6000      2500         6
    REVATHI                        HOSPITAL MANAGEMENT            PASCAL                   75000      1100         2
    REVATHI                        QUIZ MASTER                    BASIC                     2100      3200        15
    Now the task is to display the details of the software that has been developed in the language which is neither the first nor the second jurisdiction of the programmer.can u pls help me solve it.thanks in advance.


    Reg
    vids

    Now the task is I have to display the details of the software that has been developed in the language which is neither the first nor the second skill of the programmer

    SELECT s.*
    FROM   software s,
           programmer p
    WHERE  s.pname = p.pname
           AND s.dev_in NOT IN ( p.prof1, p.prof2 );  
    

Maybe you are looking for