Update a table with one column of another

Oracle 11g
Hello

i'im trying to update the two columns of table SUPPORT (SUPPORT_X, SUPPORT_Y) with two columns of table POST_HTA_BT (POSTHTABT_GPS_X, POSTHTABT_GPS_Y)

Understand that the two tables have the colum below:

SUPPORT (SUPPORT_ID, SUPPORT_PLAQUE, POSTHTABT_ID, SUPPORT_X, SUPPORT_Y,...)

POST_HTA_BT (POSTHTABT_ID, POSTHTABT_GPS_X, POSTHTABT_GPS_Y,...)

The SUPPORT_PLAQUE has type varachar. Except the keys, the other columns are varchar type in both tables.

The point here is to update the support_x, support_y with posthtabt_gps_x and posthtabt_gps_y.But before the update we have Sheik if the fifth number of the support plate is a number of characters from "0" to "9"and the rest of the caracter of the support_plaque is '00000'

Please note that the support_plaque is stored in the table with the form: "0025800000!"

So I did the below script, I try to execute in sql develop.

SET SERVEROUTPUT ON

DECLARE
chiffre_liste varchar (200): = '0 ', '1', '2', '3', '4', ' 5 ', ' 6' ', 7', ' 8 ', ' 9';
CURSOR CUR_GPS_SUPPORT IS
Select MEDIA. SUPPORT_X, SUPPORT. SUPPORT_Y, POSTE_HTA_BT. POSTHTABT_ID, SUPPORT. EXPL_ID,
SUPPORTED. SUPPORT_PLAQUE, POSTHTABT_GPS_X, POSTHTABT_GPS_Y
support,.
POSTE_HTA_BT
where
SUPPORTED. SUPPORT_X IS NULL and
SUPPORTED. SUPPORT_Y IS NULL and
SUPPORTED. POSTHTABT_ID = POSTE_HTA_BT. POSTHTABT_ID and
SUPPORTED. EXPL_ID = POSTE_HTA_BT. EXPL_ID
Order of SUPPORT. POSTHTABT_ID;

w_POSTHTABT_ID POSTE_HTA_BT. Type of POSTHTABT_ID %;
w_SUPPORT_X SUPPORT. TYPE % SUPPORT_X;
w_SUPPORT_Y SUPPORT. TYPE % SUPPORT_Y;
w_EXPL_ID SUPPORT. TYPE % EXPL_ID;
w_SUPPORT_PLAQUE SUPPORT. TYPE % SUPPORT_PLAQUE;
w_POSTHTABT_GPS_X POSTE_HTA_BT. TYPE % POSTHTABT_GPS_X;
w_POSTHTABT_GPS_Y POSTE_HTA_BT. TYPE % POSTHTABT_GPS_Y;

BEGIN
DBMS_OUTPUT. Put_line ('loading the coordoonnees GPS - GPS Coord update takes care of starting ');

FOR HEART LOOPING CUR_GPS_SUPPORT

w_POSTHTABT_ID: = cur. POSTHTABT_ID;
w_SUPPORT_PLAQUE: = cur. SUPPORT_PLAQUE;
w_SUPPORT_X: = cur. SUPPORT_X;
w_SUPPORT_Y: = cur. SUPPORT_Y;
w_POSTHTABT_GPS_X: = cur. POSTHTABT_GPS_X;
w_POSTHTABT_GPS_Y: = cur. POSTHTABT_GPS_X;

If substr (cur.support_plaque, 5, 1 chiffre_liste) and substr (cur.support_plaque, 6, 5) = '00000'
w_SUPPORT_X: = CUR. POSTHTABT_GPS_X
w_SUPPORT_Y: = CUR. POSTHTABT_GPS_Y
END if;
EXCEPTION WHEN NO_DATA_FOUND THEN w_SUPPORT_X: = NULL and w_SUPPORT_Y: = NULL;
END;

