Comparing two records from different tables error.

Hi folks!
I have this PL/SQL Block.
I want to compare the only one record from both tables to see if the content of them are equal or not, but I don't want to specified column by column to do that.
Any idea?
Thanks a lot in advanced,
Abdel E. Miranda S.
Panama
declare
cursor c_aems_prueba is
select nombre, direccion, telefono, limite, seq
     from aems_prueba;
cursor c_aems_testing is
select nombre, direccion, telefono, limite, seq
     from aems_testing;
vc_aems_prueba c_aems_prueba%rowtype;
vc_aems_testing c_aems_testing%rowtype;
vt_aems_prueba aems_prueba%rowtype;
vt_aems_testing aems_testing%rowtype;
begin
insert into aems_prueba
values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
insert into aems_testing
values('ABDEL MIRANDA', 'PAITILLA', '215-3411', 1000, 1);
commit;
open c_aems_prueba;
fetch c_aems_prueba into vt_aems_prueba;
open c_aems_prueba;
fetch c_aems_prueba into vt_aems_testing;
if vt_aems_prueba = vt_aems_prueba
then
     dbms_output.put_line('son iguales las variables, si funciona la comparacion de dos estructuras');
     else
     dbms_output.put_line('no son iguales las variables, no funciona la comparacion de dos estructuras');
end if;
close c_aems_prueba;
close c_aems_testing;
end;

Satyaki De,
Java is involving because an Outsourcing new project. The outsourcing company is developing the new application using JSF which invoke an interface java method [depending of the operation: select, update, insert] and them invoke the PLSQL API to precess tha operation.
In the case I already wrote here, the issue is this:
The user search for a specific data using the interface. The java method send a request for these operation through the API. the PLSQL process the request and return a beam, with all the column the user look for.
The user see the information in the application windows. Assuming the user wants to change some data, he modify just one field [lets say telephone number] and press the update button. The application process the request using a different method, which invoke a different function within the PLSQL API.
Once the information is returning to the API, I must know if at least one field change its value. So I was thinking to get the beam with the data before it was changed and compare it with the beam with the changing data.
If current_beam = new_beam
then
update
else
no change to process
end if;
Any idea.

