Alternate for this code(joins)

CREATE TABLE [Store](
[StoreId] [int] IDENTITY(1,1) NOT NULL,
[LOC_Name] [varchar](50) NULL,
CONSTRAINT [PK_Store] PRIMARY KEY CLUSTERED
[StoreId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Insert into [dbo].[Store]
[LOC_Name]
select 'virginia'
union all
select 'chicago'
CREATE TABLE [Employee](
[StoreId] [int] NOT NULL,
[Emp_NAME] [nvarchar](70) NULL,
) ON [PRIMARY]
Insert into [dbo].[Employee]
[StoreId]
,[Emp_NAME]
select 1,'daniel'
union all
select 1,'jack'
union all
select 1,'roger'
union all
select 1,'matt'
union all
select 2,'sam'
union all
select 2,'henry'
union all
select 2,'eston'
union all
select 2,'robert'
union all
select 2,'nadal'
CREATE TABLE [Customer](
[CustomerId] [int] IDENTITY(1,1) NOT NULL,
[StoreId] [int] NOT NULL,
[CUST_NO] [nvarchar](11) NULL,
CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED
[CustomerId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
set identity_insert [CCC_STAGE].[dbo].[Customer_test] on
Insert into [CCC_STAGE].[dbo].[Customer_test]
[CustomerId]
,[StoreId]
,[CUST_NO]
select 201,1,897456
union all
select 202,1,974652
union all
select 203,1,276294
union all
select 204,1,612348
union all
select 205,2,187906
union all
select 206,2,289123
union all
select 207,2,427403
union all
select 208,2,591654
union all
select 209,2,904563
-------------- Query to retrieve In each location each employee is working on how many customers--
select [LOC_NAME],
B.[Emp_NAME],
COUNT(distinct C.[CUST_NO]) TOTAL_CUSTOMERS
FROM [CCC_STAGE].[dbo].[Store] A
join [CCC_STAGE].[dbo].[Employee] B
on A.StoreId=B.StoreId
join [CCC_STAGE].[dbo].[Customer] c
on B.StoreId=C.StoreId
--where LOC_NAME='virginia'
--where LOC_NAME='chicago'
group by [LOC_NAME]
,B.[Emp_NAME]
ORDER BY [LOC_NAME],B.[Emp_NAME]
Hi Everyone,
I inserted the code creating tables and inserting values to tables and also there is a query which retrieves the data from the tables I created.
In this scenario, what we need to get is.....
we need to find out in each location, each employee is working on how many customers, but with the query I wrote I get the data like, all the employee's are working on all the customers. Below is the output I should get
loc_name emp_name  total_customers
chiacgo    eston             1
Chicago    henry             2
Chicago    nadal             2
Chicago    Robert          1
but I am getting the below output which is in correct
loc_name emp_name  total_customers
chiacgo    eston            5
Chicago      henry         5
Chicago    nadal           5
Chicago    Robert         5
Why I am getting this out put can any one tell me please.... I am getting an out put like all the employees are working on all the customers.
Thanks
vishu

Thank you for trying to post DDL; unfortunately, you got it wrong. You also writer really bad SQL code. Only one store and one Personnel? And Personnel is not an attribute of store! We do not use IDENTITY in RDBMS, etc. 
CREATE TABLE Stores
(store_duns CHAR(9) NOT NULL PRIMARY KEY, -- wrong!
 store_location VARCHAR(50) NOT NULL);
The DUNS is the industry standard for a business identifier, but let's keep your INTEGER for now. A location should be on the same scale – that means a city-state location name. 
Do you really have only one employee, as you said? Why do you think a store is an attribute of this one guy? You have a relationship table here. Tables must have keys. 
Why did you use a emp_name NVARCHAR(70) as a key?? 
CREATE TABLE Store_Assignments 
(emp_id CHAR(10) NOT NULL 
  REFERENCES Personnel (emp_id)
  PRIMARY KEY, 
 store_duns CHAR(9) NOT NULL
  REFERENCES Stores(store_duns));
Customers also do not have a store as an attribute! They have a relationship. Is it 1:1, 1:m, n:m or what?? I will guess 1:1. D ou know what that means? You seem to have no idea how to write a basic schema. 
CREATE TABLE Customer_Assignments 
(customer_id CHAR(16) NOT NULL PRIMARY KEY
  REFERENCES Customers(customer_id)
 ON DELETE CASCADE , 
 store_duns CHAR(9) NOT NULL
  REFERENCES Stores(store_duns)
 ON DELETE CASCADE);
>> we need to find out in each location, each employee is working on how many customers, but with the query I wrote I get the data like, all the employee’s are working on all the customers. <<
Your design is garbage. Where did you assign a customer to an employee? (“Hello, my name is Joe and I will be your salesman/waiter!”). The location of a store is unimportant for this.  You need:
CREATE TABLE Customer_Agent
(customer_id CHAR(16) NOT NULL PRIMARY KEY
  REFERENCES Customers(customer_id)
 ON DELETE CASCADE, 
 emp_id CHAR(9) NOT NULL
  REFERENCES Personnel(emp_id)
 ON DELETE CASCADE);
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • Windows 8.1 will not allow me to join a domain Setting up a new 2012 server, and am trying to join laptops running Windows 8.1 to this new domain. When I go to properties for This Computer, Join a domain wizard is greyed out. Can I join a Windows 8.1 com

    Windows 8.1 will not allow me to join a domain
    I am trying to join laptops running Windows 8.1 to  domain. When I go to properties for This Computer, Join a domain wizard is greyed out. Can I join a Windows 8.1 computer to a domain?

    Have you verified that your Windows 8.1 is a Pro or Enterprise edition? The Basic edition cannot join a domain.

  • Equivalent for this code

    Hi, Could you please let me know what is the EQUIVALENT for this code. This code replace 2 number of  0s or 1s to Just one 0 or 1. The code is very very slow when the input string is very big. Is there any way to replace it with something faster.
    Thanks 
    Attachments:
    Untitled 1.vi ‏7 KB

    This code takes 1ms to run on a string of 60,000 characters (one continuous string of 0's and 1's).  Whereas using your code, it takes about 900ms for the same string.

  • User exit for  this code

    Hi ..
    my requirement  is the program should prompt for 3 parameters (all check marks) with the follwoing text; all check marks enabled by default
    - Variables
    - Key Figures
    - Structures
    So when users select variables then do this part in main program
    test_for = 'STR'.
    perform dowork using test_for.
    for key figures
    test_for = 'CKF'.
    perform dowork using test_for.
    test_for = 'SEL'.
    perform dowork using test_for.
    for variables
    test_for = 'VAR'.
    perform dowork using test_for.
    please give  the code how to write that one.
    thanks in advance
    Madhavi

    Hi Maik,
    am using this quode for one tool .this tool is used for copy queries from one system another instead of transporting.its easy method.so i want to do some modifications for this code.please elaborate ur answer .will assign points.
    Cheers,
    Madhavi

  • HT204003 I can't get passbook to accept my loyalty cards. It keeps saying no pass available for this code. What am I doing wrong?

    I can't get passbook to accept my loyalty cards. It keeps saying no pass available for this code. What am I doing wrong?

    You may have installed your TextWrangler application without administrator privileges. In this you'll have to look for the twdiff file in the Local Applications Support Folder (refer to TextWrangler User Manual).
    To fix your problem with Dreamweaver, while selecting your File Compare tool, try looking for the twdiff file in the following location :
    Macintosh HD:usr:local:bin:twdiff
    That should definitely work. It did for me
    Cheers!

  • Is there any alternative for this code to increase performance

    hi, i want alternate code for this to increase performance.
    DATA : BEGIN OF itab OCCURS 0,
                  matnr LIKE zcst-zmatnr,
                 checked TYPE i,
                 defected TYPE i,
               end of itab.
    SELECT DISTINCT zmatnr FROM zcst INTO TABLE itab WHERE
       zmatnr IN s_matnr AND
          zwerks EQ p_plant AND
          zcastpd IN s_castpd AND
          zcatg IN s_categ.
    LOOP AT itab.
        ind = sy-tabix.
    SELECT COUNT( DISTINCT zcst~zcastn )
           FROM zcst INNER JOIN zvtrans
           ON ( zcstzcastn = zvtranszcastn AND
                zcstzmatnr = zvtranszmatnr AND
                zcstzwerks = zvtranszwerks AND
                zcstgjahr  = zvtransgjahr )
           INTO itab-checked
           WHERE
               zcst~zmatnr = itab-matnr AND
               zcst~zwerks EQ p_plant AND
               zcastpd IN s_castpd AND
               zcatg IN s_categ.
    SELECT COUNT( DISTINCT zcst~zcastn )
          FROM zcst INNER JOIN zvtrans
          ON ( zcstzcastn = zvtranszcastn AND
               zcstzmatnr = zvtranszmatnr AND
               zcstzwerks = zvtranszwerks AND
               zcstgjahr  = zvtransgjahr )
          INTO itab-defected
          WHERE
              zcst~zmatnr = itab-matnr AND
              zcst~zwerks EQ p_plant AND
              zcastpd IN s_castpd AND
              zcatg IN s_categ AND
              zvtrans~zdcode <> '   '.
      MODIFY itab INDEX ind.
      ENDLOOP.
    i think, select within loop is reducing the performance
    pls reply

    Hi,
    types : BEGIN OF t_itab ,
        matnr LIKE zcst-zmatnr,
       checked TYPE i,
       defected TYPE i,
    end of t_itab.
    data : itab type table of t_itab,
             wa_itab type t_itab.
    and instead of looping as in ur code try to use for all entries and
    use nested loop.

  • Idea for this code pls

    Hi,
    In the below code, I have certain doubts.
    1.Do I need to go for inner join statements in fetching data for parameters?..
    2. How can I group by document type and print the total of net value...for this do i need to move the datas to another internal table ?..How to ?
    tables : vbak,vbap.
    data : begin of itab occurs 0,
            vbeln like vbak-vbeln,
            auart like vbak-auart,
            netwr like vbak-netwr,
            waerk like vbak-waerk,
            zmeng like vbap-zmeng,
            zieme like vbap-zieme,
            posnr like vbap-posnr,
            matnr like vbap-matnr,
            end of itab.
    select-options : s_vbeln for vbak-vbeln.
    Parameters     : s_vkorg(10) type c,
                     s_vtweg(10) type c,
                     s_spart(10) type c.
    start-of-selection.
    select avbeln aauart anetwr awaerk bzmeng bzieme bposnr bmatnr
    into table itab from vbak as a inner join vbap as b on b~vbeln =
    avbeln where avbeln in s_vbeln .
    loop at itab.
    write : /5 itab-vbeln,15 itab-posnr,25 itab-auart,
    30 itab-matnr,35 itab-zmeng,40 itab-zieme,45 itab-netwr,50 itab-waerk..
    endloop.
    Initialization.
    at selection-screen.
    IF   s_vbeln is initial and
         s_vkorg is initial and
         s_vtweg is initial and
         s_spart is initial.
        MESSAGE e000(zam).
      ENDIF.
      IF not s_vbeln is initial.
       select vbeln  auart netwr waerk from vbak into table itab where vbeln
                                                                 in s_vbeln.
        IF sy-subrc NE 0.
             MESSAGE e001(zam).
                 ENDIF.
        else.
        if not  s_vkorg is initial.
         select vbeln auart netwr waerk from vbak into table itab
                                         where vkorg = s_vkorg.
             if sy-subrc NE 0.
                 message e002(zam).
                         endif.
                          endif.
        If not s_vtweg is initial.
         select vbeln auart netwr waerk from vbak into table itab
                                          where vtweg = s_vtweg.
           If sy-subrc NE 0.
                message e003(zam).
                      endif.
                       endif.
         if not s_spart is initial.
            select posnr matnr zmeng zieme from vbap into table itab
                                               where spart = s_spart.
            if sy-subrc NE 0.
                 message e004(zam).
                     endif.
                       endif.
       ENDIF.

    The JOIN looks OK.
    You can move the document type to the beginning of the internal table and sort on it when the data is collected.Then:
      LOOP AT itab.
        AT NEW auart.
    * Totals
        ENDAT.
        WRITE :  /5 itab-vbeln,15 itab-posnr,25 itab-auart,
                 30 itab-matnr,35 itab-zmeng,40 itab-zieme,
                 45 itab-netwr,50 itab-waerk..
      ENDLOOP.
    Rob

  • Please give me flowchart for this code...

    Writing a Java applet to communicate with a serial device attached to the Device
    Server is very straightforward. However, familiarity with Java programming and a
    Java compiler are required.
    As with any network application, open a communication channel to the remote
    device. In our example, a socket is opened and and two data streams are created to
    perform the actual sending and receiving of data.
    The following example uses a new Java Class called tcpip. Copy the following code
    into a file called tcpip.java.
    import java.*;
    import java.lang.*;
    import java.net.*;
    import java.util.*;
    import java.io.*;
    * This class opens a TCP connection, and allows reading and writing of byte
    arrays.
    public class tcpip
    protected Socket s = null;
    public DataInputStream dis = null;
    protected DataOutputStream dos = null;
    public tcpip(InetAddress ipa, int port)
    Socket s1 = null;
    try { // Open the socket
    s1 = new Socket(ipa.getHostAddress(), port);
    catch (IOException e) {
    System.out.println("Error opening socket");
    return;
    s = s1;
    try { // Create an input stream
    dis = new DataInputStream(new
    BufferedInputStream(s.getInputStream()));
    catch(Exception ex) {
    System.out.println("Error creating input stream");
    try { // Create an output stream
    dos = new DataOutputStream(new
    BufferedOutputStream(s.getOutputStream()));
    catch(Exception ex) {
    System.out.println("Error creating output stream");
    public synchronized void disconnect()
    if (s != null) {
    try {
    s.close();
    catch (IOException e){}
    public synchronized void send(byte[] temp)
    try {
    dos.write(temp, 0, temp.length);
    dos.flush();
    catch(Exception ex) {
    System.out.println("Error sending data : " + ex.toString());
    public synchronized void send(byte[] temp, int len)
    try {
    dos.write(temp, 0, len);
    dos.flush();
    catch(Exception ex) {
    System.out.println("Error sending data : " + ex.toString());
    public synchronized void send(String given)
    // WARNING: this routine may not properly convert Strings to bytes
    int length = given.length();
    byte[] retvalue = new byte[length];
    char[] c = new char[length];
    given.getChars(0, length, c, 0);
    for (int i = 0; i < length; i++) {
    retvalue[i] = (byte)c;
    send(retvalue);
    public synchronized byte[] receive()
    byte[] retval = new byte[0];
    try {
    while(dis.available() == 0); /* Wait for data */
    catch (IOException e){}
    try {
    retval = new byte[dis.available()];
    catch (IOException e){}
    try {
    dis.read(retval);
    catch (IOException e){}
    return(retval);
    public int available()
    int avail;
    avail = 0;
    try {
    avail = dis.available();
    catch (IOException e) {}
    return(avail);
    Next, create the Text_io class as the application. Copy the following code
    into a file called �Text_io.java�.
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.*;
    public class Text_io extends Panel implements Runnable,
    TextListener {
    private tcpip gtp;
    String oldmessage = new String("");
    TextArea input_box = new TextArea("", 10, 60, 3);
    TextArea output_box = new TextArea("", 10, 60, 3);
    Thread timer;
    public Text_io(tcpip tp) {
    gtp = tp;
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5,5,5,5);
    setBackground(java.awt.Color.lightGray);
    setSize(561,380);
    c.gridx = 0; c.gridy = 2; c.gridwidth = 1; c.gridheight =
    1;
    c.weightx = 0.0; c.weighty = 0.0; c.anchor =
    GridBagConstraints.WEST;
    c.fill = GridBagConstraints.NONE;
    add((new Label("To Device Server: (Type Here--->)")), c);
    //input_box
    input_box.addTextListener(this);
    c.gridx = 1; c.gridy = 2; c.gridwidth = 3; c.gridheight =
    1;
    c.weightx = 0.5; c.weighty = 0.0; c.anchor =
    GridBagConstraints.CENTER;
    c.fill = GridBagConstraints.BOTH;
    add(input_box,c);
    c.gridx = 0; c.gridy = 4; c.gridwidth = 1; c.gridheight =
    1;
    c.weightx = 0.0; c.weighty = 0.0; c.anchor =
    GridBagConstraints.WEST;
    c.fill = GridBagConstraints.NONE;
    add((new Label("From Device Server:")), c);
    c.gridx = 1; c.gridy = 4; c.gridwidth = 3; c.gridheight =
    1;
    c.weightx = 0.5; c.weighty = 0.0; c.anchor =
    GridBagConstraints.CENTER;
    c.fill = GridBagConstraints.BOTH;
    add(output_box,c);
    output_box.setEditable(false);
    timer = new Thread(this);
    timer.start();
    public void run() {
    int i;
    byte[] in;
    Thread me = Thread.currentThread();
    while (timer == me) {
    try {
    Thread.currentThread().sleep(200);
    catch (InterruptedException e) { }
    if ( (gtp != null) && ((i = gtp.available()) > 0) ) {
    in = gtp.receive();
    /* remove non-printing bytes */
    for (i = 0; i < in.length; i++) {
    if (in[i] < 0x20)
    in[i] = 0x20;
    output_box.append((new String(in)));
    public void textValueChanged(TextEvent e) {
    int len, i;
    String str = new String("");
    String message = input_box.getText();
    len = message.length() - oldmessage.length();
    if (len < 0) {
    for (i = 0; i < -len; i++)
    str += "\b";
    //System.out.println("Backspace");
    else if (len > 0) {
    str = message.substring(oldmessage.length());
    //System.out.println("len = "+str.length()+" str =
    "+str);
    oldmessage = message;
    if ( (len != 0) && (gtp != null) )
    gtp.send(str);
    Next, create the actual applet that uses the tcpip and Text_io classes. Copy
    the following code into a file called �Test.java�.
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.Applet;
    import java.net.*;
    import java.io.*;
    import java.lang.*;
    import java.text.*;
    import java.util.*;
    public class Test extends Applet {
    static private boolean isapplet = true;
    static private InetAddress arg_ip = null;
    static private int arg_port = 0;
    public tcpip gtp = null;;
    InetAddress reader_ip = null;
    int port = 10001;
    public void init()
    gtp = null;
    reader_ip = null;
    port = 10001;
    public void start()
    String st = new String("TCP/IP connection status: ");
    setFont(new Font("Dialog",Font.BOLD,16));
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight
    = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(5,5,5,5);
    setBackground(Color.yellow);
    setSize(600,500);
    /* Either get the IP address from the HTTP server if
    we're an applet, or from the commandline (if passed).
    if (isapplet) {
    try{
    reader_ip = InetAddress.getByName(getCodeBase().getHost());
    catch (UnknownHostException e){}
    else {
    reader_ip = arg_ip;
    if (arg_port != 0) {
    port = arg_port;
    /* Open a socket to the Device Server's serial port
    if (reader_ip != null) {
    if (gtp == null) {
    gtp = new tcpip(reader_ip, port);
    if (gtp.s == null) {
    st += "Connection FAILED! ";
    gtp = null;
    if (gtp == null) {
    st += "Not Connected";
    add((new Label(st)), c);
    return;
    st += "Connected";
    add((new Label(st)), c);
    /* You may now perform IO with the Device Server via
    * gtp.send(byte[] data_out);
    * byte[] data_in = gtp.receive();
    * functions.
    * In our example we'll use two TextBoxes which have
    * been extended to handle IO to the Device Server.
    *Data typed in the upper text box will be sent to
    * the Device Server, and data received will be
    *displayed in the lower text box.
    /* Start of custom application code */
    /* ADD YOUR CODE HERE */
    c.gridx = 0; c.gridy = 2; c.gridwidth = 3; c.gridheight =
    1;
    c.anchor = GridBagConstraints.WEST;
    add((new Text_io(gtp)), c);
    /* End of custom application code */
    public void destroy()
    if (gtp != null)
    gtp.disconnect();
    gtp = null;
    public void stop() {
    public static void main(String[] args) {
    Frame frame = new Frame("TCP/IP Test");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    if (args.length > 0) {
    try{
    arg_ip = InetAddress.getByName(args[0]);
    catch (UnknownHostException e){}
    if (args.length > 1) {
    try {
    arg_port = Integer.valueOf(args[1]).intValue();
    catch (NumberFormatException e) {}
    Test ap = new Test();
    frame.add(ap);
    ap.init();
    isapplet = false;
    ap.start();
    frame.pack();
    frame.show();

    Let's see a decent try by you towards a solution first. I've found that usually the more thought and effort posters put into creating and solving their questions, the better their chances are of a volunteer here taking the time and effort to consider it and give a helpful answer. In other words, show that you are putting effort into doing your own homework first.
    Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. You may want to click on the Preview tab to make sure that your code is formatted correctly. Another way is to place the tag &#91;code] at the top of your block of code and the tag &#91;/code] at the bottom, like so:
    &#91;code]
      // your code block goes here.
      // note the differences between the tag at the top vs the bottom.
    &#91;/code]or
    {&#99;ode}
      // your code block goes here.
      // note here that the tags are the same.
    {&#99;ode}good luck

  • Scroll bars for this code...

    Hai All,
    Here is the problem i am placing .. when ever there are no.of records to display i want to put the scroll bars to view.... and i am adding my code ... can any one please give me the solution how to add vertical scroll bar to this code....
    import java.util.*;
    import java.awt.*;
    import java.sql.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.lang.ArithmeticException;
    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.CallableStatement;
    import java.sql.SQLException;
    import java.awt.BorderLayout;
    import java.awt.event.AdjustmentEvent;
    import java.awt.event.AdjustmentListener;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollBar;
    public class MyExample extends Frame {
    Thread t;
    Frame f ;
    Label bat_result,proc_reply,tot_records,tot_aft_records,dtrs_label,vrs_label1,vrs_label2,vrs_label3,or,dateformat,fileno,fname,fdcode,fdob,fappdate;
    Button b1,dialup,b2,report,b5,vrs,dtrs,dtrs_search,vrs_search;
    ActionListener a;
    TextField value,value1,vrs_fileno,vrs_fdate,vrs_tdate,dtrs_date,fileno_result,fdcode_result,fname_result,fdob_result,fappdate_result;
    Image image,icon;
    Toolkit tool;
    JProgressBar progress;
    JButton button;
    JLabel label1;
    JPanel topPanel;
    Random random;
    MediaTracker mTracker,mTracker1;
    public MyExample()
    setLayout(null);
    setSize(900,600);
         setResizable(true);
         setBackground(new Color(223,224,194));
         setTitle("Menu Window!");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
         tool = Toolkit.getDefaultToolkit();
    image = tool.getImage("");
    mTracker = new MediaTracker(this);
    mTracker.addImage(image,0);
         setSize(900,600);
         a = new MyActionListener();
         add(b1 = new Button(""));
         b1.setBounds(40,180,120,20);
    b1.setBackground(new Color(12632551));
    b1.setActionCommand("");
    b1.addActionListener(a);
    b1.setVisible(true);
         add(dialup = new Button(""));
         dialup.setBounds(40,230,120,20);
    dialup.setBackground(new Color(12632551));
    dialup.setActionCommand("");
    dialup.addActionListener(a);
    dialup.setVisible(true);
         add(b2 = new Button(""));
         b2.setBounds(40,280,120,20);
    b2.setBackground(new Color(12632551));
    b2.setActionCommand("");
    b2.addActionListener(a);
    b2.setVisible(true);
         add(report = new Button(""));
         report.setBounds(40,330,120,20);
    report.setBackground(new Color(12632551));
    report.setActionCommand("");
    report.addActionListener(a);
    report.setVisible(true);
    add(vrs = new Button(" "));
         vrs.setBounds(50,370,120,20);
    vrs.setBackground(new Color(12632551));
    vrs.setActionCommand("");
    vrs.addActionListener(a);
    vrs.setVisible(false);
    add(dtrs = new Button(" "));
         dtrs.setBounds(50,410,120,20);
    dtrs.setBackground(new Color(12632551));
    dtrs.setActionCommand("");
    dtrs.addActionListener(a);
    dtrs.setVisible(false);
    add(dtrs_label = new Label(" "));
    dtrs_label.setBounds(340, 180, 80, 20);
    dtrs_label.setVisible(false);
         add(vrs_label1 = new Label(" "));
    vrs_label1.setBounds(330, 180, 80, 20);
    vrs_label1.setVisible(false);
    add(vrs_label2 = new Label(" "));
    vrs_label2.setBounds(330, 230, 80, 20);
    vrs_label2.setVisible(false);
    add(vrs_label3 = new Label(" "));
    vrs_label3.setBounds(580, 230, 60, 20);
    vrs_label3.setVisible(false);
    add(dateformat = new Label(""));
    dateformat.setBounds(520,180, 80, 20);
    dateformat.setVisible(false);
    add(vrs_search = new Button(""));
         vrs_search.setBounds(250,180,120,20);
    vrs_search.setBackground(new Color(12632551));
    vrs_search.setActionCommand("");
    vrs_search.addActionListener(a);
    vrs_search.setVisible(false);
    add(dtrs_search = new Button(""));
         dtrs_search.setBounds(600,180,120,20);
    dtrs_search.setBackground(new Color(12632551));
    dtrs_search.setActionCommand("");
    dtrs_search.addActionListener(a);
    dtrs_search.setVisible(false);
    add(or = new Label(""));
    or.setBounds(500, 270, 80, 20);
    or.setVisible(false);
         add(b5 = new Button(""));
         b5.setBounds(40,380,120,20);
    b5.setBackground(new Color(12632551));
    b5.setActionCommand("");
    b5.addActionListener(a);
    b5.setVisible(true);
         add(proc_reply=new Label(" "));
         proc_reply.setBounds(350,300,150,20);
    proc_reply.setVisible(false);
    add(tot_records=new Label(" "));
         tot_records.setBounds(350,270,150,20);
    tot_records.setVisible(false);
    add(tot_aft_records=new Label(" "));
    tot_aft_records.setBounds(350,330,180,20);
    tot_aft_records.setVisible(false);
    show();
         addWindowListener(new WindowAdapter()
         public void windowClosing(WindowEvent w)
              System.exit(0);
    public void paint(Graphics g){
    g.drawImage(image,0,0,null);
    class MyActionListener implements ActionListener {
    public void actionPerformed(ActionEvent ae) {
    String s = ae.getActionCommand();
    if( ae.getSource() == button )
    button.setEnabled( false );
         if (s.equals("")) {
    int x=JOptionPane.showConfirmDialog(f,"Do You Want To Close");
         if(x==0){
         System.exit(0);
         else if (s.equals("")) {
         batch b=new batch();
              else if (s.equals("")) {
         dialcall dc=new dialcall();
              else if (s.equals("")){
    procedure proc=new procedure();
    else if (s.equals("")){
    reportcall rc=new reportcall();
    else if (s.equals("")) {
         verification vs=new verification();
              vs.verification1();
    else if (s.equals("")) {
         datatransfer dts=new datatransfer();
         dts.datatransfer1();
                   else if (s.equals("")) {
         datatransfer dts=new datatransfer();
         dts.display(dtrs_date.getText());
    else if (s.equals("")) {
         verification vs=new verification();
         vs.ver_display(vrs_fileno.getText(),vrs_fdate.getText(),vrs_tdate.getText());
    public class batch extends MyExample{
    public batch()
    setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
         Process p1;
         try{
         b1.removeActionListener(a);
         p1 = Runtime.getRuntime().exec("");
    p1.waitFor();
    t.sleep(8000);
         batchResult br=new batchResult();
    catch(Exception bat)
              JOptionPane.showMessageDialog(batch.this, "Error: "+bat.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    public class batchResult extends MyExample{
    public batchResult(){
    String conCount="";
         Connection conresult = null;
         PreparedStatement totalrecords;
         ResultSet resultset = null;
         Statement constmt = null;
         int hh=0;
         try{
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conresult = DriverManager.getConnection( "thindriver");
    constmt = conresult.createStatement();
    conCount = "query";
    totalrecords = conresult.prepareStatement(conCount);
    resultset = totalrecords.executeQuery(conCount);
                   try{
    if(resultset.next()){
                   hh = resultset.getInt("rec");
                   }catch(Exception we)
                        JOptionPane.showMessageDialog(batchResult.this, "Error: "+we.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
                   if(hh!=0){
    JOptionPane.showMessageDialog(f,"No.of records Imported: "+hh);
    else {
                   JOptionPane.showMessageDialog(f,"No Records Found to Transfer");
                   }catch(Exception ew)
                        JOptionPane.showMessageDialog(batchResult.this, "Error: "+ew.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    public class dialcall extends MyExample{
    public dialcall()
    b1.removeActionListener(a);
    setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
         Process p2;
         try{
         b1.removeActionListener(a);
         p2 = Runtime.getRuntime().exec("");
    p2.waitFor();
    catch(InterruptedException dl)
              JOptionPane.showMessageDialog(dialcall.this, "Error: "+dl.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    catch(Exception dl)
              JOptionPane.showMessageDialog(dialcall.this, "Error: "+dl.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    public class procedure extends MyExample{
    public procedure()
    setSize(900,600);
         setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
    b1.removeActionListener(a);
         dialup.removeActionListener(a);
         //b2.removeActionListener(a);
    Statement stmt = null;
         // DB Connection Variables
    final String driverClass = "oracle.jdbc.driver.OracleDriver";
    final String connectionURL = "";
    final String userID = "";
    final String userPassword = "";
    String beforeCount="";
         String afterCount="";
         Connection con = null;
         Connection con1 = null;
         PreparedStatement bCountRecords;
    PreparedStatement aCountRecords;
    int a=0,b=0;
    ResultSet rset2 = null;
         ResultSet rset1 = null;
         String cnt="";
         String cnt1="";
         String bb=null;
         //CallableStatement cstmt1 = null;
         //CallableStatement cstmt2 = null;
         ProgressBarExample pbe=new ProgressBarExample();
         pbe.setVisible( true );
         try{
         Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection( "thindriver");
    stmt = con.createStatement ();
    beforeCount = "";
              afterCount = "";
    bCountRecords = con.prepareStatement(beforeCount);
    aCountRecords = con.prepareStatement(afterCount);
              rset1 = bCountRecords.executeQuery(beforeCount);
                   try{
                   Runtime.getRuntime().exec(" ");
              Runtime.getRuntime().exec(" ");
    catch (Exception proc1) {
    proc1.printStackTrace();
         rset2 = aCountRecords.executeQuery(afterCount);
    if(rset1.next()){
                   a = rset1.getInt("bcnt");
                   String aa = Integer.toString(a);
              display1(aa);
    if(rset2.next())
         b=rset2.getInt("acnt");
         while(true){
                   rset2 = aCountRecords.executeQuery(afterCount);
              if (rset2.next()){
                   b=rset2.getInt("acnt");
                        System.out.println(a);
                                            System.out.println(b);
    if(b==a)
         bb = Integer.toString(b);
         display2(bb);
         processbar(a,b);
         button.setVisible( false );
         JOptionPane.showMessageDialog(f,"Records Transfered Successfully");
         break;
    else if (a!=0)
    processbar(a,b);
    else {
         pbe.setVisible(false);
    JOptionPane.showMessageDialog(f,"No Records found to transfer");
    break;
         } catch (ClassNotFoundException proc) {
    // proc.printStackTrace();
              JOptionPane.showMessageDialog(procedure.this, "Error: "+proc.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    } catch (SQLException proc) {
    // proc.printStackTrace();
              JOptionPane.showMessageDialog(procedure.this, "Error: "+proc.toString(), "Warning", JOptionPane.WARNING_MESSAGE);
    // proc_reply.setBounds(240,310,150,20);
    // proc_reply.setVisible(true);
    public void display1(String count)
         tot_records.setBounds(350,250,180,20);
         tot_records.setVisible(true);
         value=new TextField(count);
         value.setBounds(550,250,180,20);
         value.setVisible(true);
         add(value);
         value.setEditable(false);
         public void display2(String count1)
    tot_aft_records.setBounds(350,450,180,20);
         tot_aft_records.setVisible(true);
         value1=new TextField(count1);
         value1.setBounds(550,450,180,20);
         value1.setVisible(true);
         add(value1);
         value1.setEditable(false);
    public void processbar(int a,int b)
    label1.setText( "Record " + b+ " of "+a );
    Rectangle labelRect = label1.getBounds();
    labelRect.x = 0;
    labelRect.y = 0;
    label1.paintImmediately( labelRect );
    progress.setValue( b*100/a );
                                  Rectangle progressRect = progress.getBounds();
    progressRect.x = 0;
    progressRect.y = 0;
                                  progress.paintImmediately( progressRect );
         DoBogusTask(b);
    public void DoBogusTask( int iCtr )
    random = new Random( iCtr );
    for( int iValue = 0; iValue < random.nextFloat() *1; iValue++ )
    public     class ProgressBarExample extends JFrame
    public ProgressBarExample()
                        setTitle( "" );
                        setLocation(450,300);
    setSize( 310, 130 );
         //setBackground( Color. );
    // setBackground(new Color(14672066));
    topPanel = new JPanel();
    topPanel.setPreferredSize( new Dimension( 310, 130 ) );
    getContentPane().add( topPanel);
    label1 = new JLabel( "Waiting to start tasks..." );
    label1.setPreferredSize( new Dimension( 280, 24 ) );
    topPanel.add( label1 );
    progress = new JProgressBar();
    progress.setPreferredSize( new Dimension( 300, 20 ) );
                        progress.setMinimum( 0 );
    progress.setMaximum(100 );
    progress.setValue( 0 );
    progress.setBounds( 20, 35, 260, 20 );
    topPanel.add( progress );
    button = new JButton( "Start Process" );
    topPanel.add( button );
                        button.setVisible(false);
    button.addActionListener( a );
         public class reportcall extends MyExample{
    public reportcall()
    report.setVisible(true);
         b1.removeActionListener(a);
         b2.removeActionListener(a);
         report.removeActionListener(a);
         b5.setVisible(false);
         b5.setBounds(40,440,120,20);
         b5.setVisible(true);
    vrs.setVisible(true);
         dtrs.setVisible(true);
    public class verification extends MyExample{
    public void verification1(){
         setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
    vrs_fileno = new TextField("");
    vrs_fileno.setBounds(450, 180, 80, 20);
    add(vrs_fileno);
    vrs_fileno.setVisible(true);
         vrs_label1.setVisible(true);
         or.setBounds(450, 210, 80, 20);
         or.setVisible(true);
         vrs_fdate = new TextField("");
    vrs_fdate.setBounds(450, 230, 120, 20);
    add(vrs_fdate);
    vrs_fdate.setVisible(true);
         vrs_label2.setVisible(true);
         vrs_tdate = new TextField("");
    vrs_tdate.setBounds(650, 230, 120, 20);
    add(vrs_tdate);
    vrs_tdate.setVisible(true);
         vrs_label3.setVisible(true);
    dateformat.setVisible(false);
    dateformat.setBounds(780, 230, 120, 20);
    dateformat.setVisible(true);
         vrs_search.setVisible(false);
         vrs_search.setBounds(500,300, 80, 20);
         vrs_search.setVisible(true);
    public void ver_display(String fno,String fdate,String tdate){
    String FILE_NO1;
    String NAME1;
    String ADDRESS_TYPE1;
    String VER_STATUS1;
    int i1=0,b=0;
    Connection con1 = null;
    Statement stmt1 = null;
    try {
         Class.forName("oracle.jdbc.driver.OracleDriver");
    con1 = DriverManager.getConnection( "thin driver");
    stmt1 = con1.createStatement();
    String qry1 = "";
         String qry2 ="";
              ResultSet rs12 = stmt1.executeQuery(qry2);
                   if(rs12.next())
         b=rs12.getInt("cnt");
    if(b==0){
              JOptionPane.showMessageDialog(f,"No Records Found");}
                   else{
                        ResultSet rs11 = stmt1.executeQuery(qry1);
    while (rs11.next()) {
                   FILE_NO1 = rs11.getString(1);
    NAME1 = rs11.getString(2);
    ADDRESS_TYPE1 = rs11.getString(3);
    VER_STATUS1 = rs11.getString(4);
    show(FILE_NO1, NAME1, ADDRESS_TYPE1, VER_STATUS1, i1++);
    catch (ClassNotFoundException proc) {
    // proc.printStackTrace();
    catch (SQLException proc) {
    //proc.printStackTrace();
    public void show(String a, String b, String c, String d,int i) {
    Label fileno=new Label("File No");
    Label fname=new Label("Name");
    Label faddtype =new Label("Address Type");
    Label fstatus=new Label("Status");
         TextField fileno_result = new TextField(a);
    TextField fname_result = new TextField(b);
    TextField faddtype_result = new TextField(c);
    TextField fstatus_result = new TextField(d);
    fileno.setBounds(340, 180, 100, 20);
    add(fileno);
    fname.setBounds(440, 180, 130, 20);
    add(fname);
    faddtype.setBounds(575, 180, 120, 20);
    add(faddtype);
    fstatus.setBounds(700, 180, 90, 20);
    add(fstatus);
         fileno_result.setBounds(320, 200 + 20 * i, 100, 20);
    add(fileno_result);
    fileno_result.setVisible(true);
    fileno_result.setEditable(false);
    fname_result.setBounds(420, 200 + 20 * i, 150, 20);
    add(fname_result);
    fname_result.setVisible(true);
         fname_result.setEditable(false);
         faddtype_result.setBounds(570, 200 + 20 * i, 120, 20);
    add(faddtype_result);
    faddtype_result.setVisible(true);
         faddtype_result.setEditable(false);
    fstatus_result.setBounds(690, 200 + 20 * i, 120, 20);
    add(fstatus_result);
         fstatus_result.setVisible(true);
    fstatus_result.setEditable(false);
    public class datatransfer extends MyExample{
    public void datatransfer1(){
    setTitle("");
         icon = Toolkit.getDefaultToolkit().getImage("");
         setIconImage(icon);
    setVisible(true);
    dtrs_date = new TextField("");
    dtrs_date.setBounds(420, 180, 80, 20);
    add(dtrs_date);
         dateformat.setVisible(true);
    dtrs_date.setVisible(true);
         dtrs_search.setVisible(true);
         dtrs_label.setVisible(true);
    public void display(String date1){
    String FILE_NO;
    String DIST_CODE;
    String NAME;
    String DOB;
              String APPLN_DATE;
    int i1=0,b=0;
    Connection con1 = null;
    Statement stmt1 = null;
    try {
         Class.forName("oracle.jdbc.driver.OracleDriver");
    con1 = DriverManager.getConnection( "thin driver");
    stmt1 = con1.createStatement();
    String qry1 = "";
    String qry2 = "";
              ResultSet rs12 = stmt1.executeQuery(qry2);
                   if(rs12.next())
         b=rs12.getInt("cnt");
    if(b==0){
              JOptionPane.showMessageDialog(f,"No Records on this date");}
                   else{
                        ResultSet rs11 = stmt1.executeQuery(qry1);
    while (rs11.next()) {
                   FILE_NO = rs11.getString(1);
    DIST_CODE=rs11.getString(2);
                   NAME = rs11.getString(3);
    DOB = rs11.getString(4);
    APPLN_DATE = rs11.getString(5);
    show1(FILE_NO, DIST_CODE, NAME, DOB,APPLN_DATE,i1++);
    catch (ClassNotFoundException proc) {
    //proc.printStackTrace();
    catch (SQLException proc) {
    // proc.printStackTrace();
    public void show1(String a, String b, String c, String d,String e,int i) {
    fileno=new Label("File No");
    fdcode=new Label("District");
    fname =new Label("Name");
    fdob=new Label("Date Of Birth");
         fappdate=new Label("Application Date");
    TextField fileno_result = new TextField(a);
    TextField fdcode_result = new TextField(b);
    TextField fname_result = new TextField(c);
    TextField fdob_result = new TextField(d);
    TextField fappdate_result = new TextField(e);
    fileno.setBounds(323, 180, 80, 20);
    add(fileno);
    fdcode.setBounds(420, 180, 40, 20);
    add(fdcode);
    fname.setBounds(480, 180, 100, 20);
    add(fname);
    fdob.setBounds(590, 180, 120, 20);
    add(fdob);
    fappdate.setBounds(710, 180, 120, 20);
    add(fappdate);
         fileno_result.setBounds(320, 200 + 20 * i, 100, 20);
    add(fileno_result);
    fileno_result.setVisible(true);
    fileno_result.setEditable(false);
    fdcode_result.setBounds(420, 200 + 20 * i, 40, 20);
    add(fdcode_result);
    fdcode_result.setVisible(true);
         fdcode_result.setEditable(false);
         fname_result.setBounds(460, 200 + 20 * i, 120, 20);
    add(fname_result);
    fname_result.setVisible(true);
         fname_result.setEditable(false);
    fdob_result.setBounds(580, 200 + 20 * i, 120, 20);
    add(fdob_result);
         fdob_result.setVisible(true);
    fdob_result.setEditable(false);
    fappdate_result.setBounds(700, 200 + 20 * i, 120, 20);
    add(fappdate_result);
         fappdate_result.setVisible(true);
    fappdate_result.setEditable(false);
    public static void main(String[] args) {
    MyExample bpd = new MyExample();
    bpd.setVisible(true);
    }

    deleted - wrong forum, try the swing posting

  • How to improve performance for this code

    Hi,
    LOOP AT lt_element INTO ls_element.
    READ TABLE lt_element_ident INTO ls_element_ident
    WITH KEY element_id = ls_element-element_id BINARY SEARCH.
    IF sy-subrc EQ 0.
    MOVE ls_element_ident-value TO lv_guid.
    SELECT * FROM zcm_valuation_at
    APPENDING CORRESPONDING FIELDS OF TABLE lt_caseattributes
    WHERE case_guid = lv_guid.
    ENDIF.
    ENDLOOP.
    LOOP AT lt_caseattributes INTO ls_caseattributes.
    IF ls_caseattributes-ext_key IS INITIAL.
    SELECT SINGLE ext_key
    INTO CORRESPONDING FIELDS OF ls_caseattributes
    FROM scmg_t_case_attr
    WHERE case_guid = ls_caseattributes-case_guid.
    ENDIF.
    *To get the Status description of the Case
    SELECT SINGLE stat_ordno_descr
    INTO ls_caseattributes-status
    FROM scmgstatprofst AS a
    INNER JOIN scmg_t_case_attr AS b
    ON aprofile_id = bprofile_id
    AND astat_orderno = bstat_orderno
    WHERE case_guid = ls_caseattributes-case_guid.
    MODIFY lt_caseattributes FROM ls_caseattributes INDEX sy-tabix TRANSPORTING status ext_key.
    ENDLOOP.
    READ TABLE lt_caseattributes INTO ls_caseattributes INDEX 1.
    Regards,
    Maruti

    Hi,
    try this kind of code:
    ==================================
    start new
    DATA:
      lt_scmgstatprofst LIKE scmgstatprofst OCCURS 0 WITH HEADER LINE,
      wa_scmg_t_case_attr LIKE scmg_t_case_attr.
    SELECT * FROM scmgstatprofst INTO TABLE lt_scmgstatprofst.
    SORT lt_scmgstatprofst BY profile_id stat_orderno.
    end new
    LOOP AT lt_element INTO ls_element.
      READ TABLE lt_element_ident INTO ls_element_ident
      WITH KEY element_id = ls_element-element_id BINARY SEARCH.
      IF sy-subrc EQ 0.
        MOVE ls_element_ident-value TO lv_guid.
        SELECT * FROM zcm_valuation_at
        APPENDING CORRESPONDING FIELDS OF TABLE lt_caseattributes
        WHERE case_guid = lv_guid.
      ENDIF.
    ENDLOOP.
    LOOP AT lt_caseattributes INTO ls_caseattributes.
      IF ls_caseattributes-ext_key IS INITIAL.
        SELECT SINGLE ext_key
        INTO CORRESPONDING FIELDS OF ls_caseattributes
        FROM scmg_t_case_attr
        WHERE case_guid = ls_caseattributes-case_guid.
      ENDIF.
    *To get the Status description of the Case
    start deletion
    SELECT SINGLE stat_ordno_descr
    INTO ls_caseattributes-status
    FROM scmgstatprofst AS a
    INNER JOIN scmg_t_case_attr AS b
    ON aprofile_id = bprofile_id
    AND astat_orderno = bstat_orderno
    WHERE case_guid = ls_caseattributes-case_guid.
    end deletion
    start new
      CLEAR wa_scmg_t_case_attr.
      SELECT SINGLE * FROM scmg_t_case_attr INTO wa_scmg_t_case_attr
        WHERE case_guid = ls_caseattributes-case_guid.
      READ TABLE lt_scmgstatprofst WITH KEY
        profile_id   = wa_scmg_t_case_attr-profile_id
        stat_orderno = wa_scmg_t_case_attr-stat_orderno
        BINARY SEARCH.
      IF sy-subrc IS INITIAL.
        ls_caseattributes-status = lt_scmgstatprofst-stat_ordno_descr.
      ENDIF.
    end new
      MODIFY lt_caseattributes FROM ls_caseattributes INDEX sy-tabix
      TRANSPORTING status ext_key.
    ENDLOOP.
    READ TABLE lt_caseattributes INTO ls_caseattributes INDEX 1.
    ==================================
    Regards
    Walter Habich
    Edited by: Walter Habich on Jun 17, 2008 8:41 AM

  • Need some help for this code.

    Hi Everyone,
    I've test codes for east region and west region.
    I've a requirement to replace the west test id with east test id.
    That mapping has been done by the onshore team, I've got the mapping doc.
    But updating these details is a tricky part. It's nothing like direct update and replace those test codes.
    As per the mapping if it's
    In case of one to one (East - West) mapping which going to affect only a single row, I’ll have to update there,directly.
    In case of one – many (East - West) mapping and which is going to affect multiple rows, I’ll have to update the latest one and rest will be deleted only in that group. To identify the latest we have to check the latest order detail for that test.
    Suppose I've a west code named W123 and it has to be replaced with E123, in this case direct update.
    But now I've a transaction table where a patient has ordered multiple tests, In this case suppose the
    patiend id is P123 and ordered tests are W123, W234, W345; I'll have to update W123 as E123 and rest
    should not be deleted.
    But if I'll get multiple west code mapped towards single east code, the latest record as per the order detail needs
    to be updated and rest needs to be deleted if mapped with multiple west test codes, for single record and group record as well. Some thing like this.
    E123 - W123, W234 so I'll have to find out the latest and update there accordingly for single record and now
    patient has orderd multiple tests and the group record is like P123(patient) -----has orederd for W123, W234, W345.
    Now only the lastest test code suppose W234 has to be replaced with E123 and W123 has be deleted and W345
    should be there with E123.
    Now please see the code.
    CREATE OR REPLACE
    PROCEDURE P_UPDATE_TEST_ID AS
    V_EAST_TEST_ID            TEST_CODE_CONVERSION.EAST_TEST_ID%TYPE;
    V_ARRAY                   VARCHAR2(4000);
    V_COUNT                   NUMBER := 0;
    BEGIN
      FOR I IN (SELECT EAST_TEST_ID
                      ,STRAGG(WEST_TEST_ID) AS V_STRING
                FROM TEST_CODE_CONVERSION
                GROUP BY EAST_TEST_ID)
      LOOP
        V_EAST_TEST_ID            := I.EAST_TEST_ID;
        V_ARRAY                   := I.V_STRING;
        V_COUNT                   := V_COUNT+1;
        DBMS_OUTPUT.PUT_LINE('EAST_TEST_ID = ' ||V_EAST_TEST_ID|| ' || '||
                             'WEST_TEST_ID = ' ||v_array);
        Now after this I need to segregate the string values and check individual record
        and group record as well, for update. Now If I'll add the regexp_substr, then how
        to map those extracted values for checking.
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('v_count = ' ||V_COUNT);
    END P_UPDATE_TEST_ID;Please suggest something.
    Regards,
    BS2012.
    Edited by: BS2012 on May 23, 2013 4:40 PM

    Hi Bawer,
    Thanks for your interest, but I've done that yesterday.
    Bawer wrote:
    Sorry, but
    >
    Here I'll have to check which one is the latest and update that with relative east test id ...
    >how do you describe the *'latest'* and *'relative east'* ?We have one more template table where we'll have to take the max of template_test_id to figure out "which one is the latest?" To identify the relative east we have a parent table named "test" from there we can find the relative test ids by the column name called East_west_ind (indicator); as per the mapping.
    and depending to this,
    >
    ... rest one has to be deleted and other should be untouched.
    >which one is here, in your sample to be deleted and which should be untouched?
    (maybe a sample after-update output?)If you see the patient id 93, we have number of tests has been ordered. But 3257, 3515 test ids are same as per the mapping. So we need to check the max of template_test_id to figure out "which one is the latest?" as we have one entry in template table always for a new order. In terms of that I'll have to update 3257 as it's the latest entry and 3515 has to be deleted and rest of the test ids should be untouched. I did it yesterday, but i couldn't respond you. Thanks once again for your interest.

  • TS3694 what is error code 1015? i can not restore my iphone for this code. thanks

    im having a issue with my sons iphone. it wont restore! can anyone help in this matter? thank you

    Your phone is jailbroken.  That's what the error code means.  It's likely you'll never get it working again. 
    Further discussion of jailbroken phones is against the Terms of Use of this forum that YOU agreed to by signing up to post here.
    You'll have to go elsewhere for help, if there's even any help to be had.

  • Please can someone do a Sequence Diagram for this code

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Bgame extends JFrame implements ActionListener
         Map map;
         Location location = new Location();
         Player[] player = new Player[2];
         int playeri = 0;
         Player playerx;
         Image boardi = null;
         Image bcar = null;
         Image gcar = null;
         JButton spinButton = new JButton("Spin");
         JLabel spun = new JLabel("");
         JButton houseButton = new JButton();
         JButton carButton = new JButton();
         JButton playersButton = new JButton();
         JButton bankButton = new JButton();
    public Bgame()
         addWindowListener(new WindowAdapter()
         public void windowClosing(WindowEvent ev)
                   dispose();
                   System.exit(0);
         setBounds(1,1,800,600);
         getContentPane().setLayout(null);
         loadImages();
         map = new Map(boardi);
         map.setLocation(111,0);
         getContentPane().add(map);
         createCpan();
         player[0] = new Player(bcar,Color.black);
         player[1] = new Player(gcar,Color.green);
         map.add(player[0]);
         map.add(player[1]);
         setVisible(true);
         playerx = player[playeri];
         playerx.spin();
         monitor();
    private void monitor()
         Timer timer = new Timer(1000, new ActionListener()
              public void actionPerformed(ActionEvent e)
                   if (playerx.hasToGo)
                        //getToolkit().beep();
                        if (spun.getForeground() == playerx.color)
                             spun.setForeground(Color.gray);
                        else spun.setForeground(playerx.color);
                        return;
                   if (playerx.hasToSpin)
                        if (spinButton.getBackground() == playerx.color)
                             spinButton.setBackground(Color.lightGray);
                        else spinButton.setBackground(playerx.color);
                        return;
              playeri++;
              if (playeri == 2) playeri = 0;
              playerx = player[playeri];
              playerx.spin();
              spun.setText("");
              spinButton.setEnabled(true);
              spinButton.setBackground(playerx.color);
         timer.start();
    private void loadImages()
         boardi = getToolkit().getImage("Game.gif");
         bcar = getToolkit().getImage("blackCar.gif");
         gcar = getToolkit().getImage("blueCar.gif");
         MediaTracker tracker = new MediaTracker(this);
         tracker.addImage(boardi,0);
         tracker.addImage(bcar,0);
         tracker.addImage(gcar,0);
         try {tracker.waitForID(0);}
         catch (InterruptedException e){}
    private void createCpan()
         JPanel pan = new JPanel();
         pan.setLayout(null);
         pan.setBounds(0,0,110,500);
         pan.setBackground(Color.pink);
         spinButton.setBounds(10,34,90,30);
         spinButton.addActionListener(this);
    pan.add(spinButton);
         spun.setBounds(10,64,90,30);
    pan.add(spun);
         getContentPane().add(pan);
    public void actionPerformed(ActionEvent e)
         if(e.getSource() == spinButton)
              int spin = (int)(Math.random()*3+1);
              spun.setText("Total spun = "+spin);
              spun.setForeground(playerx.color);
              spinButton.setBackground(Color.lightGray);
              int togo = playerx.location+spin;
              playerx.go(togo,location.getX(togo),location.getY(togo));
              spinButton.setEnabled(false);
    public static void main (String[] args)
         new Bgame();
    import java.util.*;
    public class Location
         Space[] spaces = new Space[29];
    public Location()
         spaces[0] = new Space(1,238,135,"Start Career");
         spaces[1] = new Space(2,346,135,"Pay Day");
         spaces[2] = new Space(3,417,135,"Rent a Flat Pay 5,000");
         spaces[3] = new Space(4,492,167,"Raffle Prize Collect 10,000");
         spaces[4] = new Space(5,500,218,"PAY DAY");
         spaces[5] = new Space(6,570,269,"STOP Get Married LIFE");
         spaces[6] = new Space(7,570,344,"Wedding Reception Pay 10,000");
         spaces[7] = new Space(8,517,344,"Extra Tuition Pay 5,000 to Teacter");
         spaces[8] = new Space(9,465,344,"Win Quiz Show Collect 95,000");
         spaces[9] = new Space(10,407,344,"PAY DAY");
         spaces[10] = new Space(11,352,344,"Sponsor Golf Pay 35,000 to Athlete");
         spaces[11] = new Space(12,300,344,"Play a family game LIFE");
         spaces[12] = new Space(13,246,344,"Buy Furniture PAY 10,000");
         spaces[13] = new Space(14,183,344,"Visit in laws LIFE");
         spaces[14] = new Space(15,118,344,"STOP Buy a house");
         spaces[15] = new Space(16,68,344,"PAY DAY");
         spaces[16] = new Space(17,10,356,"Swap Salary Cards with any other player");
         spaces[17] = new Space(18,10,412,"Sponsor an athletee Pay 35,000 to Athlete");
         spaces[18] = new Space(19,61,412,"Taxes Due PAY Accountant");
         spaces[19] = new Space(20,115,412,"Baby Girl LIFE");
         spaces[20] = new Space(21,175,412,"Move to a new city PAY 10,000 to Pilot");
         spaces[21] = new Space(22,235,412,"Help the homeless LIFE");
         spaces[22] = new Space(23,304,412,"Win the Lottery Collect 50,000");
         spaces[23] = new Space(24,369,412,"Art auction Pay 20,000 to Artist");
         spaces[24] = new Space(25,434,412,"Invest in a theatre PAY 5,000 To Actor");
         spaces[25] = new Space(26,489,433,"Taxes Due Pay Accountant");
         spaces[26] = new Space(27,518,470,"PAY DAY");
         spaces[27] = new Space(28,519,529,"Night School PAY 10,000 To Teacher");
         spaces[28] = new Space(29,385,529,"RETIRE");
    public int getX(int i)
         return(spaces.x);
    public int getY(int i)
         return(spaces[i].y);
    public String getText(int i)
         return(spaces[i].txt);
    public class Space
         int n,y,x;
         String txt;
    public Space(int n, int x, int y, String txt)
         this.n = n;
         this.y = y-82;
         this.x = x+14;
         this.txt = txt;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Map extends JPanel
         Image board;
         JLabel txt = new JLabel("");
    public Map(Image i)
         board = i;
         setLayout(null);
         setSize(board.getWidth(null),board.getHeight(null));
         addMouseListener(new MouseAdapter()
              public void mouseReleased(MouseEvent m)
                   System.out.println(""+m);
         txt.setBounds(456,04,200,24);
         txt.setBackground(Color.lightGray);
         txt.setOpaque(true);
         add(txt);
    public void setText(String s, Color c)
         txt.setText(s);
         txt.setForeground(c);
    public void paint(Graphics g)
         super.paint(g);
         g.drawImage(board,0,0,null);
         paintComponents(g);
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.image.BufferedImage;
    public class Player extends JLabel
         int location = -1;
         Color color;
         boolean hasToGo = false;
         boolean hasToSpin = false;
         Point sloc;
         int tox,toy;
         int mx,my;
         boolean inPlace = false;
    public Player(Image car, Color c)
         super();
         setIcon(new ImageIcon(trans(car)));
         color = c;
         setBounds(10,10,car.getWidth(null),car.getHeight(null));
         if (getWidth() < 1) setSize(40,40);
         addMouseListener(new MouseAdapter()
         {     public void mousePressed(MouseEvent m)
                   sloc = getLocation();
                   mx = m.getX();
                   my = m.getY();
              public void mouseReleased(MouseEvent m)
                   if (getBounds().contains(tox,toy)) hasToGo = false;
                        else setLocation(sloc);
                   inPlace = false;
                   repaint();
         addMouseMotionListener(new MouseMotionAdapter()
         {     public void mouseDragged(MouseEvent m)
                   if (! hasToGo) return;
                   int x = getX() + m.getX() - mx;
                   int y = getY() + m.getY() - my;
                   if (x < 0) x = 0;
                   if (y < 0) y = 0;
                   setLocation(x,y);
                   if (getBounds().contains(tox,toy)) inPlace = true;
                   else inPlace = false;
                   repaint();
    public void go(int l ,int x, int y)
         hasToGo = true;
         hasToSpin = false;
         tox = x;
         toy = y;
         location = l;
    public void spin()
         hasToSpin = true;
    public void paint(Graphics g)
         super.paint(g);
         g.setColor(color);
         if (inPlace)
              g.setColor(Color.red);
              g.fillRect(8,8,16,16);
         else
              g.setColor(color);
              g.drawRect(0,0,36,38);
              g.drawRect(1,1,34,36);
    public BufferedImage trans(Image img)
         int w = img.getWidth(null);
         int h = img.getHeight(null);
         if (w < 1) w = 40;
         if (h < 1) h = 40;
         BufferedImage to = new BufferedImage(w,h,BufferedImage.TYPE_4BYTE_ABGR);
         to.getGraphics().drawImage(img,0,0,null);
         int r1 = to.getRGB(0,0);
         for (int x=0; x < w; x++)
              for (int y=0; y < h; y++)
                   if (to.getRGB(x,y) == r1) to.setRGB(x,y,0);
         return(to);

    To be fair to Phil, the person wasn't asking how to do a sequence diagram, they just wanted one given to them. I'm sure they would have got a more friendly/informative reply if they had actually asked how to do one.

  • ANY alternate for this???

    Hi Experts,
    Pls see the current method we are following for receiving overdelivery and suggest an alternate.
    1) At material master the Base unit of Measure is "EA".
    2) No alternate unit is maintained.
    3) At PO Item level I feed in Oun = EA & OPU = KG. System asks the conversion factor between KG & EA. I enter 1 EA = 100 kg. check unlimited delivery and save.
    4) At the time of GR I realise the goods that have come in weigh 105kgs/pc. Since I pay vendor in KGs I need to show that at MIGO by not increasing quantity. (wherein I can increase total weight since EA & KG are interlinked any increase in KG will also trigger EA)
    5) Right now we are just amending the PO by changing 1 EA = 105 KGs and inwarding material.
    6) Is there anyway I can keep my quantity STATIC and change Weight only at the time of MIGO?
    Thanks & Regards,
    Rajoo

    you can get what you want by so-called batch specific units of measure.
    http://help.sap.com/saphelp_erp2005/helpdata/en/30/e1a993db3611d185160000e82013e8/frameset.htm

  • Why do i get classcast exception for this code

    import java.util.*;
    public class Test1{
    public static void main(String a[]){
    Set s = new TreeSet();
    s.add(new Person(20));
    s.add(new Person(10));
    System.out.println(s);
    class Person{
    Person(int i){}
    }

    basically classcast exception is thrown when the class can not be casted with the proper form that is demanded.
    1> in case of set the value should be mutually comparable. but unfortunately in you code you have not implemented comparable interface. you should implement that interface.
    2> after using the comparable interface you should implement the method <class object 1>.compateTo(<class object 2>)
    the above two process should exclude the exception from you code hopefully.
    check out!

Maybe you are looking for