Select statement or a procedure or a function required for this requirement

i have 2 tables t1 and t2.
t1 contains 1 column,named as c_id
t2 contains 2 columns, named as tc_id and preceeding_c_id.
select * from t1;
c_id
100
200
300
400
select * from t2;
tc_id preceeding_c_id
150 100
180 150
100
190 180
210 200
250 210
260 250
Now my requirement is:
I need to send a parameter as :c_id = 100
the ouput should be as follows
100
150
180
190
:c_id = 200
the output should be as follows:
200
210
250
260
Thanks & Regards

SQL> variable c_id number
SQL> exec :c_id := 100
PL/SQL procedure successfully completed.
SQL> with t as (
  2             select 150 tc_id, 100 preceeding_c_id from dual union all
  3             select 180, 150 from dual union all
  4             select 100, null from dual union all
  5             select 190, 180 from dual union all
  6             select 210, 200 from dual union all
  7             select 250, 210 from dual union all
  8             select 260, 250 from dual
  9            )
10   select  tc_id
11     from  t
12     start with preceeding_c_id = :c_id
13     connect by preceeding_c_id = prior tc_id
14  union all
15   select  :c_id
16     from  dual
17  order by 1
18  /
     TC_ID
       100
       150
       180
       190
SQL> exec :c_id := 200
PL/SQL procedure successfully completed.
SQL> /
     TC_ID
       200
       210
       250
       260
SQL> SY.

