SQL Update to multiple tables
I am trying to write an update statement that will allow me to 'SET' values on multiple tables.
Ex.
Table1
Fields are: EmployeeID; Name; DOB
Table2
Fields are: SSN; Address
I want to write a statement like so
update set table1.employeeID='ABC', table2.Address='123 Oars Ferry' where EmployeeID='123456'
However, when I run this statement it doesn't work. Any ideas on how I could write this statement to get it working would be appreciated.
Normally, you'd just execute two separate UPDATE statements here. If the two statements will always be run together and always need to succeed or fail together, you'd probably want to create a stored procedure that did both updates and to just call the stored procedure from your application.
Depending on the table structure, you may be able to join table1 and table2 to create a key-preserved view and update that, i.e.
UPDATE (SELECT <<list of columns>>
FROM table1, table2
WHERE <<some conditions>>)
SET ...This is generally, however, going to be substantially less clear than two simple update statements.
Justin
Similar Messages
-
Updating/Inserting multiple tables
Hi,
I've been trying to figure out how to update/insert multiple fields in 2 different tables with one RowSet. im new to java and have been using Creator for about 2 weeks
basically there are 3 tables: one containing user info(USER), one containing department info (DEPT), and one table relating the two (USER_DEPT). my form lets uers update, among others, their NAME in table USER, and DEPT_NAME in table DEPT.
These are all VARCHAR types.
I used the Clips provided by Creator to initialize and do the updating. i am using updateRow() to do the updating. the fields are bound to specific database fields. the RowSet is updatable.
in my app i chose some specific fields, but for the sake of avoiding pasting very long SQL queries lets just say i chose everything. some of the queries i tried:
SELECT *
FROM USER WHERE USER.USERNAME = ?This one works.
SELECT *
FROM USER, DEPT, USER_DEPT
where USER.ID = USER_DEPT.USER_ID
and DEPT.ID = USER_DEPT.DEPT_ID AND USER.USERNAME = ?this one gives me a Conversion Error message. i have no conversion going on whatsoever. i havent even learned how to use conversion yet.
another query i tried:
SELECT * FROM USER
INNER JOIN USER_DEPT ON USER.ID = USER_DEPT.USER_ID
INNER JOIN DEPT ON DEPT.ID = USER_DEPT.DEPT_ID
WHERE USER.USERNAME=?this one gives me no error. the app works except the database doesnt get updated. i have determined that when using this query updateRow() is skipped. i dont know why. the app keeps running in that it goes to the next page as defined by the XML, but updateRow() is never called.
so can anyone please tell me how to update/insert multiple fields in multiple tables using one RowSet PLEASE?
THANKS!The only way this can be done with a single rowset is if you do your query against a view (instead of a join), and if your JDBC driver supports updates to multiple tables through a view. Otherwise, you're going to need to update the underlying tables individually.
Craig -
SQL Loader : Loading multiple tables using same ctl file
Hi ,
We tried loading multiple tables using the same ctl file but the data was not loaded and no errors were thrown.
The ctl file content is summarised below :
LOAD DATA
APPEND INTO TABLE TABLE_ONE
when record_type ='EVENT'
TRAILING NULLCOLS
record_type char TERMINATED BY ',' ,
EVENT_SOURCE_FIELD CHAR TERMINATED BY ',' ENCLOSED BY '"',
EVENT_DATE DATE "YYYY-MM-DD HH24:MI:SS" TERMINATED BY ',' ENCLOSED BY '"',
EVENT_COST INTEGER EXTERNAL TERMINATED BY ',' ENCLOSED BY '"',
EVENT_ATTRIB_1 CHAR TERMINATED BY ',' ENCLOSED BY '"',
VAT_STATUS INTEGER EXTERNAL TERMINATED BY ',' ENCLOSED BY '"',
ACCOUNT_REFERENCE CONSTANT 'XXX',
bill_date "to_date('02-'||to_char(sysdate,'mm-yyyy'),'dd-mm-yyyy')",
data_date "trunc(sysdate)",
load_date_time "sysdate"
INTO TABLE TABLE_TWO
when record_type ='BILLSUMMARYRECORD'
TRAILING NULLCOLS
RECORD_TYPE char TERMINATED BY ',' ,
NET_TOTAL INTEGER EXTERNAL TERMINATED BY ',' ENCLOSED BY '"',
LOAD_DATE_TIME "sysdate"
INTO TABLE BILL_BKP_ADJUSTMENTS
when record_type ='ADJUSTMENTS'
TRAILING NULLCOLS
RECORD_TYPE char TERMINATED BY ',' ,
ADJUSTMENT_NAME CHAR TERMINATED BY ',' ENCLOSED BY '"',
LOAD_DATE_TIME "sysdate"
INTO TABLE BILL_BKP_CUSTOMERRECORD
when record_type ='CUSTOMERRECORD'
TRAILING NULLCOLS
RECORD_TYPE char TERMINATED BY ',' ,
GENEVA_CUSTOMER_REF CHAR TERMINATED BY ',' ENCLOSED BY '"',
LOAD_DATE_TIME "sysdate"
INTO TABLE TABLE_THREE
when record_type ='PRODUCTCHARGE'
TRAILING NULLCOLS
RECORD_TYPE char TERMINATED BY ',' ,
PROD_ATTRIB_1_CHRG_DESC CHAR TERMINATED BY ',' ENCLOSED BY '"',
LOAD_DATE_TIME "sysdate"
Has anyone faced similar errors or are we going wrong somewhere ?
Regards,
SandipanThis is the info on the discard in the log file :
Record 1: Discarded - failed all WHEN clauses.
Record 638864: Discarded - failed all WHEN clauses.
While some of the records were loaded for one table.
Regards,
Sandipan -
Hi friends, need help with the following
I need to convert the following SQL Server query to Oracle Pl/sql
UPDATE
perf
SET perf.value5 = tmp.storeCount
FROM dplapro1..ix_spc_performance perf
INNER JOIN dplapro1..ix_spc_planogram plano ON plano.dbkey = perf.dbparentplanogramkey
INNER JOIN #TMP_StoreCount tmp ON plano.dbkey6 = tmp.cmkey
WHERE
perf.dbparentproductkey = tmp.productkey
I did the following:
UPDATE dplapro1.ix_spc_performance perf
SET perf.value5 =
SELECT tmp.storeCount
FROM dplapro1.ix_spc_performance perf
INNER JOIN dplapro1.ix_spc_planogram plano
ON plano.dbkey = perf.dbparentplanogramkey
INNER JOIN tt_433_storecount tmp
ON plano.dbkey6 = tmp.cmkey
WHERE perf.dbparentproductkey = tmp.productkey
which gives me error 'single row subquery returns more than one row',
Then I tried :
UPDATE dplapro1.ix_spc_performance perf
SET perf.value5 =
SELECT tmp.storeCount
FROM dplapro1.ix_spc_performance perf
INNER JOIN dplapro1.ix_spc_planogram plano
ON plano.dbkey = perf.dbparentplanogramkey
INNER JOIN tt_433_storecount tmp
ON plano.dbkey6 = tmp.cmkey
WHERE perf.dbparentproductkey = tmp.productkey
where perf.ROWID IN
SELECT perf.ROWID
FROM dplapro1.ix_spc_performance perf
INNER JOIN dplapro1.ix_spc_planogram plano
ON plano.dbkey = perf.dbparentplanogramkey
INNER JOIN tt_433_storecount tmp
ON plano.dbkey6 = tmp.cmkey
WHERE perf.dbparentproductkey = tmp.productkey
no luck with this either
Please help me with this
ThanksI think something like this will do it for you
MERGE
INTO dplapro1.ix_spc_performance D
USING ( SELECT productkey,
storecount
FROM dplapro1.ix_spc_planogram plano
INNER JOIN tt_433_storecount tmp
ON plano.dbkey6 = tmp.cmkey
WHERE perf.dbparentproductkey = tmp.productkey ) S
ON ( D.dbparentproductkey = S.productkey )
WHEN MATCHED THEN UPDATE
SET D.value5 = s.storecount;You need to make sure that the source of the updates - USING clause - returns at most one row for each key in the destination, based on the ON clause. That is, in this case, only one productkey for each dbparentproductkey . -
SQL Loader and multiple tables
I know how to load multiple tables using the same set of data, but is it possible to load multiple tables using a different set of data for each table? Can someone point me to an example or tell me how to set up the ctl file.
Thanks.http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10825/ldr_control_file.htm#sthref852
Distinguishing Different Input Record Formats
A single datafile might contain records in a variety of formats. Consider the following data, in which emp and dept records are intermixed:
1 50 Manufacturing — DEPT record
2 1119 Smith 50 — EMP record
2 1120 Snyder 50
1 60 Shipping
2 1121 Stevens 60
A record ID field distinguishes between the two formats. Department records have a 1 in the first column, while employee records have a 2. The following control file uses exact positioning to load this data:
INTO TABLE dept
WHEN recid = 1
(recid FILLER POSITION(1:1) INTEGER EXTERNAL,
deptno POSITION(3:4) INTEGER EXTERNAL,
dname POSITION(8:21) CHAR)
INTO TABLE emp
WHEN recid <> 1
(recid FILLER POSITION(1:1) INTEGER EXTERNAL,
empno POSITION(3:6) INTEGER EXTERNAL,
ename POSITION(8:17) CHAR,
deptno POSITION(19:20) INTEGER EXTERNAL) -
SQl Developer - making multiple tables
I have the following code:
CREATE TABLE "STAFF"
"STA_ID" VARCHAR2(20 BYTE) NOT NULL ENABLE,
"STA_SURNAME" VARCHAR2(20 BYTE),
"STA_FIRSTNAME" VARCHAR2(20 BYTE),
"STA_STARTDATE" DATE,
"STA_JOBTITLE" VARCHAR2(20 BYTE),
"STA_SALARY" NUMBER,
"STA_ACTIVE" VARCHAR2(20 BYTE),
"STA_STAMP" VARCHAR2(20 BYTE),
PRIMARY KEY ("STA_ID"),
CONSTRAINT staff_ck_sta_salary CHECK (STA_SALARY>0 AND STA_SALARY<100000.00)
CREATE TABLE "HIRE"
"HIR_ID" VARCHAR2(20 BYTE) NOT NULL ENABLE,
"HIR_BRA_ID" VARCHAR2(20 BYTE),
"HIR_CUS_ID" VARCHAR2(20 BYTE),
"HIR_STA_ID" VARCHAR2(20 BYTE),
"HIR_HIREDATE" DATE,
"HIR_DUEDATE" DATE,
"HIR_RETURNDATE" DATE,
"HIR_CHARGE" VARCHAR2(20 BYTE),
"HIR_PENALTY" VARCHAR2(20 BYTE),
"HIR_TOTALPAID" NUMBER,
"HIR_COMMENTS" VARCHAR2(50 BYTE),
"HIR_STAMP" VARCHAR2(20 BYTE),
PRIMARY KEY ("HIR_ID")
In SQL Developer, if I select the SQL code for each table individually, I can run the statement and create each table. My question is this... can I select both lots of code and then create the tables with one press of the run statement button. I am asking this because I have many tables, and it is slow to do each one, one at a time.
thanks
CanningHi,
that is possible in sql * plus. but i don't know that option is there in sql developer or not.
i think you have the sql plus so you can execute from that also. -
Hi gurus,
I have a question about buildings sql trees over several tables.
This is the Output I hope for:
0
- 10, 'Company Blue1', 0
-- 101, 'Part Blue1', 10
--- 1001, 'Accounting Blue', 101
---- 10001, 'Hans Mueller', 1001
--- 1002, 'Special Problems Blue', 101
---- 10002, 'Stephen Meyer', 1002
---- 10003, 'Carlos Anceto', 1002
-- 102, 'Part Blue2', 10
--- 1003, 'Information Technology Blue', 102
---- 10004, 'Tobias Tries', 1003
- 20, 'Company Red1', 0
-- 201, 'Part Red1', 20
--- 2001, 'Accounting Red', 201
---- 20001, 'Carl Van Deser', 2001
---- 20002, 'Geromel Boats', 2002
- 30, 'Company Green1', 0
-- 301, 'Part Green1', 30
--- 3001, 'Accounting Green', 301
---- 30002, 'Peter Finnighan', 3001
--- 3003, 'Special Problems Green', 301
---- 30001, 'Loui Van Ecke', 3003This is the situation: I have 4 table which can be constraint by foreign key and all toghether build up a tree.
Table1:
tbl_company (c_id, company_name)
Values:
10, 'Company Blue1'
20, 'Company Red1'
30, 'Company Green1'
Table2:
tbl_company_parts (cp_id, part_name, company_id)
Values:
101, 'Part Blue1', 10
102, 'Part Blue2', 10
201, 'Part Red1',20
301, 'Part Green1',30
Table3:
tbl_departments (d_id, dept_name, part_id)
Values:
1, 'Accounting Blue', 101
2, 'Special Problems Blue', 101
3, 'Information Technology Blue', 102
4, 'Accounting Red',201
5, 'Accounting Green',301
6, 'Special Problems Green',301
Tablemployees (e_id, dept_name, department_id)
Values:
1, 'Hans Mueller', 1
2, 'Stephen Meyer', 2
3, 'Carlos AncetoÄ, 2
4, 'Carl Van Deser',4
5, 'Geromel Boats', 4
6, 'Loui Van Ecke',5
7, 'Peter Finnighan',6
8, 'Tobias Tries',3The problem is that I don't know how to concate alle these values and using the connect by clause creating this tree viewHi Tobias,
It was not exactly clear how the id's had to be calculated, but this example will get you going:
SQL> create table tbl_company (c_id, company_name)
2 as
3 select 10, 'Company Blue1' from dual union all
4 select 20, 'Company Red1' from dual union all
5 select 30, 'Company Green1' from dual
6 /
Table created.
SQL> create table tbl_company_parts (cp_id, part_name, company_id)
2 as
3 select 101, 'Part Blue1', 10 from dual union all
4 select 102, 'Part Blue2', 10 from dual union all
5 select 201, 'Part Red1',20 from dual union all
6 select 301, 'Part Green1',30 from dual
7 /
Table created.
SQL> create table tbl_departments (d_id, dept_name, part_id)
2 as
3 select 1, 'Accounting Blue', 101 from dual union all
4 select 2, 'Special Problems Blue', 101 from dual union all
5 select 3, 'Information Technology Blue', 102 from dual union all
6 select 4, 'Accounting Red',201 from dual union all
7 select 5, 'Accounting Green',301 from dual union all
8 select 6, 'Special Problems Green',301 from dual
9 /
Table created.
SQL> create table tbl_employees (e_id, emp_name, department_id)
2 as
3 select 1, 'Hans Mueller', 1 from dual union all
4 select 2, 'Stephen Meyer', 2 from dual union all
5 select 3, 'Carlos Anceto', 2 from dual union all
6 select 4, 'Carl Van Deser',4 from dual union all
7 select 5, 'Geromel Boats', 4 from dual union all
8 select 6, 'Loui Van Ecke',5 from dual union all
9 select 7, 'Peter Finnighan',6 from dual union all
10 select 8, 'Tobias Tries',3 from dual
11 /
Table created.
SQL> select coalesce
2 ( case when e.department_id is null then null else
3 trunc(d.part_id,-2) * 100 + dense_rank() over (partition by d.part_id order by e.e_id)
4 end
5 , trunc(d.part_id,-2) * 10 + dense_rank() over (partition by d.part_id order by d.d_id)
6 , p.cp_id
7 , c.c_id
8 , 0
9 ) id
10 , coalesce
11 ( e.emp_name
12 , d.dept_name
13 , p.part_name
14 , c.company_name
15 ) name
16 , coalesce
17 ( trunc(d.part_id,-2) * 10 + dense_rank() over (partition by d.part_id order by d.d_id)
18 , d.part_id
19 , p.company_id
20 , case grouping(c.c_id) when 0 then 0 end
21 ) parent_id
22 from tbl_company c
23 , tbl_company_parts p
24 , tbl_departments d
25 , tbl_employees e
26 where c.c_id = p.company_id
27 and p.cp_id = d.part_id
28 and d.d_id = e.department_id
29 group by rollup
30 ( ( c.c_id,c.company_name)
31 , ( p.cp_id,p.part_name,p.company_id)
32 , ( d.d_id,d.dept_name,d.part_id)
33 , ( e.e_id,e.emp_name,e.department_id)
34 )
35 order by c.c_id nulls first
36 , p.cp_id nulls first
37 , d.d_id nulls first
38 , e.e_id nulls first
39 /
ID NAME PARENT_ID
0
10 Company Blue1 0
101 Part Blue1 10
1001 Accounting Blue 1001
10001 Hans Mueller 1001
1002 Special Problems Blue 1002
10002 Stephen Meyer 1002
10003 Carlos Anceto 1002
102 Part Blue2 10
1001 Information Technology Blue 1001
10001 Tobias Tries 1001
20 Company Red1 0
201 Part Red1 20
2001 Accounting Red 2001
20001 Carl Van Deser 2001
20002 Geromel Boats 2001
30 Company Green1 0
301 Part Green1 30
3001 Accounting Green 3001
30001 Loui Van Ecke 3001
3002 Special Problems Green 3002
30002 Peter Finnighan 3002
22 rows selected.Regards,
Rob. -
SQL query with multiple tables - what is the most efficient way?
Hello I am learning PL/SQL. I have a simple procedure where I need to find number of employees and departments per location as per user input of location_id.
I have 3 Tables:
LOCATIONS
location_id (pk)
location_name
DEPARTMENTS
department_id (pk)
location_id (fk)
department_name
EMPLOYEES
employee_id (pk)
department_id (fk)
employee_name
1 Location can have 0-MANY Departments
1 Employee has 1 Department
Here is the query I came up with for PL/SQL procedure:
/*Ecount, Dcount are NUMBER variables */
SELECT SUM (EmployeeCount), COUNT(DepartmentNumber)
INTO Ecount, Dcount
FROM
(SELECT COUNT(employee_id) EmployeeCount, department_id DepartmentNumber
FROM employees
GROUP BY department_id
HAVING department_id IN
(SELECT department_id
FROM departments
WHERE location_id = userInput));
I do get the correct result, but I am just wondering if my query is on the right track and if there is a more "efficient" way of doing this.
Thanks in advance for helping a newbie out.Hi,
Welcome to the forum!
Something like this will be more efficient:
SELECT COUNT (employee_id) AS ECount
, COUNT (DISTINCT department_id) AS DCount
FROM employees
WHERE department_id IN ( SELECT department_id
FROM departments
WHERE location_id = :userInput
;You should also try a join instead of the IN subquery.
For efficiency, do only the things you need to do.
For example, you don't need a count of employees in each department, so don't compute one. That means you won't need the in-line view, so don't have one.
You don't need PL/SQL for this job, so don't use PL/SQL if you don't have to. (I realize this question was out of context, so you may have good reasons for doing this in PL/SQL.)
Do all filtering as early as possible. Don't waste effort computing things that won't be used .
A particular example of this is: Never use a HAVING clause when you can use a WHERE clause. What's the difference between a WHERE clause and a HAVING clause? The WHERE clause is applied before aggregate functions are computed, and the HAVING clause is applied after; there's no other difference. Therefore, if the HAVING clause isn't referencing an aggregate function, it could be done in a WHERE clause instead. -
Sql query across multiple tables ina database
I have 3 MS Access tables in database that are linked by keyed fields in the table. Is there a way to fetch only certain records that match a criteria across all three of these tables using the database connectivity toolset VIs?
Thanks. I am trying to mechanize/run an SQL query like this
SELECT Code_Type.Code_NUM, Code_Type.Code_Word, Word_Type.Parm_Label, Word_Type.Word_Sequence, Word_Type.Num_Words, Parameter_Label.Parm_Label, Parameter_Label.Parm_Name, Parameter_Label.Num_Bits, Parameter_Label.Num_Bits
FROM (Code_Type INNER JOIN Word_Type ON Code_Type.Code_Word = Word_Type.Code_Word) INNER JOIN Parameter_Label ON Word_Type.Parm_Label = Parameter_Label.Parm_Label;
while using the VIs in the database connectivity toolset. How do I code this using these VIs? I dont see an example of a straight SQL string like this being able to be put into the VIs. -
SQL query involving multiple tables
I have a scenario in SQL where For each post there are associated tags. A user is one who makes post and he belongs to a particular location. The location corresponds to a particular country.
I create tables as
CREATE TABLE post_table
post_id VARCHAR(20),
user_id VARCHAR(20),
PRIMARY KEY(post_id)
CREATE TABLE tags_table
post_id VARCHAR(20),
tags VARCHAR(20),
PRIMARY KEY(tags, post_id),
FOREIGN KEY(post_id) REFERENCES post_table(post_id) ON DELETE CASCADE
CREATE TABLE location
location_id VARCHAR(20),
country VARCHAR(20),
PRIMARY KEY (location_id)
CREATE TABLE user_info
user_id VARCHAR(20),
location_id VARCHAR(30),
PRIMARY KEY (user_id),
FOREIGN KEY(location_id) REFERENCES location(location_id) ON DELETE CASCADE
);Now, I insert values in these tables as
INSERT INTO post_table VALUES( 'p1', 'u1' );
INSERT INTO post_table VALUES( 'p2', 'u1' );
INSERT INTO post_table VALUES( 'p3', 'u2' );
INSERT INTO post_table VALUES( 'p4', 'u3' );
INSERT INTO post_table VALUES( 'p5', 'u2' );
INSERT INTO tags_table VALUES( 'p1', 'US Open' );
INSERT INTO tags_table VALUES( 'p1', 'Real good' );
INSERT INTO tags_table VALUES( 'p1', 'Madrid' );
INSERT INTO tags_table VALUES( 'p2', 'Madrid' );
INSERT INTO tags_table VALUES( 'p3', 'Rossoneri' );
INSERT INTO tags_table VALUES( 'p4', 'Milan' );
INSERT INTO tags_table VALUES( 'p4', 'Los Angeles' );
INSERT INTO tags_table VALUES( 'p5', 'Rossoneri' );
INSERT INTO location VALUES( 'loc1', 'Spain');
INSERT INTO location VALUES( 'loc2', 'England');
INSERT INTO user_info VALUES( 'u1', 'loc1' );
INSERT INTO user_info VALUES( 'u2', 'loc2' );
INSERT INTO user_info VALUES( 'u3', 'loc1' );Now I have to fire a query For each country, display the most seen tag(s)
So for this data the result should be like
Country MostTags
Spain Madrid
England RossoneriPlease help me write this query guys.Hi,
Something like this
select country
, tags from
select l.country
, t.tags
, dense_rank() over ( partition by l.country
order by count(*) desc) drn
from location l
, user_info u
, post_table p
, tags_table t
where l.location_id = u.location_id
and p.user_id=u.user_id
and p.post_id=t.post_id
group by l.country
, t.tags
where drn <=1 -- rank depends on like 1,2 or 3 popular tags for each countryRegards
Anurag -
Pure SQL of Select query on multiple tables in DB Adapter
I am trying use pure sql approach for a custom sql query on multiple tables for a DB adapter by modifying toplink_mappings.xml. But i am not getting other tables in my xsd. Please help.
hi Ravi,
can you pls be a bit clear? what is this about? where you are using?
thanks,
sneha. -
How to alter a Form to modify multiple tables
I want to create a form that will insert or update into multiple tables at once.
I have provided a picture of what i have in mind: http://imageshack.us/photo/my-images/21/custformexample.jpg
In this example I have 3 tables:
Customer (Cust_ID, Name,Address,Email,Phone);
Account_Manager(AM_ID, Name,Address,Email);
Customer_Account_Managers(Cust_ID,AM_ID);
A customer can have 0 to many Account Managers.
I have created a form on table with report with which I can see a report of all customers and click Edit to edit a customer or Create to create a new one.
In this form I want to add a select list that includes all Managers (I know how to create a select list and how to access it's value). I also want a report on the Account Managers which are associated with the customer, and I want to be able to add to this list, which will be saved into the Customer_Account_managers table as soon as i click Save.
Please provide me with some tips as to how to do this.
Thanks a lot!Always include the following information when asking a question:
<ul>
<li>Full APEX version</li>
<li>Full DB/version/edition/host OS</li>
<li>Web server architecture (EPG, OHS or APEX listener/host OS)</li>
<li>Browser(s) and version(s) used</li>
<li>Theme</li>
<li>Template(s)</li>
<li>Region/item type(s)</li>
</ul>
popovitsj wrote:
I want to create a form that will insert or update into multiple tables at once.
I have provided a picture of what i have in mind: http://imageshack.us/photo/my-images/21/custformexample.jpg
In this example I have 3 tables:
Customer (Cust_ID, Name,Address,Email,Phone);
Account_Manager(AM_ID, Name,Address,Email);
Customer_Account_Managers(Cust_ID,AM_ID);
A customer can have 0 to many Account Managers.
I have created a form on table with report with which I can see a report of all customers and click Edit to edit a customer or Create to create a new one.
In this form I want to add a select list that includes all Managers (I know how to create a select list and how to access it's value). I also want a report on the Account Managers which are associated with the customer, and I want to be able to add to this list, which will be saved into the Customer_Account_managers table as soon as i click Save.You can create a database views based on these tables, and create a instead of insert/update/delete trigger to populate the corresponding tables when fired.
Create an APEX form using wizard based on this database view. -
I am trying to create a report using portal that use links between multiple columns. The info I want is mainly in two tables. Some of the info in the table is numeric (Foreign Keys). I want to display them in readable format so set up joins to the respective parent tables. When I do this the result only produces 12 lines of output irrespective of the number of lines I set per page. When I show only the data from the main tables, without the joins to the other parent tables, i.e. the foreign keys as numbers I get all the rows. I have tried to create the report by using all three options given but get the same result.
I am using 9iAS verison 1.0.2.0 and Portal version 3.0.7.
Can someone please explain why this happens and how I can solve this problem urgently.Hi Ashok,
Sorry for posting the solution with delay. Actually I ran into the similar situation and upon deep analysis, I could crack it., the very next day.
This is how your write back template should be for updating on multiple tables
<?xml version="1.0" encoding="utf-8" ?>
<WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1">
<WebMessageTable lang="en-us" system="WriteBack" table="Messages">
<WebMessage name="WRITE">
<XML>
<writeBack connectionPool="Oracle Data Warehouse Connection Pool">
<insert> </insert>
<update> UPDATE FACT SET COUNT = '@{c4}', W_UPDATE_DT = CURRENT_DATE
WHERE EXISTS (SELECT ROW_WID FROM DIM WHERE DIM.ROW_WID = FACT.DIM_WID AND
DIM.X = '@{c1}' AND DIM.Y= '@{c2}' AND DIM.Z = '@{c3}' ) AND EXISTS (SELECT ROW_WID FROM DT WHERE DT.ROW_WID = FACT.DT_WID AND DT.PER_NAME_YEAR = '@{c0}') </update>
</writeBack>
</XML>
</WebMessage>
</WebMessageTable>
</WebMessageTables>
=====
Using exits, will improve the performance.
Hope it helps. If yes, pls award points. Thanks
Regards,
Sarat Nallapati -
How to update flag in multiple tables using custom sql DB adapter
hi all,
I have a scenario: I want to update flags in multiple tables in DB2. I have used toplink update only to update all tabless after creating relationships between them. But that approach is not working as it couldnot detect emmisions with DB2 and update the complete record with blank values in other columns.
So, i want to use custom sql now. Can anybody help in resolving the issue or in writing the custom sql.
Regards
RichaDear SeánMacGC thanks for reply,
But "a.changed" is not a field in GNMT_CUSTOMER_MASTER_CHG. what i am doing in this procedure is i am collecting bulck data and validating field by field from GNMT_CUSTOMER_MASTER_CHG with GNMT_CUSTOMER_MASTER table as their structure is same.. if v_name is not same as v_name_chg then i am setting changed flag to "Y" changed is "changed dbms_sql.varchar2_table" and updating GNMT_CUSTOMER_MASTER in bluck where changed flag ='Y'...
type custRec is record
n_cust_ref_no dbms_sql.number_table,
v_name dbms_sql.varchar2_table,
v_name_chg dbms_sql.varchar2_table,
rowid rowidArray,
*changed dbms_sql.varchar2_table*
i cannot use simple SQL as i need to validate field for each records with GNMT_CUSTOMER_MASTER_CHG and insert into log file as well.....
to run this procedure:
execute DO_DC_NAME_UPDATE_OTHER_TAB.DO_NAME_UPDATE_OTHER_TAB;
Thanks... -
How to update fields in multiple tables ?
Dear all,
What is the fastest way to update fields in multiple tables... from a single change table...as below is my code to update the fields but it is taking long time to update as i need to keep log file if any one update fails....
CREATE OR REPLACE
package body DO_DC_NAME_UPDATE_OTHER_TAB
as
type rowidArray is table of rowid index by binary_integer;
type custRec is record
n_cust_ref_no dbms_sql.number_table,
v_name dbms_sql.varchar2_table,
v_name_chg dbms_sql.varchar2_table,
rowid rowidArray,
changed dbms_sql.varchar2_table
procedure VALIDATE_CUST_NAME( p_n_cust_ref_no in number,p_v_name_chg in out NOCOPY varchar2, p_changed in out NOCOPY varchar2 )
is
begin
FOR cr_cust IN (SELECT --a.n_cust_ref_no,a.v_name,UPD_V_NAME, a.n_weight,a.V_LASTUPD_INFTIM
from GNMT_CUSTOMER_MASTER_CHG where n_cust_ref_no=p_n_cust_ref_no)
loop
-- v_name
if nvl(trim(cr_cust.v_name),0) != nvl(p_v_name_chg,0)
then
p_v_name_chg := p_v_name_chg;
--p_v_name := p_v_name;
p_changed := 'Y';
end if;
end loop;
end;
procedure DO_NAME_UPDATE_OTHER_TAB
is
l_record custRec;
l_array_size number default 20000;
l_done boolean;
l_cnt number default 1;
cursor c is select a.n_cust_ref_no, a.v_name,a.v_name_chg, a.rowid, 'N'
from GNMT_CUSTOMER_MASTER_CHG a--,GNMT_CUSTOMER_MASTER b
where a.v_name <> trim(a.v_name_chg); --and a.n_cust_ref_no in (1434775,1561181,1601870);
begin
open c;
loop
dbms_application_info.set_client_info
( 'processing ' || l_cnt || ' thru ' || (l_cnt+l_array_size-1) );
fetch c bulk collect into l_record.n_cust_ref_no, l_record.v_name,l_record.v_name_chg,l_record.rowid, l_record.changed
LIMIT l_array_size;
l_done := c%notfound;
--dbms_output.put_line ('message10');
for i in 1 .. l_record.n_cust_ref_no.count
loop
VALIDATE_CUST_NAME(l_record.n_cust_ref_no(i),l_record.v_name_chg(i),l_record.changed(i) );
end loop;
--dbms_output.put_line (l_record.n_cust_ref_no(i)||','||l_record.V_OCCUP_CODE(i)||','||l_record.CHANGED(i));
/*forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_CUSTOMER_MASTER q
set q.v_name = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_name) = l_record.v_name(i)
and l_record.changed(i) = 'Y';*/
-- update v_name in all the related tables
forall i in 1 .. l_record.n_cust_ref_no.count
update ADE_CUSTOMER_MASTER q
set q.v_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_name) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_POLICY_DETAIL q
set q.v_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_name) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_QUOTATION_DETAIL q
set q.v_NAME =l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_name) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update NBDT_BENEFICIARY q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSDT_NOMINATION_TRANSACTION q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSMT_POLICY_BENEFICIARY q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSMT_POLICY_TRUSTEE q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSMT_QUOTATION_BENEFICIARY q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PSMT_QUOTATION_TRUSTEE q
set q.V_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_NAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNDT_BLACKLIST_DETAIL q
set q.v_FNAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_FNAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_FNAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update INDT_LIAM_DETAIL q
set q.v_FNAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.v_FNAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.v_FNAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_POLICY q
set q.V_PAYER_NAME = l_record.v_name_chg(i)
where q.N_PAYER_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_PAYER_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PAYER_NAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_QUOTATION q
set q.V_PAYER_NAME = l_record.v_name_chg(i)
where q.N_PAYER_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_PAYER_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PAYER_NAME is not null;
commit;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_QUOTATION q
set q.V_PROPOSER_NAME = l_record.v_name_chg(i)
where q.N_PROPOSER_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_PROPOSER_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PROPOSER_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update GNMT_POLICY q
set q.V_PROPOSER_NAME = l_record.v_name_chg(i)
where q.N_PROPOSER_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_PROPOSER_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PROPOSER_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update CLMT_CLAIM_MASTER q
set q.V_CLIENT_NAME = l_record.v_name_chg(i)
where q.N_CLIENT_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_CLIENT_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_CLIENT_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update CLMT_CLAIM_MASTER q
set q.V_INTIMATOR_NAME = l_record.v_name_chg(i)
where q.N_CLIENT_REF_NO = l_record.n_cust_ref_no(i)
and trim(q.V_INTIMATOR_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_INTIMATOR_NAME is not null;
forall i in 1 .. l_record.n_cust_ref_no.count
update PYMT_VOU_MASTER q
set q.V_PAYEE_NAME = l_record.v_name_chg(i)
where q.n_cust_ref_no = l_record.n_cust_ref_no(i)
and trim(q.V_PAYEE_NAME) = l_record.v_name(i)
and l_record.changed(i) = 'Y'
and q.V_PAYEE_NAME is not null;
/*forall i in 1 .. l_record.n_cust_ref_no.count
INSERT INTO GNMT_CUSTOMER_MASTER_LOG
(N_CUST_REF_NO, V_TITLE_CODE, V_NAME, D_BIRTH_DATE, V_SEX, V_RELIGION_CODE, V_NATION_CODE, V_OCCUP_CODE, V_ALIVE, V_SMOKER,
N_NO_STICKS, D_DEATH_DATE, V_BUMI_NON_BUMI, V_AGE_ADMITTED, V_SHORT_NAME, V_FIRST_NAME, V_LAST_NAME, V_EMAIL, V_DESIGNATION,
N_HEIGHT,N_WEIGHT,V_TITLE_CODE_CHG, V_NAME_CHG, D_BIRTH_DATE_CHG, V_SEX_CHG,V_RELIGION_CODE_CHG,V_NATION_CODE_CHG, V_OCCUP_CODE_CHG, V_ALIVE_CHG,
V_SMOKER_CHG, N_NO_STICKS_CHG, D_DEATH_DATE_CHG,V_BUMI_NON_BUMI_CHG, V_AGE_ADMITTED_CHG, V_SHORT_NAME_Chg, V_FIRST_NAME_Chg,
V_LAST_NAME_Chg, V_EMAIL_Chg, V_DESIGNATION_Chg,N_HEIGHT_Chg,N_WEIGHT_Chg, V_UPD_STATUS_DC,-- V_LASTUPD_PROG, V_LASTUPD_INFTIM,
V_LASTUPD_USER_DC, V_LASTUPD_PROG_DC,V_LASTUPD_INFTIM_DC
SELECT N_CUST_REF_NO, V_TITLE_CODE, V_NAME, D_BIRTH_DATE, V_SEX, V_RELIGION_CODE, V_NATION_CODE, V_OCCUP_CODE, V_ALIVE, V_SMOKER,
N_NO_STICKS, D_DEATH_DATE, V_BUMI_NON_BUMI, V_AGE_ADMITTED, V_SHORT_NAME, V_FIRST_NAME, V_LAST_NAME, V_EMAIL, V_DESIGNATION,
N_HEIGHT,N_WEIGHT,V_TITLE_CODE_CHG, V_NAME_CHG, d_birth_date_chg, V_SEX_CHG, V_RELIGION_CODE_CHG,V_NATION_CODE_CHG, V_OCCUP_CODE_CHG, V_ALIVE_CHG,
V_SMOKER_CHG, N_NO_STICKS_CHG, D_DEATH_DATE_CHG, V_BUMI_NON_BUMI_CHG, V_AGE_ADMITTED_CHG, V_SHORT_NAME_Chg, V_FIRST_NAME_Chg,
V_LAST_NAME_Chg, V_EMAIL_Chg, V_DESIGNATION_Chg,N_HEIGHT_Chg,N_WEIGHT_Chg--, V_LASTUPD_USER, V_LASTUPD_PROG, V_LASTUPD_INFTIM
,'PROCESSED'
,user,--P_USER,
'DC_PAKAGE',
sysdate--P_DATE
FROM GNMT_CUSTOMER_MASTER_CHG where n_cust_ref_no =l_record.n_cust_ref_no(i)
--and n_cust_ref_no not in (select n_cust_ref_no from GNMT_CUSTOMER_MASTER_LOG);*/
exit when (l_done);
l_cnt := l_cnt + l_array_size;
end loop;
commit;
end;
end;
thank YouDear SeánMacGC thanks for reply,
But "a.changed" is not a field in GNMT_CUSTOMER_MASTER_CHG. what i am doing in this procedure is i am collecting bulck data and validating field by field from GNMT_CUSTOMER_MASTER_CHG with GNMT_CUSTOMER_MASTER table as their structure is same.. if v_name is not same as v_name_chg then i am setting changed flag to "Y" changed is "changed dbms_sql.varchar2_table" and updating GNMT_CUSTOMER_MASTER in bluck where changed flag ='Y'...
type custRec is record
n_cust_ref_no dbms_sql.number_table,
v_name dbms_sql.varchar2_table,
v_name_chg dbms_sql.varchar2_table,
rowid rowidArray,
*changed dbms_sql.varchar2_table*
i cannot use simple SQL as i need to validate field for each records with GNMT_CUSTOMER_MASTER_CHG and insert into log file as well.....
to run this procedure:
execute DO_DC_NAME_UPDATE_OTHER_TAB.DO_NAME_UPDATE_OTHER_TAB;
Thanks...
Maybe you are looking for
-
User Exit for T.Code : F110 - APP
Hi Guru's, My Company is developing the interface to 3rd party system. For that i have to send the all payment data to customized table. From custom table to 3rd party system. So Please Suggest the Suitable User Exit for F110 - Automatic payment Prog
-
Photoshop interface won't scale back to macbook screen size after screen change (27")
I have a macbook pro and use a larger 27" screen for working in Photoshop for example. So when i close Photoshop whilst using the large screen, it wouldnt scale when I go back to laptop screen mode. So if i forget to resize the window, it will appear
-
I have been using logic for a while, but just got a Midiman USB keyboard and wanted to do some midi tracks. The drivers are installed and it works and plays in Reason. I can record the midi notes in Logic, but there is no playback. Is there a reason
-
Regarding 1 sender and 2 receivers
Hi, i'm trying to do a scenario for 1 sender and 2 receivers. but the receiver is again based on the condition like...if my id = 1 then receiver should be a if 2 then receiver is b. please give me clear picture of the scenario. i need starting from s
-
I have an airport express and im using an 802.11b card. right now im 20 feet from my station through no walls, just across the room, and I have about half signal strength. why am i not getting the 150ft apple advertises? why not even 50 ft? I have fr