For fetching records under id

I am having a master table with data like
EMPNO     DEPTID HEAD
1     IT     0
2     IT     1
3     IT     1
4     IT     1
5     IT     2
6     IT     2
7     IT     4
8     IT     4
9     IT     5
10     IT     5
11     HR     0
12     HR     1
13     HR     1
14     HR     1
Query to findout all empno under the head by passing head empno
means if i am passing empno as 1 then
LIST SHOULD BE
2,3,4,5,6,7,8,9,10
If empno is 2 then
5,6,9,10
kindly help for the same

Are you looking for something like this...
WITH tab AS
  ( SELECT 1 empno, 'IT' deptid, 0 head FROM dual
UNION ALL
      SELECT 2 empno, 'IT' deptid, 1 head FROM dual
UNION ALL
      SELECT 3 empno, 'IT' deptid, 1 head FROM dual
UNION ALL
      SELECT 4 empno, 'IT' deptid, 1 head FROM dual
UNION ALL
      SELECT 5 empno, 'IT' deptid, 2 head FROM dual
UNION ALL  
   SELECT 6 empno, 'IT' deptid, 2 head FROM dual
UNION ALL
      SELECT 7 empno, 'IT' deptid, 4 head FROM dual
UNION ALL
      SELECT 8 empno, 'IT' deptid, 4 head FROM dual
UNION ALL
      SELECT 9 empno, 'IT' deptid, 5 head FROM dual
UNION ALL
      SELECT 10 empno, 'IT' deptid, 5 head FROM dual
UNION ALL
      SELECT 11 empno, 'HR' deptid, 0 head FROM dual
UNION ALL  
   SELECT 12 empno, 'HR' deptid, 1 head FROM dual
UNION ALL  
   SELECT 13 empno, 'HR' deptid, 1 head FROM dual
UNION ALL
      SELECT 14 empno, 'HR' deptid, 1 head FROM dual
SELECT ltrim(sys_connect_by_path(empno,','),',') lst
   FROM
  (SELECT t.*,
    row_number() over (order by empno ) rnum
     FROM
    (SELECT connect_by_root empno root,
      empno
       FROM tab
      CONNECT BY prior empno=head
      START WITH empno      =1 and deptid='IT'--change empno to 2 here for second case
    ) t
    WHERE t.empno!=t.root
  WHERE connect_by_isleaf=1
  CONNECT BY prior rnum  =rnum-1
  START WITH rnum        =1Ravi Kumar

Similar Messages

  • Writing OR query for fetching records

    Hi,
    I have dowloaded a custom wsdl and generated a java client from it using Jdeveloper.
    I have a method named customObject1QueryPage(QueryInputObj) which is used to query the CRM oD to fetch records.
    I have successfully queried using the above method for one condition:-
    QueryInputObj param= new QueryInputObj();
    QueryType q = new QueryType();
    q.set_value("='" + "ABC'");
    //q.set_value("LIKE 'A*'");
    param.setAccountName(q);
    customObject1QueryPage(param);
    But now I want to query using "OR" condition with multiple names in the condition and I don't know how to
    write query for that.
    SQL query would be like "Select * from table where name='ABC' OR name='PQR' OR name ='XYZ' ";
    I want to execute same query for CRM oD but have no idea how to write it.
    Can somebody please help me as soon as possible.
    Thanks.

    Hi,
    If your intent to Use OR Condition on a field with multiple Values
    say, AccountName = 'xyz' OR AccountName= 'abc' the syntax would be *(='xyz') OR (='abc')*
    say, AccountName = 'xyz' OR AccountName= 'abc' OR AccountName = 'pqr' the syntax would be *((='xyz') OR (='abc'))OR(='pqr')*
    You can find similar example under On Demand Web Service Documentation
    Regards
    Deepak H Andeli

  • Fetch records under 20 seconds in my view with sysdate

    hi all
    I want a query in my view that it returns records under 20 seconds and
    after 20 seconds my query do not show any records
    my query is :
    select * from cnfenterexit
    where cnf06date > sysdate - (1/86400000)
    but it didn't work.
    when I used following query whit this numbers ,
    it is OK and show records under 56 seconds
    select * from cnfenterexit
    where cnf06date > sysdate - (3/1440)
    please explain how to get under 20 seconds in me query?

    or
    select *
      from cnfenterexit
    where cnf06date > sysdate -TO_DSINTERVAL('0 00:0:20')TO_DSINTERVAL('0 00:0:20') = 0 days, 0 hours, 0 minutes, 20 seconds
    Timo

  • How to generate keys for the records

    Hi Gurus,
          can anybody explain me how to create keys for the recors while working with keymapping.
    Regards
    Ravikumar

    Hi Yugandher,
    Is your Question pertaining to Key generation in MDM or using the Remote key for importing and syndication in MDM?
    Remote Keys are system specific uniques maintained in MDM while importing source records from different source system.You need to Enable key mapping in Console and then map the <Remote key> field to the unique key in Import manager and do similar mapping in syndicator as well.
    You can view the key mapping for differnt records under the Edit key mapping (context menu) right clicking on any record.
    To know more on this refer the below link:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7051c376-f939-2b10-7da1-c4f8f9eecc8c  (Key mapping) 
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30843106-5539-2b10-75a9-da483911b0d9  (Key mapping)
    For Key generation in MDM you can use the Qualified range property of Remote system in Console for Key genearation.However these keys will be genearted only after syndication and are created and assigned within MDM and not maintained from any source remote system.
    Hope It Helped
    Thanks & Regards
    Simona Pinto

  • Linux installtion file for Creative MediaSource Player & Audio Stream Recorder under GPL licen

    I have Sound Blaster Audigy 2 sound card are where any Linux installtion file for Creative MediaSource Player & Audio Stream Recorder under GPL licens ?

    I don't think so. Creative's product CD installation seems to support Windows OS only.

  • How to see results for surveys in CIC Interaction record under script prfl?

    Dear Experts,
    In Interaction Record>Under Script tab> I have filled a survey-> upon entering all answers and saving->System showing a message, that survey has been sucessfully saved.
    But I dont know where these surveys are getting stored. and I could not find the created survey or results next time when I opened the same Interaction record.
    Kindly tell me where can we find the survey results, which is created under Script tab in Interaction Record.
    Your suggestions will be highly appreciated
    Best regards
    Raghu ram

    Hello,
    Have you found solution to this case?
    BR
    Piotr

  • How can i fetch records from 3 tables in a single query  without using join

    Hi.
    Can any body please tell me <b>How can i fetch records from 3 tables with a single query  without using joins</b>
    Thanx
    prabhudutta

    Hi Prabgudutta,
    We can fetch the data by using the views concept.
    Go throuth this info we can know the how to create view and same like database table only we can fetch the data.
    Views conatin the data at runtime only.
    Four different view types are supported. These differ in the
    way in which the view is implemented and in the methods
    permitted for accessing the view data.
    Database views are implemented with an equivalent view on
    the database.
    Projection views are used to hide fields of a table (only
    projection).
    Help views can be used as selection method in search helps.
    Maintenance views permit you to maintain the data
    distributed
    on several tables for one application object at one time.
    step by step creation of Maintenance view:
    With the help of the table maintenance generator, you are able to maintain the ENTRIES of the table in SM30 transaction.
    It can be set in transaction SE11 - Tools - Table maintenance generator.
    Table maintanance Generator is used to manually input values using transaction sm30
    follow below steps
    1) go to se11 check table maintanance check box under attributes tab
    2) utilities-table maintanance Generator-> create function group and assign it under
    function group input box. Also assign authorization group default &NC& .
    3) select standard recording routine radio in table table mainitainence generator to move table
    contents to quality and production by assigning it to request.
    4) select maintaience type as single step.
    5) maintainence screen as system generated numbers this dialog box appears when you click on create button
    6) save and activate table
    One step, two step in Table Maintenance Generator
    Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one screen where you can add, delete or edit records.
    Two step: Two screens namely the overview screen and Single screen are created. The user can see the key fields in the first screen and can further go on to edit further details.
    SM30 is used for table maintenance(addition or deletion of records),
    For all the tables in SE11 for which Table maintenance is selected , they can be maintained in SM30
    Sm30 is used to maintain the table ,i.e to delete ,insert or modify the field values and all..
    It creates the maintenance screen for u for the aprticular table as the maintenance is not allowed for the table..
    In the SE11 delivery and maintenance tab, keep the maintenance allowed..
    Then come to the SM30 and then enter the table name and press maintain..,
    Give the authorization group if necessary and give the function group and then select maintenance type as one step and give the screen numbers as system specified..
    Then create,,,
    Then u will able to see the maintenance view for the table in which u can able to insert and delete the table values...
    We use SM30 transaction for entering values into any DB table.
    First we create a table in SE11 and create the table maintenance generator for that Table using (utilities-> table maintenance generator) and create it.
    Then it will create a View.
    After that from SM30, enter the table name and Maintain, create new entries, change the existing entries for that table.
    Hope this resolves your query.
    Reward all the helpful answers.
    Rgds,
    P.Naganjana Reddy

  • BAPI for fetching the list of scheduling agreements

    This is my first post in SDN Forums so pardon me if I commit a mistake.
    My question is: Is there a standard BAPI for fetching a list of scheduling agreements?
    I know that there are BAPIs for creating and maintaining scheduling agreements like BAPI_SAG_CREATE and BAPI_SAG_CHANGE and iBAPI_SAG_GETDETAIL but each of these require the scheduling agreement number. My requirement is to list out all the scheduling agreements that are present in the system.
    I found a BAPI named BAPI_DOCUMENT_GETLIST and BAPI_DOCUMENT_GETLIST2 but I'm not able to find out what documents it is able to display. If I don't specify any selection criteria, it is fetching just two records of document type DRW. No other document of any other type is fetched.
    Another BAPI that I found was BAPI_SALESORDER_GETLIST in which if I specify the Transaction group as "3" (for scheduling agreement), it fetches them but those are related to Sales orders and not purchase orders.
    So, if anyone has any info and can help me out, I would really appreciate it.
    Edited by: rkarthea on Jul 30, 2010 10:44 AM

    Hi Raj,
    As I had said earlier, I need the Scheduling agreements related to purchase orders and not sales orders. The ones in EKKO table (Doc category: L).Will this program fetch this info?
    Also, I need a Java app (that's being developed) to fetch this info, so I'm looking for a BAPI. Is there any or can this program (if it fetches the right Scheduling agreements) be called from an external Java app?

  • How to fetch records from the database into a combo box?

    Hi:
    I&acute;m really new with ABLBPM and I&acute;m trying to fetch records from the database to display them into a combo box as valid values for a presentation but I&acute;m using a dynamic method with this code:
    <em>for each row in SELECT campo1, campo2 from TABLE</em>
    <em>do</em>
    <em>solicitudes[] = [row.campo1, row.campo2]</em>
    <em>end</em>
    <em>return solicitudes
    </em>And the debugger says that SQL instructions can be used only in fuctions and procedures that are executed on the server.
    Do you know another way to do it?
    P.D. Sorry for my terrible english
    Greetings

    Hi Steve,
    Thank you, your idea is perfect, but when I try to run the screenflow where the combo should be filled I get this error:
    fuego.lang.ComponentExecutionException: No se ha podido ejecutar correctamente la tarea.
    Motivo: 'java.lang.NullPointerException'.
         at fuego.web.execution.InteractiveExecution.setExecutionError(InteractiveExecution.java:307)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:166)
         at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
         at fuego.webdebugger.servlet.DebuggerServlet.redirect(DebuggerServlet.java:136)
         at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:85)
         at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
         at fuego.web.execution.servlet.ServletExternalContext.forwardInternal(ServletExternalContext.java:197)
         at fuego.web.execution.servlet.ServletExternalContext.processAction(ServletExternalContext.java:110)
         at fuego.webdebugger.servlet.DebuggerExecution.dispatchComponentExecution(DebuggerExecution.java:64)
         at fuego.web.execution.InteractiveExecution.invokePrepare(InteractiveExecution.java:351)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:192)
         at fuego.web.execution.impl.WebInteractiveExecution.process(WebInteractiveExecution.java:54)
         at fuego.web.execution.InteractiveExecution.process(InteractiveExecution.java:223)
         at fuego.webdebugger.servlet.DebuggerServlet.doDebug(DebuggerServlet.java:148)
         at fuego.webdebugger.servlet.DebuggerServlet.doPost(DebuggerServlet.java:82)
         at fuego.webdebugger.servlet.DebuggerServlet.doGet(DebuggerServlet.java:66)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    Any ideas??
    Thanks and greetings

  • Need a test for fetch into from a cursor or an alternative.

    I've got a small oddity.
    Ultimately it's two cursors that are exactly the same except a part of the WHERE clause. Depending on how many records I am going through (based on a counter) I need to use one cursor or the other as the outer loop, to then process an inner loop.
    My problem is I don't quite know how to exit out of the current loop when the fetch reaches the end of the cursor. Meaning, in each of these loops, there's an IF THEN to see which cursor I'm using, and then fetch from the correct one. If I use a FOR X IN CURSOR loop, I'll have to double up the code, one for each outer cursor loop.
    What's the test in Oracle for no record found or when it hits the end of a cursor with a fetch? Or am I stuck and I can only use the exception block when the fetch fails?
    Thansk!

    You can check whether your fetch returned any data with %notfound.
    DECLARE
      l_cur   sys_refcursor;
      l_var   VARCHAR2 (30);
    BEGIN
      IF TO_CHAR (SYSDATE, 'Day') = 'Monday'
      THEN
        OPEN l_cur FOR
          SELECT dummy
            FROM DUAL;
      ELSE
        OPEN l_cur FOR
          SELECT dummy
            FROM DUAL
           WHERE 1 = 2;
      END IF;
      LOOP
        FETCH l_cur
         INTO l_var;
        EXIT WHEN l_cur%NOTFOUND;
        DBMS_OUTPUT.put_line (l_var);
      END LOOP;
    END;
    /

  • Sender JDBC Adapter : Fetch records from multiple tables

    Hi Friends,
    I am using sender JDBC adapter to select few records from DB2 database table.
    This scenario is working fine.
    Now my requirement is to fetch records from 3 tables. These table are independent to each other. There is no primary key or foreign key.
    Please let me know how to write the sql in sender JDBC adapter to fetch records from these 3 tables.
    Thanks,
    Sandeep Maurya

    hi sandeep...
    if the tables are completely independent and do not share any primary / foreign key relation ship...
    why dont u think towards creating a seperate interface for each of them..
    or if u still want to select from multiple table at once..the best way would be to write a stored procedure on the sender side which do all the fetching n processing and pass the final resultset to PI
    or u can think towards fetching the data from 1 table and then in UDF do lookup from other tables..which again is tricky and performace intensive

  • Query regarding the data type for fetcing records from multiple ODS tables

    hey guys;
    i have a query regarding the data type for fetcing records from multiple ODS tables.
    if i have 2 table with a same column name then in the datatype under parent row node i cant add 2 nodes with the same name.
    can any one help with some suggestion.

    Hi Mudit,
    One option would be to go as mentioned by Padamja , prefxing the table name to the column name or another would be to use the AS keyoword in your SQL statement.
    AS is used to rename the column name when data is being selected from your DB.
    So, the query  Select ename as empname from emptable will return the data with column name as empname.
    Regards,
    Bhavesh

  • JDBC Sender Adapter - NOT FETCHING RECORDS...

    Hello Experts,
    I know this was answered in a separate thread (JDBC Sender Adapter -  NOT FETCHING RECORDS -PROCESSING STARTED).
    However, my question is, Is there a way that we can be notified if a channel has stopped fetching records?
    or is there a reporting tool that can be used to check/monitor if a channel is not processing any messages?
    Thanks & Kregards,
    allar

    Hi Sreedhar,
    Thanks for your reply.
    These case is not being captured by our alert configuration because its not throwing any error.
    in the communication channel monitoring, we see only something like this..:
    3/16/09 8:25:19 PM Processing started
    3/16/09 8:34:20 PM Processing started
    3/16/09 8:33:55 PM Processing started
    3/16/09 8:32:54 PM Processing started
    but no error is being displayed nor sent.
    Also, there was a case that the channel just stopped fetching, even though everything is active.
    example log:
            3/12/09 8:32:54 PM Processing started
    We're looking for ways on how we can trap these scenarios as early as possible,  get us notified and   perform adapter-lock release when needed.
    Regards,
    allar

  • Open single record form for particular record

    It's simple to open tabular form for particular record
    - just add page item, pass value to this item
    and add this item to WHERE clause.
    But what is common approach for single record form?
    Where is it described?

    here is my solution:
    1) create page item which will receive primary key value
    2) look at Sample Application Page 7 - customers edit page -
    you need "Automated Row Fetch", called in "After Header" block

  • No sound in PE 11 for video recorded in "focus" mic setup

    I just purchased a Panasonic X900M camcorder and Adobe Premiere Elements 11.  The Panasonic X900M allows the user to setup the internal microphone in various ways.  The
    default setting is "surround" which records the sound in 5.1 channel surround.  Another setting is "focus" which records the sound in front more clearly.  When I add a video
    clip recorded in "surround" into a PE 11 project, the audio works fine.  But if I add a video clip recorded in "focus" into a PE 11 project, there is no audio.  Both clips are recorded in an identical manner (fully automatic mode, 1080/60p resolution) except for the mic setup.  Also, both video clips play fine (with audio) in Elements Organizer (i.e., double-click on the clip) and Windows Media Player.  The audio portion of the file properties for both files are identical as shown
    below:
    Bit rate:  256kbps
    Channels:  2 (stereo)
    Audio sample rate: 48kHz
    Why does PE 11 not play sound for the clip recorded with a mic setup of "focus"?

    Not knowing that camera, my question would be which Audio channels in the file, are being used. Some cameras can record to different Audio channels (some Sony pro models), and record, under certain settings, to channels 3 & 4, rather than 1 & 2. In those instances, Premiere (Pro, or Elements) will not be picking up the signal in channels 3 & 4. In those cases, one workflow is to basically convert the file from having the Audio Stream on 3 & 4, and moving them to channels 1 & 2. I do not know if this is the problem here, but would explore the exact channel placement of the muxed (combined, or Multiplexed Audio & Video Streams), in a program, like MediaInfo, to see which channels are used.
    Good luck,
    Hunt

Maybe you are looking for