Have unique records in the table

Hello

I have this code I'm trying to make sure my table (MESSAGES) has no PASSPORTNO double and CUSTOMER_ID. Here is my code:
DECLARE

CURSOR C6 IS
SELECT PASSPORTNO,CUSTOMER_ID,AMOUNT   FROM MESSAGES; 

BEGIN
for c2_rec2 in C2(i.passportno) loop
   DBMS_OUTPUT.PUT_LINE(i.passportno||' '||i.customer_id||' '||c3_rec.AMOUNT);
   for c4_rec  in C4(i.passportno) loop
   FOR C5_REC IN C5(C4_REC.CUSTOMER_ID) LOOP

 IF (C6%FOUND) then
if C6.PASSPORTNO (NOT EQUALS symbol)  i.passportno and C6.CUSTOMER_ID (NOT EQUALS symbol) i.customer_id  then

 INSERT INTO MESSAGES (PASSPORTNO,CUSTOMER_ID,AMOUNT) VALUES (I.PASSPORTNO,C4_REC.CUSTOMER_ID,C5_REC.AMOUNT);

else

DBMS_OUTPUT.PUT_LINE('DUPLICATE VALUES IN MESSAGES TABLE');

END IF;
END IF;
I got and error:

PLS-00225: subprogram or cursor "C6" reference is out of reach


How am I suppose to change my code?
hi lee,

if you are using cursor for loop, you dont need %found,

further more you dont open cursor c6, you can only find cursor c6 when you open it 

also in dont understand what you trying to do here,

if C6.PASSPORTNO  i.passportno and C6.CUSTOMER_IDi.customer_id  theninsert ,

as per my understanding code should look like this,

c2, c5 and c6 should be parameterized cursor 

for c2_rec2 in C2(i.passportno) loop   DBMS_OUTPUT.PUT_LINE(i.passportno||' '||i.customer_id||' '||c3_rec.AMOUNT);   for c4_rec  in C4(i.passportno) loop   FOR C5_REC IN C5(C4_REC.CUSTOMER_ID) LOOP

       for c6_rec in c6 (your parameter)  loop

    INSERT INTO MESSAGES (PASSPORTNO,CUSTOMER_ID,AMOUNT) VALUES   (I.PASSPORTNO,C4_REC.CUSTOMER_ID,C5_REC.AMOUNT);end loop for c6; 

Tags: Database