-Updated the table of the supports
Update SUPPORT
Set SUPPORT_X = w_SUPPORT_X,
SUPPORT_Y = w_SUPPORT_Y
where SUPPORT_PLAQUE = w_SUPPORT_PLAQUE;
-On valid imm? immediately
commit;
EXCEPTION when no_data_found then null;
-No details found
END;

END;
/

and I got the following errors:

Error report:
ORA-06550: line 2, colum 34:
PLS-00103: symbol ',' met instead of one of the following symbols:

* & = - + ; <>/ is mod remains not rem
<>< Hurst (*) > or! = or ~ = > = < = <>and like2 or
like4 likec between | submultiset of type multiset Member
ORA-06550: line 2, column 52:
PLS-00103: symbol ';' met instead of one of the following symbols:

), * & = - + <>/ is mod remains not rem = >
<>< Hurst (*) > or! = or ~ = > = < = <>and like2 or
like4 likec between | Member of multiset must
ORA-06550: line 38, colum 48:
PLS-00103: symbol 'CHIFFRE_LISTE' met instead of one of the following symbols:

(
Symbol "(" a été substitué à "CHIFFRE_LISTE" verser continuer.) "
ORA-06550: line 39, 12 colum:
PLS-00103: symbol 'W_SUPPORT_X' met instead of one of the following symbols:

), * & -+ / at rem mod < Hurst (*) > rest and or.
multiset
ORA-06550: line 40, 12 colum:
PLS-00103: symbol 'W_SUPPORT_Y' met instead of one of the following symbols:

. (), * @ % & = - + <>/ is mod remains not rem
<>< Hurst (*) > or! = or ~ = > = < = <>and like2 or
like4 likec between | mult
ORA-06550: line 41, colum 9:
PLS-00103: symbol 'END' met instead of one of the following symbols:

. (), * @ % & = - + <>/ is mod remains not rem
<>< Hurst (*) > or! = or ~ = > = < = <>and like2 or
like4 likec between | multiset members
06550 00000 - "line %s, column % s:\n%s".
* Cause: Usually a PL/SQL compilation error.
* Action:

I checked the line number, but do not see the error in my code.

Please could you help me?

peace

Hello

glad to know that it worked. In fact, I don't see the reason to make these complicated processes.

Remember the mantra:

  • If you can do it with SQL then do it with SQL

Good evening!

Alberto

Tags: Database