Similar Messages

  • Regarding select statement for this requirement

    Hi................
    good evening
    here is a requirement.
    i want to retrieve data from the following table.but how to join these table is my dought.
    tables  fields
    t001w--werks " plant id
    t001w--name1 " pl;ant name
    t001w--regio " plant address
    ekko--ebeln " purchase  order
    ekko-erdat : creation date
    ekko-ernam "name of the person
    ekpo-ebelp " item
    ekpo-bstyp "purchase order type
    eket-erdat " delivery date
    mara-matnr " material number
    these are the tables and fields.now we want to retrive data from these tables
    how we have to code select statement.
    selection-screen is
    plant id
    order type
    delivery date
    please provide select statement for this requirement.
    thanks and regards.
    k.swaminath  reddy.

    Is this what you are looking for?
    SQL> CREATE OR REPLACE FUNCTION f_team
      2  RETURN VARCHAR2
      3  IS
      4    s_return VARCHAR2(500);
      5  BEGIN
      6    FOR i IN ( select team from t_team order by 1) LOOP
      7      s_return := s_return || i.team || ', ';
      8    END LOOP;
      9   
    10    RETURN substr(s_return, 1, length(s_return) - 2);
    11  END;
    12  /
    Function created.
    SQL>  SELECT f_team FROM dual;
    F_TEAM
    Australia, Bangladesh, England, India, Kenya, Pakistan, South Africa, UAE, USA, West Indies, Zimbabwe
    SQL>

  • Cannot install itunes 10.6. pop up msg states "There is a problem with this Windows Installer package. A program required for this install to complete could not be run.Contact ur support personnel or package vendor

    Cannot install itunes 10.6. pop up msg states "There is a problem with this Windows Installer package. A program required for this install to complete could not be run.Contact ur support personnel or package vendor.Please advise.

    Follow Microsoft instructions below on how to take control of the Folder. You may apply this on your C:\Program Files(x86)\iTunes
    You may take the ownership of the folder and then use the steps to grant permission to everyone–
    Locate the file or folder on which you want to take ownership in windows explorer 
    Right click on file or folder and select “Properties” from Context Menu 
    Click on Security tab 
    Click on “Advance”  
    Now click on Owner tab in Advance Security Settings for User windows 
    Click on Edit Button and select user from given Change Owner to list if user or group is not in given list then, click on other users or groups. Enter name of user/group and click ok. 
    Now select User/group and click apply and ok. (Check “Replace owner on sub containers and objects” if you have files and folder within selected folder) 
    Click ok when Windows Security Prompt is displayed 
    Now Owner name must have changed. 
    Now click Ok to exist from Properties windows 
    Once you have taken the ownership of file or folder
      Grant Permissions to everyone- 
    Go to C: and then click right click on folder and chooseproperties. 
    Then go to security tab and click Edit then clickAdd => Advanced. 
    If you click on advanced now click on Find Now and chooseeveryone and click Ok. 
    Then again click Ok and now click onAllow => Full control => Ok.

  • Anyway to "UN" Ken Burns stills globally or as default bringing in jpeg's?  New to iMovie. I have 3 titles that build.  First is logo, add prod't name second line, add date 3rd line.  They shift when dissolving between them. Title function NG for this.

    Anyway to "UN" Ken Burns stills globally or as default bringing in jpeg's?  New to iMovie. I have 3 titles that build.  First is logo, add prod't name second line, add date 3rd line.  They shift when dissolving between them. Title function NG for this.
    The people at the Apple store gave me a long, tedious workaround which is open Pages and bring in logo.  Export it as a PDF.  Open the PDF in Review and then "Save As" a jpg to the desktop and drag and drop into the imovie.  Even with this process, the text will sometimes shift.  When it works, it looks good, the logo comes up, then the second line fades in under it as part of the build and then the third line completes the graphic.  It would something this easy and straight forward would be easy. 
    HarveyV

    I did the work around for the titles/jpg's in this short video. 
    I'll try your fix on the next one.  I have 22 short 3-5 minute videos to produce
    and I'm on number 5.  This should save me a bunch of time. 
    It would appear that you know more than the guy at the Apple Store. 
    Thank goodness for on-line forums.
    I already tried fixing them individually as you suggested,
      by going the crop/fit route.  However, even then,
      the second in the series had always shifted. 
    The first and the third images lined up, but not number 2.. 
    So  I brought in all the images, (1, 2 and 3).  
    and then the 2nd image again and put it in the third position
    in the sequence on the time line. I deleted the "original" 2nd image.
    So I had 1, 3, then 2.  Then I dragged and dropped the correct number two
    into position two and it worked.  So what happens is that the
    client logo appears, then that stays put and the next line dissolves in
      and then the third dissolves in.  They are three separate titles, but they
    are aligned perfectly so that they build as I dissolve between them.
    I think the problem with the edit copy route would be that while
    I could edit/copy the logo, I couldn't position text through the
    iMovie text function exactly as it only gives you middle or bottom third etc.
      Each title with the product name is positioned individually depending on
    length and number of lines. By going through Pages, I can position the logo
    and the text exactly.  Also, some logos are horizontal, while others
    are square etc., so text positioning is crucial.Anyhow,
    I'll try the global approach for the next one and see how that works.
      Thanks very much for your insight and especially for your prompt reply.
    I trust you're inside on this gorgeous July 4th because you're
    making money on your computer. ;-)HarveyVOn 7/4/2011 3:57 PM, Apple Support Communities Updates wrote:
    > Apple Support Communities <https://discussions.apple.com/index.jspa>>>>       Re: Anyway to "UN" Ken Burns stills globally or as default>       bringing in jpeg's? New to iMovie. I have 3 titles that build.>       First is logo, add prod't name second line, add date 3rd line.>       They shift when dissolving between them. Title function NG for...>> created by AppleMan1958 > <https://discussions.apple.com/people/AppleMan1958> in /iMovie/ - View > the full discussion > <https://discussions.apple.com/message/15552380#15552380>> ------------------------------------------------------------------------>> I am baffled by what you are asking...but if you are asking how to > turn off the Ken Burns effect, you can do it for future photos you add > by going to File/Project Preferences and setting the default initial > photo placement to FIT or CROP rather than Ken Burns.>> For a global change on photos that are already in your project, pick a > photo. Open the Rotate, Crop, Ken Burns Tool. Select FIT or CROP.  > Exit the tool. Now select this same photo and EDIT/COPY.>> Now, EDIT/SELECT ALL.>> Finally, EDIT/PASTE ADJUSTMENTS.../CROP ADJUSTMENTS.

  • I'm not able to download Itunes.  I keep getting this Apple Software Update message that states "There is a problem with this Windows installer package.  A program required for this install to complete could not be run.  Contact your package vendor"

    Not able to access Itunes store anymore.  Just quit working for no reason.  I've tried deleting Itunes and related components from the Control Panel, but when I try to remove Apple Software Update, I get a message that states "There is a problem with this Windows installer package.  A program required for this install to complete could not be run.  Contact your support personnel or package vendor".  Not sure what this message means.  Am I suppose to contact Apple ?  What is meant by package vendor ?

    Apparently it's an itunes issue. I just tried to update and got the same issue. Called att to activate my iphone 4s and they say they can do the swap but apple is telling them itunes is down atm.  So will have to wait

  • Is UDF required for this?!! or Can we manage with Node Functions?!!!

    HI Gurus,
    I have a requirement like below desc, Is UDF required for this?!! or Can we manage with Node Functions?!!!
    Source File: ( File )
    a) PO_TYPE
    b) Style1
    c) Style2
    Note: Style1 leads to Headernode and Style2 leads to ChildNode, Style1 and Style 2 are interconnected.
    Target File: ( Idoc )
    a) Header Node ( EHDRNDE)
    b) Child NOde ( CHLDNDE)
    And my question is.... I have to populate Header Node and Child Node in target side on certain conditions of the source file. they are;
    I) Whenver a different style1 comes in file...I have to create a Headernode for that in target file. Style1 can contain number of Style2 nodes with the same node. like
    Ex:
    i) Style1 -
    Style2a, Style2b, Style2c
    ii) Style1 ....... Style2aa, Style2ab.
    For this above requirement, I have to create corresponding target nodes for Header ( Style1 ) and as well as for Child ( Style2)
    for ex1: it should be one Header node in target and 3 corresponding child nodes
    for ex2 : It should be One Header Node and 2 child nodes
    For this requirement...can we use node functions....if it is...could you please help me.
    ....Stallin
    Edited by: stallin xavier on May 1, 2008 4:18 AM

    Hi,
    You can do it by using node function as well as UDF also.
    1) If your sequence is sorted and always come in sorted order only e.g. 1st come only style1 node and child node and then come all nodes from style 2 then u can use node function.
    2) for parent node use collpse context then remove context.
    3) for child node 1st differntiat according to your condition and then use split by value(value change)
    4) If occurance of style1 node and style2 node is not fixed then you don't have any option you have to write UDF.
    I think this will help you.
    Regards,
    Rohit.
    Reward points if helpful

  • You do not have permissions to access a database that contains data required for this form to function correctly.

    I have dropdown on infopath form , and it receives data from sql server table ,  it works fine when i am running in preview mode , but when i am publishing form to sharepoint server and loading that form
    i am getting this
    You do not have permissions to access a database that contains data required for this form to function correctly.
    Can you please help?
    Thanks,

    try this one, if not yet
    Convert the data connection to UDC (store it in a Data Connection Library within the same site collection as the form library).  See if this works without any other changes, but if not, then...
    Manually edit your UDC file in Notepad (or your preferred editor) so that the authentication line is not commented out and so that it references the name of the SSO target app you created. 
    For Type, use NTLM.
    Ensure the user has rights to access the database
    Also ensure the connection file has been approved - A sharepoint admin can access a non approved Ucdx file. Go to the connection library and approve the file
    Also check this post having the similar issue:
    http://social.technet.microsoft.com/Forums/en-US/3196bafd-4bc3-40ab-ac2b-d149d1c3e0fa/sharepoint-2010-error-you-do-not-have-permissions-to-access-a-database?forum=sharepointdevelopmentprevious
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • Re-use SELECT statement in several procedures (other than copy-and-paste)

    Our site uses a procedure of the following procedure construct to generate Excel spreadsheets:
    TYPE retCur is REF CURSOR;
    PROCEDURE get_data_for_excel (
      p_filter1 VARCHAR2
      ,p_filter2 VARCHAR2
      ,c_OutCursor out retCur
    IS
      retCursor retcur
    BEGIN
      BEGIN
      OPEN c_OutCursor FOR
        SELECT XMLELEMENT("TR", XMLFOREST(
           "col1" AS "TD"
           ,"col2" AS "TD"
           ,"col3" AS "TD"
          )).getstringval()DATA FROM (SELECT * FROM
       SELECT col1, col2, col3
       FROM sometable
       WHERE somecolumn = p_filter1
        AND someothercolumn = p_filter2
       ) x);
      END;
    END get_data_for_excel
    My question is, the subselect:
    SELECT col1, col2, col3
    FROM sometable
    is used in another procedure. Is there a way to reuse the select from the other procedure into this procedure so we don't copy-and-paste each time the other procedure is changed?
    Thanks a lot.

    This is a design decision you need to make BEFORE it goes into production.
    Right now you have
    procedure get_data_for_excel (
       p_filter1 VARCHAR2
      ,p_filter2 VARCHAR2
      ,c_OutCursor out retCur );
    What, I think jihuyao is trying to say is:  convert it to a pipelined function.
    I agree with jihuyao as I have ran into to this problem before.
    create type d4e_t as object ( DATA xmltype);
    create type d4e_table is table of d4e_t;
    create or replace function get_data_for_excel (
       p_filter1 VARCHAR2
      ,p_filter2 VARCHAR2 )
      return d4e_table pipelined;
    as
    begin
      for curr in ( --start of SELECT statement
    SELECT XMLELEMENT("TR", XMLFOREST(
           "col1" AS "TD"
           ,"col2" AS "TD"
           ,"col3" AS "TD"
          )).getstringval()DATA FROM (SELECT * FROM
       SELECT col1, col2, col3
       FROM sometable
       WHERE somecolumn = p_filter1
        AND someothercolumn = p_filter2
       ) x) )
    LOOP
      pipe row( d4e_t( curr.data ) );
    end loop;
    return;
    end;
    From there, you use it elsewhere as if it were a table.
    insert into t
    select X.data from table( get_data_for_excel( l_var1, l_var2 ) ) X;
    MK

  • SELECT statement in stored procedure

    I want to be able to execute a simple SELECT statement from within a stored procedure and return a stream of data which consists of all the rows from the SELECT statement.
    Ultimately, I want to ouput this stream of data to a Crystal Report.
    Apparently, Oracle will not allow you to execute a simple SELECT statement from within a stored procedure. It will only allow execution of a SELECT INTO statment, which requires that you define a cursor, etc. etc.
    Any way around this?
    Thanks
    Bill

    Look into REF CURSORs. Still not sure about whether APEX uses them though.... Good luck.

  • How to convert simple SQL Select statements into Stored Procedures?

    Hi,
    How can I convert following SELECT statement into a Stored Procedure?
    SELECT a.empno, b.deptno
    FROM emp a, dept b
    WHERE a.deptno=b.deptno;
    Thanking in advance.
    Wajid

    stored procedure is nothing but a named PL/SQL block
    so you can do it like this see below example
    SQL> create or replace procedure emp_details is
      2  cursor c1 is SELECT a.empno, b.deptno
      3  FROM scott.emp a, scott.dept b
      4  WHERE a.deptno=b.deptno;
      5  begin for c2 in c1
      6  LOOP
      7  dbms_output.put_line('name is '||c2.empno);
      8  dbms_output.put_line('deptno is ' ||c2.deptno);
      9  END LOOP;
    10  END;
    11  /
    Procedure created.and to call it use like below
    SQL> begin
      2  emp_details;
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on;
    SQL> /
    empno is 7839
    deptno is 10
    empno is 7698
    deptno is 30
    empno is 7782
    deptno is 10
    empno is 7566
    deptno is 20
    empno is 7654
    deptno is 30
    empno is 7499
    deptno is 30
    empno is 7844
    deptno is 30
    empno is 7900
    deptno is 30
    empno is 7521
    deptno is 30
    empno is 7902
    deptno is 20
    empno is 7369
    deptno is 20
    empno is 7788
    deptno is 20
    empno is 7876
    deptno is 20
    empno is 7934
    deptno is 10Edited by: Qwerty on Sep 17, 2009 8:37 PM

  • How to write optimized select statements for this requirement

    I.     G/L Account No. Info: Get all the list of G/L Account no. , company code and the corresponding long description from SKB1 & SKAT tables based on the G/L Account no. and company code values entered in the selection screen.
    II.     No. of transactions posted: For each of the Company code & Posting date or fiscal year/ period combination, select all document numbers from BKPF table into an internal table. For each of the company code, GL Account no combination find out no. of distinct records in the BSEG table (or combination of BSIK, BSAK, BSID, BSAD, BSIS & BSAS tables) to get the No. of transactions posted.
    III.     For Last posting FY/period: for each G/L account, Company code combination, determine the MAX (Doc. No) in BSEG, and look up the corresponding document in BKPF table to get the last posting FY/Period.
    Thanks,
    Prakash.

    I) with a query (sq01/2) and logical database SDF
    or standard abap RFSKVZ00
    II)a) select bkpf
       b) select count( * ) from bsik...
    III) a)select max( belnr ) from bseg...
         b) selec single monat from bkpf
    A.

  • Please help me to write a function for this requirement!

    Hi,
        I have created a stored procedure which accepts 2 input parameters (param1 & param2 ) and its output is 'Score'
    Eg:
    Exec uspScorecalculation StudentID,DeptID 
    output: 85
    Now, My requirement is , I want to populate this value as one of the columns in a 'Select' statement.
    Can you please give me some input like how can i write a funtion to retrieve this score from the procedure and use it in the select statement?
    I assume,  the funciton should pass the two parameters into the stored procedure 'uspScorecalculation'  and retreives the Score.
    Can you please help me on this?
    thanks!

    >> I have created a stored procedure which accepts 2 input parameters (param1 & param2 ) and its output is 'Score' <<
    We have no idea from this posting what this procedure does. No code. No spec. Only a vague, useless narrative. 
    We do not put that silly “usp_” prefix on a proc name; this is one version of tibbling. When we wrote in FORTRAN I and II, we had to put “fn_” on user functions name. A procedure uses a “<verb>_<object>” format. Have you read ISO-11179 Standards
    or any book on data modeling?  
    EXEC Calculate_Something_Score student_id, dept_id; 
    >> Now, My requirement is, I want to populate this value as one of the columns in a 'SELECT' statement. <<
    Populate a column? We do not do that in a declarative language like SQL. The row with that column comes into existence all at once, and all the rows in the table come into existence all at once. This is a set-oriented language. 
    >> Can you please give me some input like how can I write a function to retrieve this score from the procedure and use it in the SELECT statement? <<
    NO! An SQL programmer will take the body of the procedure and replace the parameters with column names. It will be part of a SELECT statement and not a function call. We hate UDFs and other procedural constructs. 
    Please post the code and DDL, if you want help. Your failure and rudeness in not following Netiquette only hurt yourself. Your mindset is still locking into 1960's FORTRAN, not SQL. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Function Module for RSAP001 requires Type Pool

    Hi
    I am not an ABAP Freak:
    I want to set up a Function Module for RSAP0001.
    Setting Import and / or Tables Parameters give an Activation error:
    Type pool SBIWA has not been declared
    Message no. FL031
    Diagnosis:
    You used a type from type pool & in the interface of a function module.
    Procedure:
    For the program to be syntactically correct, you must
    declare the type pool in the global data declaration of the
    function group using the 'TYPE-POOLS: &.' statement.
    Where do I  find the global data declaration of the
    function group ?
    Thank You
    Best Wishes
    Martin

    Hi Martin,
    When you click on the function group you will find many includes declared in it.
    Some of them will be Include L<fgrp>UXX and there will be one include,
    INCLUDE L<fgrp>TOP, this is the include in which you will have to make declarations, and here you will have to declare type pool.
    Simply goto transaction SE38 and the the program name as L<functionfroupname>TOP and you can directly change this include. 
    Regards,
    Durgesh.

  • Functional Specifications for LSMW required urgently

    Hi Friends,
    Can you please provide me with the functional specifications for lsmw. I need a template document which i should be able to use as Func Specs for different lsmw objects.
    Kindly forward the same to [email protected]
    Thanks & Regards,
    Vijaya

    see the link...u will get the documents for LSMW
    https://websmp110.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000615616

  • Functional specification required for Me57 requirement

    In SAP MM, Transaction ME57, I want to pull in the Common Inventory Quantity (Not Project or Sales Order Stock) of the Material which is maintained on the Purchase Requisition.
    And also in  the T code MB52 screen, the Inventory Quantity i want to bring it.  It will be ALL Common Inventory in the Plant (minus Storage Loc a001 for Plant a000).  Again, this should NOT pull in Project or Sales Order stock.  Only Common Inventory.
    I would like a rough functional specification draft ASAP. Pleas help.

    Hi prasanna,
                    we can get SAP idoc types in tcode we31.For every requirment there will be different message type.
    For example we want idoc type for account invoice receipt.
    First find out message type for that purpose which can be found in we81-ACC_INVOICE_RECEIPT.
    Get this message type and search in we82  where we can find message type and idoc type linkage.
    try this way.
    Reward if it is usful.
    Thanks,
    Srikanth.A

