Sql Coding Help

Hello All,
I need help on getting the sql code.
Here is how the example data is laid out in my data table called example.
name     age     favorite colors
john doe     15     red:blue:green
Notice how the data is in column "favorite colors" they are set values selected from a multiple list.
I need the sql to get it to display like this.
name     age     favorite colors
john doe     15     red
john doe     15     blue
john doe     15     green
thanks

>
Here is how the example data is laid out in my data table called example.
name age favorite colors
john doe 15 red:blue:green
Notice how the data is in column "favorite colors" they are set values selected from a multiple list.
I need the sql to get it to display like this.
name age favorite colors
john doe 15 red
john doe 15 blue
john doe 15 green
>
Storing data in a denormalized form like this usually leads to trouble. Rather than getting into complex programmatic solutions simply to retrieve data, why not use a properly normalized data model that eliminates the problem?
SQL> create sequence subject_seq;
Sequence created.
SQL> create sequence color_seq;
Sequence created.
SQL> create table subjects (
  2        subject_id    integer          primary key
  3    , subject_name  varchar2(30)  not null
  4    , age            number(3, 0)  not null);
Table created.
SQL> create table colors (
  2        color_id    integer        primary key
  3    , color_name  varchar2(20)  not null,
  4    constraint color_name_uk unique (color_name));
Table created.
SQL> create table favorite_colors (
  2        subject_id  integer   not null references subjects
  3    , color_id    integer   not null references colors,
  4    constraint fav_color_pk primary key (
  5          subject_id
  6        , color_id))
  7  organization index;
Table created.
SQL> create index fav_color_ix2 on favorite_colors (
  2        color_id
  3    , subject_id);
Index created.Deal with complexity&mdash;like processing multi-value select lists&mdash;in the bits of the application that lend themselves to it: PL/SQL processes; DB packages etc, using features like the aforementioned <tt>apex_util.string_to_table</tt>:
SQL> declare
  2 
  3    l_sub_id     subjects.subject_id%type;
  4 
  5    procedure process_fav_colors (
  6          p_subject_id  in subjects.subject_id%type
  7        , p_colors_str  in varchar2)
  8    is
  9 
10        l_fav_colors  apex_application_global.vc_arr2;
11 
12    begin
13 
14        l_fav_colors := apex_util.string_to_table(p_colors_str);
15 
16        delete favorite_colors
17        where subject_id = p_subject_id;
18 
19        forall i in l_fav_colors.first()..l_fav_colors.last()
20          insert into favorite_colors
21            (subject_id, color_id)
22          select
23                 p_subject_id
24               , col.color_id
25          from
26                 colors col
27          where
28                 col.color_name = l_fav_colors(i);
29 
30    end process_fav_colors;
31 
32  begin
33 
34    insert into colors values (color_seq.nextval, 'red');
35    insert into colors values (color_seq.nextval, 'green');
36    insert into colors values (color_seq.nextval, 'blue');
37    insert into colors values (color_seq.nextval, 'rose');
38    insert into colors values (color_seq.nextval, 'black');
39    insert into colors values (color_seq.nextval, 'white');
40 
41    insert into subjects
42        (subject_id, subject_name, age)
43    values
44        (subject_seq.nextval, 'john doe', 15)
45    returning
46        subject_id into l_sub_id;
47 
48    process_fav_colors(l_sub_id, 'red:green:blue');
49 
50    insert into subjects
51        (subject_id, subject_name, age)
52    values
53        (subject_seq.nextval, 'man ray', 86)
54    returning
55        subject_id into l_sub_id;
56 
57    process_fav_colors(l_sub_id, 'black:white');
58 
59    insert into subjects
60        (subject_id, subject_name, age)
61    values
62        (subject_seq.nextval, 'pablo picasso', 91)
63    returning
64        subject_id into l_sub_id;
65 
66    process_fav_colors(l_sub_id, 'blue:rose');
67 
68  end;
69  /
PL/SQL procedure successfully completed.Then getting the data in the required form is trivial:
SQL> select
  2              sub.subject_name
  3            , sub.age
  4            , col.color_name
  5  from
  6              subjects sub
  7            , favorite_colors fc
  8            , colors col
  9  where
