Sql query into mapping

hi ,
can any one tell how to convert this query into owb mapping
INSERT INTO SMSTG.CST_PROF_ADDRESS
(IMS_ID,
PROF_ADDRESS_ID
ADDRESS_LINE_1,
CITY,
STATE_CODE,
POSTAL_CODE,
COUNTRY_CODE,
SOURCE_PROF_ID,
SOURCE_ADDRESS_ID,
ADDRESS_SOURCE,
ADDRESS_SOURCE_DATE,
INACTIVE_DATE,
INACTIVE_SOURCE,
INACTIVE_PROF_ID,
INACTIVE_ADDRESS_ID,
LOAD_DATE)
SELECT
B.REF_PROF_X,
B.REF_PROF_X||'|'||SUBSTR(A.ADDRESS_LINE_1,1,5)||'|'||SUBSTR(A.POSTAL_CODE,1,5) PROF_ADDRESS_ID,
A.ADDRESS_LINE_1,
A.CITY,
A.STATE_CODE,
A.POSTAL_CODE,
A.COUNTRY_CODE,
A.SFA_PROF_ID,
A.SFA_ADDRESS_ID,
A.ADDRESS_SOURCE,
A.ADDRESS_SOURCE_DATE,
NULL INACTIVE_DATE,
NULL INACTIVE_SOURCE,
NULL INACTIVE_PROF_ID,
NULL INACTIVE_ADDRESS_ID,
SYSDATE LOAD_DATE
FROM SMSTG.CST_PROF_SFA A
WHSUSR.MDT_SFA_PROF B
WHERE B.SFA_PROF_ADDRESS_ID = A.SFA_PROF_ADDRESS_ID
AND B.PUBLICATION_STATUS = 'C' AND B.END_DATE > SYSDATE
(SELECT ''
FROM WHSUSR.MDT_MASTER_PROF_ADDRESS D
WHERE D.PROF_ADDRESS_ID = B.REF_PROF_X||'|'||SUBSTR(A.ADDRESS_LINE_1,1,5)||'|'||SUBSTR(A.POSTAL_CODE,1,5)
AND D.ADDRESS_SOURCE_DATE =< A.ADDRESS_SOURCE_DATE
AND D.PUBLICATION_STATUS = 'C' AND D.END_DATE > SYSDATE)
OR NOT EXISTS
(SELECT ''
FROM WHSUSR.MDT_MASTER_PROF_ADDRESS E
WHERE E.PROF_ADDRESS_ID = B.REF_PROF_X||'|'||SUBSTR(A.ADDRESS_LINE_1,1,5)||'|'||SUBSTR(A.POSTAL_CODE,1,5)
AND E.PUBLICATION_STATUS = 'C' AND E.END_DATE > SYSDATE))
AND ( EXISTS
(SELECT ''
FROM SMSTG.CST_PROF_HCPS_ADDRESS F
WHERE F.PROF_ADDRESS_ID = B.REF_PROF_X||'|'||SUBSTR(A.ADDRESS_LINE_1,1,5)||'|'||SUBSTR(A.POSTAL_CODE,1,5)
AND F.ADDRESS_SOURCE_DATE =< A.ADDRESS_SOURCE_DATE)
OR NOT EXISTS
(SELECT ''
FROM SMSTG.CST_PROF_HCPS_ADDRESS G
WHERE G.PROF_ADDRESS_ID = B.REF_PROF_X||'|'||SUBSTR(A.ADDRESS_LINE_1,1,5)||'|'||SUBSTR(A.POSTAL_CODE,1,5)))
AND (EXISTS
(SELECT ''
FROM SMSTG.CST_PROF_IMS_RETURN H
WHERE H.PROF_ADDRESS_ID = B.REF_PROF_X||'|'||SUBSTR(A.ADDRESS_LINE_1,1,5)||'|'||SUBSTR(A.POSTAL_CODE,1,5)
AND H.ADDRESS_SOURCE_DATE =< A.ADDRESS_SOURCE_DATE)
OR NOT EXISTS
(SELECT ''
FROM SMSTG.CST_PROF_IMS_RETURN I
WHERE PROF_ADDRESS_ID = B.REF_PROF_X||'|'||SUBSTR(A.ADDRESS_LINE_1,1,5)||'|'||SUBSTR(A.POSTAL_CODE,1,5))) ;

Hi,
you can create mapping [use constant, expressions, join, filter, tables...], but not "convert this query into owb mapping".
Best regards.
IM