Maybe you are looking for

  • Apple Wireless Keyboard doesn't work in Vista Ultmate?

    My Apple Wireless Keyboard doesn't work (not response) on Vista Ultmate but its works properly in Mac OS X 10.5.2... Should I install the driver in Mac OS first or update the keyboard firmware? Or install a driver for Windows Vista (I can't find any

  • Asgining Xml url in  as3

    Hey guys im trying to load some http url from an xml file into an actionscript function.. Its xml gallery i was successfull in loading the pics the description but im stuck at the url.... The XML file is structured this way.... <Node myURL="images/co

  • MII report for MII table maintenance

    Hi Experts My functional consultants want an easy way to update data in bespoke tables within the MII database. They want to do mass updates. This is so they can run a demo of some interfaces, then reset the MII data to its previous state. They canno

  • BPC NW 10 Currency Conversion

    Dear All, I want to do a currency conversion in my application. is there any step by step for BPC NW 10 ? i already put my data in dimension member LC and i want to convert it to USD. i'm also already do a corversion via menu : 1. Data Manager - Run

  • Tile based help

    Hi. I'm pretty new to actionscript and especially object oriented programming. I'm trying to create simple puzzle game in which three sets of colored pieces move on a board like knights in chess; except when the pieces are on black sqares, in which c