Similar Messages

  • Create ViewCriteria comparing two columns from same table

    Does anyone know how I can create a ViewCriteria where clause that compares two columns from the same table?
    For example if I had two integer columns (MINSAL and MAXSAL) and wanted to see if they are equal. I would normally do the following SQL below.
    SELECT * FROM EMPL
    WHERE MINSAL = MAXSAL

    It works, but it is not ideal.
    Setup a Transient column that performs a groovy evaluation of MINSAL=MAXSAL and then my ViewCriteria evaluates the column to true and I set Query Execution Mode to Both.

  • Problem in identifying unique records from different tables

    Hello gurus,
    I am on E-Recruitment module.
    I order to get more fields in CANDIDATE_ATTR datasource I have enhanced it. I am getting additional fields from HRP5103 (Employer, Employment Start Date & Employment End Date) & from HRP5104 (Institute, City, Region). In both of the tables there are 9 primary keys out of which only two are different through which we can identify duplicate records i.e. OBJID (denote Candidate ID in both tables) & SEQNR(Number of Infotype Record with Same Key).
    I know that compounding InfoObjects (since i need to pull duplicate records from table as one candidate can have many institute & employer but they will always be referred by same OBJID) is one of the way but how to manage data through compounding coming from 2 tables.
    Also i donot want to create new objects as it will effect whole of the setup.
    Is there any other way.
    Can anyone give idea as to how to get records in BW.
    Thanks in advance.

    Hi Sundar,
    Thanks for your help. I wen tthrough the two discussions and found the following:
    1. I cannot include the primary/unique keys in the selection as it would make everything distinct. This restricts me from pointing me to the exact record that has changed.
    2. The columns would be dynamic. I want a config kind of solution where i can define the tables, columns on both the sides. And add/remove compare fields in the setup tables.
    Thanks,
    Faruq.

  • INSERT of two records into different tables (pk value from first to second)

    Hi there!
    Have probably stupid question
    Need to insert one record into table with primary key and then insert into other table record with value of primary key field from first record
    How can I do it?
    Thanks a lot!!!

    You have several possibilities. Most easiest one is listed first :)
    SQL> create table a (a number);
    Table created.
    SQL> alter table a add constraint a_pk primary key (a);
    Table altered.
    SQL> create table b (a number);
    Table created.
    SQL> alter table b add constraint  b_a_fk foreign key (a) references a(a);
    Table altered.
    SQL> insert into a values (0);
    1 row created.
    SQL> insert into b values (0);
    1 row created.Though that may not help always, so the next possibility maybe just using sequence with nextval and currval (currval can be used only in the same session and only after you have issued at least one nextval)
    SQL> create sequence a_seq;
    Sequence created.
    SQL>  insert into a values (a_seq.nextval);
    1 row created.
    SQL> insert into b values (a_seq.currval);
    1 row created.And you can use also famous returning clause. It is a bit easier to show that in the pl/sql block than pure SQL.
    SQL> declare
      2   v number;
      3  begin
      4   insert into a values (a_seq.nextval) returning a into v;
      5   insert into b values (v);
      6  end;
      7  /
    PL/SQL procedure successfully completed.And at last contents of the tables :)
    SQL> select * from b;
             A
             0
             1
             2
    SQL> select * from a;
             A
             0
             1
             2Gints Plivna
    http://www.gplivna.eu

  • Question about suming two columns from different tables in Subquery?

    Hello everyone,
    I have a subquery that works great for getting the total SUM of a Billing table, but I also need to add to that SUM the total surcharges or additional charges from a separate table.  I tried this by doing something like so:
    (SELECT SUM(SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No', SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill')) as [Amount],
    But it doesn't work as there is an incorrect syntax near 'FROM'.  I'm assuming this is because of the two FROM's in the Subquery?  But I am not sure how else I would be able to do this then?  
    Any help would be greatly appreciated.  I just noticed this bug and am hoping to get a fix out as quickly as possible.
    Thanks Again,

    Hi, sorry for taking so long to get back to this post. 
    I tried this example like so:
    (SELECT SUM(A1) AS Total1, SUM(A2) AS Total2
    FROM
    (SELECT
    (SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') AS A1,
    (SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') AS A2),
    However, get an error that an Incorrect Syntax exists near the ','.  I remove the comma (Which I think should be there), and I get an error that an Incorrect Syntax exists near the '.'...
    I also tried doing it like this (Based on other suggestions I've found online:
    (SELECT SUM(SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') as [Amount],
    (SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') as [Additional]),
    And I get an error that an Incorrect Syntax exists near 'SELECT'...
    I also tried doing something like this with the SQL I already had...
    (SELECT SUM(Amount) FROM Billing WHERE Billing.JobID = Jobs.ID AND Billing.BillingType = 'Invoice' AND Billing.InvoiceCanceled = 'No') as [BilledAmount],
    (SELECT SUM(Payment) FROM Payments WHERE Payments.JobID = Jobs.ID AND Payments.Type = 'Bill') as [Additional],
    SUM(BilledAmount + Additional) AS [TotalBilled],
    But I get an error that the alias' are Invalid Column Names...  I have used Alias' before so I'm not sure why this would be an issue here...
    As you can see, I've been trying to figure this issue out, but haven't had much luck...  :(

  • Can I do an Insert using two selects from different tables?

    Hi,
    I have three tables, Course (CID, NAME, TIME)
    Teacher (TID, NAME, DESCRIPTION) and OfferedBy(CID, TID) to match a course to a teacher.
    After I do an insert on Course, I want to be able to do an insert on OfferedBy using the CID of the course I inserted, and the TID of the teacher that's offering it.
    I tried this after doing inserts on Course and Teacher:
    INSERT INTO OfferedBy values (SELECT CID FROM Course where courseName = 'name' , SELECT TID FROM Teacher WHERE LastName = 'teacherName').
    I get an ORA 00907 error.
    What am I doing wrong? Can this actually be done?
    Thank you
    I

    Hi,
    How would you relate the TID with CID?
    I tried this after doing inserts on Course and Teacher:
    INSERT INTO OfferedBy values (SELECT CID FROM Course where courseName >= 'name' , SELECT TID FROM Teacher WHERE LastName = 'teacherName').
    I get an ORA 00907 error.You can use the query in this way:
    SQL> SELECT ( ( SELECT dummy FROM DUAL), (SELECT DUMMY FROM DUAL)) FROM DUAL;
    SELECT ( ( SELECT dummy FROM DUAL), (SELECT DUMMY FROM DUAL)) FROM DUAL
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    SQL> SELECT 'AA',(SELECT dummy FROM DUAL) FROM DUAL;
    'A (
    AA X
    SQL>Regards

  • How to compare two fields from different list sharepoint designer?

    hi All,
    I need to add a value to a field using SharePoint designer workflow. The value is from another column.
    for example list A has the field has loginID,  and another list B has loginID  amd another column called Desig.
    i need to compare both and get the Desig field and store it to a column. how do i do that in sharePoint Designer workflow.

    Hi, 
    you can create a workflow variable ex.Test. and add an action set Workflow variable. Then you have to set this variable value using lookUps. something like(in look up window)
    Data source: Choose List B
    Field from source: Choose Desig
    Then under find the list item
    Field: Choose login Id
    Value :(Again open lookup window by clicking "fx") and in this window choose 
        data Source: List A
      field from source :LoginId
    and click ok.
    attached is the image for your reference. (I am using other lists,you can change appropriately )

  • How to get records from different tables

    Here is my Database diagram and my scenario is that When a user enter number of person and amount, amount/person
    let suppose 4/1000=250 and now 250 is , match in Product_Price Field in RstProductDetails, and select only Restaurant where 250 is matched. Next when a
    user select Restaurant e.g KFC and then KFC Products details is show.
    Here is my [WebMethod]
    [WebMethod]
        public DataSet Restaurant(decimal amount, decimal persons)
            //       DataSet result = Amount / personHash;
             //amount.ToString("amount");
            decimal price = amount / persons ;
            DataSet result = null;
            const string SQL_COMMAND_TEXT = "SELECT Product_Name,Product_Price FROM ABCD WHERE Product_Price<= @price";
            using (SqlConnection connection = Class1.GetConnection())
                connection.Open();
                using (SqlCommand command = new SqlCommand(SQL_COMMAND_TEXT, connection))
                    command.Parameters.Add("@Rst_Name", SqlDbType.NVarChar);
                    command.Parameters.Add("@Persons", SqlDbType.NVarChar);
                    command.Parameters.Add("@price", SqlDbType.Int);
                    command.Parameters["@Rst_Name"].Value = amount;
                    command.Parameters["@persons"].Value = persons;
                    command.Parameters["@price"].Value = price;
                    using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command))
                        result = new DataSet();
                        dataAdapter.Fill(result);
            return result;

    <Table diffgr:id="Table8" msdata:rowOrder="7">
    <Product_Name>Orange/Tropical Juice Small</Product_Name>
    <Product_Price>120</Product_Price>
    </Table>
    <Table diffgr:id="Table9" msdata:rowOrder="8">
    <Product_Name>Orange/Tropical Juice Tall</Product_Name>
    <Product_Price>160</Product_Price>
    </Table>
    <Table diffgr:id="Table10" msdata:rowOrder="9">
    <Product_Name/>
    <Product_Price xml:space="preserve"></Product_Price>
    </Table>
    <Table diffgr:id="Table11" msdata:rowOrder="10">
    <Product_Name>Breakfast - Meals</Product_Name>
    <Product_Price>1,300</Product_Price>
    <Table diffgr:id="Table16" msdata:rowOrder="15">
    <Product_Name>3 pcs Hot Cakes + Small Cappuccino</Product_Name>
    <Product_Price>1,370</Product_Price>
    Sir when i debug mt web services it will show random items which is less than or greater than 325

  • Stored pl/sql procedure retrieving similar records from different tables using

    Hi all I'm trying to retrieve the employee num and employee name if they are both a driver and mechanic
    I'm script my own procedure and it compiles with no issue but when i try to execute it. they will show me this error.
    Error starting at line 29 in command:
    EXECUTE VERIFY(1,'John Smith')
    Error report:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "CARSON.VERIFY", line 8
    ORA-06512: at line 1
    01422. 00000 -  "exact fetch returns more than requested number of rows"
    *Cause:    The number specified in exact fetch is less than the rows returned.
    *Action:   Rewrite the query or change number of rows requested
    This is how my procedure look like:
    CREATE OR REPLACE PROCEDURE VERIFY(
    enum IN NUMBER,
    ename IN VARCHAR) IS
    empnum NUMBER;
    empname VARCHAR(50);
    Fail EXCEPTION;
    BEGIN
    select employee.e#, employee.name
    into empnum, empname
    from employee join driver
    on driver.e# = employee.e#
    join mechanic
    on driver.e# = enum;
    EXCEPTION
    WHEN Fail THEN
    dbms_output.put_line('OK');
    END VERIFY;
    and this is how i execute the procedure
    EXECUTE VERIFY(1,'John Smith');
    so may i know what have gone wrong? would be glad if someone is able to enlighten me.

    No need for a loop.
    Just make sure that your query always returns at most one row. Adding a predicate like 'where rownum=1' is a way to achieve that:
    select employee.e#
    ,      employee.name
    into   empnum
    ,      empname
    from   employee join driver on driver.e# = employee.e#
                    join mechanic on driver.e# = enum
    where rownum = 1;

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • SUM two fileds from different rows from the same table

    I would like to SUM two fileds from different rows from the same table but I don't know how to do that.
    E.g.
    BillingTransactionsIndex      CreateDate      UserType      UserIndex      TransType      Reference      Total      Balance
    2      6/5/2008 15:02      1      51      1      150      -288.2      -288.2
    5      6/8/2008 11:55      1      51      1      157      -1.58674      -289.787
    In the table above I want SUM fields Total and Balance for the first row and the the next row SUM 2nd row Total with 1st row Balance
    Please help
    Thanks

    SQL> with tbl as
      2  (select 1 as ID,  90 as total from dual
      3          union all
      4  select 2 as ID,  23 as total  from dual
      5          union all
      6  select 3 as ID,  15 as total  from dual
      7          union all
      8  select 4 as ID,  20 as total  from dual)
      9  select id , total, sum(total) over (order by ID) as balance from tbl
    10  /
            ID      TOTAL    BALANCE
             1         90         90
             2         23        113
             3         15        128
             4         20        148
    SQL>

  • Maximum Open cursor  Exceeded error when deleting records from a table

    I have a strange problem.
    I have a table EMP_MASTER . Whenever I am trying to delete a record from this table, I am getting Maximum no. of open cursor exceeded error. But this error doesnot come when i delete from any other tables. And no. of open cursor is much lesser than OPEN_CURSOR parameter.
    All other tables (around 700) has foreign key constraint to this EMP_MASTER table for created_user paramater.
    Is it some thing like, when I am trying to delete a record from EMP_master, implicit cursor opens up and checks all referenced tables. and that limit gets exceeded ?
    Please help.
    Thanks,
    Raj

    Raji03 wrote:
    There is no trigger defined for this table.
    Is there a limit on which no.of references made to a column ? Because one column in this field, Emp no is being referenced in almost every other table. around 700 tables. Will it have any adverse effect ?That should have nothing to do with your problem directly. Again, those tables could have triggers defined on them and you are leaking cursors in one of those triggers (wild guess).
    An example of a table with many many others foreign key'd to it.
    create table parent_of_everything
       column1 number primary key
    insert into parent_of_everything select level from dual connect by level <= 1000;
    commit;
    --create 1000 tables all with foreign keys to the parent_of_everything
    begin
       for i in 1 .. 1000
       loop
          execute immediate 'create table child_' || i || ' (column1 number, column2 number, constraint child_' || i || '_fk foreign key (column1) references parent_of_everything (column1) on delete cascade)';
          execute immediate 'insert into child_' || i || ' select level, mod(level, ' || i || ') from dual connect by level <= 1000';
          commit;
       end loop;
    end;
    TUBBY_TUBBZ?delete parent_of_everything;
    1000 rows deleted.
    Elapsed: 00:02:53.03No problems were had (none were expected).
    Cleanup script.
    --remove the 1000 child tables
    begin
       for i in 1 .. 1000
       loop
          begin
             execute immediate 'drop table child_' || i || ' purge';
          exception when others
             then
                null;
          end;
       end loop;
    end;
    /

  • To delete duplicate records from internal table

    hi friends,
    i have to delete records from internal table based on following criterion.
    total fields are 7.
    out of which  if 4 fields are same and 5th field is different,then both records must be deleted.
    in case all five fields are same,the program should do nothing.
    for example.
    if there are 3 records as follows
    a1 b1 c1 d1 e1 f g
    a1 b1 c1 d1 e2 w r
    a1 b1 c1 d1 e1 j l
    then first two records should be deleted as four fields are same but fifth(e) field differs.
    but third record should remain as it is evenif first five fields are same for first and third record.
    values of last two fields need not to be consider for deleting the records.

    LOOP AT ITAB.
      V_FILED5 = ITAB-F5. "to compare later
      V_TABIX = SY-TABIX. "used to delete if condition not matches
      READ TABLE ITAB WITH KEY F1 = ITAB-F1
                               F2 = ITAB-F2
                               F3 = ITAB-F3
                               F4 = ITAB-F4.
      IF SY-SUBRC = 0.
        IF ITAB-F5 <> V_FIELD5.
    *--both the records to be deleted,as Field5 is different.
          DELETE ITAB INDEX SY-TABIX. "deletes that record
          DELETE ITAB INDEX V_TABIX. "deletes the current record
        ENDIF.
      ENDIF.
    ENDLOOP.
    Message was edited by: Srikanth Kidambi
    added comments
    Message was edited by: Srikanth Kidambi

  • Incomplete Data on report (report does not show all records from the table)

    Hello,
    I have problem with CR XI, I'm running the same report on the same data with simple select all records from the table (no sorting, no grouping, no filters)
    Sometimes report shows me all records sometimes not. Mostly not all records on the report. When report incomplete sometimes it shows different number of records.
    I'm using CR XI runtime on Windows Server 2003
    Any help appreciated
    Thanks!

    Sorry Alexander. I missed the last line where you clearly say it is runtime.
    A few more questions:
    - Which CR SDK are you using? The Report Designer Component or the CR assemblies for .NET?
    - What is the exact version of CR you are using (from help | about)
    - What CR Service Pack are you on?
    And a troubleshooting suggestion:
    Since this works on some machines, it will be a good idea to compare all the runtime (both CR and non CR) being loaded on a working and non working machines.
    Download the modules utility from here:
    https://smpdl.sap-ag.de/~sapidp/012002523100006252802008E/modules.zip
    and follow the steps as described in this thread:
    https://forums.sdn.sap.com/click.jspa?searchID=18424085&messageID=6186767
    The download also includes instructions on how to use modules.
    Ludek

  • Compare two records within a view

    Hi,
    I wonder if it is possible to compare two or more records within a view, and how to do it.
    Thanks in advance.

    M. Comi wrote:
    I wanted to compare two records of the view and see if they are the same or not...
    My data are as follows:
    Soglia Ingresso_CL_PF     10     10
    Downgrade MDP 3     2102     2101
    I want to check if the "downgrade" records have the same values for the second and the third column, and in this case replace the values on the second record.
    But I did it with a select on the same fields of the original tables, plus two fields obtained with lag function...
    I don't know if it is clear or not, the important is that I got what I wanted.Sorry, it's not clear.
    Are you still having a problem? If so:
    (1) Please describe the problem.
    (2) What results do you want to see from the sample data you posted?
    (3) Is the second column of
    Downgrade MDP 3 2102 2101'Downgrade', 'MDP', 3, 2102, 2101, some combination, or NULL? When posting data, the most helpful thing is to post INSERT (or CREATE TABLE AS ...) statements. The second-best thing is to post formatted data. Type &#123;code&#125; before and after sections where spacing is important, and post column headers.

Maybe you are looking for

  • Itunes points to wrong files - points to random system files instead of mp3

    I noticed this about a year and a half ago when my ipod would have an error that some of the files couldnt be transfrered. Upon further inspection, it seems itunes occasionally gets confused about where files are located. The files will look fine in

  • [SOLVED] Address space collision after kernel 3.0 upgrade

    After upgrading to linux 3.0.1 I get the following error messages from kernel: kernel: [ 0.313527] pci_root PNP0A08:00: address space collision: host bridge window [mem 0x000cc000-0x000cffff] conflicts with Video ROM [mem 0x000c0000-0x000ce9ff] kerne

  • Time stamps on reporting & charts

    Is there a way to get the reports and charts on the WAAS CM to use something other than GMT?

  • Variable declaration.

    Hello there!!  As all you know, we declare on a variable name by using the keyword 'var' followed by the variable name.  My question is simply is there any way to define the variable name based on an input from the user.  Hope someone here has an app

  • Security flaw - Leaking information

    Hello, everyone! I am running the latest version of Skype for iPad on my iPad 4 (yes, I have all the updates), and instead of telling me the person's nickname/username, it tells me their real life, full name; Without permission from the contact himse