How to get seq.nextval as a result of an insert statement?

Hi,
on Oracle using sequences we can use follow command to issue an insert command and get the nextval used on this insert:
CALL INSERT INTO "TEST2550_ENTITY" ("ID","NAME") VALUES ("TEST2550_ENTITY_SEQ".nextval,?) RETURNING "ID" INTO ?
there is a way to do same thing in MaxDB using JDBC?
thanks for any tip
Clóvis

Hi Clovis,
sorry my fault. (I really should stop answering questions in the late evening...).
Well, unfortunately it looks like that this actually not possible vie JDBC.
I tried to use the getGeneratedKeys() Method that usually would give you automatically created IDs, but I only got this message:
Exception in thread "main" com.sap.dbtech.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: Retrieving auto generated keys is not supported.
     at com.sap.dbtech.jdbc.ConnectionItem.throwNotSupported(ConnectionItem.java:101)
     at com.sap.dbtech.jdbc.StatementSapDB.getGeneratedKeys(StatementSapDB.java:1108)
     at com.sap.dbtech.jdbc.trace.Statement.getGeneratedKeys(Statement.java:254)
Maybe one fo the JDBC developers is reading this and knows a better way...
best regards,
Lars

Similar Messages

  • Urgent : how I get tree type group total result

    hi master
    sir now system give me this type for result
    PARENT ACCID DRBAL CRBAL
    K1
    K11
    11 K1101 46291132
    11 K1102 13182173
    11 K1103 23784045
    11 K1104
    11 K1105
    11 K1106
    11 K1107 10001795
    11 K1108 9083529
    11 K1109
    11 K1110 4224350
    11 K1111
    11 K1112 6696832
    11 K1113 7963381
    11 K1114 742766
    1 K12
    12 K1201 1486082
    12 K1202
    12 K1203
    1 K13
    13 K1301
    1301 K130101
    1301 K130102
    1301 K130103
    1301 K130104 1977616
    1301 K130105
    1301 K130106 736266
    1301 K130107 396673
    1301 K130108 42751
    1301 K130109 298362
    1301 K130110 187696
    1301 K130111 537
    1301 K130112 942
    1301 K130113 987
    1301 K130114 1272
    1301 K130115 40000
    13 K1302
    1302 K130201
    1302 K130202
    1302 K130203
    1302 K130204
    1302 K130205 259941
    13 K1303
    1303 K130301
    1303 K130302
    1303 K130303 177716
    13 K1304
    1304 K130401
    1304 K130402
    1304 K130403
    1304 K130404
    1304 K130405
    1304 K130406 809719
    1304 K130407
    1304 K130408 1786091
    13 K1305
    1305 K130501
    1305 K130502
    13 K1306
    1306 K130601
    13 K1311
    1311 K131101 788780
    K2
    2 K21
    21 K2101
    2101 K210101
    2101 K210104
    21 K2102
    2102 K210201
    2102 K210202
    22 K2205
    2205 K220501
    2205 K220502
    220502 K22050201
    220502 K22050202
    220502 K22050203
    220502 K22050204
    22 K2206
    2206 K220601
    2206 K220602
    but sir i need this type of result
    PARENT ACCID DRBAL CRBAL
    GROUP NAME K1
    GROUP NAME K11
    11 K1101 46291132
    11 K1102 13182173
    11 K1103 23784045
    11 K1104
    11 K1105
    11 K1106
    11 K1107 10001795
    11 K1108 9083529
    11 K1109
    11 K1110 4224350
    11 K1111
    11 K1112 6696832
    11 K1113 7963381
    11 K1114 742766
    TOTAL
    1 K12
    TOTAL
    GROUP NAME
    12 K1201 1486082
    12 K1202
    12 K1203
    TOTAL
    1 K13
    13 K1301
    1301 K130101
    1301 K130102
    1301 K130103
    1301 K130104 1977616
    1301 K130105
    1301 K130106 736266
    1301 K130107 396673
    1301 K130108 42751
    1301 K130109 298362
    1301 K130110 187696
    1301 K130111 537
    1301 K130112 942
    1301 K130113 987
    1301 K130114 1272
    1301 K130115 40000
    13 K1302
    1302 K130201
    1302 K130202
    1302 K130203
    1302 K130204
    1302 K130205 259941
    13 K1303
    1303 K130301
    1303 K130302
    1303 K130303 177716
    13 K1304
    1304 K130401
    1304 K130402
    1304 K130403
    1304 K130404
    1304 K130405
    1304 K130406 809719
    1304 K130407
    1304 K130408 1786091
    13 K1305
    1305 K130501
    1305 K130502
    13 K1306
    Sir I need total group by group father group total and child group total
    Please help me how I get tree type group total result

    Hi master
    thankyou for your reply
    Sir,
    i know and you see my working i get code form master table and get detal amount form other table
    I have two table see table
    Acctab               Baltab
    PARENT           PCID
    CHILD           title
    PCID           amount
    I need heretical result use this type of query but not success
    please see my query and give me idea how I get here full tree
    select test.child,test.pcid,baltab.pcid from (select acctab.child,acctab.parent,acctab.pcid
    from acctab
    start with acctab.parent is null
    connect by prior acctab.child= acctab.parent) test,baltab
    where test.pcid=baltab.pcid ;
    CHILD PCID PCID
    1 1 1
    2 2 2
    3 3 3
    11 111 111
    12 112 112
    13 113 113
    21 221 221
    22 222 222
    23 223 223
    31 331 331
    32 332 332
    33 333 333
    but I need this type result
    CHILD PCID
    1 1
    11 111
    12 112
    13 113
    2 2
    21 221
    22 222
    23 223
    3 3
    31 331
    32 332
    33 333

  • How to get a sum of the result?

    I want to get the results to display the records only once if
    I have the same case number.
    This is my query.
    SELECT distinct c.case_number,
    c.bank_name,
    i.first_name,
    i.last_name,
    it.id_name,
    i.id_number1,
    i.date_of_birth,
    i.country_of_birth,
    (select count(*) from #application.db#.anc_comments ac
    join #application.db#.anc_hit h on ac.hit = h.hit_id
    join #application.db#.anc_individual i on i.individual_key =
    ac.individual_key
    where i.case_number = c.case_number and
    convert(integer,h.hit_code_value) > 0) as num_hits
    FROM #application.db#.anc_case c
    LEFT OUTER JOIN #application.db#.anc_individual i
    on c.case_number = i.case_number
    LEFT OUTER JOIN #application.db#.anc_id_type it on
    i.id_type1 = it.id_class
    left outer join #application.db#.anc_agency_response r
    on i.individual_key = r.individual_key
    WHERE (DATEDIFF(day, r.name_check_sent, getdate()) <= 90
    or r.name_check_sent is null)
    and (c.completed <> 'Yes' )
    order by #url.sort#
    My result displays the same case number more then onces for
    some Case numbers. How do I make my query to combine or only
    display the Case number once.
    Case Number Bank Name
    111-11-456456 AB Bank Name 2
    11-11-09-14.001 AB Bank name 3
    11-111-1114 AB Bank name 4
    94-10-01-06.002 Citizens Bancorporation, Inc.
    94-10-01-06.002 Citizens Bancorporation, Inc.
    94-10-01-06.002 Citizens Bancorporation, Inc.
    94-10-01-06.002 Citizens Bancorporation, Inc.
    94-10-01-06.002 Citizens Bancorporation, Inc.
    06-11-09-14.999 Kenco Bancshares, Inc.
    Thanks for your assistance

    Perhaps because you are using an OUTER JOIN - anytime the
    entire set of selected columns is not distinct you will get another
    row. Distinct applies to the entire row not just the case number.
    Phil

  • How to get sequencename.nextval in JSP

    In a JSP application, I would like to get a sequence number for the primary key of a view object.
    How do I go about this?.
    Thanks.
    Ravi

    Let the database trigger do this job for u, and make sure u check the "refresh after insert" at your entity object.
    null

  • How to Get Current Date from MS Access in a Select Statement

    From a java method, I want to use JDBC to get the current date from MS Access. In Oracle I would do "select sysdate from dual", but I can't figure out how to do it in MS Access. Here are some of my attempts. I have a table in my Access db called PARM.
    //        String sql = "SELECT '0', NOW() FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT NOW() AS CURR_DT FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT DATE() AS CURR_DT FROM PARM";
    //rs.next() is false
    //        String sql = "SELECT NOW()"; 
    //StringIndexOutOfBoundsException: String index out of range: -1
    //        String sql = "select { fn now() } from parm";
            String sql = "SELECT Date()";
    //java.lang.StringIndexOutOfBoundsException: String index out of range: -1
            ResultSet rs = stmt.executeQuery(sql);
            if (rs.next()) {
                return rs.getString(1);
            } else {
                   return null;
              }

    Why are you getting it as a String? You should be getting it as a timestamp.
    Although getString works for me too. There is something else wrong that you haven't shown.
    Here is some shoddy, but simple, test code that demonstrates it working.
    import java.sql.*;
    public class Test{
      public static void main(String args[])throws Exception{
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection c = DriverManager.getConnection("jdbc:odbc:stats");
        Statement s = c.createStatement();
        ResultSet rs = s.executeQuery("SELECT NOW()");
        while(rs.next()){
          System.out.println(rs.getTimestamp(1));     
        rs.close();
        s.close();
        c.close();
    }

  • How to get the value from a function using a select statement

    I have a function(user defined not built in) that returns multiple values(like an array). My question is how do i get those values in a select statement. when i tried to retrieve it,
    select pack.my_members from dual;
    i am getting an error
    ORA-00902: invalid datatype
    I am sure this must be a syntax error with the select statement
    The following is the function that give the array of data
    package pack
    package spec
    Type my_table is table of varchar2(25);
    function the_members
    return pack.my_table;
    pakcage body
    function the_members return pack.my_table
    Remarks: This function returns a table containing names of the
    members
    is
    tm pack.my_table:= pack.my_table('first member','second member','third member','fourth member');
    begin
    return tm;
    end the_members;

    Check this example on Pipelinedfunction

  • SP Designer Workflow: How to Get Full URL Path to List Item and inserted same list ITem URL in another list

    Hi,
    I have requirement in Sp Designer 2010,Get List item URL and insert in another list as one column value.When open another list and click on same item  column entry url will show the parent item information.
    Here i have create work flow and insert item URL in another list but cant find appropriate item url information.I can easily make  item url link through String builder in mail body with using current id and predefine link,but
    when try to insert the same type of item link in another list where i cant find string builder for create custom url link,only get valur of Path,URL,Absolute URL and Relative server URL,all these links or not provide me exact
    item link dispaly information.
    So I opened SharePoint Designer and start creating the workflow associated to the list.
    As there is some Field from source related to current item URL I start using it
    Encoded Absolute URL – this one should be the one to use
    Server Relative URL
    URL Path
    Unfortunately, none of these options were providing the correct link. Indeed, these options are providing an incorrect path:
    Encoded Absolute URL
    http://wfe1/Lists/bpf/1_.000
    Server Relative URL
    /Lists/bpf/1_.000
    URL Path
    /Lists/bpf/1_.000
    As you can see, the item URL is composed by an ID while it should be http://wfe1/Lists/bpf/dispform.aspx?id=1
    Hasan Jamal Siddiqui(MCTS,MCPD,ITIL@V3),Share Point Application Developer,TCS

    Unfortunately, [%Current Item:URL%] doesn't seem to be available from a "Site Workflow" associated to a List.   I'm finding less advantages to doing a "Site Workflow" when I don't necessarily need to.  One problem is the workflow is initiating
    twice.   I'm thinking I should have just created the workflow as a a "List Workflow."  
    I am going to try "Association Columns" -- that may work.  Anyone have other suggestions?

  • How to return the newly generated sequence id for an INSERT statement

    A record is to be inserted into a table with a sequence for the primary key. The newly inserted sequence value is to returned on successful insertion. Is it possible to do all this in a single statement (say executeUpdate or any other) using java.sql.* ?
    E.g.: - A student record is to be inserted into the STUDENT table. There is a sequence (by name Student_ID_SEQ) on the primary key Student_ID. Student_ID_SEQ.nextval will generate the new sequence id which will be provided as input to the SQL statement (say statement.executeUpdate) along with other student attribute values. On insertion the created sequence id should be returned. And all this should happen in a single statement (single call to database). Stored Procedures can accomplish this. But is this feasible without the use of Stored Procedures?
    Thanks.

    a better aproach is to generate the auto key on the
    database side, not on the application side.That's his problem - since the database is supplying the key for the new record his application which executed the SQL has no way to identify the record that was just added. I just create the key on the app server and accept the likelihood of overlap (which is extremely small).
    Here is a more technical explanation:
    Table Person
       ID,
       Name,
       Phone Number,
       Age
    }The field ID is an autonumber, and all other fields are not unique.
    Now, when this code executes:
    PreparedStatement pst = conn.prepareStatement("Insert Into Person (Name, Phone Number, Age) Values ?, ?, ?");
    pst.setString(1, "John");
    pst.setString(2, "405-444-5555");
    pst.setInt(3, 44);
    pst.executeUpdate();How can the app determine the ID of the person just added since no query is possible which is guaranteed to select just the record that was inserted?
    Since I am generally against Stored Procedures I would develop a way to insure that your keys were unique and generate them inside the app server.

  • How to set commit interval after n rows when generating insert statements?

    Hi
    I'm trying to generate a sql insert script with a few million rows using SQL Developer 1.5.4.
    I can generate insert scripts ok, but can't see anywhere to set the commit interval.
    In the preferences screen under migration I see you can set the commit interval under data move options, but I assume this is something different.
    I know we could use sql loader, but this insert is part of deployment package which has a series of sql scripts that we need to run together. So I don't want to run a series of sql scripts, then run sql loader, and then go back to sql scripts.
    Am i missing something, or is this just not possible with SQL Developer?
    Thanks in advance for your help,
    Pete

    Unfortunately, SQL Developer doesn't cover all of the SQL*Plus commands. There is a preference in SQL Developer to switch on autocommit in the SQL worksheet (Tools > Preferences > Database > Worksheet Parameters), but that is presumably every record, rather than every 100 as you are trying to do.
    There is a document on SQL Developer's SQL*Plus support (here), but that doesn't list autocommit in either the supported or unsupported sections.
    theFurryOne

  • How to get class B's results in class A

    Hi ,
    Let's say I have classA and classB ,
    classB has number of statements , lets say it has 200 lines that are executable. Here are very important result at line number 198 after processing the above 197 lines .  lets say variable CLASSB.RESULT holds this result.
    my question is how to get this value of CLASSB.RESULT(variable) from line 198 to CLASSA's any variable.
    hope I could explain my question.
    thanks

    Your question is vague. If you're asking how to store a value from Class A in Class B, it might as simple as
    classBObject.setValue(classAObject.getValue());

  • How to get different sum value by different types of record in sql server

    Hi,I have my query result like below
    AppID       LabType      DiaType      LabPrice    DiaPrice
      1                
    a               
    b               100          1000
      1                 a               
    cc              100          1000
      1                
    aa              b               100          1000
      1                 aa              cc             
    100          1000
      1                
    aaa            b               100          1000
      1                 aaa            cc              100         
    1000
    from this query
    select
    app.AppointmentId,
    lr.LabPrice,
    lt.LabCategoryType,
    drt.DiagnosisReportType,
        dr.DiaPrice as diaprice,
         from Appointment app
        left join DiagnosisReport dr on app.AppointmentId=dr.AppointmentId
        left join DiagnosisReportType drt on dr.DiagnosisReportTypeId=drt.DiagnosisReportTypeId
        left join LabCategoryReport lr on lr.AppointmentId=app.AppointmentId
        left join LabCategoryType lt on lt.LabCategoryTypeId=lr.LabCategoryTypeId
        where app.DeleteStatus='N'
        and app.AppointmentId='MLM-Appointment-60314748311012015'
        and dr.DeleteStatus='N'
        and lr.DeleteStatus='N'
    But I want following one line result by getting two sum result for 3 different types of Lab and 2 different
    type of Dia.
    AppID       LabPrice    DiaPrice
      1               300          2000
    Please, can anyone give me any idea or help how to get only one record query result.
    Thanks in advanced.
    Superman

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You failed. You should follow ISO-8601 rules for displaying temporal
    data. We need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I have my query result like below <<
    So you show us a result and expect that we can guess! Wow! We are magical! Did you ever read Douglas Adams? The answer is 42! Now find 
    the question. 
    Also, you have things like “lab_category_type” in this code. Is it a category or a type? In a valid data model that follow ISO-11179 rules you could have a “lab_category” or “lab_type” but never a mixed hybrid. In one of my books, I had something like “lab_category_type_id”
    as a joke; it was so stinking awful that I never dreamed any programmer would really do this! 
    Also OUTER JOINs a rare in a valid schema. A good design will have DRI so you know you have matches. Since a table is a set, their names are plural or collective; but you have only one appointment according to your unseen DDL. And only one “Diagnosis_Report”,
    etc. 
    Now think about “Lab_Category_Types” as a table. Regardless of how this ambiguous mess is resolved, it will be an attribute. An attribute is in a column, not an entity like you are modeling it. If it has a few static values then use a CHECK( x IN (..)) constraint.
    If it is dynamic or large, then use a REFERENCES. Never use a join like this. 
    That silly, magical “delete_status” looks like an assembly language flag. This is what we did with tape files in the 1950's. We would have a bit in the front of records and flip it. Later a program would  move the active records to a new tape. Ask yourself
    why everything in the universe would share a common attribute. Such an attribute would be so generic as to be useless or (your case) it would be meta data and not part of the entity at all. Oh, rows are not records; you got that wrong too. 
    Why do you keep prices in integers? Currency is decimal. Sure wish we had DDL. My guess is that this should look more like this simpler, faster query. 
    SELECT APP.appointment_id,
           LT.lab_type, LR.lab_price,
           DRT.diagnosis_type, DR.diagnosis_price
     FROM Appointments AS APP
          LEFT OUTER JOIN
          (SELECT appointment_id, diagnosis_type,
                  SUM(diagnosis_price) AS diagnosis_price_tot
             FROM Diagnosis_Reports AS DR 
            GROUP BY appointment_id, diagnosis_type)
           AS DR 
          ON APP.appointment_id = DR.appointment_id   
           LEFT OUTER JOIN       
           (SELECT appointment_id, lab_type, SUM(lab_price)lab_price_tot
              FROM Lab_Reports
             GROUP BY appointment_id, lab_type)
           AS LR 
           ON APP.appointment_id = LR.appointment_id 
     WHERE APP.appointment_id = 'MLM-APPOINTMENT-60314748311012015';
    --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

  • How to get field in Report

    Hi all,
    Please tell me how to get field from following path
    GO to MSC2N --
    insert material, batch , plant , storage location
    Now select classification...
    there is box containing 'characsteristics descr ' & value
    so how to get that value
    I think that values are store in table cawn but i wont found any link to get that
    Correct ans will be rewarded

    Hi,
    If you are trying to get the vaues of these charecteristics in your report, then
    Try using the fm VB_BATCH_GET_DETAIL
      CALL FUNCTION 'VB_BATCH_GET_DETAIL'
        EXPORTING
          matnr                    = is_final-matnr
          charg                    = is_final-charg
          werks                    = is_final-werks
          get_classification       = 'X'
    *   EXISTENCE_CHECK          =
    *   READ_FROM_BUFFER         =
    *   NO_CLASS_INIT            = ' '
    *   LOCK_BATCH               = ' '
       IMPORTING
         ymcha                    = ymcha
    *   CLASSNAME                =
    TABLES
    char_of_batch            = it_batch
    EXCEPTIONS
    no_material              = 1
    no_batch                 = 2
    no_plant                 = 3
    material_not_found       = 4
    plant_not_found          = 5
    no_authority             = 6
    batch_not_exist          = 7
    lock_on_batch            = 8
    OTHERS                   = 9
    also the function module VC_I_GET_CONFIGURATION
    And for table try cabn
    Regards
    Debarshi

  • How to get ISelectionManager

    Hi,<br /><br />I add a new javascript method to IDocument object, everything works ok and I can call the method through a jsx.<br /><br />var myDocument = app.open(myFile,true);<br />myDocument.dosomething();<br /><br />Here is a part of code<br /><br />ErrorCode CS4ServerScriptProvider::HandleEvent(ScriptID eventID, IScriptEventData* data, IScript* parent)<br />{<br />.....<br />...<br />// To get the IDocument I use this call<br />InterfacePtr<IDocument> document(parent, UseDefaultIID());<br />..<br />..<br />}<br /><br />My question is how to get the selection manager for this document, the following statement return always null.<br /><br />selectionManager = InterfacePtr<ISelectionManager>(Utils<ISelectionUtils>()->GetActiveSelection()); <br /><br />also the following call returns null <br /><br />GetExecutionContextSession()->GetActiveContext()->GetContextSelection();

    Hi John,
    As it seems, there is no "selection" property in javascript on the document object for InDesign Server. This leads me to the conclusion that selection is UI related and is not used in InDesign Server that way.
    There are other ways to manipulate items in InDesign Server, e.g. via corresponding interface-methods (C++ code) that take an UIDList as parameter.
    So you have to know what items to process; or I think you could attach your javascript-dosomething()-method directly to the desired items (e.g. PageItem instead of Document) and call the method on them.
    Kind Regards,
    mfi

  • Use NEXTVAL in an insert statement Part II

    db - 10g
    I am asking this question out of curiosity.
    I posted a question and recieved a successful answer at the following address on this forum;
    Use NEXTVAL in an insert statement
    The following insert statement uses a sequence to create an arbitrary number for each null record. The problem is, the sequence is firing regardless of the condition being true or false (but it is working in that it only inserts values when the condition is true). The result is the sequence appears to increment each time it loops through the cursor and so the first arbitrary number to be inserted is not 1001 but some other higher number.
    INSERT INTO psp_trees
    ( plot_id
    , tree_name
    , species_code)
    VALUES
    ( get_plot_id
    , c1.treenum          
    , c1.species
    ) RETURNING tree_id INTO get_tree_id;   I have gotten around the issue by removing the sequence from the insert statement and placing it outside the cursor loop as an update statement.
          UPDATE psp_trees
             SET tree_name = to_char(tree_arbitrary_name_seq.nextval)
           WHERE tree_name IS NULL;Is there anyway to get the sequence to only fire in the insert statement when the condition is true.
    This is the complete anonymous block for your reference;
    DECLARE p_access_num NUMBER;
    col_access_var VARCHAR2(30);
    type number_ptb IS table OF VARCHAR2(4000);
    p_access_nam number_ptb;
    get_plot_measurement_id NUMBER;
    update_plot_measurements VARCHAR2(4000);
    get_tree_id NUMBER;
    get_plot_id NUMBER;
    BEGIN
        p_access_num := 6;
        p_access_nam := number_ptb();
        p_access_nam.extend(7);
        p_access_nam(1) := 535;
        p_access_nam(2) := 548;
        p_access_nam(3) := 898;
        p_access_nam(4) := 544;
        p_access_nam(5) := 551;
        p_access_nam(6) := 724;
        FOR loop_int IN 1 .. p_access_num
        LOOP
          col_access_var := p_access_nam(loop_int);
          -- 1. Initiate insert process by getting PK from psp_plots.
          SELECT plot_id INTO get_plot_id FROM psp_plots WHERE plot_name = col_access_var;    
          -- 2. Insert records into psp_plot_measurements and keep relationship with psp_plots with variable get_plot_id.
          --    and get primary key value of psp_plot_measurements to insert into psp_tree_measurements during loop process.
          INSERT INTO psp_plot_measurements (plot_id) VALUES (get_plot_id) RETURNING plot_measurement_id INTO get_plot_measurement_id;   
          -- 3. Update record created at point 2.
          UPDATE psp_plot_measurements
             SET measurement_date    = (SELECT DISTINCT date_ FROM pspdata)
               , codominant_height   = (SELECT DISTINCT height_codom FROM pspdata)
               , assessor            = (SELECT DISTINCT assessor FROM pspdata)
           WHERE plot_measurement_id = col_access_var
          -- 4. Open cursor to insert rows one at a time and maintain relationships between related tables.
          FOR c1 IN (SELECT treenum
                          , dbhob
                          , treecomments
                          , species
                       FROM pspdata
                      WHERE plotnumber = col_access_var
                        AND date_ IS NOT NULL)     
              LOOP   
                -- 5. Insert record into psp_trees
                --    and get primary key value of psp_trees to insert into psp_tree_measurements.
                INSERT INTO psp_trees
                ( plot_id
                , tree_name
                , species_code)
                VALUES
                ( get_plot_id
                , c1.treenum
                --, NVL(c1.treenum , to_char(tree_arbitrary_name_seq.nextval))
                --, (CASE WHEN c1.treenum IS NULL THEN to_char(tree_arbitrary_name_seq.nextval) ELSE c1.treenum END)
                , c1.species
                ) RETURNING tree_id INTO get_tree_id;   
                -- 6. Insert records into psp_tree_measurements and keep relationship with psp_trees with variable get_tree_id.
                INSERT INTO psp_tree_measurements
                ( plot_measurement_id
                , tree_id
                , dbhob          
                , comments
                VALUES
                ( get_plot_measurement_id
                , get_tree_id
                , c1.dbhob
                , c1.comment
              END LOOP;         
      END LOOP; 
          -- 7. Update null columns with arbitrary number.
          UPDATE psp_trees
             SET tree_name = to_char(tree_arbitrary_name_seq.nextval)
           WHERE tree_name IS NULL;
    END;
    /Edited by: benton on Sep 6, 2011 1:53 PM

    Or use a function (I'll use dbms_xml.getxml):
    SQL> create sequence s_seq nocache
    Sequence created.
    SQL> select case when mod (level, 2) = 0
                then extractvalue(dbms_xmlgen.getxmltype('select s_seq.nextval from dual'), '//text()')
                else '0' end col1
              from dual connect by level < 20
    COL1                                                                           
    0                                                                              
    1                                                                              
    0                                                                              
    2                                                                              
    0                                                                              
    3                                                                              
    0                                                                              
    4                                                                              
    0                                                                              
    5                                                                              
    0                                                                              
    6                                                                              
    0                                                                              
    7                                                                              
    0                                                                              
    8                                                                              
    0                                                                              
    9                                                                              
    0                                                                              
    19 rows selected.
    SQL> select sequence_name, last_number from user_sequences where sequence_name = 'S_SEQ'
    SEQUENCE_NAME                  LAST_NUMBER
    S_SEQ                                   10
    1 row selected.

  • Alter a BAPI Result Table, how to get into the display "loop" ?

    Hello all,
    i have a problem regarding the result rows of a RFC/BAPI Call.
    There are three views, let's say 1,2,3. In View 1, i call a BAPI, and display the results in a table in View 2. I added a button in each row, which calls View 3 and displays some details concerning the selected row.
    I now want to store a flag for each row, that has been displayed in this way.
    In View 3 i store the key value of the displayed row in an own value node in the context.
    When i go back from View 3 to View 2, i want to see that flag (in an extra column) in every row, that has been selected in this session.
    So i do not know, how to alter a single row in the BAPI result table, how to get into the "loop" that is used by WD to display the table.
    already tried a supply function, but i was not able to alter single rows.
    Any suggestions/tips or perhaps code fragments of working supply functions ?
    Thank you !

    Hello,
    I'm not sure whether I understood your problem correctly, but I will try to give an answer.
    The easiest way I see is to copy the RFC Results to a Component Controller Context structure with an additional Flag field. You can use WDCopyService for copying.
    Then on the event of selecting you set your flag as appropriate for you (e.g. if you want to use an image as flag you set the Image path) on the current element of your table. Then display View 3.
    On going back View 2 should show now the new flag values...
    The trick is to copy the values (as at Time structures can not be expandend with new fields) and set the Flag on the onSelect event.
    Hope this helps,
    Frank

Maybe you are looking for