Sql Count Help

Hi Everyone,
I need to display SPER_STATUS_TEXT count as 0 if there is no data for below Query. Could someone please help me
SQL> SELECT a.sper_status_text, COUNT ( * )
2 FROM (SELECT sper.assettxt,
3 CASE
4 WHEN sper.sper_status_text = 'Affirmed Evaluation'
5 THEN
6 'Affirmed Evaluation'
7 WHEN sper.sper_status_text LIKE 'Updated - Evaluated Up%'
8 THEN
9 'Updated - Evaluated Up'
10 WHEN sper.sper_status_text LIKE 'Updated - Evaluated Down%'
11 THEN
12 'Updated - Evaluated Down'
13 ELSE
14 'Other Responses'
15 END
16 sper_status_text
17 FROM zzcus.zzcus_sper_data sper
18 WHERE sper.sper_dates = '20100801--20100831'
19 AND sper.customer_id = 'NATFINS'
20 AND sper.task_inquiry_type = 'Vendor Comparison'
21 AND sper.assettxt <> '!NA'
22 ) a
23 GROUP BY a.sper_status_text
24 ORDER BY (CASE
25 WHEN a.sper_status_text = 'Affirmed Evaluation' THEN 1
26 WHEN a.sper_status_text = 'Updated - Evaluated Up' THEN 2
27 WHEN a.sper_status_text = 'Updated - Evaluated Down' THEN 3
28 ELSE 4
29 END);
Results:
SPER_STATUS_TEXT COUNT(*)
Affirmed Evaluation 2
I need to display like below (if there is no data I need to display count as 0)
SPER_STATUS_TEXT COUNT(*)
Affirmed Evaluation 2
Updated - Evaluated Up 0
Updated - Evaluated Down 0
Other Responses 0
Please Advice

You can get it like this. By using MODEL clause,
SQL>
SQL> CREATE TABLE ZZCUS_SPER_DATA1
  2  (
  3     SPER_STATUS_TEXT VARCHAR2 (30)
  4    ,TASK_INQUIRY_TYPE VARCHAR2 (100)
  5  );
Table created.
SQL>
SQL> INSERT INTO ZZCUS_SPER_DATA1
  2       VALUES (
  3                 'Data Updated', 'Descriptive Data Challenge - Maturity date / Redemption date');
1 row created.
SQL>
SQL> INSERT INTO ZZCUS_SPER_DATA1
  2       VALUES ('Data Updated', 'Descriptive Data Challenge - Ticker / Local Code');
1 row created.
SQL>
SQL> SELECT *
  2    FROM (  SELECT A.SPER_STATUS_TEXT, COUNT (*) CNT
  3              FROM (SELECT CASE
  4                              WHEN SPER.SPER_STATUS_TEXT = 'Data Confirmed'
  5                              THEN
  6                                 'Data Item Confirmed'
  7                              WHEN SPER.SPER_STATUS_TEXT LIKE 'Data Updated'
  8                              THEN
  9                                 'Data Item Updated'
10                              ELSE
11                                 'Other Responses'
12                           END
13                              SPER_STATUS_TEXT
14                      FROM ZZCUS_SPER_DATA1 SPER
15                     WHERE 1 = 1
16                           AND SPER.TASK_INQUIRY_TYPE LIKE 'Descriptive Data Challenge%') A
17          GROUP BY A.SPER_STATUS_TEXT
18          ORDER BY (CASE
19                       WHEN A.SPER_STATUS_TEXT = 'Data Item Confirmed' THEN 1
20                       WHEN A.SPER_STATUS_TEXT = 'Data Item Updated' THEN 2
21                       WHEN A.SPER_STATUS_TEXT = 'Other Responses' THEN 3
22                       ELSE 4
23                    END))
24  MODEL
25     DIMENSION BY (SPER_STATUS_TEXT)
26     MEASURES (CNT)
27     RULES
28        (CNT ['Data Item Confirmed'] = NVL (CNT[CV ()], 0),
29        CNT ['Data Item Updated'] = NVL (CNT[CV ()], 0),
30        CNT ['Other Responses'] = NVL (CNT[CV ()], 0));
SPER_STATUS_TEXT           CNT
Data Item Updated            2
Other Responses              0
Data Item Confirmed          0
3 rows selected.
SQL> G.

