UPDATE A TABLE WITH A RECORD
Hello,
I try to figure out if it exists a syntaxe for UPDATE statement using a record like it exists for INSERT statements.
declare
v_rec EMPLOYEES%ROWTYPE;
begin
select * into v_rec from employees where rownum = 1;
v_rec.employee_id := -1;
v_rec.email := v_rec.email||'_';
INSERT INTO EMPLOYEES VALUES v_rec;
v_rec.employee_id := -1;
v_rec.email := v_rec.email||'_XX';
UPDATE EMPLOYEES SET VALUES = v_rec where employee_id = -1;
end;
/
update EMPLOYEES
set row = v_rec
where employee_id = -1
Similar Messages
-
Problem when updating af:table with new records
Hi,
I have a page that shows two tables from the same DB table but with different VOs.
Table1 displays records where date_column is within the current month, table2 displays all records.
The problem is that when I add new record and return to the page, I find out that the new record has been added to both tables, it’s shown in table1 even though its date is not within this month.
When I run the page again the problem is solved and everything is in the right place !!
How can I fix this?Hi,
you will have to re-query the iterators because you add the new row to a VO - which is an iterator - that wont filter your input (instead you add to a filtered iterator). However, its strange that both tables show that value because if these are different VO they should be independent. Only if they are instances of the same VO tehy are expected to show the same data
Frank -
Recordset - updating 2 tables with 1 recordset using application object update record
I have a recordset that uses a field from 2 different tables
with a select statement where clause that joins a userid. I can
display the field’s data just fine. Now I want to use the
Application object “update record” so I can modify
either of the fields. The problem is the Application object
“update record” only allows you to update one table.
How does Dreamweaver mx 2004 allow me to update 2 tables with one
recordset and 1 submit button? Currently using php.
Example of where:
Where member.userid = member_detail.userid
I tried creating the one form with the field from the first
table and that works just fine. I added the other field from the
other table into the form but ofcourse there isn’t any code
that will update the second table so it won’t work.
My application requires me to update alot of fields between 2
tables at the same time.
Does anyone know a way using Dreamweaver mx 2004 to do this?
I don’t have much php experience.jon-rookie wrote:
> DreamerJim,
>
> I am sorry but I don't think you are correct. I just
can't believe that with
> all the powers to be at Macromedia and now Adobe can't
figure out how to update
> two tables at once. There are millions of db's out there
that require this. I
> spent several hours today perusing lots of posts on the
internet. It seems I
> am not the only one out there that has asked this
question. Unfortunately
> there are no good answers yet to my surprise.
>
> I did find a Dreamweaver extension that does exactly
what I myself and many
> others want. The problem is it is no longer available
unless you purchase a
> bundle of software from Adobe.
>
> I have not looked into it in detail so I am not 100%
sure that is accurate!
>
> Still, alot of php programmers do this all the time
without much trouble. I
> just want to know if Dreamweaver mx 2004 has the
capability if a person knows
> the right steps.
>
> Hopefully a Dreamweaver expert will post something to
let us know for sure.
> Until then I am stuck.
>
Not even CS3 has this built in, you will either have to code
it yourself
or buy the extension you have found. Dreamweaver gives you
basic
features to help you develop applications, but if you want to
do
anything really clever you have to do it yourself.
One thing to consider is maybe creating an SQL view that is
can be
updated. I am pretty sure it exists, then you use the view
instead of
the table in the update behaviour. I have never done it
myself, but I am
sure it can be done.
Steve -
UPDATING A TABLE WITH SAME INFO FROM ANOTHER TABLE ON THE SAME DB
0down votefavorite
I am trying to update a table with info from another table on the same db with same table name. I just want the info to be the same , no primary key or constraint involve just a straight replacement of records and I keep getting errors WITH THE TABLE not
being recignize. below is my query:
UPDATE
VNDFIL
SET EOBTYP
= VNDFIL.EOBTYP,
EDI_X12_835_VERSION = VNDFIL.EDI_X12_835_VERSION
FROM
AGERECOVERY
WHERE
VNDFIL.EOBTYP
= VNDFIL.EOBTYP
AND
VNDFIL
.EDI_X12_835_VERSION
= VNDFIL.EDI_X12_835_VERSIONHi rotary,
If those two same named tables are in the same database then they have to be in different schemas. If you mean they are in the same server instance, then they may be in different databases, besides the "table not being recognized" error,
anyway you should use the fully qualified table names, that is database.Schema.Table(If across instances, ServerName should be prefixed) to avoid the table unrecognized error.
Using Identifiers As Object Names
With the fully qualified names, your update statement can be like below.
UPDATE
db1.schema1.VNDFIL
SET EOBTYP = srcTbl.EOBTYP, EDI_X12_835_VERSION = srcTbl.EDI_X12_835_VERSION
FROM
db1.schema2.VNDFIL srcTbl
WHERE
db1.schema1.VNDFIL.EOBTYP = srcTbl.VNDFIL.EOBTYP AND
db1.schema1.VNDFIL.EDI_X12_835_VERSION = srcTbl.VNDFIL.EDI_X12_835_VERSION
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
URGENT update a table with a text that has a single quote in it
Hello, I am trying to update a table with a text that has a single quote in it. I believe I need to use two singles quotes but I am not sure how.
For example:
UPDATE TEST
SET DESCRLONG='Aux fins d'exportations'
WHERE etc...
Should I put 2 singles quotes before the quote in the text?
UPDATE TEST
SET DESCRLONG='Aux fins d'''exportations'
WHERE etc...
Thank you very much :)The best way depends on the version of Oracle.
But, the quick and universal answer is to use two single quotes
SQL> connect test/test
Connected.
SQL> create table test (descrlong varchar2(128));
Table created.
SQL> insert into test values ('This is a string with a '' single quote');
1 row created.
SQL> select * from test;
DESCRLONG
This is a string with a ' single quote
SQL> update test set descrlong='Aux fins d''exportations'
2 where descrlong like 'T%';
1 row updated.
SQL> select * from test;
DESCRLONG
Aux fins d'exportations
SQL> -
Is it possible to update multiple tables with a dynamic form?
I have columns from two tables populating a dynamic form. I am trying to have the form update both tables on submit. I have tried both a linked transaction and a custom transaction but I am not making progress. Only the master table is being updated. Is it possible with ADDT to update two tables with a dynamic form?
I meant
SXMSMSTAT
SXMSSYERR
Thanks. -
How can I update the table with a single query for...
I have a table with columns C1 and C2.
C1 C2
A1 null
A1 null
A1 null
A1 null
A2 null
A2 null
A2 null
A3 null
A4 null
A4 null
I want to update my table with a single query so that I would have data like
C1 C2
A1 1
A1 2
A1 3
A1 4
A2 1
A2 2
A2 3
A3 1
A4 1
A4 2
The updated column C2 has the values like serial no grouped on the column C1.SQL> create table mytable
2 ( c1 varchar2(2)
3 , c2 number(2)
4 )
5 /
Tabel is aangemaakt.
SQL> insert into mytable (c1)
2 select 'A1' from dual union all
3 select 'A1' from dual union all
4 select 'A1' from dual union all
5 select 'A1' from dual union all
6 select 'A2' from dual union all
7 select 'A2' from dual union all
8 select 'A2' from dual union all
9 select 'A3' from dual union all
10 select 'A4' from dual union all
11 select 'A4' from dual
12 /
10 rijen zijn aangemaakt.
SQL> select * from mytable
2 /
C1 C2
A1
A1
A1
A1
A2
A2
A2
A3
A4
A4
10 rijen zijn geselecteerd.
SQL> merge into mytable t1
2 using (select c1
3 , row_number() over (partition by c1 order by null) rn
4 , rowid rid
5 from mytable
6 ) t2
7 on (t1.rowid = t2.rid)
8 when matched then
9 update set c2 = rn
10 when not matched then
11 insert values (null,null)
12 /
10 rijen zijn samengevoegd.
SQL> select * from mytable
2 /
C1 C2
A1 1
A1 2
A1 3
A1 4
A2 1
A2 2
A2 3
A3 1
A4 1
A4 2
10 rijen zijn geselecteerd.Regards,
Rob. -
Updating base table with Materialized View's data
Hi,
In order to update base table with MVs data, I am trying real time data transfer between two databases. One is Oracle 8i and other is Oracle 9i. I have created an updatable MV in 9i on a base table using database link. The base table is in 8i. Materialized View log is created in 8i on base table. MV has to be associated to some replication group, but I am not able to create replication group in 9i to which MV has to be associated. The required packages are not installed.
Replication packages are to be used to create replication group are :
/*Create Materialized View replication group*/
BEGIN
DBMS_REPCAT.CREATE_MVIEW_REPGROUP (
gname => 'TEST_MV_GRP',
master => 'TEST_DATA_LINK',
propagation_mode => 'ASYNCHRONOUS');
END;
But above block is giving error.
Can anyone suggest how to resolve this, or are there any other approaches (by not using replication packages) to update base table with MVs data ?
Thanks,
ShaileshYes, I created link between two databases and was able to update tables on 8i from 9i database using that link.
The error I am getting while creating replication group is :
ORA-06550
PLS-00201 : identifier 'SYS.DBMS_REPCAT_UTL2@'TEST_DATA_LINK' must be declared
ORA-06550
PLS-00201 : identifier 'SYS.DBMS_REPCAT_UNTRUSTED@'TEST_DATA_LINK' must be declared
ORA-06512 : at "SYS.DBMS_REPCAT_UTL", line 2394
ORA-06512 : at "SYS.DBMS_REPCAT_SNA_UTL", line 1699
ORA-06512 : at "SYS.DBMS_REPCAT_SNA", line 64
ORA-06512 : at "SYS.DBMS_REPCAT", line 1262
Is there any other approach which can be used to update base table with MVs data instead of using replication packages ?
Thanks,
Shailesh -
Best way to update a table with disinct values
Hi, i would really appreciate some advise:
I need to reguarly perform a task where i update 1 table with all the new data that has been entered from another table. I cant perform a complete insert as this will create duplicate data every time it runs so the only way i can think of is using cursors as per the script below:
CREATE OR REPLACE PROCEDURE update_new_mem IS
tmpVar NUMBER;
CURSOR c_mem IS
SELECT member_name,member_id
FROM gym.members;
crec c_mem%ROWTYPE;
BEGIN
OPEN c_mem;
LOOP
FETCH c_mem INTO crec;
EXIT WHEN c_mem%NOTFOUND;
BEGIN
UPDATE gym.lifts
SET 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 is there an easier (faster) way to update another table with new data only?
Many thanks>
This method works but is there an easier (faster) way to update another table with new data only?
>
Almost anything would be better than that slow-by-slow loop processing.
You don't need a procedure you should just use MERGE for that. See the examples in the MERGE section of the SQL Language doc
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); -
I HAVE A SOURCE TABLE WITH 10 RECORDS AND TARGET TABLE 15 RECORDS. MY QUESTION IS USING WITH THE TABLE COMPARISON TRANSFORM .I WANT TO DELETE UNMATCHED RECORDS FROM THE TARGET TABLE ?? HOW IT IS ??
Hi Kishore,
First identify deleted records by selecting "Detect deleted rows from comparison table" feature in Table Comparison
Then Use Map Operation with Input row type as "delete" and output row type as "delete" to delete records from target table. -
Select max date from a table with multiple records
I need help writing an SQL to select max date from a table with multiple records.
Here's the scenario. There are multiple SA_IDs repeated with various EFFDT (dates). I want to retrieve the most recent effective date so that the SA_ID is unique. Looks simple, but I can't figure this out. Please help.
SA_ID CHAR_TYPE_CD EFFDT CHAR_VAL
0000651005 BASE 15-AUG-07 YES
0000651005 BASE 13-NOV-09 NO
0010973671 BASE 20-MAR-08 YES
0010973671 BASE 18-JUN-10 NOHi,
Welcome to the forum!
Whenever you have a question, post a little sample data in a form that people can use to re-create the problem and test their ideas.
For example:
CREATE TABLE table_x
( sa_id NUMBER (10)
, char_type VARCHAR2 (10)
, effdt DATE
, char_val VARCHAR2 (10)
INSERT INTO table_x (sa_id, char_type, effdt, char_val)
VALUES (0000651005, 'BASE', TO_DATE ('15-AUG-2007', 'DD-MON-YYYY'), 'YES');
INSERT INTO table_x (sa_id, char_type, effdt, char_val)
VALUES (0000651005, 'BASE', TO_DATE ('13-NOV-2009', 'DD-MON-YYYY'), 'NO');
INSERT INTO table_x (sa_id, char_type, effdt, char_val)
VALUES (0010973671, 'BASE', TO_DATE ('20-MAR-2008', 'DD-MON-YYYY'), 'YES');
INSERT INTO table_x (sa_id, char_type, effdt, char_val)
VALUES (0010973671, 'BASE', TO_DATE ('18-JUN-2010', 'DD-MON-YYYY'), 'NO');
COMMIT;Also, post the results that you want from that data. I'm not certain, but I think you want these results:
` SA_ID LAST_EFFD
651005 13-NOV-09
10973671 18-JUN-10That is, the latest effdt for each distinct sa_id.
Here's how to get those results:
SELECT sa_id
, MAX (effdt) AS last_effdt
FROM table_x
GROUP BY sa_id
; -
Updating a table with billion rows
It was an interview question, what's the best way to update a table with 10 billion rows. Give me your suggestions. Thanks in advance.
svkThe best way to answer questions such as this is NOT with a absolute and specific answer. Instead, discuss your strategy for approaching the problem. The first step is to understand your exact requirement. It is surprising how often people
write update statements with an under-qualified where clause. NEVER update a row that does not need to be updated. For example, a statement like:
update mytable set cola = 'ABC' where id in (1, 45, 212);
Assuming id is unique for the table and the specified values exist in the table, we know 3 rows will be updated. Do all of those rows need to be updated? Think about it. If cola is already set to 'ABC' for any of those rows, we could ignore
those rows and make the update more efficient. To do that, you need to add "and cola <> 'ABC' " to the where clause. That is just one example of understanding exactly what you need to do - and doing only that which needs to be done.
Once you understand exactly what you need to do, you need to analyze the impact of the update and identify any potential issues. Updating a lot of rows can take a lot of time and consume large amounts of log and disk space. What else is using
the table? Can you afford to lock the table for the duration of the update? Are there concurrency issues, regardless of whether you update in batches or in one single statement? When using a batch approach, is there an issue if someone runs
a query against the table (i.e., the result is different from that of the same query run after all updates have been completed)? Are you changing something which is included in an index? Are you changing part of the clustered index?
Ultimately, every question you are asked is (or should be) designed to test your problem-solving skills and your skillset. IMO, it is relatively easy to improve your skillset of any particular tool, language, or environment. The other - not so much
and that is why they are more valuable IMO. -
How to update two tables with trigger
Hi:
how to update two tables with trigger ?
I have two tables :
(1)ASIA
MI number;
(2)ASIA_P
ID number;
When I insert a new value into the asia.MI ,I also can
insert the same value into the asia_p.id field.
I have write a trigger as follows but it does't work.
create or replace trigger MI_TRG
before insert on asia
for each row
declare
seq number;
begin
select MI_SEQ.Nextval into seq from dual;
:new.MI:=seq;
insert into ASIA_PRO(MI_ID)
values
(seq);
end MI_TRG;
How to realize it ?
thanks
zzmWhy do you say it does not work?
-
How to spool in excel sheet of table with 1561828 records
how to spool in excel sheet of table with 1561828 records
i think excel got only 65l limit?
COUNT(*)
1561828
i am using windows box...any suggestions?Raman wrote:
means excel 2007 can hold 15,61,828 records ? can i give like spool filename.xls?You can name the spool file anything you want, but surely you realize that naming it 'filename.xls' doesn't make it an xls file. A name is just a name. There are industry standards on certain names indicating certain file formats, but the name doesn't make it that format. -
Comparing Two tables with 300k records and update one table
Could you let me know how to compare two tables having 300k records and update one table.below is the scenario.
Table Tabl_1 has columns A,B and Tabl_2 has columns B,new_column.
Column B has same data in both the tables.
I need to update Tabl_2 in new_column with Tabl_1 A column data by comparing B column in both tables.
I m trying to do using PLSQL Tables.
Any suggestion?
Thanks.Hi,
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
If you're asking about a DML statement, such as UPDATE, the CREATE TABLE and INSERT statements should re-create the tables as they are before the DML, and the results will be the contents of the changed table(s) when everything is finished.
Always say which version of Oracle you're using (for example, 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
ef2019c7-080c-4475-9cf4-2cf1b1057a41 wrote:
Could you let me know how to compare two tables having 300k records and update one table.below is the scenario.
Table Tabl_1 has columns A,B and Tabl_2 has columns B,new_column.
Column B has same data in both the tables.
I need to update Tabl_2 in new_column with Tabl_1 A column data by comparing B column in both tables.
I m trying to do using PLSQL Tables.
Any suggestion?
Thanks.
Why are you trying to use PL/SQL tables? If tabl_1 and tabl_2 are regular database tables, it will be much simpler and faster just to use them.
Depending on your requirements, you can do an UPDATE or MERGE, either in SQL or in PL/SQL.
Maybe you are looking for
-
Fields in customer master ?
hai. how to make some fields in the customer master to appear in the grey mode and not in change mode to the user in the change customer master data screen (XD02) kindly update ? regards sriram.
-
Protecting Vendor Bank Details Display
Hi Gurus, My company reimburse expenses to employee, for that purpose I have created seprate Vendor group for employee vendors. Authorisatoin for create/change/display vendors are also available to Purchasing department, which is fine for normal vend
-
Unable to mark ITXEX field for first subtype in IT40
Hi, My problem is as follows: 1. I am using a bespoke ABAP program to create a subtype (any subtype) for IT40 (objects on loan). 2. The program is able to create the infotype - subtype records correctly. This is was verified using PA30. 3. However, i
-
ILOM on X4x00 - temperature monitoring snmp, automatic shutdown
Hello, we run some X4100/X4200 servers. I want to monitor temperatures via ILOM's snmp interface. Unfortunately I get all kind of information with snmpwalk like sensor typ, hysteresis, unit, .... except the current sensor readings. Did anybody succee
-
Folks, I'm trying to fix an issue we have in the DP planning book, message is date it outside of the storage buckets profile, and I'm wondering how I can back up my data to an info cube, then de-initialize the planning area, create a new time series