Question about using pl/sql to mark records in a table

I have a table where I have stored college course's details,
the pertinent for this questions are the fields:
course_number,
alt_id1,
alt_id2,
cross_relation,
What I need to do is to identify cross-listed courses (those that have an alt_id1 not null) and set the first one found to be parent in the cross_relation column, then read alt_id1 and alt_id2 and set them as children in the cross_relation column.
example: what I have (these are in no particular order)
course_number alt_id1 alt_id2 cross_relation
en101 | mu101 | hs101 |
mu101 | en101 | hs101 |
hs101 | en101 | mu101 |
what I want: Finds cross listed set it as P for parent and then finds its children an marks them as its children C.
course_number | alt_id1 | alt_id2 | cross_relation
en101 | mu101 | hs101 | P
mu101 | en101 | hs101 | C
hs101 | en101 | mu101 | C
I have tried different things with different results but not the one desired,
Please, I just need some idea on how to accomplish this.
Thank you

Sniff... sniff... sure smells like homework to me.
You're likely looking for a hierachical SQL to determine the parent-child hierachy.
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns001.htm#i1009313

Similar Messages

  • Question about using TVARV in an ABAP program

    Hello gurus, Im sorry about the silly question.
    I have a question about using TVARV in an ABAP program.
    A program is presenting a problem and I think that in this code:
    SELECT SIGN OPTI LOW HIGH
      FROM TVARV
      INTO TABLE R_1_163431035_VELOCIDADE
      WHERE  NAME = '1_163431035_VELOCIDADE'
      AND    TYPE = 'S'.
      IF ZMM001-VELOCIDADE_B   IN R_1_163431035_VELOCIDADE AND
          ZOPERADORAS-OPERADORA = 'ABCD' AND
          ZMM001-MATERIAL       IN R_1_163431035_PRODUTO.
      ELSE.
      ENDIF.
    What happens is that the value "ZMM001-SPEED" B not exist in "R1_163431035_VELOCIDADE" but the program executes commands under the IF and not under the ELSE, as I imagine it would work. Is this correct ?
    I am new to ABAP programming, but I have a lot of XP in other programming languages ​​and this makes no sense to me.
    Anyone know where I can find some documentation of the use of "TVARV" in ABAP programs?
    I search the Internet if other programmers use TVARV this way, but found nothing, which leads me to think that was a quick and dirty solution that used here.
    If this is a bad way to program, what would be the best way?
    Regards
    Ronaldo.

    Hi Ronaldo,
    But in this case, the range is not empty, there are 17 records, in this way.:
    For the column "SING" all values ​​are "E"
    It means that the result is false if ZMM001-VELOCIDADE_B has the same value as one of the 17 records (E = exclude).
    For instance, if it has value 'C' and one of 17 records matches C, then the result is false.
    The "IF" with "IN" using "TVARV" as used in the program of the post above has the same behavior of a selection screen?
    Yes, the same behavior as the selection criterion to be exact. You can press the help key in the complex selection dialog for more info.
    I know it's a silly and very basic question, but other language that I used, only the SQL has the "IN" operator, but I think they work in different ways, so I would like to understand how it works in ABAP.
    Not silly ;-). Yes they work differently.
    More info here:
    - http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba74635c111d1829f0000e829fbfe/frameset.htm
    - http://help.sap.com/saphelp_nw70/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/frameset.htm
    BR
    Sandra

  • I have a question about using multiple ipads in our school.  Each of our teachers have a iPad and AppleTV in their classroom.  The issue is, with our classrooms so close in proximity to one another, is there a way to pair teacher

    I have a question about using multiple ipads in our school.  Each of our teachers have a iPad and AppleTV in their classroom.  The issue is, with our classrooms so close in proximity to one another, is there a way to pair teacher #1 iPad to its AppleTV without effecting/projecting onto the adjacent teachers #2 classroom AppleTV?

    Not as such.
    Give the AppleTV units unique names and also enable Airplay password in settings with unique passwords for each teacher.
    AC

  • Hi, I have quick question about use of USEBEAN tag in SP2. When I specify a scope of SESSION for the java bean, it does not keep the values that I set for variable in the bean persistent.Thanks,Sonny

     

    Make sure that your bean is implementing the serializable interface and that
    you are accessing the bean from the session with the same name.
    Bryan
    "Sandeep Suri" <[email protected]> wrote in message
    news:[email protected]..
    Hi, I have quick question about use of USEBEAN tag in SP2. When I
    specify a scope of SESSION for the java bean, it does not keep the
    values that I set for variable in the bean persistent.Thanks,Sonny
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • Question about using new battery in old Powerbook

    I have a pre-intel Powerbook G4, and the battery is pretty much toast (lasts about 15 minutes now). I have ordered a new battery for it, and I have this question about using it:
    Am I smarter to keep the new strong battery out of the PB most days (as I usually work with it plugged in at home) and just pop it in when I know I will be out surfing on batteries? Or is it just as good living in my laptop 24/7 and only occasionally being called upon to do its job?
    Current bad Battery Information below:
    Battery Installed: Yes
    First low level warning: No
    Full Charge Capacity (mAh): 1144
    Remaining Capacity (mAh): 1115
    Amperage (mA): 0
    Voltage (mV): 12387
    Cycle Count: 281
    thanks folks, Shereen

    Hi, Shereen. Every Powerbook battery wants to be used — drained and then recharged — at least every couple of weeks. If you've always used your Powerbook on AC power nearly all the time, and not followed that pattern of discharging and recharging the battery every week or two, it's possible that your use habits have shortened the lifespan and prematurely diminished the capacity of your old battery. Of course it's also possible that your battery is merely old, as a battery's capacity also diminishes with age regardless of how it's used. You didn't say how old the battery is in years, so this may or may not be an issue. I mention it only because it can be an issue.
    For general information on handling a battery for the longest possible lifespan, see this article. My advice on the basis of that article and long experience reading these forums is that it would be OK to do as you propose, but I doubt that you'd derive any significant benefit from it. You would still want to be sure of putting the new battery through a charge/discharge cycle every week or two, even if you didn't have a reason to use the Powerbook away from home or your desk, because sitting unused outside the computer is just as bad for a battery as sitting unused inside it. And you should never remove the battery from your computer when it's completely or almost completely discharged and let it sit that way any longer than a day or two.
    Message was edited by: eww

  • Question about using Macbook in Vietnam.

    I have a question about using Macbook in Vietnam. I bought my mac here in the US, and I'm going to visit Vietnam, but I'm wondering if I can plug in the power directly into the wall or I have to need any convert power modem for my mac. The only thing I know that Vietnam use 220V so, can anyone help me?

    You may need a plug adaptor, but you don't need a power converter.
    (43828)

  • I have a question about using adobe CS files in CS6 edition

    I am a graphic artist . I have a question about using adobe CS files in CS6 edition. when I am gonna open thse adobe CS created files in CS6 Edition i get a color variation than i made with the CS version.Please give me an idea about this issue as soon as possible.If you need i can upload my problem as a screenshot to clearity

    donrulz,
    Are your Edit>Color Settings the same?
    Are you using spot colours, such as Pantone (there have been some changes in CMYK values with new colour books)?

  • Where Would be the best category to ask a question about using dashboard?

    Where Would be the best category to ask a question about using dashboard?

    However, don't ask it in this topic. Create a new topic for the question with a title describing that you are looking for Dashboard help.

  • Question about Using PAPI Web Service in PowerBuilder 9

    Hi, all.
    I Have a simple question about using papiws in power builder 9.
    In pb9, I created a new Web Service Proxy Wizard and I input a url for papiws(ex. http://seraphpernote:7001/papiws/PapiWebService) and click next.
    But I couldn't get any Service List.
    In Eclipse, I used this url for using papiws well.
    Does anybody know about this case??
    help me plz.

    IIRC you must activate PAPI-WS for the engine. In Studio you do it by right-clicking on the project, then "engine preferences". In enterprise/standalone you must activate PAPI-WS in the Admin Center.

  • Question about using 10g/11g and APEX ...

    Hi,
    I just recently learned of Oracle's APEX and have a few questions about using it.
    Can I use APEX with express, standard, and enterprise editions of 10g and 11g?
    Are all of these free to use?

    You might want to read about APEX rather than jumping into questions that are reasonably well documented. Info at http://www.oracle.com/technology/products/database/application_express/index.html
    Your specific questions:
    1) Apex is a package that can be installed into any properly licensed database.
    2) The price for the production license of the database varies by edition.
    The price for Express Edition is $0 for use in production. Part of the cost for that edition is 'no Oracle Support based support, no patches, data volume limitation, etc.'

  • Question about using Runtime.getRuntime();

    hi all
    i have a question about using Runtime.getRuntime(). if i use this to get a runtime reference to run an external program, is it considered as starting a new thread inside the thread that starts it?
    is it safe to do it in the Session EJB? if not, what can you recommand to do it? thanks

    hi all
    i have a question about using Runtime.getRuntime().
    if i use this to get a runtime reference to run an
    external program, is it considered as starting a new
    thread inside the thread that starts it? No. Starting a process, starts a process. Threads have nothing to do with it.
    is it safe to do it in the Session EJB? if not, what
    can you recommand to do it? thanksSo what? Run another process? If you want to run another process in java then your choices are to use Runtime.exec() or use JNI. And using JNI will probably end up doing exactly the same thing as Runtime.exec().
    "Safe" is harder. Typically to correctly use Runtime.exec() you must use threads. And as noted threads ideally should not be used. You can use them but if you do you had better understand why they didn't want you using them in the first place. You had also better be sure that you really want to wait for it to complete.
    Other than that Runtime.exec() is safe because it can't crash the VM like other interfaces can (like JNI.)

  • Question about using objects in SQL query.

    I had posted this question in the SQL/PLSQL forum but I guess nobody took the time to understand exactly what I am asking so I decided to try here hoping to get the answer. So here is the thing:
    I have created generic object type "tree" - the constructor takes as a parameter sql query which returns "node_id" and "parent_node_id" - this is all we need to have a tree. The object has all related to a tree structure member functions and one of them is "oldest_relative" (the tree may not be fully connected - it may be more like a set of many trees, so it's not necessary all nodes to have the same root).
    I also have departments table with the following fields: department_id, parent_department_id, department_name,...
    all records in the table w/out parent_departments (parent_department_id is null) are considered divisions.
    Now if I run the following query:
    SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT_NAME", tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") "DIVISION_ID" FROM departments
    my question is: Is the tree object created for every row or does Oracle somehow caches the object since the object itself is not changing but only the parameter for the oldest_relative member function.
    The table only has a few hunderd records and I can't see much of a difference in the execution time btw the query above and query like this:
    SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT_NAME", b.t.oldest_relative("DEPARTMENT_ID") "DIVISION_ID"
    FROM departments left join (select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') t from dual) b on 1 = 1
    where the object is clearly created just ones. (there is probably a better way to do it instead of this join)
    Pls elaborate
    George

    Not exactly sure what the question is...
    As I understand, you are comparing the following two constructor calls:
    +select..  tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") ... FROM ...+
    +select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') ... FROM dual+
    These calls are the same (besides the 1st one doing an immediate implicit call to a method of the object being constructed). The number of times these are being called depends on the number of times this SQL projection is applied - and that is determined by the number of rows being projected by the SELECT.
    The latter one is against DUAL which only has a single row. So that constructor is only called once. The former can be against multiple rows. Obviously a single pass through a data set is desirable - which means that the sub-select (use by the constructor) should ideally only be executed once and makes the 2nd method more desirable.
    However, I'm having a hard time understanding why the class and constructor are at all needed. Why pull data from a SQL table into PL memory? As that is where the class will need to cache and store the results of that construction parameter SQL SELECT. And once in PL memory, how does the object effectively access, search and use this cached data?
    PL memory is expensive. It is not sharable.
    PL data structures are primitive - these cannot be compared to SQL structures in the form of tables and columns that can be stored in a number of physical ways (index tables, hash tables, partitioned tables, clustered tables, etc). Cannot be indexed like SQL structures using B+tree, bitmap, function and other indexing methods. Cannot be sorted, grouped, analysed, filtered, etc like SQL structured data.
    It makes very little sense to read SQL data into a class and then deal with that data, cached in expensive PL memory, using primitive PL structures.
    And the same would be true if Java or C# was used. The best place for data is inside the SQL engine. That is the most superior environment for data. It can processes more data, scale better, perform better and offer more flexibility, than pulling data from it and then crunch that data using PL or Java or C#.

  • Another question about using objects in SQL queries

    Hi gurus, I need your thoughts on this:
    I have created generic object type "tree" - the constructor takes as a parameter sql query returning "node_id" and "parent_node_id". As a tree - the object has all related to a tree structure member functions and one of them is "oldest_relative" (the tree may not be fully connected - it may be more like a set of many trees, so it's not necessary all nodes to have the same root).
    I also have departments table with the following fields: department_id, parent_department_id, department_name,...
    all records in the table w/out parent_departments (parent_department_id is null) are considered divisions.
    Now if I run the following query:
    SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT", tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") "DIVISION_ID" FROM departments
    my question is: Is the tree object created for every row or does Oracle somehow caches the object since the object itself is not changing but only the parameter for the oldest_relative member function.
    The table only has a few hunderd records and I can't see much of a difference in the execution time btw the query above and query like this:
    SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT", b.t.oldest_relative("DEPARTMENT_ID") "DIVISION_ID"
    FROM departments left join (select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') t from dual) b on 1 = 1
    where the object is clearly created just ones. (there is probably a better way to do it instead of this join)
    Pls elaborate
    George

    Hi, TREE is not a function but PL/SQL object type I have written representing tree structure. The Oracle version is 10g.

  • Question about using cursor

    My question is about performance:
    If I have a java program to call a stored procedure using a cursor, the code segment is like this:
    ResultSet rs = oracleCallableStatement.getObject(a_cursor);
    while (rs.hasNext()) {
    rs.getString(column_name);
    My question is -- how does this work behind scene? Would my java process talk to oracle to get the next record for EACH call inside the while loop? If yes, this seems to slow down my program and we should avoid using cursor.
    Thanks in advance for any reply.
    tom

    Victor,
    Is there something similar using PL/SQL, we use a gateway connection to AS400. I see that a PL/SQL cursor is fetching as many times as there are number of rows.
    Thanks for your help in advance.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Victor Yu ([email protected]):
    Hi, Tom,
    Actually, Oracle JDBC will cache some rows in client side to reduce the round trip. It's called prefetching. Once your next() calls have run through those rows, JDBC will go back to fetch the next N rows. The default number of rows to prefetch to the client is 10. If your cursor return a lot of rows, say 1000 or more, you can change the number of rows to prefetch. Use the setRowPrefetch() method at the Statement level or setDefaultRowPrefetch() at the Connection level.<HR></BLOCKQUOTE>
    null

  • Questions about using the Voice Memos app

    I'm currently an Android user, but will be getting an iPhone 6 soon. My most used app is the voice memos app on my Android phone. I have a couple questions about the iPhone's built-in voice memos app.
    -Am I able to transfer my voice memos from my Android phone to my iPhone, so my recordings from my Android app will show up in the iPhone's voice memos app?
    -When exporting voice memos from the iPhone to computer, are recordings in MP3 format? If not, what format are they in?
    -In your opinion, how is the recording quality of the voice memos app?

    You cannot import your Android voice memos to your iPhone's voice memo app.  You might be able to play the Android memos and have the iPhone pick up the audio and record it.
    Here is the writeup about sending voice memos from the iPhone to your computer (from the iPhone User Guide):
    App quality is excellent.

Maybe you are looking for

  • Rated song in my iphone/ipad does not show in itune

    hello i had rated som song as one star in my iphone, so when i connect to itunes, the rating should show, [when i select the music of my iphone in itunes] i used to have it in old release but now i dont know why does not show . i even made smart list

  • Can't change Refresh Rate

    To try to get my new Samsung LN-R268W monitor to show what's on the screen of my Power Book G4 (OS 10.4.5), the lady at Samsung Customer Support said I need to make sure my Refresh Rate is 60 hertz. System Preferences>Displays>Color LCD>Display had t

  • How to move the cursor in JTable?

    I want to move the cursor focus a cell of JTable, but I don't know which method should be used? can you help me, pls thanks!

  • How to include IE on form Canvas (same windows)

    I Use OLE Container Object to Show IE on the forms6i Canvas (same windows) It's work like separate frame on the same Canvas ..;but when I migration to forms 9i , It's not working .Can I have any way to do this on the form9i

  • How to separate layer in layer palette using colour?

    How can I separate the layer in layer palette using colour to increase the visualbility like the image below?