Similar Questions

  • Create a table with one column '&amp; '.

    Hi all

    I need to create a column on my table with the character &. I try this way:

    SQL > CREATE TABLE 'CRIMIS_CARGA '. "" TM_EXCEL_CONSEN ".
    2 (NUMBER OF 'LINEA',
    3 'ID_INSTITUCION & ASSOCIATE' VARCHAR2 (510 char));

    but I can't because that ASD sqlplus to associate value...

    The ideas people?

    Kind regards
    dbajug

    set the escape ' \'

    Oracle@test > CREATE TABLE 'TM_EXCEL_CONSEN '.
    2 (NUMBER OF 'LINEA',
    3 VARCHAR2 (100)) 'ID_INSTITUCION\ & ASSOCIATE;

    Table created.

    Oracle@test > desc 'TM_EXCEL_CONSEN '.
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    NUMBER OF LINEA
    VARCHAR2 (100) ID_INSTITUCION & ASSOCIATE

  • Update multiple rows in a table with one value of another multiple

    Using SQL Server

    How this can be done:

    In all the lines in the upper table PS_CA_BILL_PLAN, we want to update the field LAST_XREF_SEQ_NUM with the MAX (XREF_SEQ_NUM) + 1 of the bottom table

    Where the CONTRACT_NUM and the BILL_PLAN_ID are equal

    This SQL below (in green) works for one line only

    SQL.jpg

    I think it's the SQL code you're looking for:

    UPDATE PS_CA_BILL_PLAN SET LAST_XREF_SEQ_NUM =

    (SELECT MAX (XREF_SEQ_NUM) + PS_CA_BP_XREF 1 B)

    WHERE B.CONTRACT_NUM = A.CONTRACT_NUM AND B.BILL_PLAN_ID = A.BILL_PLAN_ID)

  • Update of table with no column

    Hello

    Why oracle is that although the statement is incorrect? is there any docid for this?

    SQL > select banner version of v$.

    BANNER
    ----------------------------------------------------------------
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE Production 9.2.0.8.0
    AMT for Solaris: 9.2.0.8.0 - Production Version
    NLSRTL Version 9.2.0.8.0 - Production


    SQL > desc one
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    AA NUMBER (1)
    BB NUMBER (1)

    SQL > desc b
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    AA NUMBER (1)
    CC NUMBER (1)

    SQL > select * from a;

    AA BB
    ---------- ----------
    1 1
    2 2
    3 3
    4 4
    3 s

    SQL > select b bb;
    Select bb b
    *
    ERROR on line 1:
    ORA-00904: "BB": invalid identifier


    SQL > update a game aa = 3 where bb (select b BB); -> bb of the column does not exist in table b

    5 lines to date.

    SQL > select * from a;

    AA BB
    ---------- ----------
    1 of 3
    1 p
    3 3
    3 4
    6 P

    Thank you
    Shanker

    No specific document. He has correlated subqueries. There is, of course, usually join condition.

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_10002.htm#i2066912

  • Update of table with 14 million records

    good day, I'm updating a table with 14 million documents column. using the data from another table.
    This takes terrible time just updated to 500,000 over the weekend, which is unacceptable.
    ideas to improve my code and get the fastest update is much appreciated.

    DECLARE
    TYPE vc_type is table of index varchar2 (20) by pls_integer;
    type tabtype_rowid is table of pls_integer rowid indexes;
    my_cur sys_refcursor;
    cur_limit integer: = 10000;

    tab_rowid tabtype_rowid;

    Start
    OPEN FOR My_cur
    SELECT value, rowid
    TABLE 1A

    where the value IS NOT NULL
    and id is null;


    loop
    collect the fetch my_cur in bulk in tab_value, cur_limit limit tab_rowid;

    FORALL k IN 1.tab_npi.count

    UPDATE table 1A
    A.ID = (select id SET
    in Table 2b
    where value = tab_value (k)
    and rownum = 1
    )
    WHERE a.rowid = tab_rowid (k);

    COMMIT;

    When the output tab_value.count < cur_limit;.
    end loop;

    END;


    Thank you

    903537 wrote:
    I tried to update basic training, as a first step and it crashed...

    He didn't fail, it failed.

  • Unique table with several columns or several tables split?

    What is the best.

    A table with multiple columns inside or divided into several tables. Why?
    How will the performance in the two scenarios?

    Hello

    user13024762 wrote:
    I have a table EMP that has column EMP_ID, EMP_NAME MGR_ID, MGR_NAME, SALARY, EXP_IN_MNTHS, EXP_IN_YRS... etc with multiple columns

    I have the following tables
    EMP-> EMP_ID, EMP_NAME

    Each row in the table emp thie represents a separate employee. I guess other columns in the emp table might be birth_date, social_security_number and status (by example, 'Active', 'Leave', 'complete'). Here's what an employee has (at least) one of. If there is a one-to-many relationship between an employee and an attribute, then you probably want another table for this attribute.

    BISHOP-> EMP_ID, MGR_ID, MGR_NAME

    There is a one-to-many relationship between employees and managers? In other words, an employee may have 2 or more managers? If Yes, then you need another table.
    If there is only a one-to-one relationship between employees and managers (in other words, if an employee is never more than 1 Manager) so why don't you just have a mgr_id column in the emp table?
    Managers are also used for? (This is often the case, as in scott.emp and hr.employees.) If so, do not store their names in the EME and tables of mgr. Store name (and date of birth and other information) in the table emp only and, if you need a table of Bishop, just the emp_id and mgr_id column.

    SAL-> EMP_ID, SALARY

    There is a one-to-many relationship between the employees and wages? In other words, an employee may have 2 or more treatments? If so, how will you use the values? Is a special treatments in some way, as it will be used more often than others? (In other words, you may have a current and past wages salary, but the last wages are rarely used.)
    If you never have more than 1 salary for a given employee, why not just have a sal column in the emp table?

    EXP-> EMP_ID, EXP_IN_MNTHS, EXP_IN_YRS

    There is a one-to-many relationship between the employees and what whether you store in this table?

    etc. with more tables

    What is the best based on

    (1) performance and data recovery
    (2) ease of use
    (3) maintainability

    A one-to-many relationship requires an additional table. If an employee can have up to 3 managers, don't have mgr1, mgr2 and mgr3 columns in the emp table. Use a separate table, with up to 3 lines for the same employee, instead.
    For 1-1 relationships, it is usually best to not have separate tables.

  • Gears - error when you try to insert values into a table with multiple columns

    Hello

    I started playing with the gears and SQlLite today and I get an error when I try to insert values into a table with multiple columns.

    I have:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text, DeveloperAge int)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?, ?)', [devName, devAge]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I get the error:

    net.rim.device.api.database.DatabaseException; insert into developers values (?,?): SQL logic error or missing database.

    I use this reference: http://code.google.com/apis/gears/api_database.html

    Everything works if I have only one field as:

    var db = google.gears.factory.create('beta.database');
        db.open('developerSet');
        db.execute('create table if not exists Developers (DeveloperName text)');
    
        var devName = "Davy"
        var devAge = 32;
    
        try {
            db.execute('insert into Developers values (?)', [devName]);
            alert('success');
        }
        catch (e) {
            alert(e);
        }
    

    I use the plug-in Visual Studio 2.0 for 2008 that are running Windows XP SP and Simulator 2.13.0.56

    Thank you

    Davy

    Yes, a SQLite database will persist between battery pulls.  The database is registered either to internal MEM or removable media (not the device memory), depending on which is available on your device.

    In general, its not considered a best practice to remove your table as soon as it is empty and re - create it again when you want to add data.  This adds extra overhead fresh for the final, delete and insert first for a given table.  Instead, define and finalize your drawing before you create your table.  Once created, review the static schema.

    That being said, for development purposes, it may be easier to provide an easy way to drop your tables while you develop your schema.

    See you soon,.

    Adam

  • Simple query to find the difference between 2 numbers in one column to another column

    Hello

    I would like to know the difference between 2 numbers in same column corresponding to a condition of another column. How do that?

    For example: say I have a table with 3 columns A, B and C.

    A > Varchar2

    B > Varchar2

    C > number

    A B C
    AD1
    BC2
    CB3
    DA4

    I want something like 'column value corresponding C min min (col B) result = (col A) - value of the corresponding C column (number)' without having to write 2 select statements. How do I do that?

    Thanks in advance

    aBBy007



    Notes on the system:

    2-node 11.2.0.3.4 GI/RDBMS running on RHEL5.

    Hello

    It is not very similar to your original question.  It would be better if you asked what you really want in your first post, rather than making people to time writing solutions you want not and can not use waste.  Once you see an answer to this question, will you change the question again?

    Here's a way to do what you asked:

    WITH got_lasts AS

    (

    SELECT val.thread #.

    , MAX (val.sequence #) AS last_standby_seq_received

    MAX (CASE

    WHEN val.applied = "YES".

    THEN val.sequence #.

    END

    ) AS last_standby_seq_applied

    V $ archived_log val

    Join v$ database vdb WE val.resetlogs_change #.

    = vdb.resetlogs_change #.

    GROUP BY thread #.

    )

    SELECT thread #.

    last_standby_seq_received

    last_standby_seq_applied

    last_standby_seq_received

    -last_standby_seq_applied AS total_lag

    OF got_lasts

    ORDER BY thread #.

    ;

  • Best way to update a table with separate values

    Hi, I would really appreciate some advise:

    I need to regularly perform a task where I update 1 table with all the new data that has been entered in another table. I cannot perform a complete insert because this will create data duplicated each time it works, so the only way I can think of is the use of cursors in the script below:


    CREATE OR REPLACE PROCEDURE update_new_mem IS
    tmpVar NUMBER;

    CURSOR c_mem IS
    SELECT nom_membre, member_id
    OF gym.members;
    CREC c_mem % ROWTYPE;


    BEGIN
    OPEN c_mem.
    LOOP
    SEEK c_mem INTO crec;
    EXIT WHEN c_mem % NOTFOUND;
    BEGIN
    UPDATE gym.lifts
    Name = crec.member_name
    WHERE member_id = crec.member_id;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN NULL;
    END;
    IF SQL % NOTFOUND THEN
    BEGIN
    INSERT INTO gym.lifts
    (name, member_id)
    VALUES (crec.member_name, crec.member_id);
    END;
    END IF;
    END LOOP;
    CLOSE C_mem;

    END update_new_mem;



    This method works, but y at - it a (faster) easier way to update another table with new data only?

    Thank you very much

    >
    This method works, but y at - it a (faster) easier way to update another table with new data only?
    >
    Almost anything would be better than this treatment of slow-by-slow loop.

    You don't need a procedure, you should just use MERGE for this. See the examples in the section of the MERGER of the doc of the SQL language
    http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9016.htm

    MERGE INTO bonuses D
       USING (SELECT employee_id, salary, department_id FROM employees
       WHERE department_id = 80) S
       ON (D.employee_id = S.employee_id)
       WHEN MATCHED THEN UPDATE SET D.bonus = D.bonus + S.salary*.01
         DELETE WHERE (S.salary > 8000)
       WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
         VALUES (S.employee_id, S.salary*.01)
         WHERE (S.salary <= 8000);
    
  • Declare a type of table with multiple columns

    I have a table with a column of type, and I want to create one with two columns.

    My type is:
    create or replace type "NUMBER_TABLE" in the table of the number;

    And I use it in function:

    FUNCTION GetValues()
    return NUMBER_TABLE
    as
    results NUMBER_TABLE: = NUMBER_TABLE();
    Start
    Select OrderId bulk collect in: results from (select * from tbl_orders);
    -Other code...
    end;

    I want select it be like this:
    Select OrderId, OrderAddress bulk collect into: results from (select * from tbl_orders);

    How to do this?

    Is that what you are looking for:

    CREATE OR REPLACE TYPE two_col_rec AS OBJECT (empno NUMBER, ename VARCHAR2(10))
    /
    
    CREATE OR REPLACE TYPE two_col_table AS TABLE OF two_col;
    /
    
    CREATE OR REPLACE FUNCTION GetValues RETURN two_col_table AS
       results two_col_table := two_col_table();
    BEGIN
       SELECT two_col(empno, ename) BULK COLLECT INTO results FROM emp;
       --
       RETURN results;
    END;
    /
    show errors
    
  • Update of table with invalid identifiers

    Hello!

    I use a third-party plug-in and that comparisons of chemical structures. I want to update a table with the values of the other when the plugin matches two rows. However, I'm a problem invalid identifier.

    Two tables:
    PLATES: a VARCHAR2 columns of PLATE_SMILES, IN_DB
    INVEST: a VARCHAR2 columns of SMILES

    The operator is a binary: jc_compare (PLATE_SMILES, SMILES) = 1 (or 0 if they do not match)

    I want my query to say: "If comparison SMILES, PLATE_SMILES = 1, define IN_DB = 1 for row" - effectively asking if PLATE_SMILES exists in the table INVEST.

    I tried a number of "renditions", all identifiers not valid donations. Here is an example:

    Update (select plate. PLATE_SMILES, plate. IN_DB, invest. SMILES
    plate PLATES
    INVEST invest
    WHERE jc_compare (PLATE_SMILES, SMILES) = 1)
    set plate. IN_DB = 1;


    ORA-00904: "FLAT". "" IN_DB ": invalid identifier


    I hope that this should be an easy fix, and any help is greatly appreciated!

    Hello

    You have

    UPDATE (SELECT plate.plate_smiles,
                   plate.in_db,
                   invest.smiles
            FROM   plates plate, invest invest
            WHERE  jc_compare ( plate_smiles, smiles) = 1)
    SET    plate.in_db = 1;   -- Error here
    

    PLATE is not known outside the display online. Just remove it.

    Concerning
    Peter

  • Export an ADF table with default column order

    Hello

    Jdev 11.1.1.5.0

    We have ADF Table with column drag and drop option. Also we have implemented ADF Table with excelHTMl type of export.

    Everything works as expected. Only problem is if we try to exchange a few columns by drag-and - drop option and then export the table, we receive the order of the columns with brewing. But our demand is, the user must obtain the export with the initial order table by default.

    It would be great, if you can suggest an idea to export the ADF table with default column order.

    Thanks in advance,

    MSR.

    I realized the required functionality. We can restore the default order of the columns to aid

       Function richeTableau = this.getFetchResultsTable ();
       Iterator rItr = rTable.getChildren () .iterator ();
       {while (rItr.hasNext ())}
           ((RichColumn) rItr.next ()).setDisplayIndex(-1);
       }

    Then we can call the real export help feature

       queue the event via a JavaScript inserted into the page
       FacesContext context = FacesContext.getCurrentInstance ();
       Erks = ExtendedRenderKitService
       Service.getService (context.getRenderKit (), ExtendedRenderKitService.class);
       erks.addScript (context, "customHandler()");
  • Fill a table with two columns using a custom bean

    Hello

    Can you provide me or give me a link to an example of populating a table (with two columns) with a custom bean?

    Thank you

    TSPS

    Hello..
    I'm Jules Destrooper is what you want

    http://download.Oracle.com/docs/CD/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html

    Hopes, will help you

  • How to create a table with editable column values.

    Hello world
    I think it's very simple, but I am unable to find how to do this. This is my requirement. I need to create a table with n columns and 1 line initially. the user must be able to enter data into this table and click of a button must insert the data into the database table. Also, there should be a button at the bottom of the table to add 1 line to the table.

    I know how to do the insertion of data, but can someone please let me know how to create a table which allows the user to enter data and how to create a line button Add 1?


    Thanks in advance!

    Raghu,

    Go through the tutorial of Toolbox Page & Advanced section of the Guide of the OFA table.

    Step 1 - you need to create EO & VO from this EO. This EO will be table of database where you want to insert the data.

    Step 2 - create an advanced table region. (See this section in table advanced for more details)

    Step 3 - attach this VO in the BC4J region advanced Table component.

    Kind regards
    GYAN

  • Table with 300 columns

    While talking with a friend, he told me that sometimes he uses tables with 300 columns that will be available only once for the extraction of information. For me, it's a little strange because 300 columns looks like a large number of columns for me...

    Have tables with columns as is common practice in the data warehouse? If Yes, can you explain to me on what situations, this can happen and how often?

    Concerning

    We have tables with columns of cca 150.

    You should know that we don't talk to relational systems which are standardized. Its common practice when building data warehouse. Number of columns in the tables will depend on the complexity and the size of your warehouse and the number, size and complexity of your source systems.

    Point is that even now, when the data warehouse is "done", we still add/remove columns changes to warehouse such as changing the source systems.

Maybe you are looking for