I need sql query please help me out

I have two databases 1) erp 2) edusource
In erp database i  have table  master tables and  columns  like RecordId , value type ,Feildtext,description,Meaining,parentid etc
 data stores based on value type like
1
Country
In
India
NULL
    NULL
True
2
Country
Aus
Austrilia
NULL
    NULL
True
3
Country
Usa
United States of America
NULL
    NULL
True
4
Country
Uk
Great Britian
NULL
    NULL
True
5
State
AP
Andhrapradesh
NULL
     1
True
6
State
MH
Maharastha
NULL
     1
True
7
State
TN
Tamilnadu
NULL
     1
True
8
State
Sdy
Sydney
NULL
     2
True
9
State
MEL
Melbourne
NULL
2
True
10
Location
IN-Hyd
Hyderabad
NULL
1
True
11
Location
In SEz
Sez-Hyderabad
NULL
1
True
NULL
NULL
NULL
NULL
NULL
NULL
NULL
for  country and state we have a relation ship parentid and recordid
country
1 Country
In India
                                   NULL
NULL 1
2 Country
Aus Austrilia
                           NULL
NULL 1
3 Country
Usa United States of America    NULL
NULL 1
4 Country
Uk Great Britian
                NULL
NUL          1 
5 State
AndhraPradesh Ap
NULL 1
1
6 State
Maharastha MH
NULL 1
1
7 State
Tamilnadu        TN
NULL        1
1
8 State
Sydney            Sdy   NULL
      2 1
9 State        Melbourne       MEL
NULL       2
1
  in edusource  database i have location and columns like countryname,statename,feildtext,descriptiom,isactive
i need to insert data in edusource
 database of tbl_ maplocation from that that database

Try this out:
DECLARE @geog TABLE (ID INT, type VARCHAR(20), Abrev VARCHAR(6), name VARCHAR(30), parentID INT, Active VARCHAR(5))
INSERT INTO @geog (ID, type, Abrev, name, parentID, Active) VALUES
(1 , 'Country' ,'In ', 'India ', NULL, 'TRUE'),(2 , 'Country' ,'Aus ', 'Austrilia ', NULL, 'TRUE'),
(3 , 'Country' ,'Usa ', 'United States of America', NULL, 'TRUE'),(4 , 'Country' ,'Uk ', 'Great Britian ', NULL, 'TRUE'),
(5 , 'State' ,'AP ', 'Andhrapradesh ', 1 , 'TRUE'),(6 , 'State' ,'MH ', 'Maharastha ', 1 , 'TRUE'),
(7 , 'State' ,'TN ', 'Tamilnadu ', 1 , 'TRUE'),(8 , 'State' ,'Sdy ', 'Sydney ', 2 , 'TRUE'),
(9 , 'State' ,'MEL ', 'Melbourne ', 2 , 'TRUE'),(10 , 'Location' ,'IN-Hyd', 'Hyderabad ', 1 , 'TRUE'),
(11 , 'Location' ,'In SEz', 'Sez-Hyderabad ', 1 , 'TRUE')
SELECT g1.ID, COALESCE(g2.name,g1.name) AS countryName, g1.name AS stateName, g1.name AS fieldText, CASE WHEN COALESCE(g2.Active,'TRUE') = 'TRUE' AND g1.Active = 'TRUE' THEN 'TRUE' ELSE 'FALSE' END AS Active
FROM @geog g1
LEFT OUTER JOIN @geog g2
ON g1.parentID = g2.ID
AND g1.type IN ('location','state')
WHERE g1.Active = 'TRUE'
AND COALESCE(g2.Active,'TRUE') = 'TRUE'
I think you may want to further the relationship, and have 10 be the parent for 11, so you can get country, state, location.