10              sub.subject_id = fc.subject_id
11  and       fc.color_id = col.color_id
12  order by
13              sub.subject_name
14            , col.color_name;
SUBJECT_NAME                     AGE COLOR_NAME
john doe                      15 blue
john doe                      15 green
john doe                      15 red
man ray                       86 black
man ray                       86 white
pablo picasso                      91 blue
pablo picasso                      91 roseAnd what if there's a requirement to query and analyze the data? Answer questions like: Who likes blue? Or How many subjects have more than 2 favorite colors?
SQL> select
  2              sub.subject_name
  3  from
  4              subjects sub
  5            , favorite_colors fc
  6            , colors col
  7  where
  8              sub.subject_id = fc.subject_id
  9  and       fc.color_id = col.color_id
10  and       col.color_name = 'blue';
SUBJECT_NAME
john doe
pablo picasso
SQL> select
  2              count(*)
  3  from
  4              (select
  5                  count(*)
  6              from
  7                  subjects sub
  8                   , favorite_colors fc
  9                   , colors col
10              where
11                  sub.subject_id = fc.subject_id
12              and      fc.color_id = col.color_id
13              group by
14                  sub.subject_id
15                   , sub.subject_name
16              having
17                  count(*) > 2);
  COUNT(*)
      1This is impossible to do simply and efficiently with the original model.