Similar Messages

  • [Mostly Sorted] Extracting tags - regexp_substr and count help needed!

    My original query got sorted, but additional regexp_substr and count help is required further on down!
    Hi,
    I have a table on a 10.2.0.3 database which contains a clob field (sql_stmt), with contents that look something like:
    SELECT <COB_DATE>, col2, .... coln
    FROM   tab1, tab2, ...., tabn
    WHERE tab1.run_id = <RUNID>
    AND    tab2.other_col = '<OTHER TAG>'(That's a highly simplified sql_stmt example, of course - if they were all that small we'd not be needing a clob field!).
    I wanted to extract all the tags from the sql_stmt field for a given row, so I can get my (well not "mine" - I'd never have designed something like this, but hey, it works, sorta, and I'm improving it as and where I can!) pl/sql to replace the tags with the correct values. A tag is anything that's in triangular brackets (eg. <RUNID> from the above example)
    So, I did this:
    SELECT     SUBSTR (sql_stmt,
                       INSTR (sql_stmt, '<', 1, LEVEL),
                       INSTR (substr(sql_stmt, INSTR (sql_stmt, '<', 1, LEVEL)), '>', 1, 1)
                       ) tag
    FROM       export_jobs
    WHERE      exp_id =  p_exp_id
    CONNECT BY LEVEL <= (LENGTH (sql_stmt) - LENGTH (REPLACE (sql_stmt, '<')))Which I thought would be fine (having tested it on a text column). However, it runs very poorly against a clob column, for some reason (probably doesn't like the substr, instr, etc on the clob, at a guess) - the waits show "direct path read".
    When I cast the sql_stmt as a varchar2 like so:
    with my_tab as (select cast(substr(sql_stmt, instr(sql_stmt, '<', 1), instr(sql_stmt, '>', -1) - instr(sql_stmt, '<', 1) + 1) as varchar2(4000)) sql_stmt
                    from export_jobs
                    WHERE      exp_id = p_exp_id)
    SELECT     SUBSTR (sql_stmt,
                       INSTR (sql_stmt, '<', 1, LEVEL),
                       INSTR (substr(sql_stmt, INSTR (sql_stmt, '<', 1, LEVEL)), '>', 1, 1)
                       ) tag
    FROM       my_tab
    CONNECT BY LEVEL <= (LENGTH (sql_stmt) - LENGTH (REPLACE (sql_stmt, '<')))it runs blisteringly fast in comparison, except when the substr'd sql_stmt is over 4000 chars, of course! Using dbms_lob instr and substr etc doesn't help either.
    So, I thought maybe I could find an xml related method, and from this link:get xml node name in loop , I tried:
    select t.column_value.getrootelement() node
      from (select sql_stmt xml from export_jobs where exp_id = 28) xml,
    table (xmlsequence(xml.xml.extract('//*'))) tBut I get this error: ORA-22806: not an object or REF. (It might not be the way to go after all, as it's not proper xml, being as there are no corresponding close tags, but I was trying to think outside the box. I've not needed to use xml stuff before, so I'm a bit clueless about it, really!)
    I tried casting sql_stmt into an xmltype, but I got: ORA-22907: invalid CAST to a type that is not a nested table or VARRAY
    Is anyone able to suggest a better method of trying to extract my tags from the clob column, please?
    Message was edited by:
    Boneist

    I don't know if it may work for you, but I had a similar activity where I defined sql statements with bind variables (:var_name) and then I simply looked for witch variables to bind in that statement through this query.
    with x as (
         select ':var1
         /*a block comment
         :varname_dontcatch
         select hello, --line comment :var_no
              ''a string with double quote '''' and a :variable '',  --:variable
              :var3,
              :var2, '':var1'''':varno'',
         from dual'     as string
         from dual
    ), fil as (
         select string,
              regexp_replace(string,'(/\*[^*]*\*/)'||'|'||'(--.*)'||'|'||'(''([^'']|(''''))*'')',null) as res
         from x
    select string,res,
         regexp_substr(res,'\:[[:alpha:]]([[:alnum:]]|_)*',1,level)
    from fil
    connect by regexp_instr(res,'\:[[:alpha:]]([[:alnum:]]|_)*',1,level) > 0
    /Or through these procedures
         function get_binds(
              inp_string in varchar2
         ) return string_table
         deterministic
         is
              loc_str varchar2(32767);
              loc_idx number;
              out_tab string_table;
         begin
              --dbms_output.put_line('cond = '||inp_string);
              loc_str := regexp_replace(inp_string,'(/\*[^*]*\*/)'||'|'||'(--.*)'||'|'||'(''([^'']|(''''))*'')',null);
              loc_idx := 0;
              out_tab := string_table();
              --dbms_output.put_line('fcond ='||loc_str);
              loop
                   loc_idx := regexp_instr(loc_str,'\:[[:alpha:]]([[:alnum:]]|_)*',loc_idx+1);
                   exit when loc_idx = 0;
                   out_tab.extend;
                   out_tab(out_tab.last) := regexp_substr(loc_str,'[[:alpha:]]([[:alnum:]]|_)*',loc_idx+1);
              end loop;
              return out_tab;
         end;
         function divide_string (
              inp_string in varchar2
              --,inp_length in number
         --return string_table
         return dbms_sql.varchar2a
         is
              inp_length number := 256;
              loc_ind_1 pls_integer;
              loc_ind_2 pls_integer;
              loc_string_length pls_integer;
              loc_curr_string varchar2(32767);
              --out_tab string_table;
              out_tab dbms_sql.varchar2a;
         begin
              --out_tab := dbms_sql.varchar2a();
              loc_ind_1 := 1;
              loc_ind_2 := 1;
              loc_string_length := length(inp_string);
              while ( loc_ind_2 < loc_string_length ) loop
                   --out_tab.extend;
                   loc_curr_string := substr(inp_string,loc_ind_2,inp_length);
                   dbms_output.put(loc_curr_string);
                   out_tab(loc_ind_1) := loc_curr_string;
                   loc_ind_1 := loc_ind_1 + 1;
                   loc_ind_2 := loc_ind_2 + length(loc_curr_string);
              end loop;
              dbms_output.put_line('');
              return out_tab;
         end;
         function execute_statement(
              inp_statement in varchar2,
              inp_binds in string_table,
              inp_parameters in parametri
         return number
         is
              loc_stat dbms_sql.varchar2a;
              loc_dyn_cur number;
              out_rows number;
         begin
              loc_stat := divide_string(inp_statement);
              loc_dyn_cur := dbms_sql.open_cursor;
              dbms_sql.parse(c => loc_dyn_cur,
                   statement => loc_stat,
                   lb => loc_stat.first,
                   ub => loc_stat.last,
                   lfflg => false,
                   language_flag => dbms_sql.native
              for i in inp_binds.first .. inp_binds.last loop
                   DBMS_SQL.BIND_VARIABLE(loc_dyn_cur, inp_binds(i), inp_parameters(inp_binds(i)));
                   dbms_output.put_line(':'||inp_binds(i)||'='||inp_parameters(inp_binds(i)));
              end loop;
              dbms_output.put_line('');
              --out_rows := DBMS_SQL.EXECUTE(loc_dyn_cur);
              DBMS_SQL.CLOSE_CURSOR(loc_dyn_cur);
              return out_rows;
         end;Bye Alessandro
    Message was edited by:
    Alessandro Rossi
    There is something missing in the functions but if there is something that may interest you you can ask.

  • Hey How Do I Get Group Message On The IPhone 4s because some reason it doesn't want to show . First i did is setting then messages  it only show imessage and message count )HELP)

    ey How Do I Get Group Message On The IPhone 4s because some reason it doesn't want to show . First i did is setting then messages  it only show imessage and message count )HELP)

    At the bottom of the page Settings > Messages you should have a section headed "SMS/MMS" Turn MMS messaging on then you can turn group message on.

  • Perform SQL COUNT from AS3

    Hi there all,
    Just working away as usual and I've encountered a problem with a flash app I'm making..
    I can save and load variables from flash to the mySQL database, but when I load up the results one after the other I eventually run out of results to display, which throws an error !!
    Is there a way I can perform an SQL COUNT from flash to determine the amount of results I have in the database and loop the viewer back to the first result ??
    Many Thanks in advance for any help

    This is how I am parsing and requesting the information.. I know it's in there somewhere I just can't get the variables, do I need to add them ? It's not making much sense to me at the moment, I'm sorry !! I need to add the variables to the request somehow.. so I can receive the info, no ?
    var tab = "SQLtab";
    var filesend = "path to php file";
    var modesend = "post";
    function variableTransaction(fichier, modesend, tab, var1, var2) {
         var URLload = new URLLoader();
         var URLrequest = new URLRequest(fichier);
         var variables:URLVariables = new URLVariables();
         variables.tab = tab;
         variables.var1 = var1;
         variables.var2 = var2;
         if (modesend == "post") {
              URLrequest.method = URLRequestMethod.POST;
         } else if ( modesend == "get") {
              URLrequest.method = URLRequestMethod.GET;
         if (var1 == false && var2 == false) {
              URLload.dataFormat = URLLoaderDataFormat.VARIABLES;
              URLrequest.data = variables;
              URLload.load(URLrequest);
              URLload.addEventListener(Event.COMPLETE, loadComplete, false, 0, true);
         } else {
              URLrequest.data = variables;
              URLload.load(URLrequest);
              var receiveObject = variableTransaction(filesend, modesend, tab, false, false);

  • SQL*Plus Help

    Hi! Does anyone know where i can download SQL*Plus Help? I need to get info on select syntax, sql built-in functions, etc..
    Thanks!

    hi
    you can proceed like this :
    go to the OTN
    the click on products.
    null

  • How to install SQL*Plus help facilities and demos.

    Hi, everyone
    It appears error message say "failure to login" during SQL*Plus
    part of the Oracle8 full installation. I knew that system want
    to install SQL*Plus help and demos through logining one of
    dba account(maybe system user account). However, due to
    password's reason, can not log in SQL*Plus, so installer can't
    execute named pupbld.sql script, result in SQL*Plus help and
    demos can not be installed.
    Now, I am intend to install these stuff lonely.
    Could anyone help me? thank a lot.
    William
    null

    Hi,
    The pupbld.sql isn't the correct script to create the help
    facility, it just creates product and user profile tables.
    The help script is at $ORACLE_HOME/sqlplus/admin/help (run as
    system)
    cd $ORACLE_HOME/sqlplus/admin/help
    sqlplus system/<password> @helptbl
    sqlldr system/<password> control=plushelp.ctl
    sqlldr system/<password> control=plshelp.ctl
    sqlldr system/<password> control=sqlhelp.ctl
    sqlplus system/<password> @helpindx
    I think it is necessary to run the pupbld.sql script, without
    this script everyone who logins in oracle with sqlplus will see
    an error message, but... Run the script again:
    $ORACLE_HOME/sqlplus/admin/pupbld.sql
    Best regards,
    Ari
    William (guest) wrote:
    : Hi, everyone
    : It appears error message say "failure to login" during SQL*Plus
    : part of the Oracle8 full installation. I knew that system want
    : to install SQL*Plus help and demos through logining one of
    : dba account(maybe system user account). However, due to
    : password's reason, can not log in SQL*Plus, so installer can't
    : execute named pupbld.sql script, result in SQL*Plus help and
    : demos can not be installed.
    : Now, I am intend to install these stuff lonely.
    : Could anyone help me? thank a lot.
    : William
    null

  • Will Oracle pl/sql certification help me get  IT job

    Hello guys,
    I have completed my B.tech in Computer Science, I am confused a bit , Can i get a job after getting certified in Oracle Associate Pl/sql developer

    1005323 wrote:
    Hello guys,
    I have completed my B.tech in Computer Science, I am confused a bit , Can i get a job after getting certified in Oracle Associate Pl/sql developerYou may get a job after achieving Pl/sql developer OCA
    You may get a job after without achieving Pl/sql developer OCA
    You may fail to get a job after achieving Pl/sql developer OCA
    You may fail to get a job after without achieving Pl/sql developer OCA
    There are several factors involved in getting a job. And there are several ways a job may be obtained. But usually there are there stages:
    - Stage Zero: A company but has a job to offer.
    - And you need to be aware of it. - A friend may tell you, or an agency may tell you. And it must suit you for location and remuneration etc.
    - Stage one: An interview is obtained with the company.
    - Stage two: The job is offered to you rather than anyone else and you find it acceptable.
    So ... to your question:
    "Can i get a job after getting certified in Oracle Associate Pl/sql developer?"
    Well .... there is only three possible answers ... yes, no, and maybe; and maybe is probably the only correct answer, and most people will have worked this out, which means the question may have not been the best question to have asked.
    (( That said I now read the title of the thread and it says: Re: Will Oracle pl/sql certification help me get IT job)
    I have been known on occasion to have been given a question by a boss.
    And I have answered him:
    "You have given me the wrong question
    The question you should have answer me is this.
    And the answer I will give you is this."
    And the boss goes away happy
    So you you a better question would have been:
    How much will an OCA PL/SQL certification increase my chances of getting a job?
    Mind you even that question won't help you get a much better answer.
    For a proportion of jobs where PL/SQL is relevant that will help (for those where it is not it might be occasionally be a problem), for people with identical CV's it sometimes might help get to interview stage. But there are other factors as well. For instance if I was thinking of giving you a job on the basis of your post I might for example:
    - Not be impressed with an "Hello Guys" greeting ( though this is a forum so that isn't relevant here).
    - Not be impressed with you being confused.
    - etc.
    You probably need to get a good appreciation of the job market in your locality; and the numbers of applicants for each job. Which jobs you can apply for, what is your skillset and knowing youself as well.
    Sometimes an ITIL certification may be a better differentiator for some positions in business. But it will depend on the job you can think you can get.

  • (SQL*PLUS HELP) RUNNING PUPBLD OR HELPINS ASKS FOR SYSTEM_PASS

    제품 : ORACLE SERVER
    작성날짜 : 2002-04-22
    (SQL*PLUS HELP) RUNNING PUPBLD OR HELPINS ASKS FOR SYSTEM_PASS
    ==============================================================
    PURPOSE
    이 내용은 SQL*Plus 상에서 SQL*Plus command의 help를 보기 위한 방법이다.
    Problem Description
    SQL*Plus command의 help를 보기 위해서 helpins를 수행하면
    SYSTEM_PASS is not set이라는 에러 메시지가 발생하는 경우가 있다.
    이 자료는 pupbld 또는 helpins를 수행하기 전에 SYSTEM_PASS 환경변수를
    셋팅하는 방법에 대한 자료이다.
    아래와 같은 에러가 발생하는 경우 조치 방법에 대해 알아본다.
    SYSTEM_PASS not set.
    Set and export SYSTEM_PASS, then restart help (for helpins or
    profile for pupbld) installation.
    Workaround
    none
    Solution Description
    이 스크립트는 system user로 database에 connect되어 수행되어야 한다.
    helpins를 수행하기 위해서는 SYSTEM_PASS 환경변수가 셋팅되어 있어야 한다.
    NOTE
    For security reasons, do not set this variable in your shell
    startup scripts. (i.e. .login or .profile.).
    Set this environment variable at the prompt.
    1. Prompt에서 환경변수를 셋팅하기
    For C shell:
    % setenv SYSTEM_PASS system/<password>
    For Korn or Bourne shells:
    $ SYSTEM_PASS=system/<password> ;export SYSTEM_PASS
    2. Now run "$ORACLE_HOME/bin/pupbld" or "$ORACLE_HOME/bin/helpins".
    % cd $ORACLE_HOME/bin
    % pupbld
    or
    % helpins
    주의사항
    $ORACLE_HOME/bin/pupbld 스크립트와 $ORACLE_HOME/bin/helpins 스크
    립트를 수행하기 위해서는 반드시 SYSTEM_PASS 환경변수를 필요로 한다.
    Reference Document
    <Note:1037075.6>

    check it please whether it is a database version or just you are installing a client. Install Enterprize database on 2k system. I you are running a client software then you are to deinstall it.

  • Download Oracle SQL*Plus help related like word help

    Hello all
    I just wanna ask if where i can download Oracle SQL*Plus help related like word help.?
    ty

    <p>You can access SQL*Plus help from the command line in a SQL*Plus session by typing 'help index'. If you want more information than that, take a look at the SQL*Plus Quick Reference located <b>here</b> or the SQL*Plus User's Guide and Reference located <b>here</b>. These docs are all for Oracle 10g. Other version documentation can be found <b>here</b>.</p>
    Tom

  • SQL Server2008 help needed

    Having trouble with SQLServer 2008 (not MySQL) and my database connection in Dreamweaver CS6.  My document type is set as .asp using VBScript.  I can list the table information  but cannot use the insert wizard to add new records.  I don't get any errors after creating the insert form, but no records get inserted.  I'm not a VBScript expert, but do I have to manually write some code to insert records?  How do I attach it to a button?

    Thanks for the quick reply.  I won't be back in the office for a few days, but I'll try to post it when I get back in.  It's pretty much the code generated from the Dreamweaver Insert Record wizard.  I see where the submit button is created and the value is set but the action on the form is set to MM_insert, so I don't see where the submit code is actually called.
    Date: Wed, 3 Oct 2012 12:06:14 -0600
    From: [email protected]
    To: [email protected]
    Subject: SQL Server2008 help needed
        Re: SQL Server2008 help needed
        created by bregent in Dreamweaver General - View the full discussion
    This post should be moved to the app dev forum.  Please post the code from your form and the insert script pages.
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/4746757#4746757
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4746757#4746757
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4746757#4746757. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Dreamweaver General by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Need help on sql count

    SQL> select count(location_ip) from web_stats where page_path='Apple'; (this query is to be solved as I need to count ip addresses of a page path,I getting 0 as result
    COUNT(LOCATION_IP)
    0
    Is there any other query related to above query?

    Null values aren't counted, as mentioned already. Is that what you're asking about? To count rows regardless of whether individual columns have values or not, use <tt> count(*)</tt>.
    I don't know what you mean by "any other queries related to this query".
    btw please use tags for code, e.g.
    {noformat}{noformat}
    select count(*) from mytable;
    {noformat}{noformat}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Please help  oracle sql counts question

    Hi,
    I am trying to get some counts on a client list where l count those clients who are getting the program
    2353335 ONLY (which may be none of the cases in the example below but this is an obviously smaller subset of these data).
    How can I count all the client ids where program = 2353335 but not where program = 2340845 or program =2353340?
    Thanks in advance
    Client_id     Program
    260     2340845
    260     2353340
    510     2353340
    510     2353335
    510     2340845
    520     2340845
    520     2353340
    525     2340845
    525     2353335
    765     2353340
    1260     2340845
    1260     2353335
    1595     2353340
    1595     2340845
    1615     2340845
    1835     2353340
    1840     2353340
    1840     2353335
    1840     2340845
    1845     2353335
    1845     2340845

    Hi,
    if you want to select clients that only have program 2353335 and no other, the query below would help:
    select client_id
    from mytab m
    where program = 2353335
    and not exists (select 1 from mytab where client_id = m.client_id and program != 2353335);Just replace select client_id with select count(*) if you want just to count rows.
    Best regards,
    Nikolay
    Edited by: Nikolay Savvinov on Jan 26, 2012 11:24 PM

  • SQL/PLSQL Help - Table Name and Count on same line

    Hello,
    I need the following information returned:
    Table_Name, Current Table Count, Num_Rows.
    The table_name and num_rows are pulled from dba_tables where owner = 'XXXX'
    I can't figure out how to return this info.
    Sample of desired output and format
    Table_name Num_Rows Current Count
    AAAA 15 400
    ABBB 8000 8120
    Any help would be appreciated.
    Thanks - Chris

    May be this one helps you:
    declare
    cursor cur_cnt is
    select 'select ''' || table_name || ''', (select count(*) from ' || table_name || ') from dual' l_sql from user_tables;
    l_table_name varchar2(30);
    l_cnt number;
    begin
    dbms_output.put_line(rpad('Table Name',40)||rpad('RowCount',40));
    dbms_output.put_line('------------------------------------------------');
    for l_cur_cnt in cur_cnt
    loop
    execute immediate l_cur_cnt.l_sql into l_table_name, l_cnt;
    dbms_output.put_line(rpad(l_table_name,40)
    ||rpad(l_cnt,40));
    end loop;
    end;
    -Hari
    Hello,
    I need the following information returned:
    Table_Name, Current Table Count, Num_Rows.
    The table_name and num_rows are pulled from dba_tables where owner = 'XXXX'
    I can't figure out how to return this info.
    Sample of desired output and format
    Table_name Num_Rows Current Count
    AAAA 15 400
    ABBB 8000 8120
    Any help would be appreciated.
    Thanks - Chris

  • SQL Report help needed

    Hi All,
    I am creating a report which is having 2 sql queries ,1 for the main columns that i need to show and 2 from total sum and count.
    Report is something as given below
    SET TAB OFF;
    set linesize 1500;
    set pagesize 50;
    SET FEEDBACK OFF;
    SET WRAP OFF
    COLUMN today NEW_VALUE VAR1 NOPRINT;
    TTITLE LEFT 'ABC Inc.' SKIP 1 -
    LEFT 'Daily Report' SKIP 1 -
    LEFT 'As Of ' VAR1 SKIP 2
    BTITLE LEFT SKIP 'Page No : ' FORMAT 9999999999 SQL.PNO SKIP 3;
    COL SR_NO HEADING 'Seq'               FORMAT 999999;
    COL REFNO HEADING 'Ref No'                FORMAT A20;
    COL ORIG_NAME HEADING ' Branch Name'      
         FORMAT A50;
    SELECT      ROWNUM                SR_NO,
         REF_NO                REFNO,
         ORIGIN_NAME               BRNAME
    FROM BANK
    WHERE PASS_CD=101
    SELECT      ' Failure Count : '|| NVL(COUNT(DECODE(CODE,1,CODE,NULL)),0) ||
         ' Failure Total Amt : '|| NVL(SUM(DECODE(CODE,799,AMT,NULL)),0)
         || CHR(10) ||     
         ' Successful Count : '|| NVL(COUNT(DECODE(CODE,000,CODE,NULL)),0) ||
    ' Successful Total Amt: '|| NVL(SUM(DECODE(CODE,000,AMT,NULL)),0)
    FROM BANK;
    CLEAR BREAKS;
    CLEAR COLUMN;
    TTITLE OFF;
    When i am running this second query output is going to secong page and title is repeated again and same as 1rst page is showing page no-1
    Kindly help me,i want the output on the same page at bottom.
    Thanks

    i think its only work in ISQL* PLUS enivironment iam
    not sure.It does work in SQL*Plus
    is that i can use in the package??http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12048.htm

  • Sql tuning help

    Hi,
    I need some help on tuning this sql. We run a third party application and I have to ask thrid party for any changes. I have pasted the session statistice from the run for this sql.
    SELECT DECODE( RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,
    ' ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' '),
    RPAD(NVL(:zipout1,' '),4,' ')||RPAD(NVL(:zipin1,' '),3,' '),
    '0001', RPAD(NVL(:zipout2,' '),4,'
    ')||RPAD(SUBSTR(NVL(:zipin2,' '),0,1),3,' '), '0002',
    RPAD(NVL(:zipout3,' '),7,' '), '0003',
    RPAD('ZZ999',7,' '), '0004' ) AS CHECKER
    FROM NWKPCDREC
    WHERE NWKPCDNETWORKID = :netid
    AND NWKPCDSORTPOINT1TYPE != 'XXXXXXXX'
    AND ( (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,' ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
    RPAD(NVL(:zipout4,' '),4,' ')||RPAD(NVL(:zipin3,' '),3,' '))
    OR (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
    ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
    RPAD(NVL(:zipout5,' '),4,' ')||RPAD(SUBSTR(NVL(:zipin4,' '),0,
    1),3,' ')) OR (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
    ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') =
    RPAD(NVL(:zipout6,' '),7,' ')) OR
    (RPAD(NVL(NWKPCDOUTWDPOSTCODE,' '),4,'
    ')||RPAD(NVL(NWKPCDINWDPOSTCODE,' '),3,' ') = RPAD('ZZ999',7,
    ' ')) ) ORDER BY CHECKER
    Session Statistics 09 October 2007 22:44:56 GMT+00:00
    Report Target : PRD1 (Database)
    Session Statistics
    (Chart form was tabular, see data table below)
    SID Name Value Class
    37 write clones created in foreground 0 Cache
    37 write clones created in background 0 Cache
    37 user rollbacks 16 User
    37 user commits 8674 User
    37 user calls 302838 User
    37 transaction tables consistent reads - undo records applied 0 Debug
    37 transaction tables consistent read rollbacks 0 Debug
    37 transaction rollbacks 9 Debug
    37 transaction lock foreground wait time 0 Debug
    37 transaction lock foreground requests 0 Debug
    37 transaction lock background gets 0 Debug
    37 transaction lock background get time 0 Debug
    37 total file opens 12 Cache
    37 table scans (short tables) 8062 SQL
    37 table scans (rowid ranges) 0 SQL
    37 table scans (long tables) 89 SQL
    37 table scans (direct read) 0 SQL
    37 table scans (cache partitions) 2 SQL
    37 table scan rows gotten 487042810 SQL
    37 table scan blocks gotten 7327924 SQL
    37 table fetch continued row 17 SQL
    37 table fetch by rowid 26130550 SQL
    37 switch current to new buffer 6400 Cache
    37 summed dirty queue length 0 Cache
    37 sorts (rows) 138607 SQL
    37 sorts (memory) 13418 SQL
    37 sorts (disk) 0 SQL
    37 session uga memory max 5176776 User
    37 session uga memory 81136 User
    37 session stored procedure space 0 User
    37 session pga memory max 5559884 User
    37 session pga memory 5559884 User
    37 session logical reads 115050107 User
    37 session cursor cache hits 0 SQL
    37 session cursor cache count 0 SQL
    37 session connect time 1191953042 User
    37 serializable aborts 0 User
    37 rows fetched via callback 1295545 SQL
    37 rollbacks only - consistent read gets 0 Debug
    37 rollback changes - undo records applied 114 Debug
    37 remote instance undo header writes 0 Global Cache
    37 remote instance undo block writes 0 Global Cache
    37 redo writes 0 Redo
    37 redo writer latching time 0 Redo
    37 redo write time 0 Redo
    37 redo wastage 0 Redo
    37 redo synch writes 8683 Cache
    37 redo synch time 722 Cache
    37 redo size 25463692 Redo
    37 redo ordering marks 0 Redo
    37 redo log switch interrupts 0 Redo
    37 redo log space wait time 0 Redo
    37 redo log space requests 1 Redo
    37 redo entries 81930 Redo
    37 redo buffer allocation retries 1 Redo
    37 redo blocks written 0 Redo
    37 recursive cpu usage 101 User
    37 recursive calls 84413 User
    37 recovery blocks read 0 Cache
    37 recovery array reads 0 Cache
    37 recovery array read time 0 Cache
    37 queries parallelized 0 Parallel Server
    37 process last non-idle time 1191953042 Debug
    37 prefetched blocks aged out before use 0 Cache
    37 prefetched blocks 1436767 Cache
    37 pinned buffers inspected 89 Cache
    37 physical writes non checkpoint 3507 Cache
    37 physical writes direct (lob) 0 Cache
    37 physical writes direct 3507 Cache
    37 physical writes 3507 Cache
    37 physical reads direct (lob) 0 Cache
    37 physical reads direct 2499 Cache
    37 physical reads 1591668 Cache
    37 parse time elapsed 336 SQL
    37 parse time cpu 315 SQL
    37 parse count (total) 28651 SQL
    37 parse count (hard) 1178 SQL
    37 opens requiring cache replacement 0 Cache
    37 opens of replaced files 0 Cache
    37 opened cursors current 51 User
    37 opened cursors cumulative 28651 User
    37 no work - consistent read gets 59086317 Debug
    37 no buffer to keep pinned count 0 Other
    37 next scns gotten without going to DLM 0 Parallel Server
    37 native hash arithmetic fail 0 SQL
    37 native hash arithmetic execute 0 SQL
    37 messages sent 9730 Debug
    37 messages received 0 Debug
    37 logons current 1 User
    37 logons cumulative 1 User
    37 leaf node splits 111 Debug
    37 kcmgss waited for batching 0 Parallel Server
    37 kcmgss read scn without going to DLM 0 Parallel Server
    37 kcmccs called get current scn 0 Parallel Server
    37 instance recovery database freeze count 0 Parallel Server
    37 index fast full scans (rowid ranges) 0 SQL
    37 index fast full scans (full) 210 SQL
    37 index fast full scans (direct read) 0 SQL
    37 immediate (CURRENT) block cleanout applications 4064 Debug
    37 immediate (CR) block cleanout applications 83 Debug
    37 hot buffers moved to head of LRU 20004 Cache
    37 global lock sync gets 0 Parallel Server
    37 global lock sync converts 0 Parallel Server
    37 global lock releases 0 Parallel Server
    37 global lock get time 0 Parallel Server
    37 global lock convert time 0 Parallel Server
    37 global lock async gets 0 Parallel Server
    37 global lock async converts 0 Parallel Server
    37 global cache read buffer lock timeouts 0 Global Cache
    37 global cache read buffer blocks served 0 Global Cache
    37 global cache read buffer blocks received 0 Global Cache
    37 global cache read buffer block timeouts 0 Global Cache
    37 global cache read buffer block send time 0 Global Cache
    37 global cache read buffer block receive time 0 Global Cache
    37 global cache read buffer block build time 0 Global Cache
    37 global cache prepare failures 0 Global Cache
    37 global cache gets 0 Global Cache
    37 global cache get time 0 Global Cache
    37 global cache freelist waits 0 Global Cache
    37 global cache defers 0 Global Cache
    37 global cache cr timeouts 0 Global Cache
    37 global cache cr requests blocked 0 Global Cache
    37 global cache cr blocks served 0 Global Cache
    37 global cache cr blocks received 0 Global Cache
    37 global cache cr block send time 0 Global Cache
    37 global cache cr block receive time 0 Global Cache
    37 global cache cr block flush time 0 Global Cache
    37 global cache cr block build time 0 Global Cache
    37 global cache converts 0 Global Cache
    37 global cache convert timeouts 0 Global Cache
    37 global cache convert time 0 Global Cache
    37 global cache blocks corrupt 0 Global Cache
    37 free buffer requested 1597281 Cache
    37 free buffer inspected 659 Cache
    37 execute count 128826 SQL
    37 exchange deadlocks 1 Cache
    37 enqueue waits 0 Enqueue
    37 enqueue timeouts 0 Enqueue
    37 enqueue requests 23715 Enqueue
    37 enqueue releases 23715 Enqueue
    37 enqueue deadlocks 0 Enqueue
    37 enqueue conversions 0 Enqueue
    37 dirty buffers inspected 437 Cache
    37 deferred (CURRENT) block cleanout applications 21937 Debug
    37 db block gets 230801 Cache
    37 db block changes 160407 Cache
    37 data blocks consistent reads - undo records applied 460 Debug
    37 cursor authentications 488 Debug
    37 current blocks converted for CR 0 Cache
    37 consistent gets 114819307 Cache
    37 consistent changes 460 Cache
    37 commit cleanouts successfully completed 37201 Cache
    37 commit cleanouts 37210 Cache
    37 commit cleanout failures: write disabled 0 Cache
    37 commit cleanout failures: hot backup in progress 0 Cache
    37 commit cleanout failures: cannot pin 0 Cache
    37 commit cleanout failures: callback failure 3 Cache
    37 commit cleanout failures: buffer being written 0 Cache
    37 commit cleanout failures: block lost 6 Cache
    37 cold recycle reads 0 Cache
    37 cluster key scans 17 SQL
    37 cluster key scan block gets 36 SQL
    37 cleanouts only - consistent read gets 83 Debug
    37 cleanouts and rollbacks - consistent read gets 0 Debug
    37 change write time 108 Cache
    37 calls to kcmgrs 0 Debug
    37 calls to kcmgcs 391 Debug
    37 calls to kcmgas 8816 Debug
    37 calls to get snapshot scn: kcmgss 171453 Parallel Server
    37 bytes sent via SQL*Net to dblink 0 User
    37 bytes sent via SQL*Net to client 25363874 User
    37 bytes received via SQL*Net from dblink 0 User
    37 bytes received via SQL*Net from client 29829542 User
    37 buffer is pinned count 540816 Other
    37 buffer is not pinned count 86108905 Other
    37 branch node splits 6 Debug
    37 background timeouts 0 Debug
    37 background checkpoints started 0 Cache
    37 background checkpoints completed 0 Cache
    37 Unnecesary process cleanup for SCN batching 0 Parallel Server
    37 SQL*Net roundtrips to/from dblink 0 User
    37 SQL*Net roundtrips to/from client 302837 User
    37 Parallel operations not downgraded 0 Parallel Server
    37 Parallel operations downgraded to serial 0 Parallel Server
    37 Parallel operations downgraded 75 to 99 pct 0 Parallel Server
    37 Parallel operations downgraded 50 to 75 pct 0 Parallel Server
    37 Parallel operations downgraded 25 to 50 pct 0 Parallel Server
    37 Parallel operations downgraded 1 to 25 pct 0 Parallel Server
    37 PX remote messages sent 0 Parallel Server
    37 PX remote messages recv'd 0 Parallel Server
    37 PX local messages sent 0 Parallel Server
    37 PX local messages recv'd 0 Parallel Server
    37 OS Voluntary context switches 0 OS
    37 OS User time used 0 OS
    37 OS System time used 0 OS
    37 OS Swaps 0 OS
    37 OS Socket messages sent 0 OS
    37 OS Socket messages received 0 OS
    37 OS Signals received 0 OS
    37 OS Page reclaims 0 OS
    37 OS Page faults 0 OS
    37 OS Maximum resident set size 0 OS
    37 OS Involuntary context switches 0 OS
    37 OS Integral unshared stack size 0 OS
    37 OS Integral unshared data size 0 OS
    37 OS Integral shared text size 0 OS
    37 OS Block output operations 0 OS
    37 OS Block input operations 0 OS
    37 DML statements parallelized 0 Parallel Server
    37 DFO trees parallelized 0 Parallel Server
    37 DDL statements parallelized 0 Parallel Server
    37 DBWR undo block writes 0 Cache
    37 DBWR transaction table writes 0 Cache
    37 DBWR summed scan depth 0 Cache
    37 DBWR revisited being-written buffer 0 Cache
    37 DBWR make free requests 0 Cache
    37 DBWR lru scans 0 Cache
    37 DBWR free buffers found 0 Cache
    37 DBWR cross instance writes 0 Global Cache
    37 DBWR checkpoints 0 Cache
    37 DBWR checkpoint buffers written 0 Cache
    37 DBWR buffers scanned 0 Cache
    37 Commit SCN cached 0 Debug
    37 Cached Commit SCN referenced 1 Debug
    37 CR blocks created 203 Cache
    37 CPU used when call started 280528 Debug
    37 CPU used by this session 280528 User
    Regards
    Raj
    --------------------------------------------------------------------------------

    Thank you everybody for helping me out while tuning the query. I have managed to bring down the run time from 60 minutes to 12 minutes.
    I am posting the exisitng query, existing database objects ddl and the new query and new ddl to share my learning. This is my first use of forum, senior members, please letme know if I shouldn't have put all this here.
    /pre original code
    SELECT decode(rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' '), rpad(nvl(:zipout1, ' '), 4, ' ')
    || rpad(nvl(:zipin1, ' '), 3, ' '), '0001', rpad(nvl(:zipout2, ' '), 4,
    ' ') || rpad(substr(nvl(:zipin2, ' '), 0, 1), 3, ' '), '0002',
    rpad(nvl(:zipout3, ' '), 7, ' '), '0003', rpad('ZZ999', 7, ' '), '0004')
    AS checker, a.nwkpcdbarcode1to7 nwkpcdbarcode1to7,
    a.nwkpcdbarcode15 nwkpcdbarcode15,
    a.nwkpcdbarcodeseqkey nwkpcdbarcodeseqkey,
    a.nwkpcdsortpoint1code nwkpcdsortpoint1code,
    a.nwkpcdsortpoint1type nwkpcdsortpoint1type,
    a.nwkpcdsortpoint1name nwkpcdsortpoint1name,
    a.nwkpcdsortpoint1extra nwkpcdsortpoint1extra,
    a.nwkpcdsortpoint2type nwkpcdsortpoint2type,
    a.nwkpcdsortpoint2name nwkpcdsortpoint2name,
    a.nwkpcdsortpoint3type nwkpcdsortpoint3type,
    a.nwkpcdsortpoint3name nwkpcdsortpoint3name,
    a.nwkpcdsortpoint4type nwkpcdsortpoint4type,
    a.nwkpcdsortpoint4name nwkpcdsortpoint4name,
    b.nwkprfnetworksequence nwkprfnetworksequence,
    b.nwkprfnetworkid nwkprfnetworkid, b.nwkprfnetworkname nwkprfnetworkname,
    b.nwkprfminweight / 100 AS nwkprfminweight, b.nwkprfmaxweight / 100 AS
    nwkprfmaxweight, b.nwkprfminlengthgirth nwkprfminlengthgirth,
    b.nwkprfmaxlengthgirth nwkprfmaxlengthgirth,
    b.nwkprfminlength nwkprfminlength, b.nwkprfmaxlength nwkprfmaxlength,
    b.nwkprfparceltypecode nwkprfparceltypecode,
    b.nwkprfparceltypename nwkprfparceltypename
    FROM wh1.nwkpcdrec a, wh1.nwkprefrec b
    WHERE a.nwkpcdnetworkid = b.nwkprfnetworkid
    AND a.nwkpcdsortpoint1type != 'XXXXXXXX'
    AND (rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout4, ' '), 4, ' '
    ) || rpad(nvl(:zipin3, ' '), 3, ' ')
    OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout5, ' '), 4, ' '
    ) || rpad(substr(nvl(:zipin4, ' '), 0, 1), 3, ' ')
    OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad(nvl(:zipout6, ' '), 7, ' '
    OR rpad(nvl(a.nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(
    a.nwkpcdinwdpostcode, ' '), 3, ' ') = rpad('ZZ999', 7, ' '))
    AND :weight1 >= b.nwkprfminweight
    AND :weight2 <= b.nwkprfmaxweight
    AND b.nwkprfminlengthgirth <= 60
    AND b.nwkprfmaxlengthgirth >= 60
    AND b.nwkprfminlength <= 15
    AND b.nwkprfmaxlength >= 15
    ORDER BY b.nwkprfnetworkid, checker
    CREATE TABLE "WH1"."NWKPCDREC" ("NWKPCDFILECODE" VARCHAR2(2),
    "NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
    "NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
    VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
    "NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
    VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
    "NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
    VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
    "NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
    VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
    VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
    "NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
    VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
    VARCHAR2(30),
    CONSTRAINT "UK_NWKPCDREC" UNIQUE("NWKPCDNETWORKID",
    "NWKPCDOUTWDPOSTCODE", "NWKPCDINWDPOSTCODE")
    USING INDEX
    TABLESPACE "WH1_INDEX"
    STORAGE ( INITIAL 64K NEXT 0K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    PCTFREE 10 INITRANS 2 MAXTRANS 255)
    TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
    MAXTRANS 255
    STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    NOLOGGING
    pre original script/
    /pre modified script
    CREATE TABLE "WH1"."NWKPCEREC_OLD" ("NWKPCDFILECODE" VARCHAR2(2),
    "NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
    "NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
    VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
    "NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
    VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
    "NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
    VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
    "NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
    VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
    VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
    "NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
    VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
    VARCHAR2(30))
    TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
    MAXTRANS 255
    STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    NOLOGGING
    insert into wh1.nwkpcdrec_old select * from wh1.nwkpcdrec;
    drop table wh1.nwkpcdrec;
    CREATE TABLE "WH1"."NWKPCDREC" ("NWKPCDFILECODE" VARCHAR2(2),
    "NWKPCDRECORDTYPE" VARCHAR2(4), "NWKPCDNETWORKID" VARCHAR2(2),
    "NWKPCDOUTINWDPOSTCODE" VARCHAR2(7) NOT NULL,
    "NWKPCDOUTWDPOSTCODE" VARCHAR2(4), "NWKPCDINWDPOSTCODE"
    VARCHAR2(3), "NWKPCDSORTPOINT1CODE" VARCHAR2(2),
    "NWKPCDSORTPOINT1TYPE" VARCHAR2(8), "NWKPCDSORTPOINT1NAME"
    VARCHAR2(16), "NWKPCDSORTPOINT1EXTRA" VARCHAR2(16),
    "NWKPCDSORTPOINT2TYPE" VARCHAR2(8), "NWKPCDSORTPOINT2NAME"
    VARCHAR2(8), "NWKPCDSORTPOINT3TYPE" VARCHAR2(8),
    "NWKPCDSORTPOINT3NAME" VARCHAR2(8), "NWKPCDSORTPOINT4TYPE"
    VARCHAR2(8), "NWKPCDSORTPOINT4NAME" VARCHAR2(8), "NWKPCDPPI"
    VARCHAR2(8), "NWKPCDBARCODE1TO7" VARCHAR2(7),
    "NWKPCDBARCODE15" VARCHAR2(1), "NWKPCDBARCODESEQKEY"
    VARCHAR2(7), "NWKPCDFILLER1" VARCHAR2(7), "NWKPCDFILLER2"
    VARCHAR2(30))
    TABLESPACE "WH1_DATA_LARGE" PCTFREE 10 PCTUSED 40 INITRANS 1
    MAXTRANS 255
    STORAGE ( INITIAL 4096K NEXT 4096K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    NOLOGGING
    INSERT INTO WH1.NWKPCDREC SELECT
                   NWKPCDFILECODE,
                   NWKPCDRECORDTYPE,
                   NWKPCDNETWORKID,
                   rpad(nvl(nwkpcdoutwdpostcode, ' '), 4, ' ') || rpad(nvl(nwkpcdinwdpostcode, ' '), 3, ' '),
                   nwkpcdoutwdpostcode,
                   nwkpcdinwdpostcode,
                   NWKPCDSORTPOINT1CODE,
                   NWKPCDSORTPOINT1TYPE,
                   NWKPCDSORTPOINT1NAME,
                   NWKPCDSORTPOINT1EXTRA,
                   NWKPCDSORTPOINT2TYPE,
                   NWKPCDSORTPOINT2NAME,
                   NWKPCDSORTPOINT3TYPE,
                   NWKPCDSORTPOINT3NAME,
                   NWKPCDSORTPOINT4TYPE,
                   NWKPCDSORTPOINT4NAME,
                   NWKPCDPPI,
                   NWKPCDBARCODE1TO7,
                   NWKPCDBARCODE15,
                   NWKPCDBARCODESEQKEY,
                   NWKPCDFILLER1,
                   NWKPCDFILLER2
    FROM WH1.NWKPCDREC_OLD;
    CREATE UNIQUE INDEX "WH1"."UK_NWKPCDREC"
    ON "WH1"."NWKPCDREC" ("NWKPCDNETWORKID",
    "NWKPCDOUTINWDPOSTCODE")
    TABLESPACE "WH1_INDEX" PCTFREE 10 INITRANS 2 MAXTRANS
    255
    STORAGE ( INITIAL 8192K NEXT 8192K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1)
    LOGGING
    begin
    dbms_stats.gather_table_stats(ownname=> 'WH1', tabname=> 'NWKPCDREC', partname=> NULL);
    end;
    begin
    dbms_stats.gather_index_stats(ownname=> 'WH1', indname=> 'UK_NWKPCDREC', partname=> NULL);
    end;
    SELECT decode(a.nwkpcdoutinwdpostcode, rpad(nvl(:zipout1, ' '), 4, ' ') ||
    rpad(nvl(:zipin1, ' '), 3, ' '), '0001', rpad(nvl(:zipout2, ' '), 4, ' '
    ) || rpad(substr(nvl(:zipin2, ' '), 0, 1), 3, ' '), '0002', rpad(
    nvl(:zipout3, ' '), 7, ' '), '0003', rpad('ZZ999', 7, ' '), '0004') AS
    checker, a.nwkpcdbarcode1to7 nwkpcdbarcode1to7,
    a.nwkpcdbarcode15 nwkpcdbarcode15,
    a.nwkpcdbarcodeseqkey nwkpcdbarcodeseqkey,
    a.nwkpcdsortpoint1code nwkpcdsortpoint1code,
    a.nwkpcdsortpoint1type nwkpcdsortpoint1type,
    a.nwkpcdsortpoint1name nwkpcdsortpoint1name,
    a.nwkpcdsortpoint1extra nwkpcdsortpoint1extra,
    a.nwkpcdsortpoint2type nwkpcdsortpoint2type,
    a.nwkpcdsortpoint2name nwkpcdsortpoint2name,
    a.nwkpcdsortpoint3type nwkpcdsortpoint3type,
    a.nwkpcdsortpoint3name nwkpcdsortpoint3name,
    a.nwkpcdsortpoint4type nwkpcdsortpoint4type,
    a.nwkpcdsortpoint4name nwkpcdsortpoint4name,
    b.nwkprfnetworksequence nwkprfnetworksequence,
    b.nwkprfnetworkid nwkprfnetworkid, b.nwkprfnetworkname nwkprfnetworkname,
    b.nwkprfminweight / 100 AS nwkprfminweight, b.nwkprfmaxweight / 100 AS
    nwkprfmaxweight, b.nwkprfminlengthgirth nwkprfminlengthgirth,
    b.nwkprfmaxlengthgirth nwkprfmaxlengthgirth,
    b.nwkprfminlength nwkprfminlength, b.nwkprfmaxlength nwkprfmaxlength,
    b.nwkprfparceltypecode nwkprfparceltypecode,
    b.nwkprfparceltypename nwkprfparceltypename
    FROM wh1.nwkpcdrec a, wh1.nwkprefrec b
    WHERE a.nwkpcdnetworkid = b.nwkprfnetworkid
    AND a.nwkpcdoutinwdpostcode IN (rpad(nvl(:zipout4, ' '), 4, ' ') ||
    rpad(nvl(:zipin3, ' '), 3, ' '), rpad(nvl(:zipout5, ' '), 4, ' ')
    || rpad(substr(nvl(:zipin4, ' '), 0, 1), 3, ' '), rpad(nvl(:zipout6,
    ' '), 7, ' '), rpad('ZZ999', 7, ' '))
    AND a.nwkpcdsortpoint1type != 'XXXXXXXX'
    AND :weight1 >= b.nwkprfminweight
    AND :weight2 <= b.nwkprfmaxweight
    AND b.nwkprfminlengthgirth <= 60
    AND b.nwkprfmaxlengthgirth >= 60
    AND b.nwkprfminlength <= 15
    AND b.nwkprfmaxlength >= 15
    ORDER BY b.nwkprfnetworkid, checker
    pre modified script/

Maybe you are looking for

  • My applet shows in IE but not in Netscape

    i coded an applet. It runs well in Internet Explorer on Windows but it cannot be shown in Netscape on Linux. I have set "enable Java" but the problem remains. The error information is "Applet myapplet error: java.lang.NoClassDefFoundError:myapplet".

  • Smart case not working. Ipad Air 2 8.1.3

    Hi, I just bought a new smart case for Ipad Air 2. I notice that the case not working (open,close cover nothing happens). General setting doesn't have the turn on/off (or lock/unlock or smt like that) under auto lock settings. Anyone has the solution

  • Error in Vendor consignment return PO.

    Dear MM experts, I'm creating a vendor consignment return PO but there's an error message " Return with SD delivery not possible for consignment items". Kindly assist which config that I'm missing out. Regards, DSingh.

  • From int to char...

    Got a nice little problem: I have an int (e.g. int i = 111). This should be transformed into the appropriate ASCII-Code char (or UNICODE-char, if only this is possible). Sounds easy but I didn't manage it. In desperate need for help... :-) Hannibal_

  • DefaultWebApp on virtual host

    The documentation for WLS 8.1 says the DefaultWebApp parameter for virtual hosts is being depricated, yet you are not allowed to add more than one web application to a domain that has a context root of /. Is there another way to code a default applic