Control a record into a table and then perform action

Hello

My requirement is to check the value of a record variable in a table. Run a set of measures if it exists and some other game instruction if it does not exist.

The approach below gives the error:

IF r_emp. Employee_Code NOT IN (SELECT Emp_code FROM v_old_employee) THEN

-some actions

ON THE OTHER

-some actions

END IF;

Guide of nicely with the right approach to achieve this.

Hello

Here's one way:

SELECT COUNT (*)
IN num_found
OF v_old_employee
WHERE emp_code = r_emp.employee_code
AND ROWNUM = 1;

IF num_found > 0
THEN
... - This section is made when the value is already in the table
ON THE OTHER
... - This section is made when the value is not in the table
END IF;

The problem with your original code is that an IN subquery is exactly that: a SUB- query.  It can be used as part of a larger SQL statement only, and not as an autonomous PL/SQL operation

Tags: Database

Similar Questions

  • The tables and then splitting wrapping them (liquid)

    Just a simple question on here, is there away from separate data from the table for a web application? A perfect example would be when you create a check box form field. When the output data, it's just a unique string that looks like this "Ryan, Ashley, Melissa. Would be, I would like to do is to separate the data and then wrap with a < li >.

    I created the JQuery version of what works, but I'd like to see if it is far to do with liquid, as I'm new to the platform.

    
    
    

    {$('.padt20') .find ('ul') .each (function ()}

    var $this = $(this);

    Var words = $this.text () .split (",");

    var text = words.join ("< /li > < li > < class i ="fa fa-review"style =" margin-right: 10px; color: #F26228;) "" > < / i > ");"

    $this.html ("< li >" + "< i class ="fa fa-review"style =" margin-right: 10px; color: #F26228;) "" > < / i > "+ text +"< /li >");"

    });

    <ul>{{ArrayTag}}</ul>
    

    HI Ryan

    If we call to the output string "formdata", then all you have to do is

    {{formdata | divided: ","}}

    to get a table and then just loop through it:

    {% assign array formdata = | split: ',' %}}

    {% for me in table-%}

  • {{ i }}
  • {% endfor %}

    You must create a first variable because it will not work if you try to split in the loop for

    To bookmark this - the Developer Reference

    It provides a pretty good overview of what is available in cash & a lot of other things besides. I use it all the time.

  • Inserting data into a table and insert many records into newtable

    Hi all

    I have table A and table b.
    Suppose that if I insert the data into the table, this table is inserted, the number of records records Count I want to insert in the table B

    I have to write a procedure for this cannot so any help on this.


    Thanks in advance.


    Sikora.

    Hello

    You can use this anonymous block and extend it to create the procedure. You can delete loop or leave it there and use the cursor loop

    DECLARE
       j   NUMBER;
    BEGIN
       FOR i IN 1 .. 100
       LOOP
          INSERT INTO A
          VALUES ('col1', 'col2', 'col3');
    
          j   := j+ sql%ROWCOUNT;
       END LOOP;
    
       INSERT INTO B   VALUES ('table name ', j);
    
       COMMIT;
    EXCEPTION
       WHEN OTHERS
       THEN
          ROLLBACK;
          DBMS_OUTPUT.put_line (SUBSTR (SQLERRM, 1, 200));
          RAISE;
    END;
    

    Published by: OrionNet on January 21, 2009 12:53 AM

  • The most effective way to insert form data into multiple tables and w/autonum

    Hi all, this is my first post here. I am new to APEX and PL/SQL. I have ColdFusion and SQL, and I'm used to perform CRUD operations in my CF Tags application files. From what I've read so far, so if this is accurate, it seems that it is more efficient to perform most of the CRUD operations on the database side, I hope that for advice on the best way to accomplish what I ask - even if I'm trying to do is better off in my new APEX application I am open to this information as well.

    I have a form whose data must reside in two tables. Table A is a one-to-one relationship table and stores General information for each request. Table B is a table of one-to-many observations and should store unique records for each type of comment entered on the form, of which there are 3 comment fields on the form, I'd end up with 3 disks in table B for 1 in table A. I am generating an AutoNumber for table A with a sequence and relaxation. I want to do is take the AutoNumber I just created and use it for insertion in the Table B each insertion I have to do. This is where I am stuck.

    I would like to comment on 1) where I should put all these operations and 2) how best to go about what I want to do coding. In ColdFusion, it is as simple as inserting the record in Table A, immediately asking to table A more recent recording and storing (auto) ID in a variable and then using this var for any other table insertions, I had to do. I know it must be at least a little easier in the Oracle world, I just need a nudge in the right direction. Thank you!

    OraclePledge,

    You're pretty close to not having worked with oracle a lot.

    This section is backwards:

    insert into sch.tbl_main(cust_lname,cust_fname,acct_num)
    values(:P3_CUST_LNAME,:P3_CUST_FNAME,:P3_ACCT_NUM);
    
    select "SCH"."TBL_MAIN_SEQ".currval
          into
          v_ID
          from dual;
    

    Even if it will work if you only have a single user, it's a potential bug with two or more users. First select the key (if it's first use nextval rather than currval) can use it in the insert statement.

    See you soon,.
    Janet Tyson

    Published by: Tyson Janet on June 23, 2011 10:48

  • Inserting record in the database and then display on the next Page

    Hello!

    For a while since I posted here, but I've been pulling my hair out on this one.  Here's what I want to do.  I have a page that I want to be able to enter text in two form fields, then click on "Insert disc", and then on the next page, I just submit display.  For example, on the "insert.php" page I want to enter the field ID and Joe 43569 in the first name field.  Then after I click on submit (or insert record) the next page will have a text that says: "congratulations Joe, your ID is 43569.»  Have a great day! "Or something to that effect.

    I have the database mySQL, set up and insert records into it since this page works correctly.  Here is the code of my insert.php page which I think is the issue.   I'm just confused as to which should be added to the page detail.php to have this sentence appears correctly.  Is there something that should be added to the code on the page insert.php?  Something after the detail.php on that first line?

    Thank you, thank you, thank you in advance.

    Brent

    $insertGoTo = 'detail.php ';
    If (isset {}
    $insertGoTo. = (strpos ($insertGoTo, '?'))? « & » : « ? » ;
    $insertGoTo. = $_SERVER ['QUERY_STRING'];
    }
    header (sprintf ("location: %s", $insertGoTo));
    }
    ? > <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > ""
    " < html xmlns =" http://www.w3.org/1999/xhtml ">
    < head >
    < meta http-equiv = "Content-Type" content = text/html"; Charset = UTF-8 "/ >"
    < title > Untitled Document < /title >
    < / head >

    < body >
    < do action = "<?" PHP echo $editFormAction;? ">" method = "post" name = "form1" id = "form1" >
    < table align = "center" >
    < tr valign = 'of basic">
    < td nowrap = "nowrap" align = "right" > ID: < table >
    < td > < input type = "text" name = "ID" value = "" size = "32" / > < table > "
    < /tr >
    < tr valign = 'of basic">
    < td nowrap = "nowrap" align = "right" > first name: < table >
    < td > < input type = "text" name = "lastName" value = "" size = "32" / > < table > "
    < /tr >
    < tr valign = 'of basic">
    < td nowrap = "nowrap" align = "right" > < table >
    < td > < input type = "submit" value = "Insert file" / > < table >
    < /tr >
    < /table >
    < input type = "hidden" name = "MM_insert" value = "form1" / >

    < / make >

    When you submit the form, the form fields values are passed to the query insert as variables of $_POST, but as soon as you redirect the user to another page, these variables are destroyed.

    There are two ways to preserve the values: use sessions and session variables, or add values to the end of the redirect URL query string. Using the variables of session is probably easier since you can do it at the top of the page that inserts data into the database without affecting the code of Dreamweaver Server behavior.

    Put this at the top of the current page:

    
    

    In details.php, add top of the page. You can then use $_SESSION ['ID'] and $_SESSION ['name'] to display the values.

  • call a function inside a function to insert into a table and receiver error - ORA-14551: cannot perform a DML operation within a query.

    Hi all

    your help is greatly appreciated...

    Calling B.fucntion inside an A.fonctions to insert data into a table.


    Here when you call the B.fucntion to insert data in the table... receiver AM a mistake

    Omitted in B - SQL Error: ORA-14551: cannot perform a DML operation inside a query...


    Can someone please help me to clarify this...


    The FUNCTION A(varUPD_TYPE IN VARCHAR2) RETURN VARCHAR2 IS
    varRETURN_VALUE VARCHAR2 (25): = NULL;

    numALLOWED_COUNT PROD. PROCESS_COUNTER. TYPE % ALLOWED_COUNT;
    numLAST_COUNT_ADDED PROD. PROCESS_COUNTER. TYPE % LAST_COUNT_ADDED;
    dtCHANGE_DATE DATE: = NULL;
    varSTMT VARCHAR2 (2000);
    bln_Allowed BOOLEAN;
    myVar VARCHAR2 (32767).


    BEGIN

    IF varUPD_TYPE = "A" THEN

    BEGIN
    SELECT CH_DATE, LAST_COUNT_ADDED, ALLOWED_COUNT
    IN dtCH_DATE, numLAST_COUNT_ADDED, numALLOWED_COUNT
    PROD. PROCESS_COUNTER
    WHERE NOM_PROCESSUS = "DAILY".
    AND COUNTER_IND = A '

    IF dtCH_DATE < = trunc (sysdate) THEN
    numLAST_COUNT_ADDED: = 0;
    END IF;

    EXCEPTION
    WHILE OTHERS THEN
    numLAST_COUNT_ADDED: = 0;
    numALLOWED_COUNT: = 1;
    END;
    IF numALLOWED_COUNT > = numLAST_COUNT_ADDED + 1 THEN

    bln_Allowed: = True;

    varSTMT: = "UPDATE PROD. TMS_PROCESS_COUNTER ';
    varSTMT: = varSTMT | ' SET last_count_added = ' | (numLAST_COUNT_ADDED + 1);
    varSTMT: = varSTMT | "WHERE nom_processus =" DAILY "';
    varSTMT: = varSTMT | "AND COUNTER_IND ="D"';


    IF varSTMT IS NOT NULL
    THEN
    MyVar: = B(96,varSTMT);
    PROC_LOG (' CALL B ': myVar);
    IF myvar > 0 THEN
    NULL;
    END IF;
    END IF;
    On the other

    End if;

    END IF;

    EXCEPTION WHEN OTHERS THEN
    PROC_LOG ("A failed '");
    PROC_LOG (' SQL error: ' |) SUBSTR (SQLERRM, 1, 1000));
    RETURNS A NULL VALUE.
    PUT AN END TO;

    The FUNCTION B(numTABLE_ID IN NUMBER, varSQL_STATEMENT IN VARCHAR2) RETURNS NUMBER IS
    varINSERT_BATCH_STMT VARCHAR2 (32767): = NULL;
    varADD_REC_TYPE BATCH_TABLES. TYPE % ADD_REC_TYPE;

    BEGIN

    INSERT INTO BATCH_STATEMENT (ID, TABLE_ID, STATEMENT, QUEUE_SEQUENCE_ID)
    VALUES (Numidian, numTABLE_ID, varSQL_STATEMENT, 1);

    EXCEPTION WHEN OTHERS THEN
    PROC_LOG ('B failed');
    PROC_LOG (' SQL error: ' |) SUBSTR (SQLERRM, 1, 1000));
    RETURNS - 1;
    END B;


    Structure of the Batch_statement table:


    ID Number (15) not null
    number (2) not null table_id
    Statement varchar2 (4000) not null
    Queue_sequence_id number (5) not null


    Why do you do such coding mess full of bad practices.

    Remove the exceptions WHEN OTHERS, you're a turing a mistake in this way, they are bugs and (never) use functions to perform DML.

    Functions are not intended for DML. Period.

  • ADF Mobile: Insert a record into a table by WS - DC method

    It's something that is very basic and I could not know.

    There is this method of 'create' base on the service project to insert a single record in a table.

    I created a WS - DC on my mobile project. I see my createItem on the list method. But what I have this XItem.xsd.

    So when I get the ValueExpression binding, I don't know how to set the attribute values...

    ValueExpression ve = AdfmfJavaUtilities.getValueExpression ("#{bindings.xItemView1.inputValue}", Object.class);

    PS: GenericType does not work.

    Your service must expose a method create and then you drag this method to your page and call it with an object as a parameter.
    Should be similar to the way in which an update is done here:
    https://blogs.Oracle.com/Shay/entry/adf_mobile_update_through_web

  • Bigger disk-swapping, but down two, possible to remove them from the table, and then expand?

    I have a R710 with a PERC 6 / i, Win 2008 R2 running. I have a small disk for the operating system, the other 5 bays are filled with 1 TB disks in a RAID array-5.

    I need to add more storage, so I want to buy three discs of 3 TB. I plan on the withdrawal of old readers, and then put it in the new, bigger. I assume that it will take 1 of the 3 TB and repair. Leaving free 2 TB disk. Repeat this step twice more, which will result in three discs of 3TO with 6 TB of disk space not used in the RAID.

    Is it possible to have the controller expand storage in my table of RAID-5 existing free space, and then delete the two remaining 1 TB disks in the array?

    Who is? Is it still possible? Or do I have to backup the data on another storage device and delete the table and simply start a new one with the three discs of 3 TB and copy the data back?

    This will not work:

    (1) the PERC 6 won't take 3 TB drives; the maximum size is 2 TB.

    (2) you cannot delete records in a table - your RAID 5 5x1TB must always have records of 5 or more (you can add without deleting).  Even when using the same number of disks, isn't it possible to do the smaller table/VD.

    (3) even if you used 2 TB disks, there is no way to expand the RAID 5 using the extra space on the disks - with 5 disks in RAID 5, it will remain the same size. The only thing you can do with the new space is to create a second RAID array on the disks (called "slice").  This new VD is handled by the operating system as another "drive."

    Keep in mind if backup and restore in a larger painting, as if the VD ('disc') is greater than 2 TB, the disc "" MUST be converted to GPT and active UEFI bootmode (instead of BIOS).  Make sure that your backup software is capable of restoring one using the BIOS install on a system UEFI (and the 'disc' TPG 'disc' MBR).

  • How to insert records into a table from a button?

    Hey,.

    I use Oracle form and I have a trigger button when button pressed.

    I have a project being given for one of my classes. Basically, I have a Customers table and they hit the news. When they press submit, it must insert it into the table.

    And here is the code I wrote to be inserted inside the button

    declare


    v_cust_id customer_detail.customer_id%type;

    v_f_name customer_detail.fname%type;

    v_l_name customer_detail.lname%type;

    v_destination customer_detail.destination%type;

    v_travel_date customer_detail.travel_date%type;

    v_address customer_detail.address%type;

    v_telephone customer_detail.telephone%type;


    Start

    insert into customer_detail

    values (v_customer_id, v_fname, v_l_name, v_destination, v_travel_date, v_address, v_telephone);

    end;

    /


    But its gives me an error. Is a PLsql Oracle form different syntax?

    Why do you need to insert in the command, when applications oracle has this native features?

    Make a form based on the table and just use

    COMMIT_FORM; on your BUTTON.

    Hope this helps

    Hamid

  • Any way to record Audio narration first and then video then?

    I think it's a better workflow (and ends up being faster than both both audio and recording after). We found another program that will allow us to do (but that has fewer features than Captivate).

    Our work will not spring for the two so we're throwing on the workflow functions (unless someone knows how do - hopefully its really obvious and I were just being dumb).

    I know that in the past, people have used the notes in a PowerPoint slide - just seems weird, you can't do it for other types of video recording and demos.

    Any ideas?

    Scaffolding is a pedagogical concept in education. This is a pretty good explanation (even just the first paragraph): http://edglossary.org/scaffolding/

    Scaffolding of process (and providing limitation or restriction) can be a good way to ensure a higher quality end product. If you use a software like Adobe voice he had built scaffolding process and restrictions. First you choose a structure (who made suggestions on what should cover each slide), and then you save the audio (never longer than ten seconds at a time) and then you adjust your layout and then you choose icons or images or text you sort your music and then you go through and then you export (and adjust export credits and titles). This is a truncated version of the film process that will guide you to make a better product. It's (one of the reasons) for which voice projects come out much more pleasant and the profession you could do on other software. You could do the same thing with PowerPoint, but you would use copious workaround solutions to get your content and PowerPoint does not provide you with this scaffolding as well, even as the most talented producers still fighting produce something better than a typical project of the voice.

    I'm not fussed on the subject all beings in a single product. I use the product adobe for over 15 years now - I can switch between programs that respond to different tasks. The real reason, I can't use both, it's that my work won't pay for two software which have similar results. If Captivate could do screencast-o-matic can do (without the workaround solutions), it would be a simple choice to go with Captivate. It would be even to be in the Captivate program - it could be in a sister program available with package of Captivate. The same way After Effects and first compliment.

    Now, it seems Captivate has more functions, but an integrated of any process which means that we will probably just stick with Screencast-O-Matic.

    What I want to really, it is on Adobe to take the understanding of theories and teaching that they applied to the voice and slate and apply that Captivate (or a program that is packaged in a purchase of Captivate). I think it's weird that they have not yet...

  • Create the custom for more than one table, and then another user authentication scheme

    Hello

    I already test to create an courable authentication scheme. It works very well!

    My problem is that I designed a database on the data requirements. So the results are two different user tables - one record data of the company and the other to consist of data from dealers. Both can register on my web application with e-mail address (Unique).

    The authentication scheme in APEX checks the table right on a data user!

    A possible solution is to call the company with the dealer table table. But in the picture of society isn't some attributes wich find no need in the dealer table and vice versa.
    Further, that it is not possible that the concessionaire may register that they self as a company with the same which e-mail they use for registration as a reseller.

    Can you give me some more ideas how slove/manage this problem...

    I am using APEX 4.0.2 on an Oracle 10 g database.

    NEDO

    Edited by: Mr.Nedo the 12.05.2011 02:16

    >
    The authentication scheme in APEX checks the table right on a data user!

    A possible solution is to call the company with the dealer table table. But in the picture of society isn't some attributes wich find no need in the dealer table and vice versa.
    Further, that it is not possible that the concessionaire may register that they self as a company with the same which e-mail they use for registration as a reseller.
    >

    Create a view which combines common elements of the user of the 2 tables and the authentication scheme based checks on the view.

  • Find the date max and then perform a calculation.

    Hello

    I have two tables. CC Cla_case and this Cla_event. The join between the two tables is on cc.cla_event_no = ce.cla_event_no.
    In cla_case, I have the following columns: Discover_date and Notification_date. Cla_event I have the Incident_date column.

    I need to perform a subquery that is the last (most recent) date, what cc comparison. Discover_date and this. Incident_date. Once he did that I then have to subtract this recording of cc. Notification_date to find out how many DAYS was held until the incident has been reported.

    My date format is as follows: 16 April 2008 07.50
    Once more, I need only DAYS between Notification and last date between Discover and Incident.

    Thank you very much!

    Banner:
    Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    "CORE 11.2.0.2.0 Production."
    AMT for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    Hello

    It is always useful to post some build instructions in the table and a small set of data to work with an example of your desired output. In this case, as I understand it, I don't think that you need a subquery - instead, you just use the LARGEST function...

    WITH cla_case AS
    (     SELECT 1 event_no, to_date('01/10/2011','dd/mm/yyyy') discover_date, to_date('02/10/2011','dd/mm/yyyy') notification_date from dual union all
         SELECT 2 event_no, to_date('02/10/2011','dd/mm/yyyy') discover_date, to_date('03/10/2011','dd/mm/yyyy') notification_date from dual union all
         SELECT 3 event_no, to_date('03/10/2011','dd/mm/yyyy') discover_date, to_date('04/10/2011','dd/mm/yyyy') notification_date from dual
    ),
    cla_event AS
    (     SELECT 1 event_no, to_date('02/10/2011','dd/mm/yyyy') incident_date from dual union all
         SELECT 2 event_no, to_date('02/10/2011','dd/mm/yyyy') incident_date from dual union all
         SELECT 3 event_no, to_date('03/10/2011','dd/mm/yyyy') incident_date from dual
    )
    SELECT
        cc.event_no,
        cc.discover_date,
        cc.notification_date,
        ce.incident_date,
         cc.notification_date - GREATEST(cc.discover_date,ce.incident_date)
    FROM
         cla_case cc,
         cla_event ce
    WHERE
         cc.event_no = ce.event_no
    /
      EVENT_NO DISCOVER_DATE        NOTIFICATION_DATE    INCIDENT_DATE              DIFF
    ---------- -------------------- -------------------- -------------------- ----------
             1 01-OCT-2011 00:00:00 02-OCT-2011 00:00:00 02-OCT-2011 00:00:00          0
             2 02-OCT-2011 00:00:00 03-OCT-2011 00:00:00 02-OCT-2011 00:00:00          1
             3 03-OCT-2011 00:00:00 04-OCT-2011 00:00:00 03-OCT-2011 00:00:00          1
    
    3 rows selected.
    
    Elapsed: 00:00:00.03
    

    HTH

    David

  • Store data from the Serial Port in the buffer and then take action?

    Hello! Everyone,

    I'm new to LabVIEW and I take assistance from various videos and stuffs available online to get started with LabVIEW.

    But I have a duty, therefore needing help.

    initially I see some of the tutorial videos and learned about the LabVIEW interface, and does a little project to communicate with the Port series (receiving and sending data).

    Happens to my task.

    My LabVIEW application will send a few State request packets on my device or control and based on the response packet that I have to display values.

    The Structure of package is as

    Header, length, Op_Code, data Checksum

    There is no terminator as newline or carriage return or anything else.

    In C language, I read the data from the Serial Port, and based on the length, I conclude that I got the full package or not, and then by recalculating the checksum value, the integrity of the package is verified and then based on that Op-Code has been sent will be decided.

    (I'm dealing with hexadecimal data)

    But how can I do this in LabVIEW.
    A tutorial or any referece will be useful for me.

    1. I suggest that you learn to use Shift Registers instead of local and global variables.  They are much more efficient (memory and execution speed) and make it much easier to read the schema.

    2. you don't need this inside the loop property node.  Is there a way to configure a Serial Port to turn off the stop character.

    3. you don't need to wait for playback VISA will limit the rate of loop if no data is coming.

    4. Once you have the length, you simply read the rest of the entire message and process it at a time.  This will make things a LOT faster.

    5. you should really do this enum a def type so that you can ensure that all your enum constants have the same values.  If you need to add a State later, simply update your enum in the same place then.

  • Question to load data using sql loader in staging table, and then in the main tables!

    Hello

    I'm trying to load data into our main database table using SQL LOADER. data will be provided in separate pipes csv files.

    I have develop a shell script to load the data and it works fine except one thing.

    Here are the details of a data to re-create the problem.

    Staging of the structure of the table in which data will be filled using sql loader

    create table stg_cmts_data (cmts_token varchar2 (30), CMTS_IP varchar2 (20));

    create table stg_link_data (dhcp_token varchar2 (30), cmts_to_add varchar2 (200));

    create table stg_dhcp_data (dhcp_token varchar2 (30), DHCP_IP varchar2 (20));

    DATA in the csv file-

    for stg_cmts_data-

    cmts_map_03092015_1.csv

    WNLB-CMTS-01-1. 10.15.0.1

    WNLB-CMTS-02-2 | 10.15.16.1

    WNLB-CMTS-03-3. 10.15.48.1

    WNLB-CMTS-04-4. 10.15.80.1

    WNLB-CMTS-05-5. 10.15.96.1

    for stg_dhcp_data-

    dhcp_map_03092015_1.csv

    DHCP-1-1-1. 10.25.23.10, 25.26.14.01

    DHCP-1-1-2. 56.25.111.25, 100.25.2.01

    DHCP-1-1-3. 25.255.3.01, 89.20.147.258

    DHCP-1-1-4. 10.25.26.36, 200.32.58.69

    DHCP-1-1-5 | 80.25.47.369, 60.258.14.10

    for stg_link_data

    cmts_dhcp_link_map_0309151623_1.csv

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    DHCP-1-1-2. WNLB-CMTS-03-3,WNLB-CMTS-04-4,WNLB-CMTS-05-5

    DHCP-1-1-3. WNLB-CMTS-01-1

    DHCP-1-1-4. WNLB-CMTS-05-8,WNLB-CMTS-05-6,WNLB-CMTS-05-0,WNLB-CMTS-03-3

    DHCP-1-1-5 | WNLB-CMTS-02-2,WNLB-CMTS-04-4,WNLB-CMTS-05-7

    WNLB-DHCP-1-13 | WNLB-CMTS-02-2

    Now, after loading these data in the staging of table I have to fill the main database table

    create table subntwk (subntwk_nm varchar2 (20), subntwk_ip varchar2 (30));

    create table link (link_nm varchar2 (50));

    SQL scripts that I created to load data is like.

    coil load_cmts.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_cmts IS SELECT *.

    OF stg_cmts_data;

    TYPE t_stg_cmts IS TABLE OF stg_cmts_data % ROWTYPE INDEX BY pls_integer;

    l_stg_cmts t_stg_cmts;

    l_cmts_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_cmts.

    Get the c_stg_cmts COLLECT in BULK IN l_stg_cmts;

    BECAUSE me IN l_stg_cmts. FIRST... l_stg_cmts. LAST

    LOOP

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_cmts (i) .cmts_token;

    IF l_cmts_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_cmts (i) .cmts_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_cmts (i) .cmts_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_cmts EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for dhcp


    coil load_dhcp.log

    Set serveroutput on

    DECLARE

    CURSOR c_stg_dhcp IS SELECT *.

    OF stg_dhcp_data;

    TYPE t_stg_dhcp IS TABLE OF stg_dhcp_data % ROWTYPE INDEX BY pls_integer;

    l_stg_dhcp t_stg_dhcp;

    l_dhcp_cnt NUMBER;

    l_cnt NUMBER;

    NUMBER of l_cnt_1;

    BEGIN

    OPEN c_stg_dhcp.

    Get the c_stg_dhcp COLLECT in BULK IN l_stg_dhcp;

    BECAUSE me IN l_stg_dhcp. FIRST... l_stg_dhcp. LAST

    LOOP

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = l_stg_dhcp (i) .dhcp_token;

    IF l_dhcp_cnt < 1 THEN

    INSERT

    IN SUBNTWK

    (

    subntwk_nm

    )

    VALUES

    (

    l_stg_dhcp (i) .dhcp_token

    );

    DBMS_OUTPUT. Put_line ("token has been added: ' |") l_stg_dhcp (i) .dhcp_token);

    ON THE OTHER

    DBMS_OUTPUT. Put_line ("token is already present'");

    END IF;

    WHEN l_stg_dhcp EXIT. COUNT = 0;

    END LOOP;

    commit;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    for link -.

    coil load_link.log

    Set serveroutput on

    DECLARE

    l_cmts_1 VARCHAR2 (4000 CHAR);

    l_cmts_add VARCHAR2 (200 CHAR);

    l_dhcp_cnt NUMBER;

    l_cmts_cnt NUMBER;

    l_link_cnt NUMBER;

    l_add_link_nm VARCHAR2 (200 CHAR);

    BEGIN

    FOR (IN) r

    SELECT dhcp_token, cmts_to_add | ',' cmts_add

    OF stg_link_data

    )

    LOOP

    l_cmts_1: = r.cmts_add;

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    SELECT COUNT (1)

    IN l_dhcp_cnt

    OF subntwk

    WHERE subntwk_nm = r.dhcp_token;

    IF l_dhcp_cnt = 0 THEN

    DBMS_OUTPUT. Put_line ("device not found: ' |") r.dhcp_token);

    ON THE OTHER

    While l_cmts_add IS NOT NULL

    LOOP

    l_add_link_nm: = r.dhcp_token |' _TO_' | l_cmts_add;

    SELECT COUNT (1)

    IN l_cmts_cnt

    OF subntwk

    WHERE subntwk_nm = TRIM (l_cmts_add);

    SELECT COUNT (1)

    IN l_link_cnt

    LINK

    WHERE link_nm = l_add_link_nm;

    IF l_cmts_cnt > 0 AND l_link_cnt = 0 THEN

    INSERT INTO link (link_nm)

    VALUES (l_add_link_nm);

    DBMS_OUTPUT. Put_line (l_add_link_nm |) » '||' Has been added. ") ;

    ELSIF l_link_cnt > 0 THEN

    DBMS_OUTPUT. Put_line (' link is already present: ' | l_add_link_nm);

    ELSIF l_cmts_cnt = 0 then

    DBMS_OUTPUT. Put_line (' no. CMTS FOUND for device to create the link: ' | l_cmts_add);

    END IF;

    l_cmts_1: = TRIM (SUBSTR (l_cmts_1, INSTR (l_cmts_1, ',') + 1));

    l_cmts_add: = TRIM (SUBSTR (l_cmts_1, 1, INSTR (l_cmts_1, ',') - 1));

    END LOOP;

    END IF;

    END LOOP;

    COMMIT;

    EXCEPTION

    WHILE OTHERS THEN

    Dbms_output.put_line ('ERROR' |) SQLERRM);

    END;

    /

    output

    control files -

    DOWNLOAD THE DATA

    INFILE 'cmts_data.csv '.

    ADD

    IN THE STG_CMTS_DATA TABLE

    When (cmts_token! = ") AND (cmts_token! = 'NULL') AND (cmts_token! = 'null')

    and (cmts_ip! = ") AND (cmts_ip! = 'NULL') AND (cmts_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:cmts_token))' cmts_token,

    cmts_ip ' RTRIM (LTRIM(:cmts_ip)) ")". "

    for dhcp.


    DOWNLOAD THE DATA

    INFILE 'dhcp_data.csv '.

    ADD

    IN THE STG_DHCP_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (dhcp_ip! = ") AND (dhcp_ip! = 'NULL') AND (dhcp_ip! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    dhcp_ip ' RTRIM (LTRIM(:dhcp_ip)) ")". "

    for link -.

    DOWNLOAD THE DATA

    INFILE 'link_data.csv '.

    ADD

    IN THE STG_LINK_DATA TABLE

    When (dhcp_token! = ") AND (dhcp_token! = 'NULL') AND (dhcp_token! = 'null')

    and (cmts_to_add! = ") AND (cmts_to_add! = 'NULL') AND (cmts_to_add! = 'null')

    FIELDS TERMINATED BY ' |' SURROUNDED OF POSSIBLY "" "

    TRAILING NULLCOLS

    ('RTRIM (LTRIM (:dhcp_token))' dhcp_token,

    cmts_to_add TANK (4000) RTRIM (LTRIM(:cmts_to_add)) ")" ""

    SHELL SCRIPT-

    If [!-d / log]

    then

    Mkdir log

    FI

    If [!-d / finished]

    then

    mkdir makes

    FI

    If [!-d / bad]

    then

    bad mkdir

    FI

    nohup time sqlldr username/password@SID CONTROL = load_cmts_data.ctl LOG = log/ldr_cmts_data.log = log/ldr_cmts_data.bad DISCARD log/ldr_cmts_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    nohup time username/password@SID @load_cmts.sql

    nohup time sqlldr username/password@SID CONTROL = load_dhcp_data.ctl LOG = log/ldr_dhcp_data.log = log/ldr_dhcp_data.bad DISCARD log/ldr_dhcp_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_dhcp.sql

    nohup time sqlldr username/password@SID CONTROL = load_link_data.ctl LOG = log/ldr_link_data.log = log/ldr_link_data.bad DISCARD log/ldr_link_data.reject ERRORS = BAD = 100000 LIVE = TRUE PARALLEL = TRUE &

    time nohup sqlplus username/password@SID @load_link.sql

    MV *.log. / log

    If the problem I encounter is here for loading data in the link table that I check if DHCP is present in the subntwk table, then continue to another mistake of the newspaper. If CMTS then left create link to another error in the newspaper.

    Now that we can here multiple CMTS are associated with unique DHCP.

    So here in the table links to create the link, but for the last iteration of the loop, where I get separated by commas separate CMTS table stg_link_data it gives me log as not found CMTS.

    for example

    DHCP-1-1-1. WNLB-CMTS-01-1,WNLB-CMTS-02-2

    Here, I guess to link the dhcp-1-1-1 with balancing-CMTS-01-1 and wnlb-CMTS-02-2

    Theses all the data present in the subntwk table, but still it gives me journal wnlb-CMTS-02-2 could not be FOUND, but we have already loaded into the subntwk table.

    same thing is happening with all the CMTS table stg_link_data who are in the last (I think here you got what I'm trying to explain).

    But when I run the SQL scripts in the SQL Developer separately then it inserts all valid links in the table of links.

    Here, she should create 9 lines in the table of links, whereas now he creates only 5 rows.

    I use COMMIT in my script also but it only does not help me.

    Run these scripts in your machine let me know if you also get the same behavior I get.

    and please give me a solution I tried many thing from yesterday, but it's always the same.

    It is the table of link log

    link is already present: dhcp-1-1-1_TO_wnlb-cmts-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-02-2

    link is already present: dhcp-1-1-2_TO_wnlb-cmts-03-3
    link is already present: dhcp-1-1-2_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-5

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-01-1

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-8
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-6
    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-0

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-03-3

    link is already present: dhcp-1-1-5_TO_wnlb-cmts-02-2
    link is already present: dhcp-1-1-5_TO_wnlb-cmts-04-4

    NOT FOUND CMTS for device to create the link: wnlb-CMTS-05-7

    Device not found: wnlb-dhcp-1-13

    IF NEED MORE INFORMATION PLEASE LET ME KNOW

    Thank you

    I felt later in the night that during the loading in the staging table using UNIX machine he created the new line for each line. That is why the last CMTS is not found, for this I use the UNIX 2 BACK conversion and it starts to work perfectly.

    It was the dos2unix error!

    Thank you all for your interest and I may learn new things, as I have almost 10 months of experience in (PLSQL, SQL)

  • Impossible to insert a record into a table

    Hello

    I was working on a procedure in which I had to insert 1,00,000 records each in 3 tables. But the process stopped after inserting 56000 records.
    After that I ran the query again, but now it is not insert a single record.

    I just created a fictitious table

    create the table vinod1 (no number);

    and I tried to insert a value by using

    insert into vinod1 values (100);

    But to my surprised the query has executed since the past 10 years and has not inserted a line.

    I also tried on SQLPLUS and I use oracle 10g


    Can you please help me and explain why I'm unable to insert the same if I am able to create the table.


    Thank you
    -Vinod

    are you using an option can be REPLICATED in your session, also what is the quota given to the user on the tablespace. The storage space that you used to create the table.

Maybe you are looking for

  • How to unblock facebook? (accidentally blocked)

    I was just facebook pages "unliking" that I had previously "liked." I found a list of events to come, which included an event from a page I had on my wall just "unpopular". I clicked to block this event and somehow it blocks facebook completely. When

  • Windows 10 Bios error

    Hello Today, when I opened my computer I came across a message and he said is not supported by windows 10 free upgrade so I continued and he opened and said to check for compatibility and says BIOS, how do I fix. Thank you peace and blessings, Gman

  • Numeric value of time zone

    Hi all How can I get the numeric value of the current time zone on the device ex: GMT = 0.0 Cairo = + 2.0 XXX = - 6.0 coz the API zone get a string representation of the time zone Id, not the digital representation. Thank you, all

  • How many user accounts is permitted in windows 7 Home Premium

    Hi, I finally bought Windows 7 Home Premium and had a number of questions below: (1) how many users can use Windows 7 Home Premium?(2) can I use my (created during the installation of windows) default Administrator account and the guest account?(3) c

  • Please help me... I just forgot to cancle my adobe the 14th day that it became 17th

    and why I need to pay for the whole year? I'm just graduated and had need of Photoshop for a quick project, and can't afford it. I just got an email would charge me $ 114 for Photoshop and $ 226 for illustrator. I thought it was a monthly. Please und