Using SQL cumulative number

Hi guys,.

I have the following sql query:
select trim(to_char(to_date(substr(assn.creationdate,
                                   0,
                                   instr(assn.creationdate, ':', 1, 3) - 1),
                            'YYYY/MM/DD-HH24:MI:SS') + 10 / 24,
                    'mm')) || ' - ' ||
       to_char(to_date(substr(assn.creationdate,
                              0,
                              instr(assn.creationdate, ':', 1, 3) - 1),
                       'YYYY/MM/DD-HH24:MI:SS') + 10 / 24,
               'YYYY') as par_date,
       (case
         when prochis.stateoutreq = 't1Issued' then
          'A-Submit'
         when prochis.stateoutreq = 'LcsRejected' then
          'A-Return'
         when prochis.stateoutreq = 't3RevResp' then
          'A-Return'
         when prochis.stateoutreq = 'CcfReview' then
          'A-Return'
         when prochis.stateoutreq = 't3Validated' then
          'A-Return'
       end) as par_stage,
       count(case
               when (prochis.processname = 't3_AWD_Awaiting_Cust_Response') then
                1
               when (prochis.processname = 't3_AWD_Send_PAR') then
                1
               when (prochis.processname = 't3_AWD_Send_PAR_PartB') then
                1
               when (prochis.processname = 't3_AWD_Await_PAR_B_Response') then
                1
             end) as par_stage_count
  from awdbt1m4.cmchrqit par
  left outer join ttcadminref@TCDWHS aref
    on par.lifecyclestate = aref.short
 inner join awdbt1m4.asgsig assn
    on assn.left = par.obid
 inner join awdbt1m4.prochist prochis
    on assn.right = prochis.obid
 where (case
         when prochis.stateoutreq = 't1Issued' then
          'A-Submit'
         when prochis.stateoutreq = 'LcsRejected' then
          'A-Return'
         when prochis.stateoutreq = 't3RevResp' then
          'A-Return'
         when prochis.stateoutreq = 'CcfReview' then
          'A-Return'
         when prochis.stateoutreq = 't3Validated' then
          'A-Return'
         when prochis.statein = 't3IssPartB' then
          'B-Submit'
         when prochis.stateoutreq = 't3RevPartB' then
          'B-Return'
         when prochis.stateoutreq = 't1FinRev' then
          'B-Return'
       end) is not null
   and prochis.stateoutreq in
       ('t1Issued', 'LcsRejected', 't3RevResp', 'CcfReview', 't3Validated')
   and prochis.lifecyclename = 'PAR Lifecycle'
 group by trim(to_char(to_date(substr(assn.creationdate,
                                      0,
                                      instr(assn.creationdate, ':', 1, 3) - 1),
                               'YYYY/MM/DD-HH24:MI:SS') + 10 / 24,
                       'mm')) || ' - ' ||
          to_char(to_date(substr(assn.creationdate,
                                 0,
                                 instr(assn.creationdate, ':', 1, 3) - 1),
                          'YYYY/MM/DD-HH24:MI:SS') + 10 / 24,
                  'YYYY'),
          (case
            when prochis.stateoutreq = 't1Issued' then
             'A-Submit'
            when prochis.stateoutreq = 'LcsRejected' then
             'A-Return'
            when prochis.stateoutreq = 't3RevResp' then
             'A-Return'
            when prochis.stateoutreq = 'CcfReview' then
             'A-Return'
            when prochis.stateoutreq = 't3Validated' then
             'A-Return'
          end)
 order by par_stage
and I want to make a sum accumulated on the results returned by
 count(case
               when (prochis.processname = 't3_AWD_Awaiting_Cust_Response') then
                1
               when (prochis.processname = 't3_AWD_Send_PAR') then
                1
               when (prochis.processname = 't3_AWD_Send_PAR_PartB') then
                1
               when (prochis.processname = 't3_AWD_Await_PAR_B_Response') then
                1
             end) as par_stage_count
contained in the sql query.

I tried many ways to do it, but with the help of County and the amount in the same query with a group clause is causing many questions... Any help is greatly appreciated.

If I add the following section to the application after the statement of counting: over (partition by column) I - not a group expression error message.

Thank you
Rohan

Published by: rbha4 on 11/03/2010 15:45

Could you place everything in a view online and apply the analytical function in the outer query?

Tags: Database

