How to insert record in sorted table

Hi,
Please tell me how to inser the record in the sorted internal table. This is the code which is not working properly. just tell me what r the changes need to b done.
Thanks,(reward points for sure)
DATA: BEGIN OF connection,
        cityfrom TYPE spfli-cityfrom,
        cityto   TYPE spfli-cityto,
        distid   TYPE spfli-distid,
        distance TYPE spfli-distance,
      END OF connection.
DATA connection_tab LIKE sorted TABLE OF connection
                    WITH  KEY cityfrom
                                 with header line.
SELECT cityfrom cityto distid distance
       FROM spfli
       INTO connection.
  INSERT connection INTO connection_tab.
ENDSELECT.
loop at connection_tab.
write: / connection_tab-cityfrom, connection_tab-cityto, connection_tab-distid, connection_tab-distance.
endloop.
connection-cityfrom = 'Bangalore'.
connection-cityto = 'Delhi'.
connection-cityfrom = 'KL'.
connection-cityfrom = '2500'.
insert connection to  connection_tab .
loop at connection_tab.
write: / connection_tab-cityfrom, connection_tab-cityto, connection_tab-distid, connection_tab-distance.
endloop.

Hi,
sorry that's by mistake.. but  i m getting runtime error if i insert record into sorted table
DATA: BEGIN OF connection,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
distid TYPE spfli-distid,
distance TYPE spfli-distance,
END OF connection.
DATA connection_tab LIKE sorted TABLE OF connection
WITH  unique KEY cityfrom
with header line.
SELECT cityfrom cityto distid distance
FROM spfli
INTO connection.
INSERT connection INTO connection_tab.
ENDSELECT.
loop at connection_tab.
write: / connection_tab-cityfrom, connection_tab-cityto, connection_tab-distid, connection_tab-distance.
endloop.
connection-cityfrom = 'Bangalore'.
connection-cityto = 'Delhi'.
connection-distid = 'KL'.
connection-distance = '2500'.
insert connection into table connection_tab .
loop at connection_tab.
write: / connection_tab-cityfrom, connection_tab-cityto, connection_tab-distid, connection_tab-distance.
endloop.

