How can I convert this small pl/sql block in a single query?

Hello,
I need to have a single SQL query which gives the same output as the following piece of code, which uses a cursor to iterate on the rows in order to get the informations I need:
declare
cursor c(p varchar2) is
select context_id, id, parent_id
from CONTEXT_CONTEXT
start with parent_id is null
and context_id = p
connect by prior id = parent_id
and context_id = p;
begin
for r in (select context_id from ALL_CONTEXTS where context_type in ('MYTYPE'))
loop
for j in c(r.context_id)
loop
-- I want to obtain the values of the following colums from a query:
dbms_output.put_line(j.context_id || ' ' || j.id || ' ' || j.parent_id);
end loop;
end loop;
end;
Additional informations:
CONTEXT_CONTEXT.context_id references ALL_CONTEXTS.id
CONTEXT_CONTEXT.id references ALL_CONTEXTS.id as well
CONTEXT_CONTEXT.parent_id references ALL_CONTEXTS.id as well
id is primary key of ALL_CONTEXTS
(context_id, id) is primary key of CONTEXT_CONTEXT
*/

user10047839 wrote:
Unfortunately, the CONNECT_BY_ROOT is not supported by my version of the DB 9i.
SELECT  context_id,
        SUBSTR(
               SYS_CONNECT_BY_PATH(context_id,'/'),
               2,
               INSTR(
                     SYS_CONNECT_BY_PATH(context_id,'/') || '/',
                     1,
                     2
                    ) - 2
              ) AS parent_context_id
  FROM  CONTEXT_CONTEXT
  START WITH parent_id IS NULL
    AND context_id IN (
                       SELECT  context_id
                         FROM  all_contexts
                         WHERE context_type IN ('MYTYPE')
  CONNECT BY PRIOR ID = parent_id
         AND context_id = PRIOR context_id;SY.

Similar Messages

  • I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?

    I have 13 dollars left on an apple store gift card, how can I convert this into money for my iTunes account?

    You can't.

  • How can i convert this data(00000000) into date format(yyyy-MM-dd)

    Hi,
    i am using this method to convert date format from string.
    public static string FormatDate(string inputDate, string inputFormat)
                System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
                string datepresent = DateTime.Now.Date.ToString("yyyy-MM-dd");
                return datepresent;
    its working properly,
    but when input data is like 00000000 i am getting error this is not valid.
    how can i convert this into date format any help..!

    Have you tried the above code:
    I can see it is working with both Date and DateTime destination nodes.
    Map:
    Functoid Parameters:
    Functoid Script:
    public static string FormatDate(string inputDate, string inputFormat)
    string datepresent;
    if (inputDate == "00000000")
    datepresent = "0000-00-00";
    else
    System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
    datepresent = date.ToString("yyyy-MM-dd");
    return datepresent;
    Input:
    <ns0:InputDateString xmlns:ns0="http://DateFormat.SourceSchema">
    <DateString>00000000</DateString>
    </ns0:InputDateString>
    Output:
    <ns0:OutputDate xmlns:ns0="http://DateFormat.DestinationSchema">
    <Date>0000-00-00</Date>
    </ns0:OutputDate>
    If this answers your question please mark as answer. If this post is helpful, please vote as helpful.

  • How can I translate this from PL/SQL into embedded SQL!?

    CURSOR TEMP1 is
    SELECT emp.fname fname, emp.lname lname, emp.ssn, dname,emp.salary salary, emp1.fname supervisor_fname, emp1.minit supervisor_mdlname,emp1.lname supervisor_lname FROM employee emp, employee emp1,department d
    WHERE emp.superssn=emp1.ssn(+) and emp.dno=dnumber order by ssn;
    PNTR_TEMP1 TEMP1%ROWTYPE;
    --calcualting values for the cursor TEMP1
    for PNTR_TEMP1 in TEMP1 loop
    fname:= PNTR_TEMP1.fname;
    lname:= PNTR_TEMP1.lname;
    ssn := PNTR_TEMP1.ssn;
    dname:=PNTR_TEMP1.dname;
    sup_name:=PNTR_TEMP1.supervisor_fname||' '|| PNTR_TEMP1.supervisor_mdlname||' '||PNTR_TEMP1.supervisor_lname;
    salary := PNTR_TEMP1.salary;
    n_deps:=0 ;
    /* how can I translate this to embedded SQL...I'm using C++*/

    Hi,
    you can follow this link to use cursor in Pro*c /C++
    http://www.csee.umbc.edu/help/oracle8/server.815/a68022/sql.htm
    Regards

  • How can I write this small function to create number of Array(s), please?

    Guys,
    How can I have a function create Array depending upon the passed argument. Am I doing this right?
    function createArray(n:int):Array
        for(var i:int=0; i<n; i++)
           var nArr = new Array();
           return nArr[i];
    Thanks a lot.

    var aArraySet:Array = createArraySets(5); //create 5 arrays
    // Array 1 -> aArraySet[0]
    // Array 2 -> aArraySet[1]
    // Array 3 -> aArraySet[2]
    // Array 4 -> aArraySet[3]
    // Array 5 -> aArraySet[4]
    function createArraySets(n:uint):Array
        var aArraySet:Array = new Array();
        for(var i:uint=0; i<n; i++)
           aArraySet.push(new Array());
        return aArraySet;

  • How can I load this XML with sql loader ?

    Hi,
    Im try to load a XML file into a XML table:
    Create table TEST of XMLTYPE;
    XML file is something like this:
    <!DOCTYPE list SYSTEM "myfile.dtd">
    <list>
    <item id = 1> lot of tags an info here </item>
    <item id = 9000> lot of tags an info here </item>
    </list>
    I dont know how to exactly create an appropriate control file to my XML. All examples I saw in documentation are similar to this one:
    this is an example control file
    LOAD DATA
    INFILE *
    INTO TABLE test
    APPEND
    XMLTYPE (xmldata)
    FIELDS
    I dont know how to complete this control file. Can anyone help me ?
    thank you!
    Message was edited by:
    pollopolea

    Well I found this working code
    LOAD DATA
    INFILE *
    INTO TABLE test APPEND
    xmltype(xmldata)
    FIELDS
    ext_fname filler char(30),
    xmldata LOBFILE (ext_fname) TERMINATED BY EOF
    BEGINDATA
    mifile.xml
    mifile2.xml
    mifile3.xml
    the main diference I found is that when i use:
    Insert into test values (XMLType(bfilename('XMLDIR', 'swd_uC000025127.xml'),nls_charset_id('AL32UTF8')));
    tag <!DOCTYPE list SYSTEM "myfile.dtd"> is expanded
    (I explain at DTD insertion and errors with long DTD entities
    Now using sql loader the tag is not modified.
    I dont know if is there any difference, between each case. did I lost performance?
    Message was edited by:
    pollopolea

  • How can I convert this UDF to be Dynamic?

    Hi there I have this UDF that calls a RFC, currently you can specify which table you want to read from and some input parameters. Could someone help me modify this so that I can specify which RFC to call? It only has to have 1 input parameter so not to worry about that. I am trying to change it to another RFC but it does not work. Heres the original UDF calling a static RFC with any table:
    // declare parameters
    String returnValue = "";
    String rfcXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <ns0:RFC_READ_TABLE xmlns:ns0=\"urn:sap-com:document:sap:rfcfunctions\"><QUERY_TABLE>ZMAPPING_TABLE</QUERY_TABLE><DATA></DATA><FIELDS></FIELDS><OPTIONS><item><TEXT>EAN_UPC =  '"EAN_UPC"'</TEXT></item></OPTIONS></ns0:RFC_READ_TABLE>";
    AbstractTrace trace = container.getTrace();
    RfcAccessor accessor = null;
    ByteArrayOutputStream out = null;
    try
    // 1. Determine a communication channel (Business system + Communication channel)
    Channel channel = LookupService.getChannel(businessSystem,communicationChannel);
    // 2. Get a RFC accessor for the channel.
    accessor = LookupService.getRfcAccessor(channel);
    // 3. Create an XML input stream that represents the RFC request message.
    InputStream inputStream = new ByteArrayInputStream(rfcXML.getBytes());
    // 4. Create the XML Payload
    XmlPayload payload = LookupService.getXmlPayload(inputStream);
    // 5. Execute the lookup.
    Payload result = null;
    result = accessor.call(payload);
    InputStream in = result.getContent();
    // 6. Create a DOM structure from the input XML
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(in);
    NodeList list = document.getElementsByTagName("WA"); // The lookupValue is available as WA tag in the response
    Node node = list.item(0);
    if (node != null) {
    node = node.getFirstChild();
    if (node != null) {
    returnValue = node.getNodeValue();
    // 7. To free resources, close the accessor..
    if (accessor!=null) {
    try {
    accessor.close();
    } catch (LookupException e) {
    trace.addWarning("Error while closing accessor " + e.getMessage() );
    } catch (Exception e) {
    trace.addWarning("Error" + e);
    // 8. return a single id value to the message mapping
    return returnValue;
    And here is the one I have dynamically calling a RFC:
    // declare parameters
    String returnValue = "";
    String rfcXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <ns0:" + RFC_NAME + " xmlns:ns0=\"urn:sap-com:document:sap:rfcfunctions\"><INPUT_PAR>Input_Value</INPUT_PAR></ns0:" + RFC_NAME + ">";
    AbstractTrace trace = container.getTrace();
    RfcAccessor accessor = null;
    ByteArrayOutputStream out = null;
    try
    // 1. Determine a communication channel (Business system + Communication channel)
    Channel channel = LookupService.getChannel(businessSystem,communicationChannel);
    // 2. Get a RFC accessor for the channel.
    accessor = LookupService.getRfcAccessor(channel);
    // 3. Create an XML input stream that represents the RFC request message.
    InputStream inputStream = new ByteArrayInputStream(rfcXML.getBytes());
    // 4. Create the XML Payload
    XmlPayload payload = LookupService.getXmlPayload(inputStream);
    // 5. Execute the lookup.
    Payload result = null;
    result = accessor.call(payload);
    InputStream in = result.getContent();
    // 6. Create a DOM structure from the input XML
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(in);
    NodeList list = document.getElementsByTagName("WA"); // The lookupValue is available as WA tag in the response
    Node node = list.item(0);
    if (node != null) {
    node = node.getFirstChild();
    if (node != null) {
    returnValue = node.getNodeValue();
    // 7. To free resources, close the accessor..
    if (accessor!=null) {
    try {
    accessor.close();
    } catch (LookupException e) {
    trace.addWarning("Error while closing accessor " + e.getMessage() );
    } catch (Exception e) {
    trace.addWarning("Error" + e);
    // 8. return a single id value to the message mapping
    return returnValue;
    Thanks,
    Jan

    1)You can check the Second RFC Response Structure using SE37.
    Check export structure using Display code.
    2)Second way.......
    Change the code here
    if (node != null) {
    returnValue = node.getNodeValue();
    if (node != null) {
    returnValue = node.getNodeValue();
    }else
    returnValue = "No WA tag in response";
    Now execute the mapping using Test Tab. Now you should see "No WA tag in response" in the target structure for the mapped field.
    Edited by: Praveen Gujjeti on Mar 16, 2009 5:26 PM

  • How can I execute this procedure in sql developer, cursortype is refcursor

    PROCEDURE GET_CNTRY(CNTRY_NME_IN IN VARCHAR2 DEFAULT NULL,
    QRY_RSLT_OUT OUT CURSORTYPE) AS
    BEGIN
    OPEN QRY_RSLT_OUT FOR
    select
    CNTRY_NME,
    FRGN_CNTRY_CDE,
    INV_VEH_CNTRY_CDE,
    FRGN_CNCY_CDE,
    WTHH_PCT_COLA_CDE
    FROM
    CNTRY
    WHERE
    CNTRY_NME = NVL(CNTRY_NME_IN,CNTRY_NME);
    END GET_CNTRY;

    In SQL Developer run the following code as script (You need to hit F5 to run it as script).
    var rc refcursor
    exec get_cntry (<give your cntry_nme_in>, :rc)
    print :rc

  • How can I make this a smaller file?

    Hi,
    I was wondering how I can make this movie smaller.
    I don't understand why it is so big.
    The sound is a .wav that comes in at 596 kb recorded at 22.5
    khz in mono.
    The rest must be the video. How can I get this smaller?
    Thanks
    The movie is at the link below:
    www.kapowdesign.com/leosbday.htm

    Here are tools that can help you reduce the size of your SWF
    http://www.flashjester.com/index.php?section=faq&cPath=50#318
    Try it.
    Regards
    FlashJester Support Team
    e. - [email protected]
    w. -
    http://www.flashjester.com
    There is a very fine line between "hobby" and
    "mental illness."

  • How can I convert output data (string?) from GPIB-read to an 1D array?

    Hello all,
    I am reading a displayed waveform from my Tektronix Oscilloscope (TDS3032) via the GPIB Read VI. The format of the waveform data is: positive integer data-point representation with the most significant byte transferred first (2 bytes per data point).
    The output data of GPIB-Read looks like a string(?) where the integer numbers and a sign like the euro-currency sign are seperated by spaces e.g. #5200004C3 4 4 4 4 3C3C3........ (C represents the euro-currency sign).
    How can I convert this waveform data into a 1D/2D array of real double floatingpoint numbers (DBL) so I can handle the waveform data for data-analysis?
    It would be very nice if someone know the solution for this.
    t
    hanks

    Hi,
    First of all, I'm assuming you are using LabVIEW.
    The first you need to do is parse the string returned by the instrument. In this case you need to search for the known symbols in the string (like the euro sign) and chop the string to get the numeric strings. Here are some examples on parsing from www.ni.com:
    Keyword Search: parsing
    Once you parse the numeric strings you can use the "String/number conversion VIs" in the String pallette.
    Hope this helps.
    DiegoF.Message Edited by Molly K on 02-18-2005 11:01 PM

  • How can we convert .mov ( implemented by quicktime APi)  to .WAV file

    Hi,
    How can we convert one .MOV audio file (generated by quicktime API) to .WAV audio file ( need LINER - encoding format).
    Here I dont know the encoding format of .MOV audio input file.
    regards,
    Rams

    mfrasyid1 wrote:
    I wonder why this happens? The "unable to handle.." really does come out twice. Is it because the inputfile.mov which I wanna convert comes from the merging oftwo wave files? If so, then how can I convert this into single wave file? Thank you.That is a weird message, but yes, the .mov file probably stored the 2 original WAV files as 2 tracks of data, rather than 1 track. So whenever it's trying to transcode to a WAV file, it fails to transcode both tracks.
    As for fixing it... I dunno. I know that JavaSound can mix two WAV files at the sample-level, so it actually mixes the sound instead of adding 2 tracks to a file...but I don't know why that's giving you those error messages, unless perhaps it's trying to transcode the video track into an audio track (perhaps the code isn't smart enough to handle transcoding a video file into an audio file? You'd have to check the code to see if that's the case...)

  • How can I convert video with srt subtitles?

    If I have an avi plus an .srt subtitles file, how can I convert this to play on the iPad?
    If, on my iMac, I use Quicktime, I can save the avi as .mov with hard subs.  But when I convert this .mov to mp4, the subtitles disappear.

    Why go to all the trouble of converting? Why not just download an app that can play .avi files with subtitle support?

  • How can I convert scanned docs into reconizable text?

    I have a very large PDF file of scanned documents the content of which is mostly text. How can I convert this into recognizable text so I could do a word search that would reveal results like a web search (speed wise)?

    Can the OCR apps convert preexisting PDF files on
    your system to text or do you have to scan directly
    into the OCR program at the time you do the original
    scan?
    You don't have to scan again. OCR apps can read from graphics files. If the OCR you pick can't use PDF, you can use Preview, or another application (e.g. Graphics Converter), to convert to a file format that the OCR can handle. All OCR apps should be able to handle TIFF. OmniPage Pro X can read both TIFF and PDF, but I wouldn't recommend it. It is overpriced, has no support, and is tricky to install on any OSX more recent than 10.1

  • OSX sometimes places 31 character limit on file names. How can I get this error to stop?

    This error notice doesn't make sense, since many of my file names exceed 31 char. This error message pops up when saving documents, esp. web pages. As a consequence, OSX will refuse to let me save the file, until I shorten the name and so remove informative identifying features of the file name. But most of the time, OSX is perfectly happy to save files with names longer than 31 char. How can I get this error notice and block to turn off?

    I have also seen this issue it occurs regularly when transferring word documents files from my Macbook Pro running OSX 10.5.8 to my iMac running 10.9.4.
    My iMac HD should be formatted to factory standards as well since I have not mucked around with it since I bought it.

  • Can't open any links within my emails. The display reads, "Firefox doesn't know how to open this address, because the protocol (blockedhttp) isn't associated with any program." How can I fix this?

    Can't open any links within the emails using Firefox. I can open them in other browsers however. The message reads, "Firefox doesn't know how to open this address, because the protocol (blockedhttp) isn't associated with any program.". How can I fix this?

    Looks like blocking software to purposely block a page by messing with the url.
    *http://kb.mozillazine.org/Parental_controls
    *http://kb.mozillazine.org/Blocking_sites (more links)

Maybe you are looking for