Similar Messages

  • Can I put a SQL query into a bind variable and then use it to output report

    Hi,
    Can I put a SQL query into a bind variable and then use it to output report?
    I want to create a report and an item "text area" (say P1_TEXT) which can let user to input a SQL query(they are all technical users and knows SQL very well). Then, I use a bind variable (that text area) to store the SQL statement. Then, I add a submit button and I want to use the following to output the report:
    select * from (:P1_TEXT);
    Do you think it is possible to do that? Any known limitations for APEX in this area?
    Thanks a lot,
    Angela

    You can, but make sure it's what you really want to do. Make sure you are VERY familiar with SQL Injection. Most people who know what it is, go out of their way to prevent SQL Injection. You're going out of your way to allow it.
    You can try using &P1_TEXT. instead of bind variable syntax. Bind variables are one of the best ways to prevent SQL Injection, which is why it's not working for you.
    Once again, I strongly urge you to consider the implications of your app, but this suggestion should get it working.
    Tyler

  • Help with SQL query into Crystal

    Afternoon all,
    I am trying to convert the following SQL query into Crystal by using the tables given in the query however the relationship given in the query is bit awkward, in a sense that I cannot create a relationship under Crystal desgin.
    Here is the query
    select count(order_progressed.order_no),reason_code
    from order_progressed,lab_reasons, rework_groups
    where
    order_progressed.date_created=Today
    and (order_progressed.order_status=from_gate
    and lab_reasons.reason_code between from_reason and to_reason)
    group by lab_reasons.reason_code
    order by 2
    We have three tables
    1: Order_Progressed
    2: Lab Reasons
    3: Rework_Groups
    Order_progressed can be linked with rework_group by Status (if you see the line order_progressed.order_status=from_gate)
    However how to link the following line?
    lab_reasons.reason_code between from_reason and to_reason
    I mean when I try to link it by Lab Reasons.Reason Code to From_reason, to reason, it doesn't seem to work.
    The report is grouped by Lab Reasons. Reason Code, so I really have to some how create a relationship between Lab Reasons table and Rework_Group table.
    This is what I get when I run the same query into Crystal using the relationship
    SELECT lab_reasons.reason_code, order_progressed.date_created, order_progressed.order_no
    FROM   maxmast.lab_reasons lab_reasons, kevin.order_progressed order_progressed,
    roger.rework_groups rework_groups
    WHERE  (order_progressed.order_status=rework_groups.from_gate) AND
    ((lab_reasons.reason_code=rework_groups.from_reason) AND
    (lab_reasons.reason_code=rework_groups.to_reason)) AND (order_progressed.date_created>={ts
    '2008-01-01 00:00:00'} AND order_progressed.date_created<={ts '2008-12-17 00:00:00'})
    Any ideas?
    Many thanks
    Kind Regards
    Jehanzeb

    Sastry I didn't understand why did you use Lab_reasons.reason_code twice in your SQL.
    What I have done since I posted this thread,
    I created a command like this
    Select *
    from rework_groups,lab_reasons
    where
    lab_reasons.reason_code between from_reason and to_reason
    Then I took out the lab_reasons table and rework_groups table, then I linked the order_status from Order_progressed table to From_gate of the newly created table (I called it Reason_Code).
    This made the report running but it is crunching quite allot of numbers. I wonder if I made a mistake somewhere?
    Oh and please note, I'd like to create an SQL (if need be) without the date entry which was done in the original SQL because I'd like to setup my own date range within Crystal Reports instead of getting passed by SQL itself.
    This is how it looks like in Crystal now.
    sae1_live
    SELECT order_progressed.date_created, order_progressed.order_no, order_progressed.order_status
    FROM   kevin.order_progressed order_progressed
    WHERE  (order_progressed.date_created>={ts '2008-01-01 00:00:00'} AND
    order_progressed.date_created<={ts '2008-12-17 00:00:00'})
    EXTERNAL JOIN order_progressed.order_status={?sae1_live: Reason_Code.from_gate}
    sae1_live
    Select *
    from rework_groups, lab_reasons
    where lab_reasons.reason_code between from_reason and to_reason
    EXTERNAL JOIN Reason_Code.from_gate={?sae1_live: order_progressed.order_status}
    Regards
    Jehanzeb

  • SQL QUERY into PROCEDURE

    Hi! I am a newbie in PL/SQL..
    Can somebody teach me on how to make this SQL QUERY into a PROCEDURE?
    TABLE 1: LOGS
    TABLE 2: MASTER LIST
    Logs = records the logs
    Master list = list of all registered name.
    select * from table1
    where not exists
    select host, user, name
    from table2
    where table2.host = table1.host and
    table2.user = table1.user and
    table2.name = table1.name
    TABLE 1
    HOST | USER | NAME
    ==============
    1 | A | A1
    1 | A | A1
    1 | A | A1
    1 | A | D1
    TABLE 2
    HOST | USER | NAME
    =============
    1 | A | A1
    1 | A | B1
    1 | A | C1
    Result:
    HOST | USER | NAME
    ===============
    1 | A | D1
    Thanks. :)

    QKWS wrote:
    Hi! I am a newbie in PL/SQL..
    Can somebody teach me on how to make this SQL QUERY into a PROCEDURE?
    TABLE 1: LOGS
    TABLE 2: MASTER LIST
    Logs = records the logs
    Master list = list of all registered name.
    select * from table1
    where not exists
    select host, user, name
    from table2
    where table2.host = table1.host and
    table2.user = table1.user and
    table2.name = table1.name
    TABLE 1
    HOST | USER | NAME
    ==============
    1 | A | A1
    1 | A | A1
    1 | A | A1
    1 | A | D1
    TABLE 2
    HOST | USER | NAME
    =============
    1 | A | A1
    1 | A | B1
    1 | A | C1
    Result:
    HOST | USER | NAME
    ===============
    1 | A | D1
    Thanks. :)Hi,
    Question is not clear, really.
    Do you want that, I don't sure?
    CREATE TABLE t1 ( CHOST NUMBER,  CUSER VARCHAR2(10), CNAME VARCHAR2(10));
    INSERT INTO t1 VALUES(1,'A','A1');
    INSERT INTO t1 VALUES(1,'A','A1');
    INSERT INTO t1 VALUES(1,'A','A1');
    INSERT INTO t1 VALUES(1,'A','D1');
    Commit;
    CREATE TABLE t2 AS  SELECT *  FROM t1;
    INSERT INTO t2 VALUES(1,'A','A1');
    INSERT INTO t2 VALUES(1,'A','B1');
    INSERT INTO t2 VALUES(1,'A','C1');
    commit;
    select * from t1  table1
    WHERE NOT EXISTS
    ( SELECT 1 FROM t2 table2
       WHERE table2.chost = table1.chost
         AND table2.cuser = table1.cUSER
         AND table2.cNAME = table1.cNAME
    DECLARE
    P_HOST T1.CHOST%TYPE;
    P_USER T1.CUSER%TYPE;
    P_NAME T1.CNAME%TYPE;
    BEGIN
    select CHOST, CUSER,CNAME INTO P_HOST,P_USER, P_NAME
    from t1  table1
    WHERE NOT EXISTS
    ( SELECT 1 FROM t2 table2
       WHERE table2.chost = table1.chost
         AND table2.cuser = table1.cUSER
         AND table2.cNAME = table1.cNAME
    dbms_output.put_line('HOST | USER | NAME  : '|| TO_CHAR(P_HOST)||' | '||P_USER||' | '||P_NAME);
    END;
    /Regards
    Mahir M. Quluzade

  • SQL Query for mapping a set of batches to a class rooms group

    Hi All,
    I am using Oracle 11g Release 2 database.
    I have the following data set:
    ClassRooms
    ClassId ClassName                    Capacity     Group
    1 Babbage/Software Engg Lab          24          1
    2     Basement - PG Block               63          1
    3     Classroom 1                    56          1
    4     Classroom 10                    24          1
    5     Classroom 11                    24          1
    6     Classroom 12                    35          1
    7     Classroom 13                    42          1
    8     Classroom 14                    42          1
    9     Classroom 15                    42          1
    10     Classroom 2                    35          1
    11     Classroom 3                    35          1
    12     Classroom 4                     35          1
    13     Classroom 5                    35          1
    14     Classroom 6                    25          1
    15     Classroom 7                    25          1
    16     Classroom 8                    24          1
    17     Classroom 9                    24          1
    18     Control Sys Lab                    24          1
    19     Dig & Embd Sys Lab               20          1
    20     DSP & Comm Lab                    20          1
    21     Electromechanical System Lab     28          1
    22     Farabi/Web Tech Lab               36          1
    23     Gen Purpose Lab                    40          1
    24     Shirazi/DB Tech Lab               36          1
    25     Adv Elect Lab                    30          2
    26     Classroom 16                    42          2
    27     Classroom 17                    49          2
    28     Classroom 18                    56          2
    29     Classroom 19                    42          2
    30     Classroom 20                    49          2
    31     Classroom 21                    35          3
    32     Classroom 22                    35          3
    33     MDA Lab                         20          3
    DegreeBatches
    BatchId      BatchName Strength
    1          BIT-11          79          
    2          BIT-12          28          
    3          BS(CS)-1          35          
    4          BS(CS)-2          78          
    5          BE(SE)-1          69          
    6          BE(SE)-2          84          
    7          BE(SE)-3          64          
    8          BICSE-7          84          
    9          BICSE-8          43          
    10          BEE-1          112          
    11          BEE-2          151          
    12          BEE-3          157          
    13          BEE-4          157          
    I want to map a degree batch combination to a class rooms group in such away that they fully utilize maximum capacity of the class rooms within a group (Ideal case) or as close to it as possible. Can it be done with a SQL query?
    Any response will be highly appreciated.
    SQL Scripts to generate the required tables and populate data is below:
    CREATE TABLE ClassRooms (ClassId NUMBER, ClassName     VARCHAR2(50), Capacity NUMBER, Group NUMBER);
    INSERT INTO ClassRooms VALUES(1,'Babbage/Software Engg Lab',24,1);
    INSERT INTO ClassRooms VALUES(2,'Basement - PG Block',63,1);
    INSERT INTO ClassRooms VALUES(3,'Classroom 1',56,1);
    INSERT INTO ClassRooms VALUES(4,'Classroom 10',24,1);
    INSERT INTO ClassRooms VALUES(5,'Classroom 11',24,1);
    INSERT INTO ClassRooms VALUES(6,'Classroom 12',35,1);
    INSERT INTO ClassRooms VALUES(7,'Classroom 13',42,1);
    INSERT INTO ClassRooms VALUES(8,'Classroom 14',42,1);
    INSERT INTO ClassRooms VALUES(9,'Classroom 15',42,1);
    INSERT INTO ClassRooms VALUES(10,'Classroom 2',35,1);
    INSERT INTO ClassRooms VALUES(11,'Classroom 3',35,1);
    INSERT INTO ClassRooms VALUES(12,'Classroom 4',35,1);
    INSERT INTO ClassRooms VALUES(13,'Classroom 5',35,1);
    INSERT INTO ClassRooms VALUES(14,'Classroom 6',25,1);
    INSERT INTO ClassRooms VALUES(15,'Classroom 7',25,1);
    INSERT INTO ClassRooms VALUES(16,'Classroom 8',24,1);
    INSERT INTO ClassRooms VALUES(17,'Classroom 9',24,1);
    INSERT INTO ClassRooms VALUES(18,'Control Sys Lab',24,1);
    INSERT INTO ClassRooms VALUES(19,'Dig & Embd Sys Lab',20,1);
    INSERT INTO ClassRooms VALUES(20,'DSP & Comm Lab',20,1);
    INSERT INTO ClassRooms VALUES(21,'Electromechanical System Lab',28,1);
    INSERT INTO ClassRooms VALUES(22,'Farabi/Web Tech Lab',36,1);
    INSERT INTO ClassRooms VALUES(23,'Gen Purpose Lab',40,1);
    INSERT INTO ClassRooms VALUES(24,'Shirazi/DB Tech Lab',36,1);
    INSERT INTO ClassRooms VALUES(25,'Adv Elect Lab',30,2);
    INSERT INTO ClassRooms VALUES(26,'Classroom 16',42,2);
    INSERT INTO ClassRooms VALUES(27,'Classroom 17',49,2);
    INSERT INTO ClassRooms VALUES(28,'Classroom 18',56,2);
    INSERT INTO ClassRooms VALUES(29,'Classroom 19',42,2);
    INSERT INTO ClassRooms VALUES(30,'Classroom 20',49,2);
    INSERT INTO ClassRooms VALUES(31,'Classroom 21',35,3);
    INSERT INTO ClassRooms VALUES(32,'Classroom 22',35,3);
    INSERT INTO ClassRooms VALUES(33,'MDA Lab',20,3);
    CREATE TABLE DegreeBatches (BatchId NUMBER, BatchName VARCHAR2(50), Strength NUMBER);
    INSERT INTO DegreeBatches VALUES(1,'BIT-11',79);          
    INSERT INTO DegreeBatches VALUES(2,'BIT-12',28);          
    INSERT INTO DegreeBatches VALUES(3,'BS(CS)-1',35);          
    INSERT INTO DegreeBatches VALUES(4,'BS(CS)-2',78);          
    INSERT INTO DegreeBatches VALUES(5,'BE(SE)-1',69);          
    INSERT INTO DegreeBatches VALUES(6,'BE(SE)-2',84);          
    INSERT INTO DegreeBatches VALUES(7,'BE(SE)-3',64);          
    INSERT INTO DegreeBatches VALUES(8,'BICSE-7',84);          
    INSERT INTO DegreeBatches VALUES(9,'BICSE-8',43);          
    INSERT INTO DegreeBatches VALUES(10,'BEE-1',112);          
    INSERT INTO DegreeBatches VALUES(11,'BEE-2',151);     
    INSERT INTO DegreeBatches VALUES(12,'BEE-3',157);     
    INSERT INTO DegreeBatches VALUES(13,'BEE-4',157);     
    Best Regards
    Bilal
    Edited by: Bilal on 27-Dec-2012 09:52
    Edited by: Bilal on 27-Dec-2012 10:07

    Bilal, thanks for the nice problem! Another possibility for duplicate checking is to write a small PL/SQL function returning 1 if a duplicate id is found, then equate it to 0: 'Duplicate_Token_Found (p_str_main VARCHAR2, p_str_trial VARCHAR2) RETURN NUMBER'. This would parse the second string and might use p_str_main LIKE '%,' || l_id || ',%' for each id. Anyway the full query (without that) is given below:
    Solution with names
    SQL> WITH rsf_itm (con_id, max_weight, nxt_id, lev, tot_weight, tot_profit, path, root_id, lev_1_id) AS (
      2  SELECT c.id,
      3         c.max_weight,
      4         i.id,
      5         0,
      6         i.item_weight,
      7         i.item_profit,
      8         ',' || i.id || ',',
      9         i.id,
    10         0
    11    FROM items i
    12   CROSS JOIN containers c
    13   UNION ALL
    14  SELECT r.con_id,
    15         r.max_weight,
    16         i.id,
    17         r.lev + 1,
    18         r.tot_weight + i.item_weight,
    19         r.tot_profit + i.item_profit,
    20         r.path || i.id || ',',
    21         r.root_id,
    22         CASE WHEN r.lev = 0 THEN i.id ELSE r.nxt_id END
    23    FROM rsf_itm r
    24    JOIN items i
    25      ON i.id > r.nxt_id
    26     AND r.tot_weight + i.item_weight <= r.max_weight
    27   ORDER BY 1, 2
    28  ) SEARCH DEPTH FIRST BY nxt_id SET line_no
    29  , rsf_con (nxt_con_id, nxt_line_no, con_path, itm_path, tot_weight, tot_profit, lev) AS (
    30  SELECT con_id,
    31         line_no,
    32         To_Char(con_id),
    33         ':' || con_id || '-' || (lev + 1) || ':' || path,
    34         tot_weight,
    35         tot_profit,
    36         0
    37    FROM rsf_itm
    38   UNION ALL
    39  SELECT r_i.con_id,
    40         r_i.line_no,
    41         r_c.con_path || ',' || r_i.con_id,
    42         r_c.itm_path ||  ':' || r_i.con_id || '-' || (r_i.lev + 1) || ':' || r_i.path,
    43         r_c.tot_weight + r_i.tot_weight,
    44         r_c.tot_profit + r_i.tot_profit,
    45         r_c.lev + 1
    46    FROM rsf_con r_c
    47    JOIN rsf_itm r_i
    48      ON r_i.con_id > r_c.nxt_con_id
    49   WHERE r_c.itm_path NOT LIKE '%,' || r_i.root_id || ',%'
    50     AND r_c.itm_path NOT LIKE '%,' || r_i.lev_1_id || ',%'
    51     AND r_c.itm_path NOT LIKE '%,' || r_i.nxt_id || ',%'
    52  )
    53  , paths_ranked AS (
    54  SELECT itm_path || ':' itm_path, tot_weight, tot_profit, lev + 1 n_cons,
    55         Rank () OVER (ORDER BY tot_profit DESC) rnk,
    56         Row_Number () OVER (ORDER BY tot_profit DESC) sol_id
    57    FROM rsf_con
    58  ), best_paths AS (
    59  SELECT itm_path, tot_weight, tot_profit, n_cons, sol_id
    60    FROM paths_ranked
    61   WHERE rnk = 1
    62  ), row_gen AS (
    63  SELECT LEVEL lev
    64    FROM DUAL
    65  CONNECT BY LEVEL <= (SELECT Count(*) FROM items)
    66  ), con_v AS (
    67  SELECT  b.itm_path, r.lev con_ind, b.sol_id, b.tot_weight, b.tot_profit,
    68          Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev - 1) + 1,
    69            Instr (b.itm_path, ':', 1, 2*r.lev) - Instr (b.itm_path, ':', 1, 2*r.lev - 1) - 1)
    70             con_nit_id,
    71          Substr (b.itm_path, Instr (b.itm_path, ':', 1, 2*r.lev) + 1,
    72            Instr (b.itm_path, ':', 1, 2*r.lev + 1) - Instr (b.itm_path, ':', 1, 2*r.lev) - 1)
    73             itm_str
    74    FROM best_paths b
    75    JOIN row_gen r
    76      ON r.lev <= b.n_cons
    77  ), con_split AS (
    78  SELECT itm_path, con_ind, sol_id, tot_weight, tot_profit,
    79         Substr (con_nit_id, 1, Instr (con_nit_id, '-', 1) - 1) con_id,
    80         Substr (con_nit_id, Instr (con_nit_id, '-', 1) + 1) n_items,
    81         itm_str
    82    FROM con_v
    83  ), itm_v AS (
    84  SELECT  c.itm_path, c.con_ind, c.sol_id, c.con_id, c.tot_weight, c.tot_profit,
    85          Substr (c.itm_str, Instr (c.itm_str, ',', 1, r.lev) + 1,
    86            Instr (c.itm_str, ',', 1, r.lev + 1) - Instr (c.itm_str, ',', 1, r.lev) - 1)
    87             itm_id
    88    FROM con_split c
    89    JOIN row_gen r
    90      ON r.lev <= c.n_items
    91  )
    92  SELECT v.sol_id,
    93         v.tot_weight s_wt, v.tot_profit s_pr, c.id c_id, c.name c_name, c.max_weight m_wt,
    94         Sum (i.item_weight) OVER (PARTITION BY v.sol_id, c.id) c_wt,
    95         i.id i_id, i.name i_name, i.item_weight i_wt, i.item_profit i_pr
    96    FROM itm_v v
    97    JOIN containers c
    98      ON c.id = To_Number (v.con_id)
    99    JOIN items i
    100      ON i.id = To_Number (v.itm_id)
    101   ORDER BY sol_id, con_id, itm_id
    102  /
        SOL_ID S_WT S_PR  C_ID C_NAME          M_WT C_WT  I_ID I_NAME     I_WT I_PR
             1  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     3 BSCS-2       35   35
                                                             5 BEE-4        50   50
             2  255  255     1 SEECS UG Block   100   95     4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   70     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
             3  255  255     1 SEECS UG Block   100  100     3 BSCS-2       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     1 BIT-10       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
             4  255  255     1 SEECS UG Block   100  100     3 BSCS-2       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     1 BIT-10       35   35
                                                             5 BEE-4        50   50
             5  255  255     1 SEECS UG Block   100   95     2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   70     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
             6  255  255     1 SEECS UG Block   100  100     2 BIT-11       40   40
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     1 BIT-10       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
             7  255  255     1 SEECS UG Block   100  100     2 BIT-11       40   40
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     1 BIT-10       35   35
                                                             5 BEE-4        50   50
             8  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   85     3 BSCS-2       35   35
                                                             5 BEE-4        50   50
             9  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            10  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   65     2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
            11  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             2 IAEC Building     70   65     4 BSCS-3       40   40
                                                             6 BICSE-7      25   25
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            12  255  255     1 SEECS UG Block   100   95     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     2 BIT-11       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
            13  255  255     1 SEECS UG Block   100   95     1 BIT-10       35   35
                                                             3 BSCS-2       35   35
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   70     4 BSCS-3       40   40
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     2 BIT-11       40   40
                                                             5 BEE-4        50   50
            14  255  255     1 SEECS UG Block   100  100     1 BIT-10       35   35
                                                             2 BIT-11       40   40
                                                             6 BICSE-7      25   25
                             2 IAEC Building     70   65     3 BSCS-2       35   35
                                                             7 BESE-3       30   30
                             3 RIMMS Building    90   90     4 BSCS-3       40   40
                                                             5 BEE-4        50   50
    98 rows selected.
    Elapsed: 00:00:01.42Edited by: BrendanP on 20-Jan-2013 11:25
    I found the regex needed to deduplicate:
    AND RegExp_Instr (r_c.itm_path || r_i.path, ',(\d+),.*?,\1,') = 0

  • Combine multiple web services with the same SQL query into one

    Hello,
    I would like to ask a question regarding combine multiple similar web services into one. Can you please tell me if it is possible to combine 4-5 web services into one since they built on the same SQL query with 5 different criterias or condition so that the user can enter any of the 5 criterias to populate the data on the form instead of having 5 different web services?
    e.g Query: Select appName, permit#, address, phone, description, type, section, from table where appName = can be 'appName, permit#, address, phone, or description' to populate the rest of the data to the form.
    Does any one have ever done some thing like this in Workbench ES? If so please assist. I know it can be easier to build it in Visual Basic, C#, or dot.net but the requirement is to build it in workbench ES.
    Thanks in advance,
    Han Dao

    If you are querying for Name, PhoneNumber, and SSN, and you queried for all people with a phone number that started with 867, you would have a potentially long list of people.  So to keep track of all of the people, we store each record in XML complex elements.  The root node is just any name you want, and the repeating element is the complex element name. 
    So using the example from above, I'm going to specify the following:
         Root Node: Result
         Repeating Element: Person
    So now when I do a query, my resultXML will look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
    </Result>
    If your query returned multiple results (like ours would probably), it would look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
          <Person>
                 <Name>Han</Name>
                 <PhoneNumber>867-2169</PhoneNumber>
                 <SSN>222-22-2222</SSN>
          </Person>
    </Result>
    So Result and Person is just to give a little bit of structure to the xml result (containers really).  So you can name them whatever is helpful for you.
    The column name mappings map the query columns (Name, PhoneNumber, SSN) to some node in the XML (Name, PhoneNumber, SSN).  So you don't need to specify which field maps to what in the form.  Just copy the column names to the element name so you have a 1-to-1 naming.  If you want to manipulate the XML a bit though, you could do:
    Column Name               Element
    Name                            YourName
    PhoneNumber                Phone
    SSN                              Secret
    which would then make your xml look like:
    <Result>
          <Person>
                 <YourName>Alex</YourName>
                 <Phone>867-5309</Phone>
                 <Secret>111-11-1111</Secret>
          </Person>
    </Result>
    It lets you change the XML element names to whatever you want. Otherwise by default they take on their column names.
    In your form, you could bind to the WSDL through the Data Connections pane and point it to your web service.  This will then create form elements that you can just drag and drop allowing you to have the information available when the service gets ran.  Once the service is called, you can modify the field's data to get whatever information you need in order to populate other form fields. 
    If that is too confusing, feel free to send me your form (e-mail is on profile page) and I'll add comments to it to show you how to set up the form for the web service call (and also give me the link to your webservice)

  • Loading an Oracle SQL query into an MSSQL table

    I have a select query on an Oracle table. I want to load this data into an MSSQL table.
    Problem is that I cannot create an interim table on the Oracle database (lack of privelages)
    Is there a way to load an Oracle query into the MSSQL table without an interim table?
    Many thanks
    Z

    Yes,
    1) Create an ODI procedure
    2) Create a step inside
    3) at source tab put the oracle query
    4) at target tab put the sql insert code
    Refer to the oracle returned values like "#column_name_from_oracle_query"
    Make sense?
    Cezar Santos
    [www.odiexperts.com]

  • Plugging a sql query into OWB.

    Hi,
    I have a complex Sql query which returns some records. I want to use this query in OWB. But i don't want to write any procedures or functions. Is there a way just to plug this code into OWB to run it.
    vasu

    Any objection to putting the query into a view?
    The only other possible way I can think of that might work would be to create an expression object, define your desired output columns in the output group, and then copy in your query per column as the defined expression for that column. (hardly the efficient option!). I think you might have to create some sort of dummy input for this to pass through the validation for expressions too (e.g. perhaps also use a constant defined as sysdate passed as an input to the expression, but then never referenced in the queries).
    Can't say for sure if you can fool OWB into using your query in an expression object or not - but that would be the only way I can think of which might be possible to avoid using a view/function/procedure.

  • Complete novice needs help getting SQL Query into Crystal Reports XI

    Post Author: MissMarnie
    CA Forum: Data Connectivity and SQL
    So I was given an intro level web course and a monster reference guide in prep to format a report. One of our developers wrote me everything I need for the report into a SQL Query and now I'm supposed to format it in CR XII literally do not know what to do from here. I'm able to set up the correct server as a datasource, if that's useful, but I don't know how to make the querey into a bunch of formattable fields in  CR. If anyone can walk me through this, I'd be so grateful. I've attempted to look up SQL query in both the help and the book but I keep hitting a wall. The help dialog says things like "press this button" with no reference to what "this button" is. I'm sure it's obvious to the knowledgeable but I'm in a complete fog. Thanks in advance   

    Post Author: synapsevampire
    CA Forum: Data Connectivity and SQL
    IF you're trying to get assistance with setting up a query as the source for a report, try posting your Crystal version and the database type.
    Different software works differently.
    In CR 9 and above, under the connection to the database you'll see Add Command. Select that and you can paste the query in.
    As for not knowing how to generate a report, that requires experience, there's no generic solution of course..
    -k

  • How to convert an sql query into a recordset?

    HI, I'm having a hard time building a locations of service form for users to insert, update the cities, counties, zip codes based on the states selected.
    so I found this  query that works great if I use basic  menus and text boxes, but can't use to make comma separated menus because it is nat a record set.
    The problem is that I have a table called zip_codes, with the following fields: state_label, Zip_b, county, city.
    zip codes correspond to the cities, counties and states.
    example:
    Colorado,  Colorado Springs, El Paso,  80918
    Users make a selection of state or states and the recordset is filtered by user selection.
    I manage the part of making a select mutiple drop menu that passes the values to my query page like this.
    <form action="litsTA.php"; method="post">
    <h3>Choose State(s)</h3>
    <p>hold Control key to select multiple states</p>
    <select  name="States_served[]_<?php echo $cnt1; ?>" multiple="multiple" onchange='showselection()'>
      <?php
    do { 
    ?>
      <option value="<?php echo $row_state['state_label']?>"><?php echo $row_state['state_label']?></option>
      <?php
    } while ($row_state = mysql_fetch_assoc($state));
      $rows = mysql_num_rows($state);
      if($rows > 0) {
          mysql_data_seek($state, 0);
           $row_state = mysql_fetch_assoc($state);
    ?>
    </select>
    <p>
      <input type="submit" value="submit" />
    </p>
    </form>
    And the query I need to convert into a recordset looks like this
      mysql_select_db($database_duitop, $duitop);
    $query_TONY = "SELECT * FROM zip_code WHERE state_label IN (";  
    for ($i=0; $i<=count($state_list)-1; $i++) {
    //echo $state_list[$i];
    $query_TONY = $query_TONY . "'" . $state_list[$i] . "'";
    if ($i < count($state_list)-1) {
    $query_TONY = $query_TONY . ", ";
    $query_TONY = $query_TONY . ") GROUP BY county ORDER BY state_label, city ASC";
    Any way that was my attempt to converting the query into a recordset.
    any help, or samples will be appreciated.

    Use Tcode SQ01.
    Give the query name press Enter.
    The query will be listed in the table below.
    Select the Query => From the Main menu select QUERY => More Functions => Display Report Name.
    You will get the program name, now go to Se38 and display the program...

  • Input result from a SQL-query into a Variable in ProcessFlow

    I am trying to select a value from a table with file names.
    This file name should be input to an ftp function. I use a owb function to read the file name then I try to asign the result to a variable.
    The function GET_FILENAME looks like
    f_name varchar2(30);
    BEGIN
    select distinct FILENAME_SOURCE into f_name from CTL_SOURCE_FILES
    where FILEID = (select min(FILEID) from CTL_SOURCE_FILES where status is null);
    RETURN f_name;
    END;
    When running it as a SQL-script it returns only one row/name.
    When I am running it in the ProcessFlow the following message is found:
    RPE-02040: Internal error: GET_FILENAME cannot be converted to a constant value.

    Let me talk about this in context of a mapping:
    create a mapping :
    use a function within a mapping
    assign the output of the mapping to a mapping input variable"
    use this mapping within your process flow and see if it works.
    if you are directly going to use the output of a function in a process flow , the FTP should be able to accept the filename from the outparam of the function which i am not sure how it works.
    try using the first approach as it is relatively simple and straightforward.

  • Date Validation-SQL Query or Mapping

    Dear Friends,
    I'm using sender JDBC adapter and fetching data.
    Let say the table structure is Name,ID,Datetime.
    I want to select the query and the resultset must be in the following fomat
    I want to check the validation that if Datetime value is 2 weeks greater than current date return YES, else return NO
    Is the above condition possible while selecting from the database itself?
    If we can't achieve it using query, then I've to go for Mapping. Can you guys tell me the logic to implement the same.
    <Rows>
    <Name>J</Name>
    <ID>126376</ID>
    <DateTime>YES</DateTime>
    </Rows>
    <Rows>
    <Name>P</Name>
    <ID>126372</ID>
    <DateTime>YES</DateTime>
    </Rows>
    <Rows>
    <Name>S</Name>
    <ID>126334</ID>
    <DateTime>NO</DateTime>
    </Rows>
    If the above requirement is not clear, please let me know.
    Thanks for all of  your valuable time!!!
    Best regards,
    raj.

    Satish & Matias,
    Thanks a lot for ur valuable time and help.
    @Matias I tried to query with the SQL , but I failed since its throwing exception always.
    @Satish: I wrote UDF and achieved the same.
    <b>Code:</b>
    //Sample input date: 2005-06-16 14:33:21.0
    int year=Integer.parseInt(time.substring(0,4));
    int month=Integer.parseInt(time.substring(5,7))-1 ;
    int date=Integer.parseInt(time.substring(8,10));
    int hour=Integer.parseInt(time.substring(11,13));
    int min=Integer.parseInt(time.substring(14,16));
    int sec=Integer.parseInt(time.substring(17,19));
    Calendar c1 = Calendar.getInstance();
    Calendar c2 = Calendar.getInstance();
    c1.set(year,month,date,hour,min,sec);
    c1.add(Calendar.DAY_OF_MONTH,14);
    if(c2.before(c1))
    return "NO";
    else
    return "YES";
    Thanks friends!!!
    Best regards,
    raj.

  • Answer from a sql query into a java variable ?

    Hey!
    Got a simple question :
    String dml = ("INSERT INTO student " +
                                         "VALUES ( SELECT MAX(id) +1 FROM student "  +
                                         "','" + student.getFornavn() +
                                         "','" + student.getEtternavn() +
                                         "','" + student.getKlasse() + "')");This sql syntax would work in sql+ , but for some reason not in java.. Need to add 1 to max id every time new student are added , or is there any way i could make sql add a new unique nubmer when id = NULL ?
    The other solution could be to get the answer from SELECT MAX (id) + 1 into a java variable and use that number value in insert query ?
    Or maybe the best would be to make a procedure ?

    Thanks!
    How would the syntax be to execute this procedure in java :
    CREATE OR REPLACE PROCEDURE legg_til_student (p_fnavn student.fornavn%TYPE, p_enavn student.etternavn%TYPE, p_klasseid student.klasseid%TYPE) IS
    v_id student.id%TYPE;
    BEGIN
         SELECT MAX(id) +1 INTO v_id
         FROM student;     
         IF p_klasseid > 3 THEN
         DBMS_OUTPUT.PUT_LINE ('Ugyldig klasseid');
         ELSE
         INSERT INTO student VALUES (v_id, p_fnavn, p_enavn, p_klasseid);
         END IF;
    END;
    /Only this into a stmt sentence ? :
    exec legg_til_student ('Test', 'Test', 2); ? thanks :)

  • SQL Query in mapping to load warehouse table

    Hi experts,
    I hope you can help me to solve my problem. I already searched here in forum how we can add a query in a mapping but still not found an answer.
    In my warehouse I have a time dimension table which has a unique dimension key and all date information. In my source database I have a table for sales information. In that sales table I have a field called date. This date will be in format dd.mm.yyyy.
    I also have a sales table in my warehouse what is nearly a copy of the source sales table. I have only one more field in this warehouse sales table called "time_dim_key". That field should get the dimension key of the warehouse time dimension table depending to the date out of the sales table from source.
    To do that I'm thinking about a mapping what includes:
    - the source sales table
    - the warehouse dimension time table
    - the warehouse sales table
    The normal fields I can directly map from source sales table to warehouse sales table.
    But the "time_dim_key" field of warehouse sales table should get filled like:
    select dimension_key from warehouse_time_dim_table where day_date = source_sales_table.date
    Unfortunately I don't know how I include a query to get the correct date out of that source sales table in the mapping to fill the warehouse sales table.
    I hope somebody can help me to solve that issue.
    Thanks a lot!
    Regards,
    David

    take joiner from the pallete
    and create two groups
    1.warehouse_time_dim_table
    2.source_sales_table
    then in join condition write
    warehouse_time_dim_table.day_date = source_sales_table.date
    That will solve the purpose.
    Cheers
    Nawneet

  • Script task to convert output from a sql query into send mail task body formatting

    SSIS 2008R2 Version
    Code from script task
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    namespace ST_29dd6843bd6c4aee9b1656c1bbf55ba8.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            public void Main()
                Variables varCollection = null;
                string header = string.Empty;
                string message = string.Empty;
                Dts.VariableDispenser.LockForWrite("User::gsEmailMessage");
                Dts.VariableDispenser.LockForWrite("User::gsWebserviceName");
                Dts.VariableDispenser.LockForWrite("User::gsNoOfCallsInADay");
                Dts.VariableDispenser.LockForWrite("User::gsCalledBySystem");
                Dts.VariableDispenser.GetVariables(ref varCollection);
                //Set the header message for the query result
                if (varCollection["User::gsEmailMessage"].Value == string.Empty)
                    header = "Hi, Count is greater then 50 :\n\n";
                    //header = "Execute SQL task output sent using Send Email Task in SSIS:\n\n\n";
                    header += "----------------------------------------------------------------------------------------------------------------------" + "\n";
                    header += string.Format("{0}\t\t\t\t{1}\t\t{2}\n", "WebService Name", "No Of Calls In A Day", "Called By System");
                    header += "----------------------------------------------------------------------------------------------------------------------" + "\n";
                    varCollection["User::gsEmailMessage"].Value = header;
                //Format the query result with tab delimiters
                     message = String.Format("<HTML><BODY><P>{0}</P><P>{1}</P><P>{2}</P></BODY></HTML>",
                                            varCollection["User::gsWebserviceName"].Value,
                                            varCollection["User::gsNoOfCallsInADay"].Value,
                                            varCollection["User::gsCalledBySystem"].Value);
                varCollection["User::gsEmailMessage"].Value = varCollection["User::gsEmailMessage"].Value + message + "\n";
                Dts.TaskResult = (int)ScriptResults.Success;
    Above code will return data in below format and then i send this output in aemail using send mail task.
    Hi, count is greater then 50 :
    WebService Name                                                         
    No Of Calls In A Day                        Called By System
    WebServiceone                                                     1                             
    Internetbutiken
    WebServiceGetdetailstwo                                                  1                             
    Internetbutiken
    Servicenamethree                                                            2                             
    MOB
    As you can see above code is not in align as if we service name is shorter then 2nd column get disallign and its not look good.I need output should be like below.
    Hi, count is greater then 50 :
    WebService Name                                                         
    No Of Calls In A Day                        Called By System
    WebServiceone                                                              1                             
    Internetbutiken
    WebServiceGetdetailstwo                                              1                             
    Internetbutiken
    Servicenamethree                                                          2                             
    MOB
    Please suggest something...
    Thanks 
    SR_MCTS

    See code explained here
    http://microsoft-ssis.blogspot.in/2013/08/sending-mail-within-ssis-part-2-script.html
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
    This will not help.As I am not creating smtp connectin ,send from ,send to in script task.I am just creating email body from sql output.

Maybe you are looking for