Similar Messages

  • 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 IN SQL+ CODING USING POINTERS

    GOOD MORNING BOARD,
    I HAVE A CODING ISSUE DEALING WITH POINTERS AND BUILDING TABLES USING THEM CAN SOMEONE PLEASE HELP??
    I CAN SEND THE CODE TO U VIA ATTACHMENT
    THANK YOU IN ADVANCE
    A...

    GOOD MORNING BOARD,
    I HAVE A CODING ISSUE DEALING WITH POINTERS AND BUILDING TABLES USING THEM CAN SOMEONE PLEASE HELP??
    I CAN SEND THE CODE TO U VIA ATTACHMENT
    THANK YOU IN ADVANCE
    A...

  • NEED HELP IN SQL CODING

    I AM HAVING SERIOUS PROBLEMS DROPPING TABLES IN MY SQL CODE... PLEASE HELP
    ...A

    here is a copy of the code... i can also send it as an attachment via email... thank you in advance...
    set pause on
    spool output-file
    echo on
    rem Asfa Taitt
    rem Project2
    drop table T_ENROLL;
    drop table T_SECTION;
    drop table T_STUDENT;
    drop table T_INSTRUCTOR;
    drop table T_COURSES;
    drop table T_SCHOOL;
    drop table T_MAJOR;
    create table T_SCHOOL (School char(4) not null,
    primary key (School));
    create table T_MAJOR (Major char(4) not null,
    School char(4),
    primary key (Major),
    foriegn key (School) references T_SCHOOL);
    create table T_STUDENT (Student_No integer not null,
    Student_Name Char(20),
    Major char(4),
    primary key (Student_No),
    foriegn key (Major) references T_MAJOR);
    create table T_INSTRUCTOR (Instructor_No integer not null,
    Instructor_Name Char(20),
    School char(4),
    primary key (Instructor_No),
    foriegn key (School) references T_SCHOOL);
    create table T_COURSES (Course Char(7) not null,
    MAX_Allowed Integer,
    Credit_Hours Integer,
    GOA Char(1),
    primary key (Course));
    create table T_SECTION (semester Char(7),
    School char(4),
    Course Char(7),
    Sec_No Char(4) not null,
    Sec_Loc char(5),
    Section_Time char(13),
    Instructor_No integer,
    primary key (Sec_No),
    foreign key (Instructor_No) references T_INSTRUCTOR,
    foreign key (Course) references T_COURSES,
    foreign key (School) references T_SCHOOL);
    create table T_ENROLL (
    Semester Char(7),
    Course Char(7),
    Sec_No Char(4),
    Student_No integer,
    GOS Char(1),
    Major char(4),
    foreign key (Student_No) references T_STUDENT,
    foreign key (Course) references T_COURSES,
    foreign key (Sec_No) references T_SECTION,
    foriegn key (Major) references T_MAJOR);
    insert into T_COURSES values ('IFSM410',30,3,'R');
    insert into T_COURSES VALUES ('CMIS300',30,3,'R');
    insert into T_INSTRUCTOR values (111223333,'BABISKIN ROBERT G');
    insert into T_INSTRUCTOR values (222997777,'CODD TED E');
    insert into T_SECTION values ('SPR01','BUS','IFSM410','4031','RM32','TUTH3:30-5:00',111223333);
    insert into T_SECTION values ('SPR01','ENG','CMIS300','4011','RM407','MWF 1:30-2:30',222997777);
    insert into T_STUDENT values (222445555,'HARRIS JOHN H');
    insert into T_STUDENT values (215557777,'LITTLE BOB K');
    insert into T_STUDENT values (517443333,'JONES JANE G');
    insert into T_ENROLL values ('SPR01','IFSM410','4031',222445555,'R','IFSM');
    insert into T_ENROLL values ('SPR01','CMIS300','4011',215557777,'R','CMIS');
    insert into T_ENROLL values ('SPR01','CMIS300','4011',222445555,'R','IFSM');
    insert into T_ENROLL values ('SPR01','CMIS300','4011',517443333,'R','CMIS');
    insert into T_ENROLL values ('SPR01','IFSM410','4031',517443333,'R','CMIS');
    DELETE from T_ENROLL
    WHERE T_ENROLL.Student_No = 222445555 and T_ENROLL.Course = 'IFSM410';
    commit;
    select * from T_INSTRUCTOR;
    select * from T_COURSES;
    spool ofF

  • Related to Pl/SQL Coding plz help me its Urgent.

    A recordset depends on date range -
    1 week : approx 1000 records
    1 month : approx 5000 records
    1 year : approx 50000 records.
    Need to perform calculations on each of the row in the recordset.
    For each row recurrsive function is called to reach at the end product. (i.e for each of the 50000 rows)
    This function keeps on inserting rows in a temporary table against the data generated in the recurrsive function call.
    Hence Takes lots of time and the temp_table goes in increasing, creating performance issue.
    The session at user end becomes inactive....but at server side it remains active and the insertion of records is going on.
    Logic is working fine. But for limited date range (i.e a day or two)
    For a month processing or a year processing it fails....
    What would be the optimized soln on the above prob.?

    It's a bit difficult to give advice without knowing precisely what it is you're doing. What is the point of the recursive function? Why are you inserting into a temporary table? Does the recursive function do something with the records in the temporary table? If so then presumably your problem stems from the fact that a week only has to do 1000 * 1000 actions whereas a year has to undertake 50000 * 50000 actions.
    Have you traced these sessions to see what is going on?
    Cheers, APC

  • Sql query help

    hi guys
    i have sample data as mentioned below... need to find the duplicate rows where cd=cd and dt1=dt1 and tm1 difference should be less than or equal to 4 hrs..
    i can get the data with the query written below but my problem is that i am not allowed to use in-built sql server function... can you help me in writing the same without using in-built function...
    CREATE TABLE #t (id INT,dt1 datetime, tm1 datetime,cd varchar(10))
    INSERT INTO #t VALUES (101,'2013-04-24','1900-01-01 12:20:00.000','TC')
    INSERT INTO #t VALUES (101,'2013-04-24','1900-01-01 12:30:00.000','TC')
    INSERT INTO #t VALUES (101,'2013-08-02','1900-01-01 14:30:00.000','MN')
    INSERT INTO #t VALUES (101,'2013-08-02','1900-01-01 15:07:00.000','MN')
    INSERT INTO #t VALUES (101,'2013-07-06','1900-01-01 09:07:00.000','XY')
    INSERT INTO #t VALUES (101,'2013-11-27','1900-01-01 09:50:00.000','LM')
    INSERT INTO #t VALUES (101,'2013-07-06','1900-01-01 15:07:00.000','XY')
    select * From #t
    WITH MyCTE (rn,id, dt1, tm1, cd)
    AS(
    select row_number() over (partition by id ORDER BY dt1, tm1) rn,* from #t
    select case when ((dt1 = lead_start_Date) and (ct <='4.0') and (base_cd = lead_cd)) then 'Duplicate_Req' else '' end dt123,* from
    select abs(convert(decimal(5,1),datediff(MI,lead_Start_time,tm1)/60.00)) ct, * from
    SELECT base.rn b_rn,LEAd.rn l_rn,BASE.id
    ,BASE.dt1
    ,BASE.tm1
    ,base.cd base_cd
    ,LEAD.dt1 LEAD_START_DATE
    ,LEAD.tm1 LEAD_START_TIME
    ,lead.cd lead_cd
    --,DATEADD(dd,-1,LEAD.dt1) EXPECTED_END_DATE
    FROM MyCTE BASE
    LEFT JOIN MyCTE LEAD ON BASE.id = LEAD.id
    AND BASE.rn = LEAD.rn+1
    ) b
    )c

    if this code will not work for you then not sure if there are any other options
    Converted the CTE into an actual temp table.
    CTE and barebones T-SQL code are included in the script below.
    CREATE TABLE #t (id INT,dt1 datetime, tm1 datetime,cd varchar(10))
    INSERT INTO #t VALUES (101,'2013-04-24','1900-01-01 12:20:00.000','TC')
    INSERT INTO #t VALUES (101,'2013-04-24','1900-01-01 12:30:00.000','TC')
    INSERT INTO #t VALUES (101,'2013-08-02','1900-01-01 14:30:00.000','MN')
    INSERT INTO #t VALUES (101,'2013-08-02','1900-01-01 15:07:00.000','MN')
    INSERT INTO #t VALUES (101,'2013-07-06','1900-01-01 09:07:00.000','XY')
    INSERT INTO #t VALUES (101,'2013-11-27','1900-01-01 09:50:00.000','LM')
    INSERT INTO #t VALUES (101,'2013-07-06','1900-01-01 15:07:00.000','XY')
    INSERT INTO #t VALUES (101,'2013-08-02','1900-01-01 15:07:00.000','MN')
    select * From #t
    ;WITH MyCTE (rn,id, dt1, tm1, cd)
    AS(
    select row_number() over (partition by id ORDER BY dt1, tm1) rn,* from #t
    select case when ((dt1 = lead_start_Date) and (ct <='4.0') and (base_cd = lead_cd)) then 'Duplicate_Req' else '' end dt123,* from
    select abs(convert(decimal(5,1),datediff(MI,lead_Start_time,tm1)/60.00)) ct, * from
    SELECT base.rn b_rn,LEAd.rn l_rn,BASE.id
    ,BASE.dt1
    ,BASE.tm1
    ,base.cd base_cd
    ,LEAD.dt1 LEAD_START_DATE
    ,LEAD.tm1 LEAD_START_TIME
    ,lead.cd lead_cd
    --,DATEADD(dd,-1,LEAD.dt1) EXPECTED_END_DATE
    FROM MyCTE BASE
    LEFT JOIN MyCTE LEAD ON BASE.id = LEAD.id
    AND BASE.rn = LEAD.rn+1
    ) b
    )c
    select * into #copy From #t order by id, cd, dt1, tm1
    alter table #copy add seqno int identity(1,1)
    select distinct y.id,y.cd,y.dt1,y.tm1,y.seqno,case when z.cd is not null then 'Duplicate_Req' else '' end dt123
    from #copy y
    left outer join
    (select a.id,a.cd,a.dt1,a.tm1
    From #copy a
    left outer join #copy b
    on a.id = b.id
    and a.cd = b.cd
    and a.dt1 = b.dt1
    where a.seqno > b.seqno
    and abs(datediff(MINUTE,b.tm1,a.tm1)) <= 240) z
    on y.id = z.id
    and y.cd = z.cd
    and y.dt1 = z.dt1
    and y.tm1 = z.tm1
    order by y.dt1,y.tm1
    drop table #copy
    drop table #t

  • SQL Query Help Needed

    I'm having trouble with an SQL query. I've created a simple logon page wherein a user will enter their user name and password. The program will look in an Access database for the user name, sort it by Date/Time modified, and check to see if their password matches the most recent password. Unfortunately, the query returns no results. I'm absolutely certain that I'm doing the query correctly (I've imported it directly from my old VB6 code). Something simple is eluding me. Any help would be appreciated.
    private void LogOn() {
    //make sure that the user name/password is valid, then load the main menu
    try {
    //open the database connection
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:LawOffice2000", "", "");
    Statement select = con.createStatement();
    String strTemp = "Select * From EMPLOYEES Where INITIALS = '" + txtUserName.getText() + "' Order By DATE Desc, TIME Desc";
    ResultSet result = select.executeQuery(strTemp);
    while(result.next()) {
    if (txtPassword.getPassword().toString() == result.getString("Password")) {
    MenuMain.main();
    else {
    System.out.println("Password Bad");
    System.out.println(txtUserName.getText());
    System.out.println(result.getString("Password"));
    break; //exit loop
    //close the connection
    con.close(); }
    catch (Exception e) {
    System.out.println("LawOfficeSuite_LogOn: " + e);
    return; }
    }

    The problem is here: "txtPassword.getPassword().toString() == result.getString("Password"))"
    Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same characters), use equals(), e.g. if (str1.equals(str2))...
    Example:String s1 = "foo";
    String s2 = new String("foo");
    System.out.println("s1 == s2: " + (s1 == s2)); // false
    System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out Comparison operators: equals() versus ==

  • Need Assistance On PL/SQL Coding

    Hi,
    I'm doing the procurement system and I need to generate a report base on the <request_no> to locate each <order_item> record which had ordered for last two years.
    For example:
    =========
    request_no: REQ10010001
    Order Item:
    ITEM Output
    ===== =======
    1. LAMP PILOT TUBULAR CLEAR E-1 SEP'09 (75 pcs), NOV'09 (50 pcs)
    2. LAMP PILOT TUBULAR CLEAR E-2 DEC'08 (16pcs), AUG'09 (12 pcs), OCT'09 (80 pcs)
    3. LAMP PILOT TUBULAR CLEAR E-3 SEP'09 (4 pcs)
    Note: Generate the output as of today's query date, to locate back the past two years record and count the no. of pieces ordered /per item /per month.
    Please advice should I use function or store procedure to return the record?
    Please assist to provide the code sample on this for easy reference.
    Best regards,
    sm

    Hi,
    OK, i have a tablename: hdr_pos
    Fields: PO_NO, PO_DATE, PO_ITEM_NO etc...
    This table was keeping 10 years past history record.
    Can give me a sample of code in PL/SQL:-
    - I will input a PO_NO to generate the output (and in this PO is consisting 10 items).
    - As of today's date (03-Mar-2010) to locate past two years record based on PO_DATE, the past two years date range should be from (03-Mar-2008 to 03-Mar-2010).
    - The PO_DATE between (03-Mar-2008 to 03-Mar-2010) total up the no. of orders for every month.
    - Ouput listing will be by PO_ITEM, total of order/month.
    Example:-
    ITEM Output
    ===== =======
    1. LAMP PILOT TUBULAR CLEAR E-1 -------output-------> SEP'09 (75 pcs), NOV'09 (50 pcs)
    2. LAMP PILOT TUBULAR CLEAR E-2 -------output-------> DEC'08 (16pcs), AUG'09 (12 pcs), OCT'09 (80 pcs)
    3. LAMP PILOT TUBULAR CLEAR E-3 -------output-------> SEP'09 (4 pcs)
    10
    Hope you can help
    rdgs,
    sm

  • 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