Similar Questions

  • How to count the number of columns in an oracle table using sql

    How to count the number of columns in an oracle table using sql

    You must put the name of the table in capital letters

    As

    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = 'EMP';
    
    or
    
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = UPPER('Emp');
    

    Concerning
    Arun

  • XML data in the table using sql/plsql

    Hi experts,

    Could you please help with the following requirement. I have the tags xml (.xml on a server file) below. I need to access this file and read the XML and insert into the db table using sql and plsql. Is it possible with the cdata below? And there is a nested this table.

    Could someone please guide me if you have a sample code file and xml.

    <? XML version = "1.0" encoding = "UTF-8"? >

    < generation_date > <! [CDATA [17/11/2015]] > < / generation_date >

    < generated_by > <! [CDATA [Admin Admin]] > < / generated_by >

    < year > <! [CDATA [2015]] > < / year >

    < month > <! [CDATA [01]] > < / month >

    < author >

    < author > <! [CDATA [user author]] > < / author > < author_initial > <! [CDATA [user]] > < / author_firstname > < author_country > <! [CDATA [author]] > < / author_lastname >

    < author_email > <! [CDATA [[email protected]]] > < / author_email >

    < author_data_01 > <! [CDATA []] > < / author_data_01 >

    < author_data_02 > <! [CDATA []] > < / author_data_02 >

    < items >

    < article_item >

    < article_id > <! [CDATA [123456]] > < / article_id >

    < publication > <! [CDATA [Al Bayan]] > < / publication >

    < section > <! [CDATA [Local]] > < / section >

    < issue_date > <! [CDATA [11/11/2015]] > < / issue_date >

    < page > <! [CDATA [2]] > < / print this page >

    < article_title > <! [CDATA [title.]] > < / article_title > < number_of_words > <! [CDATA [165]] > < / number_of_words >

    < original_price > <! [CDATA [200]] > < / original_price >

    < original_price_currency > <! [CDATA [DEA]] > < / original_price_currency >

    < price > <! [CDATA [250]] > < / price >

    < price_currency > <! [CDATA [DEA]] > < / price_currency >

    < / article_item >

    < / articles >

    < total_amount > <! [CDATA [250]] > < / total_amount >

    < total_amount_currency > <! [CDATA [DEA]] > < / total_amount_currency >

    < / author >

    < / xml >

    Thanks in advance,

    Suman

    XMLTABLE using...

    SQL > ed
    A written file afiedt.buf

    1 with t (xml) as (select xmltype ('))
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [[12 [email protected]]] >
    13
    14
    15
    16
    17
    18
    19


    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33 ") of the double)"
    34-

    35 end of sample data
    36-
    37 - assumptions:
    (38 - a) XML may have several tags
    (39 - b) each may contain more
    40-
    41 select x.gen_by, x.gen_date, x.mn, x.yr
    42, y.author, y.auth_fn, y.auth_ln, y.auth_cnt, y.auth_em, y.auth_d1, y.auth_d2

    43, z.id, z.pub, z.sec, z.iss_dt, z.pg, z.art_ttl, z.num_wrds, z.oprice, z.ocurr, z.price, z.curr
    44 t
    45, xmltable ('/ authxml')
    from $ 46 t.xml
    path of 47 columns gen_date varchar2 (10) '. / generation_date'
    48, path of varchar2 (15) of gen_by '. / generated_by'
    49, path of varchar2 (4) year '. "/ year"
    50 varchar2 (2) mn road '. "/ month"
    51, path of xmltype authors '.'
    52                 ) x
    53, xmltable ('/ authxml/authors ')
    from $ 54 x.authors
    author of 55 path of varchar2 columns (15) '. / author'
    56, path of varchar2 (10) of auth_fn '. / author_firstname'
    57, path of varchar2 (10) of auth_ln '. / author_lastname'
    58 road of VARCHAR2 (3) auth_cnt '. / author_country'
    59 road of varchar2 (20) of auth_em '. / author_email'
    60 road of varchar2 (5) of auth_d1 '. / author_data_01'
    61, path of varchar2 (5) of auth_d2 '. / author_data_02'
    62, path of xmltype articles '. / Articles'
    63                 ) y
    64, xmltable ('/ Articles/article_item ')
    from $ 65 y.articles
    path id 66 number columns '. / article_id'
    67, path of varchar2 (10) pub '. ' / publication.
    68 road of varchar2 (10) dry '. / section'
    69, path of varchar2 (10) of iss_dt '. / issue_date'
    70 road of VARCHAR2 (3) pg '. "/ print this page"
    71, path of varchar2 (20) of art_ttl '. / article_title'
    72, path of varchar2 (5) of num_wrds '. / number_of_words'
    73, path of varchar2 (5) of oprice '. / original_price'
    74 road to VARCHAR2 (3) ocurr '. / original_price_currency'
    75, path of varchar2 (5) price '. "/ price"
    76, path of VARCHAR2 (3) curr '. / price_currency'
    77*                ) z
    SQL > /.

    GEN_DATE GEN_BY YEAR MN AUTHOR AUTH_FN AUTH_LN AUT AUTH_EM AUTH_ AUTH_ ID PUB DRY ISS_DT PG ART_TTL NUM_W OPRIC HEARTS PRICE OCU
    ---------- --------------- ---- -- --------------- ---------- ---------- --- -------------------- ----- ----- ---------- ---------- ---------- ---------- --- -------------------- ----- ----- --- ----- ---
    17/11/2015 Admin Admin 2015 01 user author user author [email protected] 123456 UAE Al Bayan Local 11/11/2015 2 is the title.   165 200 AED AED 250

    Of course, you'll want to change the types of data, etc. as needed.

    I assumed that the XML can contain several "" sections and that each section can contain several entries.

    Thus the XMLTABLE aliasing as 'x' gives information of XML, and supplies the data associated with the XMLTABLE with alias 'y' which gets the multiple authors, which itself section of the XMLTABLE with alias 'z' for each of the article_item.

    CDATA stuff are handled automatically by SQLX (XML functionality integrated into Oracle's SQL)

  • 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)

  • DatabaseMetaData and ResultSetMetaData return different codes of Type SQL for number

    Hello

    I was testing the code of a colleague who used ResultSetMetaData who was retrieved with Statement.getMetaData () of a select statement. ResultSetMetaData.getColumnType (I) returned 2 (digital) for the SQL type number. My DatabaseMetaData used test code comes from Connection.getMetaData (). DatabaseMetaData.getColumns returned 3 (decimal) for the SQL number type.

    Here is a snippet of code to illustrate the issue:

    The database must contain table MY_TABLE with a column of type "digital."

    String username = "user";

    String password = "password";

    String host = "host".

    Port of String = "port";

    String sid = 'sid ';


    DriverManager.registerDriver (new oracle.jdbc.OracleDriver ());

    Connection connection =

    DriverManager.getConnection ("JDBC: thin: @" + host + ': ' + port + ': ' + sid, user, password);

    Get the SQL with DatabaseMetaData type

    Metadata DatabaseMetaData = connection. getMetaData();

    ResultSet tables is metadata.getTables ( user, null,null, new String [] { "TABLE" });.

    My_table should be the first table

    if (tables. next()) {

    String tableName = table.getString (3);

    log.info (tableName);

    ResultSet columns is metadata.getColumns ( user, tableName,null, null);.

    while (columns. next()) {

    String columnName = columns.getString (4);

    String columnType = columns.getString (5);

    System.out.println (columnName + "' + columnType" ");

    Column type 3

    }

    columns. close();

    }

    tables. close();

    Get the SQL with ResultSetMetaData type

    Statement statement = connection. createStatement();

    String SQL = ' SELECT * FROM my_table ';

    . Perform statement(sql);

    ResultSet resultSet = statement. getResultSet();

    ResultSetMetaData metaData2 = resultSet. getMetaData();

    for (int i = 1; I < = metaData2. getColumnCount(); i++) {

    System.out.println (metaData2.getColumnName (I) + "' .getColumnType metaData2(i) +" ");

    Column type is 2

    }

    Is there a reason for the discrepancy?

    Kind regards

    Johannes

    A bug has been filed for this. You must get your license in any case. ojdbc14 is the obsolete way.

  • 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

  • Demonstrating the PL/SQL using SQL Developer functions

    Good afternoon

    I started writing some PL/SQL functions to replace some of the SQL I use most often.  Some very simple examples would be:

    create or replace function func_test (p_1 number) return number
    
    is
    
    x number;
    y number;
    
    begin
    
    
    x :=1;
    y :=2;
    
    
    return p_1 * x * y;
    
    
    end func_test;
    
    

    create or replace function func_test2 (p_1 varchar2) return varchar2
    
    
    is
    
    
    return_val varchar2(10);
    
    
    begin
    
    
    select p_1 into return_val from dual;
    
    
    return return_val;
    
    
    end func_test2;
    

    However, on my place of work that I have not been granted created function privileges again until I can show some examples, which is understandable.

    For the moment, without these privileges, is there a way I can build/test functions in principle locally using SQL Developer without the need to write functions in our database? I.e. can demonstrate meanings in SQL Developer, but devoid of envelope to create or syntax of replace?

    I hope that's not too vague.

    Using Oracle 11 g 2 (not connected to the database of the workplace at this time for a specific version not.)

    3.4 SQL Developer

    Thank you

    TP

    Hello

    The obvious solution is to get privileges.  If your employer wants to do you something, they give you the necessary privileges to do so.  It's silly for them to tell you to do something, but refuses to let you do.

    Otherwise, you can install Oracle on your own machine, as suggested above.  It's free and legitimate, if you only use it for learning and development.  Oracle Express Edition is very easy to install.

    As a last resort, you can write functions and procedures that are local to an anonymous block, like this:

    SET SERVEROUTPUT ON

    DECLARE
    Function func_test (p_1 number) return number
    is
    x number;
    number of y;
    Start
    x: = 1;
    y: = 2;
    return p_1 * x y;
    end func_test;
    BEGIN
    dbms_output.put_line (func_test (3))
    || '= func_test results.
    );
    END;
    /

    You can only call this kind of function of the anonymous block in which it is defined.

  • Replacement of alpha-numeric characters using SQL only

    Hello

    I have a field with the following distribution of the alpha-numeric

    C84 CW66, GED54,

    How can I change the following format for

    Cw 66, 54, C 84 GOL

    only by using SQL commands and not to the help of PL/SQL procedures or function?

    Thank you.

    Hello

    Welcome to the forum!

    REGEXP_REPLACE ( str     -- or maybe INITCAP (str)
                , '([[:alpha:]])([[:digit:]])'
                , '\1''\2'
                )
    

    Returns a copy of the str string, with a single quote added after each letter (upper or lower case) which was initially followed immediately by a number.
    If you want to change the case at the same time, use INITCAP (str) as 1st REGEXP_REPLACE argument.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always tell what version of Oracle you are using. REGEXP_REPLACE works in Oracle 10.1 or more.
    See the FAQ forum {message identifier: = 9360002}

  • How to insert data into a BLOB column using sql

    Hi all

    How to insert data into the BLOB column directly using sql.
    create  table temp
    (
      a blob,
      b clob);
    
    SQL> /
    Insert into temp  values ('32aasdasdsdasdasd4e32','adsfbsdkjf') ;
                                      *
    ERROR at line 1:
    ORA-01465: invalid hex number
    
    Please help in this.
    Thank you
    Prakash P

    Insert into temporary values (UTL_RAW. CAST_TO_RAW ('32aasdasdsdasdasd4e32'), 'adsfbsdkjf');

  • ORA-22901 when you use sql (no space) union

    I have a number of spatial views. I want to take some common fields and a column of the geometry of each of these points of view and use sql union to get a single view of all the data that meet certain criteria.

    Example:

    / / DESC View1
    Identification number,
    Comment varchar2 (200)
    geom mdsys.sdo_geometry

    View2 DESC
    Identification number
    Comment varchar2 (200)
    geom mdsys.sdo_geometry

    I want to do this:
    Create view viewUnion as
    SELECT id, comment, geom, viewname 'View1' View1
    Union
    SELECT id, comment, geom, "view2 viewname of view2;

    The creation of the view is accepted, but when I try select * from viewUnion; I get ORA-22901.

    Can I get there from here? Is there something about the space object that prevents the union from working?

    Any guidance will be appreciated.

    Thank you

    View of the "union all" is right for your application?
    i.e.

    Create view viewUnion as
    SELECT id, comment, geom, viewname 'View1' View1
    Union of all the
    SELECT id, comment, geom, "view2 viewname of view2;

  • Cumulative NUMBER

    Hello

    Anyone know how I can reach a cumulative number?

    For example, I have the select statement:

    Select deptno from scott.emp

    20
    30
    30
    40
    20
    10

    what I get is the following:

    DEPTNO County

    20 1
    30 2
    30 2
    40 3
    20 3
    4 of 10

    I'm playing my mind with analithycal functions, but without result so far.

    Have a tip?

    Thank you in advance!

    Published by: user817006 on January 23, 2009 06:15

    user817006 wrote:
    No, he should count on all ranks, how many separate departments are to this day. Like this:

    Well you shouldn't change your needs when someone is already working on it. ; P

    SQL> ed
    Wrote file afiedt.buf
    
      1  select deptno, sum(rn) over (partition by 1 order by empno) cnt
      2  from (
      3    select empno, deptno, decode(row_number() over (partition by deptno order by empno),1,1,0) rn
      4    from emp
      5    )
      6* order by empno
    SQL> /
    
        DEPTNO        CNT
    ---------- ----------
            20          1
            30          2
            30          2
            20          2
            30          2
            30          2
            10          3
            20          3
            10          3
            30          3
            20          3
            30          3
            20          3
            10          3
    
    14 rows selected.
    
    SQL>
    
  • I lost my ipad I need to add the device to icloud by using the serial number. Can I do this?

    I lost my ipad I need to add the device to icloud by using the serial number. Can I do this?

    N ° you can not add it without physical access to the device.

  • IMessage will use the telephone number; use a colurriel instead

    I had no service iphone since February, so I only use imessage on wifi. Today, however, he ceased to imessages send my phone number, and I don't know what to do. I tried to turn on and off imessage but it said activation pending and send & receive there is a circle of loading of my phone number and number highlighted grey. I've never had this happen before that I am at a loss

    UH I have never asked a question here but: iPhone 5. 64G, about 38 available; I don't know what everything is on my phone :-/

    beachpickle wrote:

    I got no service iphone since February

    This is perhaps the reason for your question?  You use an iPhone that has no telephone service?  So you have no cellular carrier currently associated with the iPhone?  Yet, you want to use this phone number non-functional as the mechanism for your iMessages?

  • How and where can I find my Macbook Pro using the model number

    How and where can I find my Macbook Pro "using the MODEL number" NOT the serial NUMBER please...

    Hello world:

    I would like to know more about my MacbookPro using model # is if there is a website or a program that I can type my model # so she'll tell me more on my computer...?

    http://www.EveryMac.com

  • Using a Skype number for working

    Hello

    I live in Italy and I work for a Dutch company. I'll have to call a large number of Dutch customers and they should be able to remember. It's very expensive to call with my phone to other countries, so I was thinking of using Skype for this. Of course, if I use Skype to call, I also want people to call me on Skype while I don't need to use my phone at all. That's why I read on the Skype number that seems a good idea. However, I have a few questions.
    1. I understand that does not allow the number of Skype to call, because you have to buy credits. I understand that, but my question is if buy Skype credit and I'm connected with my Skype number, when I call clients, they see my Skype number? It would be perfect if they can remember easily.

    I hope you can help me with this question.

    Kind regards
    Laura

    A number of Skype is for people to call you only and didn't need to make credit or any other subscription that I am aware, so you get your number Skype in Holland and they can contact you at the national rate rather than international rates.

    You can set up identification of the calling line, this "Caller ID" Skype call, you can use your Skype number in there, or your number of laptop if you want to receive texts, your choice, but be aware that some parts of the country, telecommunications companies and even individuals turn off this option isn't 100% that each person you are calling will see your number , but most.

    To make calls from phone numbers you need credits or a subscription, from what I've seen and developed, subscriptions work cheaper than the credits and the bigger the package you sub for best case, given you call another European country, I'd watch the landline and mobile phones Europe unlimited, but you can just get a package for the call of the Nederland , your choice, but if you pay every month it's more expensive to pay each year.

    If you have a subscription, you get a discount on your Skype number subscription, look the best deal for you.

    Hope that helps.

Maybe you are looking for

  • How can I fix this terminal?

    Hello I was not able to type in my terminal for the past four months. Please any assistance to resolve this problem will be very welcome. Kind regards Motun635.

  • Synchronization of the cells through arrays - (cell) <>- (B-cells)

    How can I synchronize the cells on sheets, tables or spreadsheets even so that I can change A cell and it updates the B cells or I change cell B and it changes a cell?

  • Lack driver download web page

    Hi, I had to post a new question due to the lack of response on a previous post. Just a quick and simple question: Where the driver download page went to the HP Envy 15 laptop computer 151sa j? I was more on the page only 2 weeks ago, and it isn't he

  • How to enable Windows Defender via Group Policy

    I had no problem when I ran Trend Titanium Internet Security with Windows Defender. Now that I've upgraded to Titanium Maximum Security 2012, my Windows Defender is disabled. Whenever I try to turn it on, he asks me to activate it via Group Policy. A

  • PC does not have two video cards installed

    I recently bought a HP Compaq 6005 Pro Athlon II desktop, running Windows 7 Pro 64 bit. I like to use two monitors, so I bought a XFX Plus Edition video card to run my second monitor. Now my PC only sees the new video card. Read the specs for the PC,