Similar Messages

  • How to insert records into the Table?

    Dear Sir,
    I'm new to JDeveloper. Now I managed to create a Frame in JDeveloper with many Text fields and a button. In the back end, I have a procedure to insert records to a table, to which I pass the values of the fields as parameters. Now I'm not getting the steps to call the PL/SQL Stored procedure when I click on the button. I'm using Oracle 9i JDeveloper version 9.0.3.1. and Oracle 9i Database.
    Please give me the complete steps to achieve my task - it is quite urgent.
    Thanking You in advance.
    Regards,
    Senthil .A. Perumal.

    The JDBC tutorial will show you how to call a stored procedure from Java:
    http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm
    One more thing, why are you using such an old version of JDeveloper? any reason not to upgrade to the 10.1.3 version of JDeveloper?
    Also you might want to look into ADF and how it makes these type of database interactions easier.
    See this demo:
    http://www.oracle.com/technology/obe/obe1013jdev/adf_swing/master_detail_page_adfswing_bc.htm

  • How to insert record in child table with foreign key

    Hi,
    I am using Jdeveloper 11.1.2.0. I have two master table one child table.
    How to insert and update a record in child table with foreign key ?
    I have created VO based on three EO(one eo is updatable other two eo are references) by using joined query.
    Thanks in Advance
    Edited by: 890233 on Dec 24, 2011 10:40 PM

    ... And here is the example to insert using sequenceimpl by getting the primary key of the master record and insert master and detail together.
    Re: Unable to insert a new row with a sequence generated column id
    -Arun

  • How to Insert records in Nested Table

    Hello Friends,
    I have doubt in below Nested table.
    I have inserted the value in emp table
    EMP TABLE
    EMPNO ENAME PROJECTS
    1 A DATASET
    2 B DATASET
    but not in project_type object. Now I want to insert the record in project_type for name and role field. Please resolve my problem.
    SQL> create type project_type as object
    2 (
    3 name varchar2(50),
    4 role varchar2(20)
    5 )
    6 /
    Type created.
    SQL>
    SQL> create type ProjectTable as Table of Project_type
    2 /
    Type created.
    SQL>
    SQL> create table emp
    2 ( empno number(5),
    3 ename varchar2(30),
    4 projects projecttable
    5 )
    6 nested table projects store as projects_nt
    7 /
    Table created.
    Thanks...

    Ok if you have inserted a row in the emp table and now you want to update the projects column which is null then you would do something like:
    update emp
    set projects = projecttable(project_type('..', '..'))
    where empno = ...However say that the projects column is not null and you want to add a new record into the nested table then you would do:
    insert into (select projects from emp where empno = ...)
    values ('...', '...')And finally imagine you have a record in the nested table that you want to update then you would do the following:
    update (select projects from emp where empno = ...)
    set role = '...'
    where name = '...'

  • Please Help me in inserting record in a table

    Hi,
    Kindly help me on how to insert records in a table that the values are from the another table.
    for example :
    i have table1, all of the records in column1 of table1 will be inserted to table2 column2 . .
    I already tested it to a visual foxpro programming language and it's ok, i used this command :
    *"INSERT INTO table1 (column1) SELECT column2 FROM table2"*
    but when I try it to a JAVA Program, there's an error.
    Please help me.. Thank You.

    Sir, this is what you mean?
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1585)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1500)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1485)
    at remittance.utility.security.frmRole.addtoPermission(frmRole.java:197)
    at remittance.utility.security.frmRole.btnADDActionPerformed(frmRole.java:177)
    at remittance.utility.security.frmRole.access$200(frmRole.java:22)
    at remittance.utility.security.frmRole$3.actionPerformed(frmRole.java:92)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:5517)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
    at java.awt.Component.processEvent(Component.java:5282)
    at java.awt.Container.processEvent(Container.java:1966)
    at java.awt.Component.dispatchEventImpl(Component.java:3984)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3819)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.java:2010)
    at java.awt.Window.dispatchEventImpl(Window.java:1791)
    at java.awt.Component.dispatchEvent(Component.java:3819)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

  • How to insert records in user defined tables through DI Server API

    Hi All,
    I have created a UDO using some userdefined tables .I am able to insert records in the user defined tables using DI API but problem is that now I want to insert records in those tables using DI Server API but I dont know how to do that please give me some way to do that
    Thanks and Regards
    Utpal

    The AddObject message is :
    <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
      <env:Header>
        <SessionID>...</SessionID>
      </env:Header>
      <env:Body>
        <dis:AddObject xmlns:dis="http://www.sap.com/SBO/DIS">
          <BOM>
            <BO>
              <AdmInfo>
                <Object>...</Object>
              </AdmInfo>
            </BO>
          </BOM>
        </dis:AddObject>
      </env:Body>
    </env:Envelope>
    How to use it with a user defined table ?

  • How to find last inserted record in the table.

    Version: Oracle 10g
    I have a table called "Manufacture" and 3 columns as mfno,itemname,quantity.
    How to find last inserted record in the table "Manufacture".
    As i come to know that Rowid is not result perfect results. Please provide your inputs.

    user13416294 wrote:
    Version: Oracle 10gThat is not a version. That is a product name. A version is 10.1.0.2 or 10.2.0.4, etc.
    I have a table called "Manufacture" and 3 columns as mfno,itemname,quantity.
    How to find last inserted record in the table "Manufacture".Not possible as your data model does not cater for it. That simple.
    If there is a need to determine some order or associate some time to an entity, then that should be part of the data model - and a relationship, or one or more attributes are needed to represent that information. Thus your data model in this case is unable to meet your requirements.
    If the requirements are valid, fix the data model. In other words - your question has nothing to do with Oracle and nothing to do with rowid, rowscn or other pseudo columns in Oracle. It is a pure data modeling issue. Nothing more.

  • How to insert records dynamically in a table at run time

    hi, all
      please help me out,
      my problum is how can i insert records from on table to another table at  run time dynamically. Initally the records are coming  from R/3 backend.
    regards

    Hi,
    One way is to first create a Value node (NewNode) with structure binding of that of the model node. Then iterate through the model node, create NewNode elements and set the value from model node elements into it.
    IPrivate<view>.I<model node> mele;
    IPrivate<view>.I<NewNode> nele;
    for(int=0;i<wdContext.node<output>().node<record>().size();i++)
    mele = wdContext.node<output>().node<record>().get<record>ElementAt(i);
    nele = wdContext.node<NewNode>().create<NewNode>Element();
    wdContext.node<NewNode>().addElement(nele);
    nele.set<attr>(mele.get<attr>());
    Second way is to create that NewNode inside the model node and create a supply function.
    Regards,
    Piyush.

  • Inserting records into a table with all caps

    Hello
    I have a procedure that inserts records into a table. How do I ensure that the text values inserted are recorded all capital letters into the table?
    Thanks.

    You can use UPPER(..) function in your insert statement, so that values are converted to UPPER, before insert.
    If you want to check at table level, you can achieve that by writting a before insert trigger and in that trigger check
    IF UPPER(:new.<col>) != :new.<col> THEN
    RAISE_APPLICATION_ERROR(-20101,'Error: Not all values are in upper case')
    END IF;

  • Using Crystal 2008 to insert records into a table

    Hi,
    We have a unique need to use Crystal to insert records into a table. We have managed to test a report that can write into a temporary table.  This is done by using sql command object  and uses  the following code :
    INSERT INTO TEMP_TABLE  (ORDERID)
    VALUES ({?orderid})   (-- where orderid a parameter).
    This test report asks for an order id and then inserts the record perfectly fine.
    Now moving on to the real report - This report basically prints orders in batches and we want to insert order id into a temporary table to ensure we don't print orders that were already printed. To do this we created a sub report "insert orders" that has the above insert command. The main report passes the orderid to subreport and the idea is that the subreport would insert each time an order is passed. So if main report printed 50 orders ids, the then it would do 50 inserts individually into the temp table. 
    This however is NOT working. The report runs fine but there is no insert.  Our hunch is that  Crystal is not committing after every order id is passed from the main report.  Not sure if we can set the AUTO COMMIT ON  as a default somewhere?
    Wondering if any one has attempted this or has any insights?
    Regards,
    Mohit.
    Environment is - Crystal 2008 and Oracle 11GR2, we are using Oracle drivers (and not odbc)

    Hmmm... I don't use Oracle but the syntax looks good...
    You've already tested it and I assume that you are using the same driver in the production report as you used in the test, so that shouldn't be an issue...
    how are you pulling the data? Is the final SELECT statement that pulls the report data in the same command as the INSERT script, or is the INSERT script in it's own command?
    The reason I ask... If you are trying to pass a multi-valued parameter to a command, it won't work. If you have the insert command as it's own command while the data is being pulled with linked tables or a separate command, it is possible that the report itself will execute as expected w/o passing a value to the insert script.
    If it's all in 1 command (as it should be), a bad parameter would fail in the final SELECT causing an error.
    Also... are rows null or empty string values being added to table when the report executes? This would be an indication that the command is being executed but isn't getting the parameter value.
    Jason

  • How to insert records into an Excel file

    i was wondering if anyone knows how to insert records from a pl/sql block straight into an excel file

    try with spool or UTL_FILE...
    Re: CSV into Oracle and Oracle into CSV
    SQL> spool c:\test1.csv
    SQL> select substr(str,2,length(str)-3) from (select regexp_replace(column_value,'\s*<[^>]*>[^>]*>',',') str from table(xmlsequence(cursor(select * from test_emp))));
    SUBSTR(STR,2,LENGTH(STR)-3)
    9999,fredi&apos;s,CLERK,2345,10-OCT-06,1250,123,20
    4567,STEWART,ANALYST,3456,02-APR-07,3200,215,30
    2345,Cockrel,CLERK,7566,23-JAN-82,800,30
    3 rows selected.
    SQL> spool off;

  • Find the latest updated or the latest inserted record  in a table

    Hi All,
    Thanks in advance
    Just a simple question
    How do we find the latest updated or the latest inserted record in a table ?
    Provide some queries in SQL?

    You can order by rowid desc to get lately inserted records, but I'm not sure about updated records.That is incorrect, Oracle might use old rowid's even in inserts and you cannot assure that the max(rowid) refers to the latest record.
    If the table is created with rowdependencies one can use ORA_ROWSCN pseudo column to check on date/time when the last dml has been performed over that table. But, that has some limitations too, Old snapshots will be erased hence one can check the last dml with a time frame of few days.
    Regards,
    Prazy

  • Retrive last inserted  record  from database table

    Hi,
    some body inserting a record into table 'A' through some procedure/java program.i want to retrive the last inserted record from database table.records are not stored in order.Can any body help me.

    In general, unless you are storing a timestamp as part of the row or you have some sort of auditing in place, Oracle has no idea what the "first" or "last" record in a table is. Nor does it track when a row was inserted.
    - If you have the archived logs from the point in time when the row was inserted, you could use LogMiner to find the timestamp
    - If the insert happened recently (i.e. within hours), you may be able to use flashback query to get the value
    - If you're on 10g or later and the table was built with ROWDEPENDENCIES and the insert happened in the last few days and you can deal with a granularity of a few seconds and you don't need 100% accuracy, you could get the ORA_ROWSCN of the row and convert that to a timestamp.
    If this is something you contemplate needing, you need to store the data in the row or set up some sort of auditing.
    Justin

  • How to make records  to the table TRFCQIN

    hi all,
    anyone can tell me
    how to make records  to the table TRFCQIN
    regards

    Hi Wanna,
                    Write a module pool program to enter record into table TRFCQIN.
    Take fields to which u want to make entries in module pool.
    Use insert command to append data in table TRFCQIN.
    Refer this code :
    CASE OK_CODE_101.
    WHEN 'SAV1'.
    TRFCQIN-QNAME = 'XYZ'.
    TRFCQIN-QCOUNT = "Screen field name at which user will enter value
    INSERT TRFCQIN.
    if sy-subrc <> 0.
    message e007.
    else.
    clear TRFCQIN.
    clear ok_code_101.
    endif.
    endcase.
    Reward points if helpful.
    Regards,
    Heamnt

  • Reg : first inserted record in a table

    Hello all,
    Could any of you help me in writing a query to get the first
    inserted record into a table.
    Suppose I've the following table :
    my_table : structure
    Name Null? Type
    ID NOT NULL NUMBER
    Ive inserted value 20 into the table first, and then inserted
    value 10. I want to retrieve the first inserted record with
    value 20. How do I write the query for that ??????
    Awaiting for the reply,
    Thanks in Advance...
    Srini

    One small disagreement with Andrew's posting, but
    rownum is assigned to rows after they have been identified
    as part of the result set, but before the ORDER BY is
    applied. Hence the two queries ...
    select * from my_table
    where rownum = 1
    order by id ASC
    ... and ...
    select * from my_table
    where rownum = 1
    order by id DESC
    ... will probably return the same result.
    However in neither case is the result guaranteed to be the
    first inserted row.
    If you had created a table very recently, and it had only a
    single extent, you could get the first row of the first block of
    that extent with ...
    select * from my_table where rowid =
    (select min(rowid) from my_table)
    ... but as Andrew says, the only way to do the job properly is
    to timestamp the rows as they are inserted. Anything else
    would only be of theoretical interest.

Maybe you are looking for

  • Applications that sync with the Curve?

    Are there any other applications available ( free or not ) to sync the memo pad, tasks and calendar OTHER THAN Microsoft Outlook? When I tried to configure and synchronize my BB 8330 Curve so i can transfer stuff from my computer onto my memo pad or

  • Speakers for Mac Pro?????

    Ok, I'm waiting on my new Mac Pro to arrive (Tuesday...) In the mean time I've been taking a quick inventory of what I'll be able to move over from my other older systems. In the process, I looked at my current Logitech THX 5.1 speaker setup and was

  • Deleting emails with in a specific date range

    Is there a way to delete a specific date range of email using 10.9.3 or Gmail. Thanks

  • Copy/export a drill down report created by CXR0 in PRD

    Hi Gurus, I am trying to copy/export a drill down report created by CXR0 in PRD ( can not move transport from PRD to QAC, transport doesnot allow ) to QAC and DEV,  is there any other way to export / import , download /upload option to transfer repor

  • AS2 , Hermes2 SOAP ERROR ???

    Hi to all expert . iam new to java as well we AS2 . i have installed Hermes2 on my Fedora system with java JDK 1.5.06 i know its old but its the most recommended version , i have installed as well JCE since this program depends on it. i keep facing a