Similar Questions

  • Not able to read the values in group by, when no records in the table

    Hi all, I have this query

    Select p.header_id,

    Type "some_constant."

    sum (nvl (p.total_amount, 0)) sum_of

    from table_name p

    P.header_id group

    When there is record in the table, it works fine, but I want to if there is no any folder that it returns as below,

    header_id type sum_of

    some_constant 0 0

    How to...?

    Help, please.

    Kind regards

    SELECT * FROM (select p.header_id,

    Type "some_constant."

    sum (nvl (p.total_amount, 0)) sum_of

    from table_name p

    P.header_id group

    UNION ALL

    SELECT 0,

    BOX WHEN (SELECT COUNT (*) FROM table_name) = 0 THEN type of 'some_constant',

    ANOTHER NULL

    END type as,

    0

    THE DOUBLE)

    WHERE type IS NOT NULL;

    Post edited by: 000000

  • How to find inserted last record in the table.

    Version: Oracle 10g

    I have a table called 'Manufacturing' and 3 columns as mfno, itemname, quantity.
    How to find inserted last record in the table 'manufacturing '.

    As I got to know that the Rowid is not a result perfect result. Please provide your inputs.

    user13416294 wrote:
    Version: Oracle 10g

    This is not a version. It's a product name. A version is 10.1.0.2 or 10.2.0.4, etc.

    I have a table called 'Manufacturing' and 3 columns as mfno, itemname, quantity.
    How to find inserted last record in the table 'manufacturing '.

    Not possible as your data model do not answer for him. As simple as that.

    If there is a need to determine an order or associate some time to an entity, then that should be part of the data model - and a relationship, or one or several attributes are necessary to represent this information. Your data model in this case is therefore unable to meet your requirements.

    If the requirements are valid, set the data model. In other words - your question has nothing to do with Oracle and nothing to do with the other pseudo columns in Oracle, the rowscn or the rowid. It is a question of pure data modeling. Nothing more.

  • How to insert huge records in the table for the practice.

    Hello

    I created a new database in my personal inbox. Now, I want some specimen for different practical feature of oracle 10g. I need at least 1,00,000 records with different lines and columns.
    any buddy tell me of any request or package that can create the table and insert unique records in this table.

    Looking for valuable advice.

    Thank you

    Can be dbms_random.string, dbms_random.value and dbms_random.random can help.

  • Add new records to the table of the ADF

    Hello

    I use Jdev 11.1.1.3.0.
    I have a Page of the ADF with detail Table of form - master, I want to add new records to the table reflecting in DB. Is it possible to do? pointers or demo?


    Thank you
    MB

    What are the components are used in your table? When you created the table originally, you specified as a table read-only? If your table contains components of af: outputText, then you will need either manually change components entry way, or remove the table and re-drop-the-in the form of table (not read-only)

    John

  • Form check synchronize on Popup to the selected record from the table

    I'm trying to recreate what I did on the portals of the OAS in Weblogic/ADF. I have JDeveloper 11.1.1.2.0. What I do seems to be a little different than the tutorials: I need something like the tutorial master-detail, but instead the details appearing on the same page, it should appear in a popup. I managed to build the part table/popup. But when the popup appears, it displays the wrong record. Here are the steps I used to create this page:

    After you create the ADF Fusion Middleware project:

    1 create templates for the tables I need.
    2. create the JSF Page.
    3 drop panelCollection on the page.
    4. remove my data to see in panelCollection control and choose the Table read-only ADF. Select the sorting and selection options.
    5 change table properties: selected = DisplayRow, EditingMode = clickToEdit
    6 drag the Popup on the page.
    7. remove my data from view in popup control and choose the form of the ADF. Select the send option.
    8 drop showPopupBehavior on the page. Name of the popup. The value triggerType to the 'selection '. (triggerType "click" works, too)
    9 deploy.

    The table is displayed. I click on a line. The pop-up window appears. The form of popup displays the first record in the table. I click on any line.

    I just bought the merger Oracle 11g Developer Guide, but were not able to answer this question yet.

    Any ideas?

    Thank you.

    See this video for how it works for me:
    http://www.ScreenToaster.com/watch/stWUtcRkVLQ1BcSV1aX15Q

  • How can I recover only odd or even number of records in the table?

    Hello

    How can I recover only odd or even number of records in the table?

    Thank you

    Hi IndiMinds,

    Alternatively, you can use in queries. :

    Odd:

    SELECT *.

    Of

    (SELECT rownum row_count, id, name FROM bigemp

    )

    WHERE mod (row_count, 2) = 1;

    Still:

    SELECT *.

    Of

    (SELECT rownum row_count, id, name FROM bigemp

    )

    WHERE mod (row_count, 2) = 0;

    Thank you

  • Total number of records in the table read

    Here is the procedure to read total no of record in the table specified by the user during execution. But it still gives the same answer for all the table. Can someone help me?

    create or replace procedure p3 (varchar2, not on the number tab)
    as
    Start
    Select count (*) from no tab;
    end;

    You need dynamic SQL statements.

    Or:
    http://laurentschneider.com/wordpress/2007/04/how-do-i-store-the-counts-of-all-tables.html
    To get the name of the Table and no lines
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:1725645184471282:P11_QUESTION_ID:1660875645686

    Or simply use the data dictionary, collect statistics of the table, then:
    Select table_name, num_rows from user_tables;

  • text have not correction under the table (IE6?)

    Here is a link to a page in safari that I work well, which seems to work in FF and Safari.

    http://myjobmarket.ca/joblistemp.php?emp_id=1

    In IE6 (haven't checked the newer versions yet) displays the meter to record under the table of results ('record 1 to 2 of 2") to the right of the table, wedged against the sidebar.  Everyone sees why? Is this a CSS problem?

    Thanks in advance,

    Greg

    Remove align = "left" of the nested table.

  • Create record in the Table of results gives error

    Hi all

    Update page there is a table of results with the Add button to create a new line.

    Everything by creating a new record on the table of results gives an error

    The attributes defined for AccessId in the view object xxlcupdvariablesvo1 failed

    I checked the EO and VO attributes, everything seems to be good.
    Updatable also has the value "Always".


    Still don't know why this error is coming.

    Please help resolve this error.


    Thank you
    SK

    SK

    Don't forget that your AO made correctly and you do your from VO of the two OS after this AO. If possible, allow Jdev to create your AO. Try to create is not in manuallly

    Hope it solves your problem

    Thank you
    AJ

  • Validate values inserted into a table against an another record in the table.

    Hi, I have this two tables on my Oracle Database 10g:
            Status                                    
    
    Id_Status | Description        
    --------------------------------       
      102     |   Ok                 
      123     |   Damaged 
      345     |   Broken
    
    Cars
    
    Car_ID|  wheel  |  hood  |  bumper  |  radiator
    -------------------------------------------------
      1   |   1     |     2  |     2    |   3
    and what I have to do is to make sure that you can only insert a record if the [wheel, hood, bumper, radiator etc...] values are values that already exist in the State of the table, but I do not know if you add FK as:
    ALTER TABLE "RCVRY"."COMPANY" 
        ADD (CONSTRAINT "CITY_ID" FOREIGN KEY("STATE") 
        REFERENCES "RCVRY"."CITIES"("STATE")
    is the right way to do it.

    If anyone can help by providing code samples or pointing to the right place in the documentation to look out it will be greatly appreciated.
    Concerning

    JMHP

    Hello

    José M. Hurtado says:
    Hi, I have this two tables on my Oracle Database 10g:

    Status                                    
    
    Id_Status | Description
    --------------------------------
    102     |   Ok
    123     |   Damaged
    345     |   Broken
    
    Cars
    
    Car_ID|  wheel  |  hood  |  bumper  |  radiator
    -------------------------------------------------
    1   |   1     |     2  |     2    |   3
    

    and what I have to do is to make sure that you can only insert a record if the [wheel, hood, bumper, radiator etc...] values are values that already exist in the State of the table, but I do not know if you add FK as:

    ALTER TABLE "RCVRY"."COMPANY"
    ADD (CONSTRAINT "CITY_ID" FOREIGN KEY("STATE")
    REFERENCES "RCVRY"."CITIES"("STATE")
    

    is the right way to do it.

    Yes, foreign keys are the right way to do it.
    Make sure that first of all, there is a constraint of PRIMARY KEY (or UNIQUE) on status.id_status.

    If anyone can help by providing code samples or pointing to the right place in the documentation to look out it will be greatly appreciated.

    The code you have posted has an imbalance ' (' between ADD and CONSTRAINT.) Lose that ' (' and you have the right syntax.)
    Double quotes are necessary only if you use non-standard names. Do not.
    The schema name (RCVRY in the above example) is optional.

    So, you could say:

    ALTER TABLE     cars
    ADD CONSTRAINT     cars_wheel_fk
    FOREIGN KEY     (wheel)
    REFERENCES     status (id_status)
    ;
    

    I hope that answers your question.
    If this is not the case, after a test script.
    Publish instructions CREATE TABLE for tables and ALTER TABLE instructions for constraints (if they are not part of the CREATE TABLE statements).
    Let's just do the constraint on wheel first. Once you know how to do this, add similar constraints for the other columns (radiator, hood, bumper,) will be easy.
    After a series of INSERT statements (and update, if you want) for the two tables, which must be executed in order.
    Say if you want as each INSERT (or UPDATE) statement of work or not. (Include a few of them).

    Published by: Frank Kulash, December 7, 2010 19:15

  • Purge of the records of the Table and the size of the data file

    11.2.0.4/Oracle Linux 6.4

    We want to reduce the size of the DB (file size of data), so that our RMAN backup size will be reduced. So, let's create stored procedures that will purge old data in huge tables.

    After you remove records, we will decrease the tables using the:

    change the movement line of table ITEM_MASTER enable;

    change the waterfall table retractable ITEM_MASTER space;

    ALTER table ITEM_MASTER deallocate unused;

    The commands above will reduce the file size of data (see dba_Data_files.bytes) or it will reduce the size of the segment?

    Only the segment formats will be reduced.  Oracle has never reduced the sizes of data file automatically.  You would have to reduce them.  You may not be able to reduce the size of data file if there are extensions to the 'end' (highwatermark) data files.  In this case, you will need to create a new tablespace and move all the objects for the new tablespace OR export, drop, create tablespace and import.

    Hemant K Collette

  • Update the records in the table

    I have an INCOME_LOT table. Now, I need to update records with the current max (lot_id) + rownum where lot_id = 0.
    Note: There are multiple records with lot_id = 0.

    CREATE TABLE INCOME_LOT
    (
    LOT_ID NUMBER OF NON-NULL,
    NUMBER OF DETAIL_ID
    DATE OF EFFECTIVE_DATE,
    DATE OF UPDATE_DATE
    )
    It is only a sample data of 4 records, while in fact, I have millions of records to be updated.

    Insert into INCOME_LOT
    (LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
    Values
    (0, 5773490, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
    Insert into INCOME_LOT
    (LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
    Values
    (0, 5773491, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
    Insert into INCOME_LOT
    (LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
    Values
    (0, 5773492, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
    Insert into INCOME_LOT
    (LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
    Values
    (0, 5773493, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:41 ',' DD/MM/YYYY HH24:MI:SS'));))
    COMMIT;

    Can someone help me to update all records with a single SQL query or maybe a PL/SQL block? I could design a cursor to update, but it would be tedious to use.

    Do you want this:

    UPDATE INCOME_LOT

    Set lot_id = 262696 + ROWNUM

    WHERE lot_id = 0;

  • by comparing the number of records in the table child

    I have 3 tables below:

    Table 1 - Parent Table
    Table table2 child - who has the number of records for each record in Table1 (row_id in Table1 corresponds to par_row_id in Table2)
    Child table table 3 - has that number of records for each record in Table1 (row_id in Table1 corresponds to par_row_id in table 3)

    I would like to run an Oracle SQL query to identify all the separate row_id on Table1, for which the number of child records in Table2 does not match the number of child records in Table3

    I ask for help to identify the best way to identify these records in the parent table. If possible an example too, please.

    Thank you

    Published by: cseshan on February 3, 2013 01:35

    All by adding the simplest example (with the sample data that you were supposed to provide) below

    create table table1(row_id number primary key);
    
    create table table2(par_row_id number references table1);
    
    create table table3(par_row_id number references table1);
    
    insert into table1 values(1);
    insert into table2 values(1);
    insert into table3 values(1);
    
    insert into table1 values(2);
    insert into table2 values(2);
    insert into table2 values(2);
    
    insert into table1 values(3);
    insert into table3 values(3);
    insert into table3 values(3);
    
    insert into table1 values(4);
    insert into table2 values(4);
    insert into table2 values(4);
    insert into table2 values(4);
    insert into table3 values(4);
    insert into table3 values(4);
    
    commit;
    
    with child1_cnt as
    (
      select par_row_id,count(*) cnt
      from table2
      group by par_row_id
    ),
    child2_cnt as
    (
      select par_row_id,count(*) cnt
      from table3
      group by par_row_id
    ),
    all_counts as
    (
      select p.row_id,nvl(c1.cnt,0) c1_cnt,nvl(c2.cnt,0) c2_cnt
      from table1 p
       left outer join child1_cnt c1
         on ( p.row_id = c1.par_row_id )
       left outer join child2_cnt c2
         on ( p.row_id = c2.par_row_id )
    )
    select row_id,c1_cnt,c2_cnt
    from all_counts
    where c1_cnt != c2_cnt;
    
    ROW_ID C1_CNT C2_CNT
    ------ ------ ------
         2      2      0
         4      3      2
         3      0      2 
    
  • Get the value of the record in the table and set the Disabled property...

    Hello! I have the table in my JSPX page. I search for records and that you press one of the files with a right click, see: http://my.jetscreenshot.com/2677/20120203-fas1-30kb
    I put property disabled like that of my commandMenuItem:
    #{row.GenResGrupa != 'true'}
    But as you can see in my photo above, the disabled property do not work. Where I am wrong with my code:
     <af:commandMenuItem text="#{sampleBundle.pases}"
                                                  id="commandMenuItem1"
                                                  action="adfMenu_pasesDati"
                                                  actionListener="#{bindings.setCurrentRowWithKeyValue.execute}"
                                                  disabled="#{row.GenResGrupa != 'true'}"/> 
    Please correct me! If you need further information, please let me know.

    Best regards, Debuger!

    Dear Debuger,

    Add in your pageDef:





    And in your jspx:
    Disabled = ' #{bindings. " GenResGrupa.inputValue! = 'true'} '.

    NOTE: no disabled = "#{row.bindings.GenResGrupa.inputValue! = 'true'} '"

Maybe you are looking for

  • Cannot access router Readyshare

    This topic was preciously posted, but I have still not found no answer. Here's my situation: -Netgear model router with USB inserted Readyshare C3000. -Windows 7 access Readyshare desktop computer -10 Windows laptop already accessed Readyshare. All o

  • HP f4480: no ink on paper

    Hi, I had a HP f4480 printer all-in-one my father bought home and downloaded the drivers etc, but it won't be ink on paper, print test page for the habit and keeps telling me that he used to align. The machine goes through all the motions and for all

  • BlackBerry Z10 z10 partially locked

    I bought a Z10, a little more than a week, and after that I loaded this morning I can open only the Hub, phone, SMS, voice command, browser applications. But mostly I can't open settings, advice, help, etc. When I press the icon, the screen turns as

  • After trying to connect to the internet error message knows unidentified network

    Original title: problem connecting (unidentified network) environment. A few times my labtop is big when it connects with the Ethernet cable say: unidentified networkBut when I connect it to an another labtop its connect to the Internet.I don't know

  • I have can´t Acrobat Reader DC downlond, always appear "413 header length too large", why?

    I have MAC OS, I can´t download Download Adobe Acrobat Reader DC