Update tables in a view
Is it possible to update the tables in a view?
After a long time, here is the answer: "It depends."
Peter
Similar Messages
-
Need to update table from Maintenance view (Very Urgent !!!)
Hi Abap Guru's,
I got a requirement where in I need to create a new Zprog so that it shld give a call to view v_abc and thru this view I need to update the table abc if any duplicate entries are entered then I shld popup a message.
Cld u plz help me out how to go further with this requirement and any suggestions...
if we create a table maintenance generator for the table abc then it will check for the duplicate entries are not ? if it checks for the duplicate entries then my job is done esaily but how to assign the zt-code to the table maintenance ?
awaiting for u r answer's and realyy appreciated with lots of points.
Regards,
Ravi V GanjiHi,
table generator will check duplicate entries as any
other table .
table maintanance Generator is used to manually
input values using transaction sm30
follow below steps
1) go to se11 check table maintanance check box under
attributes tab
2) utilities-table maintanance Generator->
create function group and assign it under
function group input box.
also assign authorization group default &NC& .
3)
select standard recording routine radio in table
table mainitainence generator to move table
contents to quality and production by assigning
it to request.
4) select maintaience type as single step.
5) maintainence screen as system generated numbers
this dialog box appears when you click on create
button
6) save and activate table
using sm30 you can create entries manually.
also check below thread to assign transaction code to
table generator
Re: Table Maintanance Generator
create transaction use se93
select parameter transaction and give below attributes
Transaction code ZTX1
Transaction text Maintain View ZSDCZTVIEW
Transaction SM30 Screen 0
From module pool
Name of screen field Value
VIEWNAME ZSDCZTVIEW
UPDATE X -
Want to update data in a view based on multiple tables
Hi
I am facing a problem i want to update data in tables using a view. As that view is based on multiple tables so i am unable to update data. i came to know we can update table from view only if view is based on single table. so if anyone knows any alternative please let me know.
Thanx
DevinderDevinder,
The table can be updated through a view based on multiple tables, if and only if the table is a "key preserved" table. Rather than explaining myself, i avoided the burden of typing by finding the material in Oracle Docs and pasting it for you :-)
If you want a join view to be updatable, all of the following conditions must be
true:
1. The DML statement must affect only one table underlying the join.
2. For an INSERT statement, the view must not be created WITH CHECK
OPTION, and all columns into which values are inserted must come from a
key-preserved table. A key-preserved table in one for which every primary
key or unique key value in the base table is also unique in the join view.
3. For an UPDATE statement, all columns updated must be extracted from a
key-preserved table. If the view was created WITH CHECK OPTION, join
columns and columns taken from tables that are referenced more than once
in the view must be shielded from UPDATE.
4. For a DELETE statement, the join can have one and only one key-preserved
table. That table can appear more than once in the join, unless the view was
created WITH CHECK OPTION.
HTH
Naveen -
How to update multiple records in a table created in view (web dynpro)
Here is my coding......
*coding to get the district value
DATA lo_nd_district TYPE REF TO if_wd_context_node.
DATA lo_el_district TYPE REF TO if_wd_context_element.
DATA ls_district TYPE wd_this->element_district.
DATA lv_district_txt LIKE ls_district-district_txt.
navigate from <CONTEXT> to <DISTRICT> via lead selection
lo_nd_district = wd_context->get_child_node( name = wd_this->wdctx_district ).
get element via lead selection
lo_el_district = lo_nd_district->get_element( ).
get single attribute
lo_el_district->get_attribute(
EXPORTING
name = `DISTRICT_TXT`
IMPORTING
value = lv_district_txt ).
*coding to diplay records when clicking a button(Submit)
DATA lo_nd_table TYPE REF TO if_wd_context_node.
DATA lo_el_table TYPE REF TO if_wd_context_element.
DATA ls_table TYPE wd_this->element_table.
DATA lv_district LIKE ls_table-district.
navigate from <CONTEXT> to <TABLE> via lead selection
lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
get element via lead selection
lo_el_table = lo_nd_table->get_element( ).
get single attribute
lo_el_table->set_attribute(
EXPORTING
name = `DISTRICT`
" IMPORTING
value = lv_district_txt ).
The above coding updates only one record to that
table created in view.
If i enter 2nd district value means then the first record
in the table is overwritten.
So my need is the record should not be overwritten.
it(2nd record ) should be displayed after the 1st record.
Any one can help me and send the coding plz....instead of using set attribute you should use bind table method to display/update the records in table view.
step1 ) collect all the data in a local table
step2 ) and the bind that lacal table with your node
search1 = wd_context->get_child_node( name = `TABLE1` ).
search1->bind_table( lt_detail)
here lt_detail is your local table and TABLE1 is node which is bound with table ui element. -
Update a table from a view (WITH)
Hello,
Is the below valid? Can I update table1 from table2 (view)?
Oracle is 9i
UPDATE
WITH t2 AS (
SELECT....................
SELECT t1.name n1, t2.name n2
FROM cell_info t1, t2
WHERE t1.cell = t2.cell
AND t1.name IS NULL
SET n1 = n2;
SQL Error: ORA-01732: data manipulation operation not legal on this view
01732. 00000 - "data manipulation operation not legal on this view"Hi,
there are cases where you can update an inline view :Scott@my10g SQL>create table t1 as select level id, chr(96+level) val
2 from dual
3 connect by level <= 6
4 /
Table created.
Scott@my10g SQL>create table t2 as select level id, cast(null as varchar2(30)) val
2 from dual
3 connect by level <= 6
4 /
Table created.
Scott@my10g SQL>alter table t1 add constraint t1_pk primary key (id);
Table altered.
Scott@my10g SQL>alter table t2 add constraint t2_pk primary key (id);
Table altered.
Scott@my10g SQL>select * from t1;
ID VAL
1 a
2 b
3 c
4 d
5 e
6 f
6 rows selected.
Scott@my10g SQL>select * from t2;
ID VAL
1
2
3
4
5
6
6 rows selected.
Scott@my10g SQL>update (
2 select t1.id, t1.val t1val, t2.val t2val
3 from t1
4 join t2
5 on t1.id=t2.id
6 )
7 set t2val=t1val
8 /
6 rows updated.
Scott@my10g SQL>select * from t2;
ID VAL
1 a
2 b
3 c
4 d
5 e
6 f
6 rows selected. -
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 -
Updating a Base Table through a View having UNPIVOT function.
Hi,
I have a requirement of updating a Base Table through a View.
This View has the query using a UNPIVOT function for displaying the columns of the Base tables in rows.
I need to update/insert into/delete the Base Table by accessing the View (The user doesn't have an access to the Base Table, hence the DML's on the View).
Following is the table I've created:-
CREATE TABLE PERSON_DETAILS
PID VARCHAR2(10 BYTE),
FIRSTNAME VARCHAR2(1000 BYTE),
LASTNAME VARCHAR2(1000 BYTE),
PHONENUMBER VARCHAR2(1000 BYTE),
ADDRESS1 VARCHAR2(1000 BYTE),
ADDRESS2 VARCHAR2(1000 BYTE),
COUNTRY_CODE VARCHAR2(1000 BYTE),
LANGUAGE_CODE VARCHAR2(1000 BYTE),
EMAIL VARCHAR2(1000 BYTE)
)The sample values are inserted in this table through the below script:-
insert into person_details values ('1','XYZ','ABC','1234567890','India','Asia','IN','EN','[email protected]');
insert into person_details values ('2','XYZ2','ABC2','1234567890','India','Asia','IN','EN','[email protected]');The code for the view is as below:-
CREATE OR REPLACE FORCE VIEW PERSON_DETAILS_VIEW
PID,
CD_NAME,
CD_VALUE
AS
SELECT "PID", "CD_NAME", "CD_VALUE"
FROM person_details UNPIVOT INCLUDE NULLS (cd_value
FOR cd_name
IN (firstname AS 'First Name',
lastname AS 'Last Name',
phonenumber AS 'Phonenumber',
address1 AS 'address1',
address2 AS 'address2',
country_code AS 'Country Code',
language_code AS 'Language Code',
email AS 'Email') );Below are the values from the view:-
PID CD_NAME CD_VALUE
1 First Name XYZ
1 Last Name ABC
1 Phonenumber 1234567890
1 address1 India
1 address2 Asia
1 Country Code IN
1 Language Code EN
1 Email [email protected]
2 First Name XYZ2
2 Last Name ABC2
2 Phonenumber 1234567890
2 address1 India
2 address2 Asia
2 Country Code IN
2 Language Code EN
2 Email [email protected] user would fire some statement like below:-
update person_details_view
set cd_value = 'US' where CD_NAME = 'IN'The above statement should update the base table PERSON_DETAILS.
I understand I can write an INSTEAD OF trigger but I do not know what logic to write in the trigger so that the requirement gets fulfilled.
My Oracle Version
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Solaris: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionAny help would be highly appreciated.
Thank You,
Ankit Khare.
Edited by: Ankit_Khare84 on Jun 28, 2012 2:47 PMit is definitively possible with an instead of trigger.
for Example:
create or replace
TRIGGER ioft_person
INSTEAD OF UPDATE
ON person_details_view
FOR EACH ROW
declare
firstname1 person_details.firstname%type;
BEGIN
SELECT firstname_new into firstname1
FROM (SELECT pid, cd_name, cd_value
FROM
select * from person_details_view where (pid, cd_name) not in (select :new.pid, :new.cd_name from dual)
union all
select :new.pid, :new.cd_name, :new.cd_value from dual
PIVOT ( max(cd_value) AS new FOR (cd_name) IN
('First Name' AS firstname,
'Last Name' as lastname,
'Phonenumber' as phonenumber,
'address1' as address1,
'address2' AS address2,
'Country Code' as country_code,
'Language Code' as language_code,
'Email' as email
) where pid = :old.pid;
UPDATE person_details
SET firstname = firstname1
WHERE pid = :old.pid;
END ioft_role_perm;and than run
update person_details_view
set cd_value = 'X|X' where cd_name = 'First Name' and pid=1The logic is: you must convert back the view through pivoting -
Problem regarding updation of Z-table through maintenance view
hi ,
I m facing problem in updation of Z-table through maintenance view (SM30).
The scenario is that I have one customizing field in my Z-table which is checkbox.
Now I need to populate 2 fields in Z-table on tick of this checkbox and clicking of SAVE button.
For this I have created one module ''change_field'' in PAI.
Actually my database table is being updated but as soon as the control left my module all the updation that take place vanishes away.....
So please help me in this matter.Thanks for ur previous effort it is updating the database but its effect is not shown immediately on screen.After i referesh the transaction it is dispalying the data.
So can u please suggest me any way....
Now i have one scenario infront of me....
I need to restrict the data shown in maintenance view.
I think it would be same as pop-up window displayed when we tick on 2nd radiobutton ("ENTER CONDITIONS")
of intial screen of t-code SM30.
Please suggest what shud i do....
Thanks and reagrds,
Amit
Edited by: amit gupta on Jul 18, 2008 1:35 PM -
I want o update the Table using the view of a table of different schema. A dblink is created between two schema's ?
Kindly suggest the method to implement this ?
What Form type should i use?
Its is possible to use collections?
Sanjayuser12957777 wrote:
I want o update the Table using the view of a table of different schema. A dblink is created between two schema's ?
Kindly suggest the method to implement this ?
What Form type should i use?
What do you mean by "connection"?
If you use a single database then just add schema's preffix and that's all.
under table owner:
insert into <table_name> select * from <schema>.<view>under view owner:
insert into <schema>.<table_name> select * from <view>But make sure your users get necessary grants. -
FRM-40602: Cannot insert into or update data in a view
Hi all!
I have a form based on a view and I want to get rid off this message.
I set the properties blocks query only but it still doesn't work.
Does someone met with this situation?
Many thanks!Hello
I've just been messing about with a similar problem. Basically, I have a view that involves a join across two tables, I have a data block in my form that's based on the view, and I've written an INSTEAD OF trigger to insert/update/delete from the two tables.
I was getting the error message 'Cannot insert or update data in a view', and it turned out that the error was happening because the join column between the two tables was the primary key on one of the tables, but the corresponding column on the join table had no unique key on it. This meant that Oracle couldn't establish a one-to-one relationship between rows in the view and rows in the underlying tables. The column on the join table was in fact unique on that table, and adding a unique constraint on that column in the database cured the problem.
Hope that's of use.
regards
Andrew
UK -
Hi,
trying to update data from a view with:
- Company (table)
- Products (table)
In a form, the user wants to update
e.g: both products.product_name and Company.company_name.
Is there a way to update a view records built on 2 tables ?
Any idea will be really appreciated
ThksAn other question on INSTEAD OF Trigger:
Base Tables:
1.
SQL> desc pcs_companies;
Name Null? Type
COMPANY_ID NOT NULL NUMBER(12)
COUNTRY VARCHAR2(350)
COMPANY_NAME VARCHAR2(320)
COMPANY_PHONE VARCHAR2 (320)
COMPANY_FAX VARCHAR2(320)
COMPANY_URL VARCHAR2(150)
UPDATED_DATE DATE
2.
SQL> desc pcs_individuals;
Name Null? Type
INDIVIDUAL_ID NOT NULL NUMBER(12)
COMPANY_ID NUMBER(12)
FIRST_NAME VARCHAR2(320)
LAST_NAME VARCHAR2(320)
LOB VARCHAR2(300)
JOB_ROLE VARCHAR2(300)
TITLE VARCHAR2(300)
GENDER VARCHAR2(3)
EMAIL VARCHAR2(720)
FAX VARCHAR2(720)
PHONE_NO VARCHAR2(720)
UPDATED_DATE DATE
COUNTRY VARCHAR2(150)
ADDRESS_1 VARCHAR2(720)
ADDRESS_2 VARCHAR2(720)
ADDRESS_3 VARCHAR2(720)
CITY VARCHAR2(720)
3. pcs_individuals.COMPANY_ID = FK, ref pcs_companies.
4.
SQL> CREATE VIEW V_PCS_COMPANY_IND
AS
SELECT
i.INDIVIDUAL_ID,
c.company_id,
c.country,
c.Company_name,
c.company_phone,
i.Company_id indiv_company_id,
i.gender,
i.first_name,
i.last_name,
i.lob,
i.job_role,
i.title,
i.email_address,
i.fax,
i.phone_no ,
i.address_1,
i.address_2,
i.address_3,
i.city
FROM
pcs_individuals i,
pcs_companies c
WHERE
i.company_id = c.company_id
5.
CREATE OR REPLACE TRIGGER PCS_ADMIN.PCS_COMP_IND_UPDATE_TR
INSTEAD OF UPDATE ON PCMS_ADMIN.V_PCS_COMPANY_IND
FOR EACH ROW
begin
update PCS_COMPANIES
set
Company_name = nvl(:new.company_name,company_name),
company_phone = nvl(:new.company_phone,company_phone)
where company_id = :new.company_id;
update PCS_INDIVIDUALS
set
gender = nvl(:new.gender,gender),
first_name = nvl(:new.first_name,first_name),
last_name = nvl(:new.last_name,last_name),
lob = nvl(:new.lob,lob),
title = nvl(:new.title,title),
email_address = nvl(:new.email_address,email_address),
phone_no = nvl(:new.phone_no,phone_no),
fax = nvl(:new.fax,fax),
country = nvl(:new.country,country),
address_1 = nvl(:new.address_1,address_1),
address_2 = nvl(:new.address_2,address_2),
address_3 = nvl(:new.address_3,address_3),
city = nvl(:new.city,city)
where company_id = :new.company_id;
end PCMS_COMP_IND_UPDATE_TR;
6.
CREATE OR REPLACE TRIGGER PCS_ADMIN.NEW_COMPANY_ID_INSERT
INSTEAD OF INSERT ON PCS_ADMIN.V_PCS_COMPANY_IND
DECLARE
ID number;
BEGIN
INSERT INTO pcs_companies (org_id)
select v_pcs_comp_id_seq.nextval
into ID
from dual;
:new.company_id = ID;
INSERT INTO pcs_individuals (company_id)
select v_pcs_comp_id_seq.nextval
into ID
from dual;
:new.company_id = ID;
end;
My question
On point 6:
Assumption:
- Company_id is PK of pcs.Company and FK in pcs.individuals
- It should be feed by sequence (v_pcs_comp_id_seq)
Now how can i insert the same value for company_id (current.v_pcs_comp_id_seq) in both pcs_companies and pcs_individuals ? I've tested it in the above INSTEAD OF Trigger.It failed.
Thks for any advice,
lamine -
Creating a better update table statement
Hello,
I have the following update table statement that I would like to make more effecient. This thing is taking forever. A little background. The source table/views are not indexed and the larger of the two only has 150k records. Any ideas on making more effecient would be appreciate.
Thanks.
Ryan
Script:
DECLARE
V_EID_CIV_ID SBI_EID_W_VALID_ANUM_V.SUBJECT_KEY%TYPE;
V_EID_DOE DATE;
V_EID_POE SBI_EID_W_VALID_ANUM_V.POINT_OF_ENTRY%TYPE;
V_EID_APPR_DATE DATE;
V_CASE_CIV_ID SBI_DACS_CASE_RECORDS.CASE_EID_CIV_ID%TYPE;
V_CASE_DOE DATE;
V_CASE_POE SBI_DACS_CASE_RECORDS.CASE_CODE_ENTRY_PLACE%TYPE;
V_CASE_APPR_DATE DATE;
V_CASE_DEPART_DATE DATE;
V_SBI_UPDATE_STEP SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP%TYPE;
V_SBI_CIV_ID SBI_DACS_CASE_RECORDS.SBI_CIV_ID%TYPE;
CURSOR VALID_CIV_ID_FROM_EID IS
SELECT EID.SUBJECT_KEY,
TO_DATE(EID.PROCESS_ENTRY_DATE),
EID.POINT_OF_ENTRY,
TO_DATE(EID.APPREHENSION_DATE),
DACS.CASE_EID_CIV_ID,
TO_DATE(DACS.CASE_DATE_OF_ENTRY,'YYYYMMDD'),
DACS.CASE_CODE_ENTRY_PLACE,
TO_DATE(DACS.CASE_DATE_APPR,'YYYYMMDD'),
TO_DATE(DACS.CASE_DATE_DEPARTED,'YYYYMMDD'),
DACS.SBI_UPDATE_STEP,
DACS.SBI_CIV_ID
FROM SBI_EID_W_VALID_ANUM_V EID,
SBI_DACS_CASE_RECORDS DACS
WHERE DACS.CASE_NBR_A = EID.ALIEN_FILE_NUMBER;
BEGIN
OPEN VALID_CIV_ID_FROM_EID;
SAVEPOINT A;
LOOP
FETCH VALID_CIV_ID_FROM_EID INTO V_EID_CIV_ID, V_EID_DOE, V_EID_POE,V_EID_APPR_DATE,V_CASE_CIV_ID, V_CASE_DOE,V_CASE_POE,V_CASE_APPR_DATE,V_CASE_DEPART_DATE,V_SBI_UPDATE_STEP,V_SBI_CIV_ID;
DBMS_OUTPUT.PUT_LINE('BEFORE');
EXIT WHEN VALID_CIV_ID_FROM_EID%FOUND;
DBMS_OUTPUT.PUT_LINE('AFTER');
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_CASE_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 1
WHERE V_CASE_CIV_ID IS NOT NULL
AND V_CASE_CIV_ID <> 0;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 2
WHERE V_SBI_CIV_ID IS NULL AND V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE
AND V_EID_APPR_DATE = V_CASE_DEPART_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 3
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 4
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4 ;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 5
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE <> V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 6
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 7
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 8
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 9
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 10
WHERE V_SBI_UPDATE_STEP = 0
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
END LOOP;
CLOSE VALID_CIV_ID_FROM_EID;
COMMIT;
END;
-----Thats it. Thanks for your help.
RyanPlease use [ code] or [ pre] tags to format code before posing:
DECLARE
V_EID_CIV_ID SBI_EID_W_VALID_ANUM_V.SUBJECT_KEY%TYPE;
V_EID_DOE DATE;
V_EID_POE SBI_EID_W_VALID_ANUM_V.POINT_OF_ENTRY%TYPE;
V_EID_APPR_DATE DATE;
V_CASE_CIV_ID SBI_DACS_CASE_RECORDS.CASE_EID_CIV_ID%TYPE;
V_CASE_DOE DATE;
V_CASE_POE SBI_DACS_CASE_RECORDS.CASE_CODE_ENTRY_PLACE%TYPE;
V_CASE_APPR_DATE DATE;
V_CASE_DEPART_DATE DATE;
V_SBI_UPDATE_STEP SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP%TYPE;
V_SBI_CIV_ID SBI_DACS_CASE_RECORDS.SBI_CIV_ID%TYPE;
CURSOR VALID_CIV_ID_FROM_EID IS
SELECT EID.SUBJECT_KEY,
TO_DATE(EID.PROCESS_ENTRY_DATE),
EID.POINT_OF_ENTRY,
TO_DATE(EID.APPREHENSION_DATE),
DACS.CASE_EID_CIV_ID,
TO_DATE(DACS.CASE_DATE_OF_ENTRY,'YYYYMMDD'),
DACS.CASE_CODE_ENTRY_PLACE,
TO_DATE(DACS.CASE_DATE_APPR,'YYYYMMDD'),
TO_DATE(DACS.CASE_DATE_DEPARTED,'YYYYMMDD'),
DACS.SBI_UPDATE_STEP,
DACS.SBI_CIV_ID
FROM SBI_EID_W_VALID_ANUM_V EID,
SBI_DACS_CASE_RECORDS DACS
WHERE DACS.CASE_NBR_A = EID.ALIEN_FILE_NUMBER;
BEGIN
OPEN VALID_CIV_ID_FROM_EID;
SAVEPOINT A;
LOOP
FETCH VALID_CIV_ID_FROM_EID INTO V_EID_CIV_ID, V_EID_DOE,
V_EID_POE,V_EID_APPR_DATE,V_CASE_CIV_ID, V_CASE_DOE,
V_CASE_POE,V_CASE_APPR_DATE,V_CASE_DEPART_DATE,V_SBI_UPDATE_STEP,V_SBI_CIV_ID;
DBMS_OUTPUT.PUT_LINE('BEFORE');
EXIT WHEN VALID_CIV_ID_FROM_EID%FOUND;
DBMS_OUTPUT.PUT_LINE('AFTER');
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_CASE_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 1
WHERE V_CASE_CIV_ID IS NOT NULL
AND V_CASE_CIV_ID <> 0;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 2
WHERE V_SBI_CIV_ID IS NULL AND V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE
AND V_EID_APPR_DATE = V_CASE_DEPART_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 3
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 4
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4 ;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 5
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE <> V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 6
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 7
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 8
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 9
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 10
WHERE V_SBI_UPDATE_STEP = 0
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
END LOOP;
CLOSE VALID_CIV_ID_FROM_EID;
COMMIT;
END;Peter D. -
Help with UPDATE table and database RELATIONSHIPS
HI there, I have been trying to create an update table for
weeks now and keep getting error messages.
The database has a table named:
"books" in the table cells are "idbook" and "book".
"suppliers" in the table cells are "idsupplier" and
"supplierName".
"category" in the table cells are "idcategory" and
categoryName"
They all have a relationships with this table:
"results" in the cells are "idbook", "idsupplier" and
"idcategory".
This "results" table brings all of the above tables together.
When I try to do an update, i am doing one to the results
table. Is this correct?
The updates have problems because when drawing the text to
the update table to view it comes in text form.
When trying to update, it wont becuase all of the cells in
the results table are numeric. This is because of the
relationships.
Can anyone suggest where i may be going wrong.
Ask anything you need to.
TAMM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Session("MM_UserName") <> "") Then
Recordset1__MMColParam = Session("MM_UserName")
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_connSeek_STRING
Recordset1.Source = "SELECT * FROM Query1 WHERE UserName = '"
+ Replace(Recordset1__MMColParam, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim rsUpdate
Dim rsUpdate_numRows
Set rsUpdate = Server.CreateObject("ADODB.Recordset")
rsUpdate.ActiveConnection = MM_connSeek_STRING
rsUpdate.Source = "SELECT * FROM tblSpecies"
rsUpdate.CursorType = 0
rsUpdate.CursorLocation = 2
rsUpdate.LockType = 1
rsUpdate.Open()
rsUpdate_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<link href="css%20files/paragraph.css" rel="stylesheet"
type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new
Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a
.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0"
marginwidth="0" marginheight="0"
onLoad="MM_preloadImages('images/Publicationb.gif','images/Factsheetsb.gif')">
<table width="100%" height="100%" border="1"
cellpadding="0" cellspacing="0" bordercolor="#5D5D5D">
<tr>
<td colspan="2">
<div align="right"></div>
<div align="left"></div>
</td>
</tr>
<tr>
<td colspan="2"><table width="100%" height="100%"
border="0" cellpadding="0" cellspacing="0"
bordercolor="#5D5D5D">
<tr>
<td valign="top"><form
ACTION="<%=MM_editAction%>" METHOD="POST" name="form1">
<table width="90%" border="0" align="center"
cellpadding="0" cellspacing="0">
<tr>
<td valign="top"><div
align="center"></div> <table border="1" align="center"
cellpadding="2" cellspacing="0" bordercolor="#FFFFFF">
<tr bgcolor="ECECD7">
<td colspan="2"><div align="center">
<p><strong><font size="3">Update Key Word
& Category</font></strong></p>
</div>
</td>
</tr>
<tr>
<td><div align="center">
<p><font size="1">Enter Up to 10 Species /
Product
Name</font></p>
</div>
</td>
<td><div align="center">
<p><font size="1">Select a
Category</font></p>
</div>
</td>
</tr>
<tr>
<td colspan="2" bordercolor="#D0D09D">
<%
While ((Repeat1__numRows <> 0) AND (NOT
Recordset1.EOF))
%>
<table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr><td width="50%"><div align="center">
<input name="f1" type="text" id="f13"
value="<%=(Recordset1.Fields.Item("TimberSpecies").Value)%>"
size="33">
</div></td>
<td width="45%"><div
align="center"></div></td></tr></table>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend %>
<div align="center"> </div> <div
align="center">
</div></td></tr><tr>td
colspan="2"> </td></tr><tr><td
colspan="2"><div align="right"><p><font
size="1">To Finalise Your Changes Please Press the Update
Button
<input name="update2" type="submit" id="update"
value="Update">
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%=
rsUpdate.Fields.Item("TimberSpecies").Value %>"> -
Load / Update Table from a .csv file
Hi All,
I thought I would just throw this out there..be kind.
I have a requirement to build a page that allows the user to upload a excel (well I'll have them save it as a .csv) and upate an existing table in their schema.
I have successfully created a similar page for inserting into an existing table however my update is not working. Then I realized what the Oracle Application Express Tool does that for me on, LOAD DATA page. The feature I like best is that after browsing for the file and clicking next it shows the column header and the row data underneath. I would really like to duplicate the functionality of this page.
I looked into the flows schema found related procedures , for example wwv_flow_load_excel_data,but I'm lost on how to use them.
Is there a way to duplicate the LOAD DATA Page and fit it to meet the users requirement?
Also I have included my coding attempt :
CREATE OR REPLACE PROCEDURE exceltotable2
AS
NAME: exceltotable
PURPOSE:
REVISIONS:
Ver Date Author Description
1.0 11/17/2008 1. Created this procedure.
NOTES:
Automatically available Auto Replace Keywords:
Object Name: exceltotable
Sysdate: 11/17/2008
Date and Time: 11/17/2008, 2:02:03 PM, and 11/17/2008 2:02:03 PM
Username: (set in TOAD Options, Procedure Editor)
Table Name: (set in the "New PL/SQL Object" dialog)
v_blob_data BLOB;
v_blob_len NUMBER;
v_position NUMBER;
v_raw_chunk RAW (10000);
v_char CHAR (1);
c_chunk_len NUMBER := 1;
v_line VARCHAR2 (32767) := NULL;
v_data_array APEX_APPLICATION_GLOBAL.VC_ARR2;
v_rows NUMBER;
v_asset_id NUMBER;
v_new_location GINOS_LOCATION.ID_LOCATION%TYPE ;
sql_stmt VARCHAR2 (2000);
--delete from data_upld;
BEGIN
-- Read data from wwv_flow_files</span>
SELECT blob_content
INTO v_blob_data
FROM wwv_flow_file_objects$
WHERE NAME = 'F32700/scannedforrdc.csv';
--(used this for testing)
-- WHERE last_updated = (select max(last_updated) from WWV_FLOW_FILE_OBJECTS$ where UPDATED_BY
-- = 'ADMIN')
--and id = (select max(id) from WWV_FLOW_FILE_OBJECTS$ where UPDATED_BY = 'ADMIN');
v_blob_len := DBMS_LOB.getlength (v_blob_data);
v_position := 1;
-- Read and convert binary to char</span>
WHILE (v_position <= v_blob_len)
LOOP
v_raw_chunk := DBMS_LOB.SUBSTR (v_blob_data, c_chunk_len, v_position);
v_char := CHR (hex_to_decimal(RAWTOHEX(v_raw_chunk)));
v_line := v_line || v_char;
v_position := v_position + c_chunk_len;
-- When a whole line is retrieved </span>
IF v_char = CHR (10)
THEN
-- Convert comma to : to use wwv_flow_utilities </span>
v_line := REPLACE (v_line, ',', ':');
-- Convert each column separated by : into array of data </span>
v_data_array := APEX_UTIL.string_to_table (v_line);
-- Update assets with RDC location
-- First get the current location id of the RDC
-- Next take each serial number from the spreadsheet and update the location and rack details </span>
Select id_location into v_new_location from ginos_location gl, ginos_site gs, ginos_agency ga
where nm_office = 'OCFS Resource Distribution Center' and gl.id_site = gs.id_site
And gl.id_agency = ga.id_agency And ga.nm_agency ='Office of Children and Family Services';
-- test with only the serial number/location
UPDATE GINOS_ASSET SET ID_LOCATION = v_new_location WHERE NM_SERIAL = v_data_array(1);
-- Clear out
v_line := NULL;
v_rows := v_rows + 1;
END IF;
END LOOP;
END;
Any advice/assistance is always appreciated
Thanks
MoeDan
Thank You for your reply, I actually bookmark your site yesterday when googling this problem.
I am going to give it a try. I have ran through steps 1 through 4. Step 4 , I modified to my page.
Just a little more help..
do I put my update table code in the procedure (step 4) - how do I view and extract the information from the collection?
DECLARE
l_blob BLOB;
PROCEDURE cleanup
IS
BEGIN
DELETE FROM WWV_FLOW_FILES
WHERE name = :P103_UPLOAD;
END cleanup;
BEGIN
SELECT blob_content
INTO l_blob
FROM WWV_FLOW_FILES
WHERE name = :P103_UPLOAD;
csv.create_collection_from_blob(l_blob, 'CSV_UPLOAD', 'Y');
-- I looked in the ginodba schema (the ref schema for the app) for this collection but it's not there
cleanup;
EXCEPTION
WHEN OTHERS
THEN
cleanup;
RAISE;
END;
Thanks Again
MOe -
Slide Site Not Updateing in Other Users Views
I have created a slide site with 100's of slides. Everyslide has an "owner" assigned to it so people can filter for the slides they are responsible to update. When I view the site I can see all the "owners" in the filter
list that I have assigned and are supposed to be there, in the contributors views they can only see a few names, some of them which actually don't have slides in the deck.
After uploading slides, I used Edit in datasheet view to update the "owners".
Any thoughts?Okay,
I think I have figured out the real issue here. In just about every other viewer the table that the materialized view or snapshot dumps to is viewable through the list of tables. It does not seem to be doing that in Raptor. Why we are not seeing the m.views or snapshots is that we give the select grants to the table object. (oops?)
While I see the logic for separating them out, I think it would be a smart idea to be able to see the tables for the m.views and snapshots in the table list instead of filtering them out. I am sure we are not the only ones who does the grants in the method that we used.
Maybe you are looking for
-
Macbook Pro w/Retina: Processors nearing 100ºC?!
As part of my school's technology requirements, I purchased a Macbook Pro recently. It is the 2012 Retina Display model. All in all, it's a great computer, and most of the time, it runs quite cool or a little warm. However, when I stress the computer
-
EWA Configuration in Solution Manager 7.1 in SP08
Hi All, Could any one please advice on the Changes that has been taken place for EWA configuration in Solution Manager 7.1. Warm Regards, Sudhakar G
-
HT1414 where do you request that an iphone be unlocked?
I bought a second-hand iPhone 4 that is locked with a certain carrier that is not my regular carrier. I tried the easiest route: I plugged it into my Mac and opened iTunes... hoping for a miracle that didn't happen. What I got was a message suggestin
-
My printer is not connecting, the chooser is not able to choose a port, i inadvertlantly changed the settings, and don't remember how to get back there, can you help?
-
How do you progamatti​cally set break on fail, base on a variable?
I am writing an application that will require me to break on fail but only if certain conditions apply after login. I have looked through a lot of the material online and in the help file and cannot seem to get it working or find an good solution. Ca