Similar Messages

  • Cluster bar chart- sql query please help-

    Hi,
    I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
    Here is my table
    city     region      issue     value
    c1     north     i1     y
    c1     north     i2     y
    c2     north     i1     n
    c2     north     i2     y
    c3     south     i1     y
    c3     south     i2     n
    c4     east     i1     n
    c4     east     i2     n
    The bar chart will have 3 series, north south and east.
    And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
    How can I get something like this from the above table-
    region     issue     count(yes)
    north     i1     1
    north     i2     2
    south     i1     1
    south     i2     0
    east     i1     0
    east     i2     0
    thanks

    WITH table1 AS
    (SELECT 1435177 qte_id, 2 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no
    FROM dual
    table2 AS
    SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
    FROM dual
    SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
    FROM
    (SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
    FROM table1 t1, table2 t2
    WHERE t2.qte_id = t1.qte_id (+)
    AND t2.seq_no = t1.seq_no(+)
    ORDER BY 1,2
    WHERE t1_seq_no IS NOT NULL
    ORDER BY 1,2
    QTE_ID T2_SEQ_NO DIFF
    1435177 2 0
    1435177 5 0
    1435177 7 0
    1435177 8 0
    1435177 12 0
    1435177 14 0

  • Passing parameter to a SQL query - Please help

    Hi All,
    I am new to JDBC. I have been trying to pass an external variable to an SQL Query.
    The query is
    String username1="le";
    PreparedStatement pstmt = null;
    pstmt = c.prepareStatement("select * from users where USER_NAME like '%?%'");
         pstmt.setString(1, username1);
         pstmt.executeQuery();
         ResultSet rs = pstmt.getResultSet();
    I am trying to retrieve values from the users table where the USER_NAME column value that is a String contains the supplied value username1.
    I am using the question mark (?) character to pass the value from the variable username1. I am also using the '%' substitution character which matches for any number of characters. So, the above query should retrieve rows where the USER_NAME is something like "charles","leander","Elena" etc.( that contains "le")
    I am getting the error:
    SQLException: java.sql.SQLException: ORA-01006: bind variable does not exist
    I changed the query to
    PreparedStatement pstmt = null;
    pstmt = c.prepareStatement("select * from users where USER_NAME like '% " + username1 + "%'");
         //pstmt.setString(1, username1);
         pstmt.executeQuery();
    This time , it is not giving the error and retrieving properly.
    But I want to use the original query and use the "pstmt.setString(1, username1); " . Is there any way of achieving this?
    Please help.
    Cheers,
    charles_am

    hi,
    try this...
    String username1="%le%";
    pstmt = c.prepareStatement("select * from users where USER_NAME like ?")
    pstmt.setString(1,username1);
    cheers,
    rpk

  • Single sql query-please help

    Hi experts,
    what i want to do is write a single query which will show whether a employee
    exits in the company or not.I have two tables emp and dept.There are as follows.
    SQL> select * from emp;
    NAME DEPTNO EMPNO
    xxx 10 33036
    YYY 12 2345
    ZZZ 13 678
    KKK 14 5678
    RRR 15 7865
    SQL> select * from dept;
    DEPTNO LOCATION
    10 AAA
    11 BBB
    12 CCC
    13 DDD
    what i want is it will select records from the emp table and find whether corrosponding
    deptno really exists in the dept table.If the value is found in deptno column the dept table then it will set the value
    Y other wise it will be N and all i have to do with the help of a single query.
    expected result
    name empno exists
    xxx 33036 Y
    YYY 2345 Y
    ZZZ 678 Y
    KKK 5678 N
    RRR 7865 N
    Please help.
    Regards
    Rajat

    SELECT EMPNO, NAME , EMPNO , NVL( ( SELECT 'Y' FROM    DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO),'N') EXIST
    FROM EMP
    ORDER BY 1
    Demo
    SQL> WITH EMP AS(
      2  SELECT 'XXX' NAME , 10 DEPTNO ,33036  EMPNO FROM DUAL UNION
      3  SELECT 'YYY', 12, 2345 FROM DUAL UNION
      4  SELECT 'ZZZ', 13 ,678 FROM DUAL UNION
      5  SELECT 'KKK', 14 ,5678 FROM DUAL UNION
      6  SELECT 'RRR', 15 ,7865 FROM DUAL  ),
      7  DEPT AS(
      8  SELECT 10  DEPTNO,'AAA' DNAME FROM DUAL UNION
      9  SELECT 11 ,'BBB' FROM DUAL UNION
    10  SELECT 12 ,'CCC' FROM DUAL UNION
    11  SELECT 13 ,'DDD'FROM DUAL )
    12  SELECT EMPNO, NAME , EMPNO , NVL( ( SELECT 'Y' FROM    DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO),'N')
    EXIST
    13  FROM EMP
    14  ORDER BY 1
    15  /
         EMPNO NAM      EMPNO E
           678 ZZZ        678 Y
          2345 YYY       2345 Y
          5678 KKK       5678 N
          7865 RRR       7865 N
         33036 XXX      33036 Y
    SQL> Edited by: Salim Chelabi on Dec 7, 2008 4:15 AM

  • SQL Query -- Please Help

    Table1
    QTE_ID     SEQ_NO
    1435177     2
    1435177     5
    1435177     7
    1435177     8
    1435177     12
    1435177     14
    Table2
    QTE_ID     SEQ_NO     CMMT_CURR_AMT
    1435177     1     98500
    1435177     2     98500
    1435177     3     0
    1435177     4     98500
    1435177     5     98500
    1435177     7     98500
    1435177     8     98500
    1435177     11     59300
    1435177     12     59300
    1435177     14     59300
    The result should be
    QTE_ID     SEQ_NO     CMMT_CURR_AMT
    1435177     2     0 (where 0 = cmmt_curr_amt of seq 2 - cmmt_curr_amt of seq 1 from table 2)
    1435177     5     0 (where 0 = cmmt_curr_amt of seq 5 - cmmt_curr_amt of seq 4 from table 2)
    1435177     7     0 (where 0 = cmmt_curr_amt of seq 7 - cmmt_curr_amt of seq 5 from table 2)
    1435177     8     0 (where 0 = cmmt_curr_amt of seq 8 - cmmt_curr_amt of seq 7 from table 2)
    1435177     12     0 (where 0 = cmmt_curr_amt of seq 12 - cmmt_curr_amt of seq 11 from table 2)
    1435177     14     0 (where 0 = cmmt_curr_amt of seq 14 - cmmt_curr_amt of seq 12 from table 2)
    I have to get the difference of cmmt_curr_amt from the table2 from seq 14 to seq 12 for seq14 in table 1.
    Please help me in writing the query.
    Thanks in advance.
    Srinivas

    WITH table1 AS
    (SELECT 1435177 qte_id, 2 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no
    FROM dual
    table2 AS
    SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
    FROM dual
    UNION ALL
    SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
    FROM dual
    SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
    FROM
    (SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
    FROM table1 t1, table2 t2
    WHERE t2.qte_id = t1.qte_id (+)
    AND t2.seq_no = t1.seq_no(+)
    ORDER BY 1,2
    WHERE t1_seq_no IS NOT NULL
    ORDER BY 1,2
    QTE_ID T2_SEQ_NO DIFF
    1435177 2 0
    1435177 5 0
    1435177 7 0
    1435177 8 0
    1435177 12 0
    1435177 14 0

  • I need to denormalize data in sql query, please help!

    With the query
    select ref, start_time, end_time, person
    from appointments
    I get, eg:
    REF START_TIME END_TIME PERSON
    1234 10:00 11:00 USER1
    1234 10:00 11:00 USER2
    The users want to see it like this:
    REF START_TIME END_TIME PERSON
    1234 10:00 11:00 USER1, USER2
    How do I do this just in sql?
    cheers
    Tracey.

    Apologies, my mistake, I forgot to connect by the ref as well...
    (Note: you can ignore the CAST to VARCHAR2(40) as that just helped me get the formatted output.)
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 1234 as ref, '10:00' as start_time, '11:00' as end_time, 'USER1' as person from dual union all
      2             select 1234, '10:00', '11:00', 'USER2' from dual union all
      3             select 345, '11:00', '12:00', 'USER3' from dual)
      4  -- END OF TEST DATA
      5  select ref, start_time, end_time, CAST(MAX(LTRIM(SYS_CONNECT_BY_PATH(person,', '),', ')) AS VARCHAR2(40)) as users
      6  from (select ref, start_time, end_time, person
      7              ,row_number() over (partition by ref, start_time, end_time order by person) rn
      8        from t) t
      9  CONNECT BY rn = PRIOR rn+1 AND ref = PRIOR ref
    10  START WITH rn = 1
    11* GROUP BY ref, start_time, end_time
    SQL> /
           REF START END_T USERS
          1234 10:00 11:00 USER1, USER2
           345 11:00 12:00 USER3
    SQL>

  • NEED SQL QUERY writing help

    oracle 10g.
    os : linux
    table data appears like this
    SQL> select * from test_grp;
    COL1 COL2
    aaa 111
    aaa 444
    aaa 222
    bbb 333
    bbb 555
    SQL> select * from test_grp order by 2;
    COL1 COL2
    aaa 111
    aaa 222
    bbb 333
    aaa 444
    bbb 555
    As per my application requirement I need to seggerage the data as
    follows
    aaa (2) ie --- 111,222
    bbb(1) is --- 333
    aaa(1) is --- 444
    bbb(1) is -- 555
    I am not able to frame this. Any help ?

    SQL> create table test_grp
      2  as
      3  select 'aaa' col1, 111 col2 from dual union all
      4  select 'aaa', 444 from dual union all
      5  select 'aaa', 222 from dual union all
      6  select 'bbb', 333 from dual union all
      7  select 'bbb', 555 from dual
      8  /
    Tabel is aangemaakt.
    SQL> select col1
      2       , col2s
      3    from ( select col1
      4                , rtrim(col2s,',') col2s
      5                , rn
      6                , sumn
      7             from ( select col1
      8                         , col2
      9                         , sum(n) over (order by col2) sumn
    10                      from ( select col1
    11                                  , col2
    12                                  , case when col1 = lag(col1) over (order by col2) then 0 else 1 end n
    13                               from test_grp
    14                           ) t
    15                  )
    16            model
    17                  partition by (sumn)
    18                  dimension by (row_number() over (partition by sumn order by col2) rn)
    19                  measures (col1, cast(col2 as varchar2(100)) col2s)
    20                  rules
    21                  ( col2s[any] order by rn desc = col2s[cv()] || ',' || col2s[cv()+1]
    22                  )
    23         )
    24   where rn = 1
    25   order by sumn
    26  /
    COL COL2S
    aaa 111,222
    bbb 333
    aaa 444
    bbb 555
    4 rijen zijn geselecteerd.Regards,
    Rob.

  • SQL Query, please help very urgent

    I am a newbie is sql.
    I have two tables called test_master and test_detail.
    Both tables contains pos_id as common field.
    In test_detail got sub_id and to get the people under a given pos_id, I join with pos_id of test_master.
    In the where condition, when I give the pos_id, it's returning only
    the first level. How can I get the second level and get all the levels?
    Any help is highly appreciable.It's very urgent.
    Looking forward to hear from you.
    Thanks
    Newbie

    Ok, I am pasting the description of the master and detail in the order.
    Master
    EMPLOYEE_NO VARCHAR2(30)
    ORGANIZATION_ID NUMBER(15)
    ORGANIZATION_NAME VARCHAR2(240)
    POSITION_ID NUMBER(15)
    POSITION_NAME VARCHAR2(240)
    Detail
    POSITION_ID NUMBER(15)
    SUBORDINATE_ID NUMBER(15)
    ORGANIZATION_ID NUMBER(15)
    POSITION_NAME VARCHAR2(50)
    Here is the sql, I want to get all the subordinates under a given position_id of the master.
    Looking forward to hear from you.
    select a.employee_no,a.POSITION_ID,a.POSITION_NAME,a.EMPLOYEE_NAME,
    b.position_id,b.subordinate_id from portal_employee_master_test a,
    portal_structure_test b
    where a.POSITION_ID = b.POSITION_ID and a.POSITION_ID='xyz'
    and b.position_ID=a.POSITION_ID

  • SQL experts please help for a query

    I have following table1.
    What query can give the result as given below, SQL experts please help on this.
    TABLE1
    Event DATETIME
    in 2/JAN/2010
    out 2/JAN/2010
    in 13/JAN/2010
    out 13/JAN/2010
    in 5/JAN/2010
    out 5/JAN/2010
    RESULT REQUIRED FROM THE SQL QUERY
    COL1_IN COL2_OUT
    2/JAN/2010 2/JAN/2010
    13/JAN/2010 13/JAN/2010
    5/JAN/2010 5/JAN/2010

    I tried to help, but this puzzles me.
    Why is this not returning pre-selected set of rows, why it's doing some merge join cartezian ?
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> select * from table1;
    EVENT      DATETIME
    in         2/JAN/2010
    out        2/JAN/2010
    in         13/JAN/2010
    out        13/JAN/2010
    in         5/JAN/2010
    out        5/JAN/2010
    6 rows selected.
    SQL> explain plan for
      2  with a as
    (select datetime from table1 where event='in'),
    b as
    (select datetime from table1 where event='out')
    select  a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
    Explained.
    SQL> set wrap off
    SQL> set linesize 200
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 185132177
    | Id  | Operation            | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |        |     9 |   288 |     8   (0)| 00:00:01 |
    |   1 |  MERGE JOIN CARTESIAN|        |     9 |   288 |     8   (0)| 00:00:01 |
    |*  2 |   TABLE ACCESS FULL  | TABLE1 |     3 |    48 |     3   (0)| 00:00:01 |
    |   3 |   BUFFER SORT        |        |     3 |    48 |     5   (0)| 00:00:01 |
    |*  4 |    TABLE ACCESS FULL | TABLE1 |     3 |    48 |     2   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - filter("EVENT"='in')
       4 - filter("EVENT"='out')
    Note
       - dynamic sampling used for this statement
    21 rows selected.
    SQL> with a as
    (select datetime from table1 where event='in'),
    b as
    (select datetime from table1 where event='out')
    select  a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
    COL1_IN         COL2_OUT
    2/JAN/2010      2/JAN/2010
    2/JAN/2010      13/JAN/2010
    2/JAN/2010      5/JAN/2010
    13/JAN/2010     2/JAN/2010
    13/JAN/2010     13/JAN/2010
    13/JAN/2010     5/JAN/2010
    5/JAN/2010      2/JAN/2010
    5/JAN/2010      13/JAN/2010
    5/JAN/2010      5/JAN/2010
    9 rows selected.
    SQL>

  • Posted this query several times but no reply. Please help me out

    Hi all,
    How to know whether a servlet had completely sent its response to the request.
    The problem what i am facing is, I send response to a client's request as a file.
    The byte by byte transfer happens, now if the client interrupts or cancels the operation, the response is not completed.
    At this stage how to know the response status. I am handling all exception, even then I am unable to trap the status.
    Please help me out.
    I have posted this query several times but no convincing reply till now. Hence please help me out.
    If somebody wants to see the code. I'll send it through mail.
    regards
    venkat

    Hi,
    thanks for the reply,
    Please check the code what I have written. The servlet if I execute in Javawebserver2.0 I could trap the exception. If the same servlet is running in weblogic 6.0 I am unable to get the exception.
    Please note that I have maintained counter and all necessary exception handling even then unable to trap the exception.
    //code//
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.security.*;
    public class TestServ extends HttpServlet
    Exception exception;
    public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException, UnavailableException
         int bytesRead=0;
         int count=0;
         byte[] buff=new byte[1];
    OutputStream out=res.getOutputStream ();
    res.setContentType( "application/pdf"); // MIME type for pdf doc
    String fileURL ="http://localhost:7001/soap.pdf";
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    boolean download=false;
         int fsize=0;
         res.setHeader("Content-disposition", "attachment; filename="+"soap.pdf" );
    try
                   URL url=new URL(fileURL);
         bis = new BufferedInputStream(url.openStream());
         fsize=bis.available();
         bos = new BufferedOutputStream(out);
    while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
              try
                        bos.write(bytesRead);
                        count +=bytesRead;
                        bos.flush();
                   }//end of try for while loop
                   catch(StreamCorruptedException ex)
                        System.out.println("Exception ="+ex);
                        setError(ex);
                        break;
                   catch(SocketException e)
                        setError(e);
                        break;
                   catch(Exception e)
                        System.out.println("Exception in while of TestServlet is " +e.getMessage());
                        if(e != null)
                             System.out.println("File not downloaded properly"+e);
                             setError(e);
                             break;
                        }//if ends
                   }//end of catch for while loop
    }//while ends
              Exception eError=getError();
              if(eError!=null)
                   System.out.println("\n\n\n\nFile Not DownLoaded properly\n\n\n\n");
              else if(bytesRead == -1)
              System.out.println("\n\n\n\ndownload \nsuccessful\n\n\n\n");
              else
              System.out.println("\n\n\n\ndownload not successful\n\n\n\n");
    catch(MalformedURLException e)
    System.out.println ( "Exception inside TestServlet is " +e.getMessage());
    catch(IOException e)
    System.out.println ( "IOException inside TestServlet is " +e.getMessage());
         finally
              try
         if (bis != null)
         bis.close();
         if (bos != null)
         {bos.close();}
              catch(Exception e)
                   System.out.println("here ="+e);
    }//doPost ends
    public void setError(Exception e)
         exception=e;
         System.out.println("\n\n\nException occurred is "+e+"\n\n\n");
    public Exception getError()
              return exception;
    }//class ends
    //ends
    regards,
    venakt

  • Hi, i was wounding if anyone would help me get information on the company regarding the acquisition of, beats by dre, could someone please help me out as i am doing a college report on this and need some good sources of information

    hi, i was wounding if anyone would help me get information on the company regarding the acquisition of, beats by dre, could someone please help me out as i am doing a college report on this and need some good sources of information

    Try a search with Google.
    Why should we do your homework for you?

  • Hi can u please help me out to display multiple [b]thumbnail images[/b]

    hi,
    hi,
    please help me out!
    please help me out!!
    I need to display multiple thumbnail images on the jframe or on a jpanel . From the database where the path of the images are stored
    say i should first get thumbnail of the images and then display
    any one can please give me the code
    Thanx and Regards

    What is the context you're asking these questions in? Are these interview questions? Homework questions? Or is there some underlying business problem you're trying to solve?
    user644700 wrote:
    Create Query to restrict the user to a single row.                     I don't understand the question. You may be trying to create a VPD policy for the table, but that is far from clear from the question.
    Query to get the first inserted record FROM a table.                Probably not possible in general. Oracle doesn't track the date at which a row was inserted.
    Concatenate a column value with multiple rows.                          Again, I don't understand the question.
    Query to delete all the tables at once.                You'd need dynamic SQL. And a definition of "all tables"-- are you talking about all tables in a particular schema? All the tables in multiple schemas? Something else? Does "at once" imply that you want things to run in parallel? And does "delete" really mean delete (a DML operation)? truncate (a DDL operation)? or drop?
    SQL Query for getting Orphan Records.You'd need a definition of "orphan record" and requirements for what the parent and child tables are. The normal approach to finding parent and child tables dynamically would leverage foreign key constraints, but that would generally preclude the presence of orphan records.
    Justin

  • Pivot table query - PLEASE HELP

    I have one requirement whichis similar like this.
    I have following tables.
    POSITIONS (one account holds multiple securities)
    account_id     security_id     total
    1          101          300
    1          102          500
    2          102          300
    2          103          600
    3          104          400
    4          104          800
    SECURITIES
    security_id     security_name     country          region
    101          ABC          USA          NA
    102          EFG          USA          NA
    103          PQR          GBR          EUR
    104          XYZ          CANADA          NA
    I will get all the account numbers from front end application, for which I have to display output like this. For example I am getting accounts, 1,2,3 and 4 and have to display like columns at the end. I have to groupy by region and country.
    REGION     COUNTRY          SECURITY_ID     SECURITY_NAME          1     2     3     4
    NA     USA          101          ABC               300
                   102          EFG               500     300
                             COUNTRY TOTAL          800     300
         CANADA          104          XYZ                         400     800
                             REGION TOTAL          800     300     400     800
    EUR     GBR          103          PQR                    600
                             COUNTRY TOTAL               600          
                             REGION TOTAL          800     900     400     800
    I am working on Oracle 9i Release 2 and front end is .net. Can anyone please help me out with a solution using a query or a stored proc. For Stored procedure, I should send refcurser as OUT parameter or any possible solution.
    Thanks in advance.

    You could do the following:
    In SQL
    You can use the decode function and SUM over it.
    Get the totals by region and country
    select region,country, s.sec_id, sec_name,
    sum(decode(acct_id,1,total,0)) a1,
    sum(decode(acct_id,2,total,0)) a2,
    sum(decode(acct_id,3,total,0)) a3,
    sum(decode(acct_id,4,total,0)) a4
    from positions p, securities s
    where p.SEC_ID = s.SEC_ID
    group by region,country, s.sec_id, sec_name
    You can run similar sql to get totals by country or region separately ... just remove from select and group by clause the column name that you do not want to be displayed.
    The limitation here is that you would need to write the decode statement for every account. Some programming may be needed here.
    In PLSQL
    create or replace procedure acct_sum (cr OUT sys_refcursor)
    is
    cursor c1 is
    select distinct acct_id from positions order by 1 asc;
    var1 varchar2(1000) := ' ';
    var2 varchar2(1000);
    begin
    for i in c1 loop
    var1 := var1 || ' sum(decode(acct_id, ' || i.acct_id || ', total,0) ),';
    end loop;
    var1 := substr(var1,1,length(var1)-1);
    open cr for
    'select region,country, s.sec_id, sec_name, ' || var1 ||
    'from positions p, securities s
    where p.SEC_ID = s.SEC_ID
    group by region,country, s.sec_id, sec_name';
    end acct_sum;
    You may want to modify the code so pass in an array of accounts and loop through the content to get all the accounts.
    Hope this helps
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for DBAs and Developers

  • Please Help Me Out In Beans

    hai every one ....
    i created three files and saved in respective areas
    new.jsp--->C:\Tomcat 5.0\webapps\ROOT
    one.html--->C:\Tomcat 5.0\webapps\ROOT
    MyBean.java--->C:\Tomcat 5.0\webapps\ROOT
    MyBean.class--->C:\Tomcat 5.0\webapps\ROOT\WEB-INF\classes
    this is the coding part------------------------------------------------------------------------- -------------------------------------------------------------------------------- --------------------------------
    --------------------------------new.jsp---------------------------------------- ---
    <%@page contentType="text/html"%>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.util.*" %>
    <%@ page language="java" %>
    <html>
    <body>
    <jsp:useBean id= "mars" scope="session" class="MyBean"/>
    <jsp:setProperty name ="mars" property="cname" value=request.getParameter("cname");/>
    <jsp:setProperty name ="mars" property="cid" value=request.getParameter("cid");/>
    </body>
    </html>
    ---------------------------------one.html-------------------------------------- -
    <html>
    <body bgcolor="667788">
    <form method="post" action="new.jsp">
    <table>
    <tr>
    <td>
    name
    </td>
    <td>
    <input type="text" name="cname">
    </td>
    </tr>
    <tr>
    <td>
    id
    </td>
    <td>
    <input type="text" name="cid">
    </td>
    </tr>
    <tr>
    <td>
    <input type="submit" value="submit">
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    --------------------------------mybean.java------------------------------------ ---
    import java.util.*;
    import java.sql.*;
    import java.io.*;
    public class MyBean implements Serializable
    private String cname;
    private String cid;
    public MyBean()
    cname = "";
    cid = "";
    public String getCname()
    return cname;
    public String getCid()
    return cid;
    public void setCname(String x)
    cname=x;
    public void setCid(String y)
    cid=y;
    public boolean insertDB()
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String query = "insert into apply(name,email) values( ?,? )";
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:mysqlDSN","","");
    PreparedStatement pstmt = con.prepareStatement(query);
    pstmt.setString(1,cname);
    pstmt.setString(2,cid);
    int count = pstmt.executeUpdate();
    if(count != 1)
    return false;
    pstmt.close();
    con.close();
    catch(Exception e){
    System.out.println(e.getMessage());
    return false;
    return true;
    im getting this error when i press submit
    --------------------------------ERROR------------------------------------------ --
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: /new.jsp(21,22) equal symbol expected
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.jav a:83)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:402)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:126)
    org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:238)
    org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:188)
    org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:201)
    org.apache.jasper.compiler.ParserController.getPageEncodingForJspSyntax(ParserC ontroller.java:449)
    org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserCo ntroller.java:419)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:203)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:137)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:237)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    note The full stack trace of the root cause is available in the Tomcat logs.
    Apache Tomcat/5.0.18
    ------------------------------------------------->>>><<<<<<<<<<<-----------------------------------------
    please help me out.....
    any kind of help is appriciated
    Rakesh

    For visual beans, check out jsp:plugin
    This will convert you bean to an applet.
    For non-visual beans, check out jsp:useBean

  • SQL query tunning help

    Hi All,
    Could you please help me out the below SQL query tuning .
    Temp table is having 1 Million records
    Master table is having 60 Million records
    Query :
    SELECT B.*,U.ID, SD, LE, LAE
    FROM client.Temp B, client.Master
    U WHERE U.policyno = B.policyno
    AND B.UPFLAG = 0
    1.     Indexes are created on both email columns and Upflag for both tables.
    2.     Gathered DBMS Stats for MASTER Table
    Data is loading 100k/hour on production .

    When your query takes too long ...
    When your query takes too long ...
    HOW TO: Post a SQL statement tuning request - template posting
    HOW TO: Post a SQL statement tuning request - template posting

Maybe you are looking for

  • Asset history sheet (S_ALR_87011990) is not working ok

    Hello,      I have problems with the asset history sheet (S_ALR_87011990) because it doesen't shows the right amount for the totals. I chose the "Lisst assets or group totals only" check mark and the totals amounts for one asset class are not equal w

  • Decide target directory dynamically.

    Hi All I need to configure a receiver communication channel with file adapter. Important thing is target directory need to be decided dynamically based on some content in the message.  Please let me know what are the possibilities to achieve this. Th

  • Fixed-length numbers and strings

    Hello, I have to make a critical decision about API usage. I would be grateful if some of you could share their experiences. This will help me make an informed decision and avoid potential trouble further down the line. I have to use fixed-length int

  • Custom Icons in Lync Menus

    Is it possible to create Custom icon for Lync Custom Menus (Icons in the red circle) I have to create 3 Menus Is it possible to separate the top and bottom by a line in Lync Custom Menus

  • Change sort order manually

    Anyone noticed that in iTunes 7.2 you can no longer manually change the songs sort order? When I copy podcasts or songs on my iPod, sometimes I want to change the order in which they will play. In 7.1.1 I could simply upload the songs and drag and dr