Trigger loops and update field based on sysdate
Hi people:
I have a trigger that can update an inactive ('STATUS') field when a vaccine is after expiry date ("matching").
This is the current structure of the table:
CREATE TABLE WAREHOUSE. () VACCINE_INVENTORY
VACCINE VARCHAR2 (200 BYTE) NOT NULL,
RECEIPT_DATE DATE NOT NULL,
CONTAINER_SIZE VARCHAR2 (200 BYTE),
QUANTITY NUMBER (6, 0),
NUMBER OF REQUISITION (6, 0),
NUMBER OF FISCAL_YEAR (4, 0),
RECEIVED_BY VARCHAR2 (50 BYTE),
DATE OF CORRESPONDENTS,
LOT_NUMBER VARCHAR2 (30 BYTE) NOT NULL,
VARCHAR2 (200 BYTE) OF THE SELLER,
STATUS VARCHAR2 (10 BYTE),
NUMBER OF CATALOG_NUMBER (5, 0),
CONSTRAINT PK_VACC PRIMARY KEY (VACCINE, RECEIPT_DATE, LOT_NUMBER) USING INDEX TABLESPACE STORAGE WAREHOUSE
So the idea is that if SYSDATE > correspondents the expiration date should be changed from active to inactive.
I guess I would need to create a loop so that when the trigger is executed, it will make a loop on all records in the table and set each vaccine expired to Inactive.
I'd appreciate some help...
Thank you
Matthew
Another alternative is to simply have a SQL statement that runs once a day:
UPDATE warehouse.vaccine_inventory
SET status = 'inactive '.
WHERE the correspondents<>
AND status = 'Active';
Tags: Database
Similar Questions
-
Help me in creating a trigger Insert and Update Options
Hello
Please help me in creating a trigger.
My requirement is that, after insert or update on a Table, I want to launch an event.
I have started this way, but does not know how to fully implement it.
I have a dept table
CREATE TRIGGER DepartmentTrigger
INSERT AFTER on Dept
BEGIN
INSERT INTO mytable VALUES("123","Kiran");
END DepartmentTrigger;
Please tell me how I can put the update option also.
Thanks in advance.Please tell me how I can put the update option also.
Add "or update". ;-)
Here are a few suggestions, but you definitely need to refer to the manual page that suggested the previous poster.
CREATE OR REPLACE the TRIGGER DepartmentTrigger
AFTER INSERT or Update ON Dept
BEGIN
INSERT INTO mytable VALUES(:new.) Dept 'DEPT ADDED OR CHANGED');
END DepartmentTrigger;The "or replace" means that you can replace the shutter button as you develop without having to type in a drop statement each time. Just change and reissue your script over and over again until you get it right.
The addition of "update or" or "Or remove" fact the trigger too much fire for these events. Note, you peut want separate triggers in different scripts and with different names for each event. You must decide whether your design is really the same thing either an insert or an update.
: new. Dept, this is how you should refer to the vale has changed the Dept column (: old.) Dept is the previous value). I changed the double quotes in the string in the clause VALUES of apostrophes.
Andy
-
Loop and masking subform based on checkbox
I have a form where forms have a box in them. I need a script when the user clicks a button to hide all forms of sub who do not have the enabled checkbox. Thanks for any help you can provide.
var allChildElements;
var intNumElements;
var currentElement;
var i;
allChildElements = CRT130.nodes;
intNumElements = allChildElements.length;
for (i = 0; i < intNumElements; i ++)
{
currentElement = allChildElements.item (i);
If (currentElement.className = "checkbox")
{
if(currentElement.RawValue == 0)
{
currentElement.presence = 'hidden ';
}
}
}
Hello
className of a checkbox control is "on the ground", if you want to check if the item is a checkbox, you must Access the field in the UI to be able to check what kind of field it is.
Even if a className checkbox checkButton instead of the check box.
You must create a recursive function to traverse each subform and also each elements in the subform.
function recursiveLoop (rootObject) {}
for (var i = 0, oLen = rootObject.nodes.length; i)< olen;="">
var currentElement = rootObject.nodes.item (i);
If (currentElement.nodes.length > 0 & currentElement.className == "subform") {}
recursiveLoop (currentElement);
} ElseIf (currentElement.isPropertySpecified ("ui") & currentElement.ui.nodes.item (0) .className == "checkButton") {}
{If (currentElement.rawValue == {currentElement.getDisplayItem (1)})}
rootObject.presence = 'hidden ';
}
}
}
}
Create a script object (xfaCheckBoxes) with the function above to the breast, and then you can call the function on the click event of the button
Button1::click-(JavaScript, client)
xfaCheckBoxes.recursiveLoop (CRT10);
This should do the trick,
I hope this will help!
-
Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE Production 11.2.0.4.0
AMT for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
I create the structure of the table like that.
create table test1 (a primary key, b (2) char number, date c, d varchar2 (10), date of e);
create table test2 (number of ab, cd (2) tank, date of the ef, gh varchar2 (10), date of the ij, kl varchar2 (100));
Create materialized view log on test1;
create materialized view fast refresh test1_v on commit in select * from test1;
I have create a trigger of the sample
CREATE OR REPLACE TRIGGER test1_trig
AFTER INSERT OR UPDATE OR DELETE
ON test1_v
FOR EACH LINE
DECLARE
lr_test2 test2% ROWTYPE;
lv_error VARCHAR2 (4000);
BEGIN
lr_test2. AB: =: NEW.a;
lr_test2. CD: =: NEW.b;
lr_test2. GH: =: NEW.d;
IF THE INSERTION
THEN
lr_test2. EF: = SYSDATE;
lr_test2.IJ: = SYSDATE;
lr_test2.KL: = 'INSERT ';
INSERT INTO test2
VALUES lr_test2;
ELSIF UPDATE
THEN
lr_test2.IJ: = SYSDATE;
lr_test2.KL: = 'UPDATE ';
UPDATE test2 = lr_test2 ab WHERE = LINE: OLD.a;
ELSIF REMOVAL
THEN
DELETE FROM test2
AB = WHERE: old.a;
END IF;
EXCEPTION
WHILE OTHERS
THEN
lv_error: = SQLERRM;
INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR
VALUES ('test1_trig',
: OLD.a,.
"test1_trig,"
LV_ERROR,
SYSDATE);
COMMIT;
END test1_trig;
/
So, if check you my code,.
When I insert EF = SYSDATE, IJ = SYSDATE.
Update EF is not changed, IJ = SYSDATE.
So I like to capture their insertion and update dates.
But if updates or insert arrives on the materialized table. The trigger themselves as an INSERT only.
So how do you capture the updates?
I use the statemnet with out merger with performance and also able to capture the update dates.
CREATE OR REPLACE TRIGGER test1_trig_merge
AFTER INSERT OR UPDATE OR DELETE
ON test1_v
FOR EACH LINE
DECLARE
lr_test2 test2% ROWTYPE;
lv_error VARCHAR2 (4000);
BEGIN
IF THE REMOVAL
THEN
DELETE FROM test2
AB = WHERE: old.a;
ELSIF INSERTION
THEN
MERGE INTO test2 one
B using (SELECT 1 FROM DUAL)
WE (ab =: new.a)
WHEN MATCHED
THEN
UPDATE the VALUE ab =: NEW.a.
CD =: NEW.b,
GH =: NEW.c
IJ = SYSDATE,
KL = "Update"
AB WHERE =: old.a
WHEN NOT MATCHED
THEN
INSERTING VALUES (: NEW.a,)
: NEW.b,.
: NEW.c.
: NEW.d,.
: NEW.e,.
"INSERT");
END IF;
EXCEPTION
WHILE OTHERS
THEN
lv_error: = SQLERRM;
INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR
VALUES ('test1_trig',
: OLD.a,.
"test1_trig,"
LV_ERROR,
SYSDATE);
END test1_trig_merge;
/
DISPLAY ERRORS;
-
When I check the updates, it goes into endless loop and never off.
Original title: windows updates
When I check the updates, it goes into endless loop and never off. Even if there is no new update, he said usaly. What is gpoing?
Please run the Windows Update Troubleshooter:
http://go.Microsoft.com/?linkid=9830262Please provide details of any problem it reports as not fixed.
-
Mr President.
I create a form based on two tables that have sequences also. When I create insert only row is inserted in the fields in table first and second fields of the table are empty. Why?
the page source is
<?xml version='1.0' encoding='UTF-8'?> <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich" xmlns:f="http://java.sun.com/jsf/core"> <af:panelFormLayout id="pfl1"> <af:group id="Group"> <af:inputText value="#{bindings.VoucherId.inputValue}" label="#{bindings.VoucherId.hints.label}" required="#{bindings.VoucherId.hints.mandatory}" columns="#{bindings.VoucherId.hints.displayWidth}" maximumLength="#{bindings.VoucherId.hints.precision}" shortDesc="#{bindings.VoucherId.hints.tooltip}" id="it1"> <f:validator binding="#{bindings.VoucherId.validator}"/> <af:convertNumber groupingUsed="false" pattern="#{bindings.VoucherId.format}"/> </af:inputText> <af:inputDate value="#{bindings.VoucherDate.inputValue}" label="#{bindings.VoucherDate.hints.label}" required="#{bindings.VoucherDate.hints.mandatory}" columns="#{bindings.VoucherDate.hints.displayWidth}" shortDesc="#{bindings.VoucherDate.hints.tooltip}" id="id1"> <f:validator binding="#{bindings.VoucherDate.validator}"/> <af:convertDateTime pattern="#{bindings.VoucherDate.format}"/> </af:inputDate> <af:inputText value="#{bindings.Credit.inputValue}" label="#{bindings.Credit.hints.label}" required="#{bindings.Credit.hints.mandatory}" columns="#{bindings.Credit.hints.displayWidth}" maximumLength="#{bindings.Credit.hints.precision}" shortDesc="#{bindings.Credit.hints.tooltip}" id="it2"> <f:validator binding="#{bindings.Credit.validator}"/> </af:inputText> </af:group> <af:group id="g1"> <af:inputText value="#{bindings.Lineitem.inputValue}" label="#{bindings.Lineitem.hints.label}" required="#{bindings.Lineitem.hints.mandatory}" columns="#{bindings.Lineitem.hints.displayWidth}" maximumLength="#{bindings.Lineitem.hints.precision}" shortDesc="#{bindings.Lineitem.hints.tooltip}" id="it3"> <f:validator binding="#{bindings.Lineitem.validator}"/> <af:convertNumber groupingUsed="false" pattern="#{bindings.Lineitem.format}"/> </af:inputText> <af:inputText value="#{bindings.VoucherId1.inputValue}" label="#{bindings.VoucherId1.hints.label}" required="#{bindings.VoucherId1.hints.mandatory}" columns="#{bindings.VoucherId1.hints.displayWidth}" maximumLength="#{bindings.VoucherId1.hints.precision}" shortDesc="#{bindings.VoucherId1.hints.tooltip}" id="it4"> <f:validator binding="#{bindings.VoucherId1.validator}"/> <af:convertNumber groupingUsed="false" pattern="#{bindings.VoucherId1.format}"/> </af:inputText> <af:inputText value="#{bindings.Debit.inputValue}" label="#{bindings.Debit.hints.label}" required="#{bindings.Debit.hints.mandatory}" columns="#{bindings.Debit.hints.displayWidth}" maximumLength="#{bindings.Debit.hints.precision}" shortDesc="#{bindings.Debit.hints.tooltip}" id="it5"> <f:validator binding="#{bindings.Debit.validator}"/> </af:inputText> <af:inputText value="#{bindings.Credit1.inputValue}" label="#{bindings.Credit1.hints.label}" required="#{bindings.Credit1.hints.mandatory}" columns="#{bindings.Credit1.hints.displayWidth}" maximumLength="#{bindings.Credit1.hints.precision}" shortDesc="#{bindings.Credit1.hints.tooltip}" id="it6"> <f:validator binding="#{bindings.Credit1.validator}"/> </af:inputText> <af:inputText value="#{bindings.Particulars.inputValue}" label="#{bindings.Particulars.hints.label}" required="#{bindings.Particulars.hints.mandatory}" columns="#{bindings.Particulars.hints.displayWidth}" maximumLength="#{bindings.Particulars.hints.precision}" shortDesc="#{bindings.Particulars.hints.tooltip}" id="it7"> <f:validator binding="#{bindings.Particulars.validator}"/> </af:inputText> <af:inputText value="#{bindings.Amount.inputValue}" label="#{bindings.Amount.hints.label}" required="#{bindings.Amount.hints.mandatory}" columns="#{bindings.Amount.hints.displayWidth}" maximumLength="#{bindings.Amount.hints.precision}" shortDesc="#{bindings.Amount.hints.tooltip}" id="it8"> <f:validator binding="#{bindings.Amount.validator}"/> <af:convertNumber groupingUsed="false" pattern="#{bindings.Amount.format}"/> </af:inputText> </af:group> <f:facet name="footer"> <af:button text="Submit" id="b1"/> <af:button actionListener="#{bindings.CreateInsert.execute}" text="CreateInsert" disabled="#{!bindings.CreateInsert.enabled}" id="b2"/> <af:button actionListener="#{bindings.Commit.execute}" text="Commit" disabled="#{!bindings.Commit.enabled}" id="b3"/> <af:button actionListener="#{bindings.Rollback.execute}" text="Rollback" disabled="#{!bindings.Rollback.enabled}" immediate="true" id="b4"> <af:resetActionListener/> </af:button> </f:facet> </af:panelFormLayout> </ui:composition>
Concerning
Go to your VO Wizard, select the tab of the entity and to check if both the EO is editable or not.
See you soon
AJ
-
Compare multiple columns and update a column based on the comparison
Hi all
I have to update the column STATUS of the slot structure of the table.
Status should be 'P' if all the columns count are equal on the other should be "F".
The value of the column can be "NA'. If the value is NA, then avoid this comparison column; compare only other 3 columns.
My output should look like below.
State of cnt1, cnt2 cnt3 ID cnt4
1 4 4 4 4 P
2 4 5 4 4 F
3 4 4 NA 4 P
NA 4 4 3 4
I tried with the statemnt with BOX WHEN conditions and DECODE UPDATE, but could not succeed, can someone please help
To do this, if you use my statement in response #11 box (Re: Re: comparison of multi-column and update a column based on the comparison of)
-
I have a map of PXI - 6281 M series and tries to use a pause trigger door acquisition and synchronize two 6281 cards.
If the door is activated after start of the task, the T0 the output waveform is based on the task start time. Breaks in acquisition lead no gap in the output waveform.
I do not plan to have a break in the middle of the acquisition, but the T0 start must be based on the leading edge of the break. Not the task start VI call.
Is there a way to do this?
Thank you
XL600
I think I've answered my own question...
T0 is locked on the first call to the read DAQmx VI where the data are available and has nothing to do with the early or interromptre. This is described in terms clear here. T0 is generated by the driver, not the card for the M Series DAQ cards.
What I used to minimize the delay is an edge detect calendar source connected to my trigger for acquisition (which is used to control the start-up or interromptre). I ran in a loop timed and used the global time in the form of stamp from the 'edge '. I also sent a notifier for awhile waiting for loop and captured the first T0. They are less than 1 sample clock rate multiple between 1 Hz and 10 kHz. I'm sure there will be some jitter in T0 based on LabView RT priorities, but I am happy that the technique works well.
An interesting side effect is that T0 the newspaper of TDMS is also hooked the first reading in the newspaper and reading mode (not tried to connect only... could be interesting to know that behavior).
Thanks for the comments,
XL600
-
Create triggers in the table, sequence, insert and update with "model"?
It must be of rtfm, trial and error thing but you wanted to ask, is it possible to have models or similar automation for the following scenario:
1.), I add the table to the logic model
2.) Using glossary I transform a relational model that was recovered / synchronized with the data dictionary
3.) then I have the new table to add
-but
I would then have auto-DDL of to be synchronized to database:
-create sequence for the id column
-create table
-create indexes for the id column pk
-Create triggers for insert and update
-l' idea is to have db_created_dt and db_modified_dt defined in the table, so that each table has them to the fields of record etc.
-activate the triggers
Each of them following the same naming convention.
Similarity with approx. generator Apex workshop utils sql create table of the copy paste "excel" that creates 'id' - column + sequence and insert the trigger.
rgrds Paavo
Hi Paavo,
most of the steps can be made in one or other way
-create sequence for the id column
-create table
-create indexes for the id column pk
If you want to start in the logic model and you don't want to have the ID column in the logic model and select 'Create the surrogate key' checkbox in the dialog entity - you will get an identity column in the relational model and the version of database and settings in ' preferences > Data Modeler > model > physics > Oracle "you can set the sequence generation and the trigger for taking in load.
fields of record defined in the table, so that each table has them
You can add the same set of columns in all tables with the transformation script 'model of Table... ».
You can also look here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts
to see how to grant your DDL generation using the transformation script. DM comes with example to generate separate tables of logging and triggers. You can create your build script of triggers that support logging in these common columns.
Philippe
-
in bulk accumulate in plsql and update the same table.
Hello
I use bulk collect and update the table that I use the slider. This table has nearly 1 million records. There will be problems with my code? Any help is greatly appreciated.
DECLARE
terminate_reason VARCHAR2 (1000);
time_line NUMBER;
limit_in NUMBER;
CURSOR cur_violations IS
SELECT * from abc_table;
TYPE cur_abc_table_type IS TABLE OF cur_abc_table % ROWTYPE INDEX BY PLS_INTEGER;
cur_abc_table_rec cur_abc_table_type;
BEGIN
limit_in: = 5000;
OPEN cur_abc_table.
LOOP
Get the cur_abc_table COLLECT in BULK
IN limit_in LIMIT cur_abc_table_rec;
dbms_output.put_line ('new count is' | cur_abc_table_rec.count);
WHEN OUTPUT cur_abc_table_rec.count = 0;
BECAUSE me in 1... cur_abc_table_rec. Count
LOOP
time_line: = trunc (sysdate) - cur_abc_table_rec (i) .viol_date;
IF (time_line > 1000)
THEN
terminate_reason: = 'NOTWELL. "
ON THE OTHER
terminate_reason: = 'PUSHED ';
END IF;
UPDATE abc_table v
SET
v.pers_terminate_reason = terminate_reason;
END LOOP;
END LOOP;
COMMIT;
CLOSE Cur_abc_table;
EXCEPTION
WHEN no_data_found THEN
dbms_output.put_line ('no data is found in the selection' |) SQLERRM);
WHILE OTHERS THEN
dbms_output.put_line ('another error' |) SQLERRM);
END;
Thank you
KK
What happened when you tried? The sliders were ' for the update of "syntax, so there is no general problem update lines inside a loop of cursor.
The big question you have, it is that the loop is completely and totally useless. What you can do in SQL, do in SQL - not to complicate things with PL/SQL that you don't need.
-
Deleting and updating through a procedure
Hello
I'm a dynamic naïve for collections of Oracle & SQL concepts and always learning, here is a procedure that I wrote. First of all, it will delete the records if a version of records already exist and update dates with null, prior to their release records as the current version. Grateful if you can spot the mistakes, I think to make bulk binding when I updated but still struggling to come up with a approach, please help me with all the entries. Thank you.
create or replace
procedure fcs_stage_data_delete2 (p_extract_dt in varchar2, p_provider in varchar2, p_uninum in varchar2, p_ver_num in numbers, retval number)
IS
i_commit pls_integer: = 100000;
i_rowcount pls_integer: = 0;
v_code NUMBER;
v_errm VARCHAR2 (64);
TABLIST TYPE IS THE TABLE OF THE VARCHAR2 (20);
TABNAME TABLIST: IS TABLIST('FEED_PROCESS_LOG','CUSTOMER','LOAN','HASH_TOTALS_FY1213');.
Start
--------------------------------------------------------------------------------------------------------------------------
/ * DELETION OF THE STAGE TABLES * /.
--------------------------------------------------------------------------------------------------------------------------
Start
REMOVE FROM CUSTOMER_LOAN_XREF
WHERE CUSTOMER_EXTRACT_DT = p_extract_dt
AND CUSTOMER_PROVIDER = P_PROVIDER
AND CUSTOMER_UNINUM = P_UNINUM
AND CUSTOMER_VER_NUM = P_VER_NUM
AND LOAN_EXTRACT_DT = p_extract_dt
AND LOAN_PROVIDER = p_provider
AND LOAN_UNINUM = p_uninum
AND LOAN_VER_NUM = p_ver_num;
COMMIT;
end;
RUN IMMEDIATELY 'ALTER TABLE CUSTOMER_LOAN_XREF DISABLE CONSTRAINT FK_CUSTOMER_LOAN_XREF_CUSTOMER;
RUN IMMEDIATELY 'ALTER TABLE CUSTOMER_LOAN_XREF DISABLE CONSTRAINT FK_CUSTOMER_LOAN_XREF_LOAN;
FOR I IN TABNAME. FIRST... TABNAME. LAST
LOOP
IMMEDIATE EXECUTION
'REMOVE'. TABNAME (I) | »
WHERE EXTRACT_DT =: HAS
AND PROVIDER =: B
AND UNINUM =: C
"AND VER_NUM =: D"
WITH THE HELP OF P_EXTRACT_DT, P_PROVIDER, P_UNINUM, P_VER_NUM;
COMMIT;
END LOOP;
RUN IMMEDIATELY 'ALTER TABLE CUSTOMER_LOAN_XREF ENABLE CONSTRAINT FK_CUSTOMER_LOAN_XREF_CUSTOMER;
RUN IMMEDIATELY 'ALTER TABLE CUSTOMER_LOAN_XREF ENABLE CONSTRAINT FK_CUSTOMER_LOAN_XREF_LOAN;
-------------------------------------------------------------------------------------------------------------------------
/ * UPDATE THE PAINTINGS OF SCENE * /.
-------------------------------------------------------------------------------------------------------------------------
IF p_ver_num > 1
then
Start
because me in (SELECT ROWID, T.* FROM FEED_PROCESS_LOG T T.EXTRACT_DT = P_EXTRACT_DT WHERE
and T.PROVIDER = P_PROVIDER AND T.UNINUM = P_UNINUM AND T.VER_NUM = P_VER_NUM-1)
loop
UPDATE FEED_PROCESS_LOG SET ACT_END_DT = NULL, UPDATE_ID = NULL, UPDATE_DT = NULL WHERE ROWID = I.ROWID;
end loop;
commit;
end;
Start
for i in (SELECT ROWID, T.* FROM CUSTOMER T WHERE T.EXTRACT_DT = p_extract_dt and T.PROVIDER = P_PROVIDER
AND T.UNINUM = P_UNINUM AND T.VER_NUM = P_VER_NUM-1)
loop
UPDATE CUSTOMER SET ACT_END_DT = NOTHING WHERE ROWID is i.ROWID;.
end loop;
commit;
end;
end if;
retval: = 0;
exception, then than others
then
v_code: = SQLCODE;
v_errm: = SUBSTR (SQLERRM, 1, 64);
retval: = 1;
end fcs_stage_data_delete2;
I'm talking about the loops that do updates, not deletions.
Bulk collect a bunch of SQL UPDATE of ROWID instructions just use directly.
I compared the time taken with and "bulk collect" and I see better performance when I bulk collect and update.
Sorry - I don't believe you. I don't see anything in BULK COLLECT (which were not yet made you in the first code you posted) may possibly be faster than an update SQL statement.
Most collect must search for lines, download the ROWID, create a collection and then move this collection to the SQL engine to make the update
An UPDATE to SQL finds the lines and then did the update. It does not use the PL/SQL, a collection or get the collection back.
Summary - COLLECTION BULK actually what does the SQL UPDATE and more.
The new code in BULK COLLECT you posted also has two major problems in it.
First of all there is no LIMIT clause to limit the amount of memory of expensive PGA which is used.
In the second place, because there is no LIMIT clause, there not need all of the loop.
Just use an SQL UPDATE statement that removes lines based on the WHERE clause you are currently using to find the ROWID.
-
Importing a flat at Oracle and update another table
Hey everybody,
I am a newbie with Oracle, and I tried for 2 days to fix this below. But all my research and all attempts have failed.
I have a text file called ReturnedFile.txt. This is a comma separated text file that contains the records of two fields... Envelope and Date returned.
At the same time, I have a table in Oracle called manifest. This table contains the following fields:
Envelope
DateSentOut
DateReturnedI need to write something that matter the ReturnedFile.txt in a temporary Oracle table named UploadTemp and compares the data in the field of the envelope of UploadTemp with the domain of the envelope in the manifest. If it is a match, then the field of clear needs updated with field DateReturned in UploadTemp DateReturned.
I did it with SQL Server without problem, but I tried for two days to make it work with Oracle and I can't understand it. I tried to use SQL * Loader, but I can not even run properly on my machine.
I create a file of control, registered as RetFile.ctl. Here is the content of the CTL file:
DOWNLOAD THE DATA
INFILE 'C:\OracleTest\ReturnedFile.txt '.ADD
IN THE UploadTemp TABLE
"FIELDS TERMINATED BY '"
(
ENVELOPE,
DATERETURNED
)If I could get SQL * Loader works, here's the code I came with to import the text file, then compare it to the clear table and update if necessary:
sqlldr UserJoe/Password123 CONTROL=C:\OracleTest\RetFile.ctl LOG = RetFile.log BAD = RetFile.bad
update the manifest m set m.DateReturned =
(select t.DateReturned
of UploadTemp t
where m.Envelope = t.Envelope
*)That's all I had. As I said, I can't find a way to test it and I have no idea if it's still close.
Please... can anyone help me? Even close, I'm on this thing?
Joe
If your ReturnedFile.txtfile is a comma, you must FINISH BY ',' not COMPLETED BY "'" in your control file. If it happens to not be a comma ending on a line, then you must also add TRAILING NULLCOLS in your control file. You must also use a date format for your date in your control file that corresponds to the date format in your file ReturnedFile.txt, where it does not match the format of the date on your system. You must add a WHERE EXISTS clause in your update statement to prevent any lines that do not have the updated DateReturned with a null value. Please see the example below. If it doesn't then please do a copy and paste as I did, that includes a few lines of sample data and table structure. It would also be useful to see your SQL * Loader or logs SQL * Loader error message. If you can not get SQL * Loader is running properly, then you may have other issues, such as the permissions of files at the operating system level. Also, there are options other than the methods below. For example, you can use an external table, instead of SQL * Loader, if your ReturnedFile.txtfile is on your Serer, not your client. You can also use the merger instead of update.
Scott@orcl_11gR2 > type host returnedfile.txt
enV2, 07/03/2013
ENV3, 07/04/2013
ENV4, 07/05/2013
Scott@orcl_11gR2 > type host retfile.ctl
DOWNLOAD THE DATA
INFILE 'ReturnedFile.txt '.
ADD
IN THE UploadTemp TABLE
FIELDS TERMINATED BY ', '.
trailing nullcols
(ENVELOPE
DATERETURNED date "yyyy-mm-dd")
Scott@orcl_11gR2 > create table uploadtemp
2 (envelope varchar2 (15),)
date of datereturned 3)
4.
Table created.
Scott@orcl_11gR2 > create clear table
2 (envelope varchar2 (15),)
3 date of DateSentOut,
4 date of DateReturned)
5.
Table created.
Scott@orcl_11gR2 > insert all
2 in manifests values ("env1", sysdate-7, sysdate-3)
3 in obvious values ("env2", sysdate-6, null)
4 in the obvious values ('env3' sysdate-5, null)
5 Select * of the double
6.
3 lines were created.
Scott@orcl_11gR2 > select * from manifest
2.
ENVELOPE DATESENTO DATERETUR
--------------- --------- ---------
ENV1 June 28, 13 2 July 13
enV2 29 June 13
ENV3 30 June 13
3 selected lines.
Scott@orcl_11gR2 > host sqlldr scott/tiger CONTROL = RetFile.ctl LOG = RetFile.log BAD = RetFile.bad
SQL * Loader: release 11.2.0.1.0 - Production on Fri Jul 5 13:15:06 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit the point reached - the number of logical records 3
Scott@orcl_11gR2 > select * from uploadtemp
2.
ENVELOPE DATERETUR
--------------- ---------
enV2 3 July 13
ENV3 4 July 13
ENV4 July 5, 13
3 selected lines.
Scott@orcl_11gR2 > clear day m
2. set m.DateReturned =
3 (select t.DateReturned
4 t UploadTemp
5 where m.Envelope = t.Envelope)
6 where there is
7 (select t.DateReturned
UploadTemp 8 t
9 where m.Envelope = t.Envelope)
10.
2 lines to date.
Scott@orcl_11gR2 > select * from manifest
2.
ENVELOPE DATESENTO DATERETUR
--------------- --------- ---------
ENV1 June 28, 13 2 July 13
enV2 June 29, 13 3 July 13
ENV3 June 30, 13 4 July 13
3 selected lines.
-
Loopback, setting and update! Oh my.
Hello all, I am very new to CF and our regular guy is on taxes so I could really use some help. I get geo location of Bing for several address I have in a database. Then add the latitude and longitude for the fields of latitude and longitude of the respective row, I am able to run the indivulally functions, but I need help, loop through each line. Here's what I have. I hope that makes sense!
<! - query the db - >
< cfquery datasource = "square" name = "ListingShort" >
SELECT
MLS_Id, List_Price, Public_Address Street_Number, Street_Name, Unit_Number, city, zip_code, Subd ivision_Name, bedroom, Baths_Total, Full_Baths, Half_Baths, Square_Feet, Lot_Sqft, Garage_Capacit y, Garage_Type, High_School, Junior_School, Property_Description, Listing_Office_Name, Listing_O, ffice_Id, Listing_Agent_Name, Listing_Agent_Phone, Listing_Agent_Id, Short_Sale, Open_House_Fla g Last_Image_Update, Price_Change_Date, Image_Count, Latitude, Longitude
OF GLVAR_daily_bulk
WHERE MLS_Id = 1375233
< / cfquery >
<! - recover data from Bing - >
" < cfhttp url = ' http://dev.virtualearth.net/REST/v1/Locations/US/NV/#ListingShort.Zip_Code#/#ListingShort. City#/#ListingShort.Street_Number#%20#ListingShort.Street_Name#?o=XML & key = AgM3wR0ojSpxYaJe h6WS7p2kcckECqVQ5HkrweFcZCcyOjE3mYVvIrF_WzbETMeb"timeout ="2"method ="GET"> ".
< cfset xbinglocation = xmlparse (cfhttp.filecontent) >
< cfset xbinglocation = lat. Response.ResourceSets.ResourceSet.Resources.Location.Point.Latitude.Xml text >
< cfset = long xbinglocation. Response.ResourceSets.ResourceSet.Resources.Location.Point.Longitude.X mlText >
<! - updated the latitude and longitude fields - >
< cfquery datasource = "square" name = "addGeo" >
UPDATE glvar_daily_bulk
SET Latitude = #lat #.
Longitude = #long #.
WHERE MLS_Id = 1375233
< / cfquery >
Yo thanks. Worked perfectly. I'm sure that what was easy for you, but you saved me countless google searches! I owe you one.
-
Setting in LOOP FOR update instructions
I have a UPDATE 4 * (no insert or delete) * statements in a loop for loop runs for each current month and prev (2 months IE 60/61 days and so 60 / 61 times). The UPDATE occurs on a bulky table with 1.5 crore documents.
------------------------------------------------------------------------------
LD_START_DATE = Date1;
For Date1 loop... Date60
UPDATE STG DAST
SET TRAVEL_COUNTRY = (SELECT TRAVEL_COUNTRY_FULL FROM (SELECT TRAVEL_COUNTRY_FULL, PERSON_ID,
RANK() AT GRADE (A.PERSON_ID ORDER BY A.LAST_UPDATE_DATE DESC, A.LOC_START_DATE DESC, ASC A.LOC_END_DATE PARTITION)
FROM APPS. TCS_MIS_EIT_LOCATION_EX HAS
WHERE = A.TRAVEL_TYPE the of '
AND LD_START_DATE BETWEEN A.EFFECTIVE_START_DATE AND A.EFFECTIVE_END_DATE
AND LD_START_DATE BETWEEN A.LOC_START_DATE AND A.LOC_END_DATE)
WHERE RANK = 1 AND PERSON_ID = DAST. PERSON_ID),
TRAVEL_TYPE = "ST".
WHERE EXISTS (SELECT 1
FROM (SELECT TRAVEL_COUNTRY_FULL, PERSON_ID,
RANK() AT GRADE (A.PERSON_ID ORDER BY A.LAST_UPDATE_DATE DESC, A.LOC_START_DATE DESC, ASC A.LOC_END_DATE PARTITION)
FROM APPS. TCS_MIS_EIT_LOCATION_EX HAS
WHERE = A.TRAVEL_TYPE the of '
AND LD_START_DATE BETWEEN A.EFFECTIVE_START_DATE AND A.EFFECTIVE_END_DATE
AND LD_START_DATE BETWEEN A.LOC_START_DATE AND A.LOC_END_DATE)
WHERE RANK = 1 AND PERSON_ID = DAST. PERSON_ID)
AND DAST. ENTRY_DATE = LD_START_DATE
ERRORS in the LOG IN STG_ERR ('ErrLine->' |) ERR_LINE | 'Date->' | To_char(sysdate, 'DD-mon-yyy hh:mi:SS am')) DISMISS LIMIT UNLIMITED;
ERR_LINE: = 4.2;
UPDATE STG DAST
SET TRAVEL_COUNTRY = (SELECT TRAVEL_COUNTRY_FULL
FROM (SELECT TRAVEL_COUNTRY_FULL, PERSON_ID,
RANK() TO RANK (SCORE FROM A.PERSON_ID ORDER BY A.LAST_UPDATE_DATE DESC, A.LOC_START_DATE DESC, ASC A.LOC_END_DATE) FROM APPS. TCS_MIS_EIT_LOCATION_EX HAS
WHERE A.TRAVEL_TYPE = 'B'
AND LD_START_DATE BETWEEN A.EFFECTIVE_START_DATE AND A.EFFECTIVE_END_DATE
AND LD_START_DATE BETWEEN A.LOC_START_DATE AND A.LOC_END_DATE)
WHERE RANK = 1 AND PERSON_ID = DAST. PERSON_ID),
TRAVEL_TYPE = 'B '.
WHERE IS (1 SELECTION (SELECT TRAVEL_COUNTRY_FULL, PERSON_ID,
RANK() AT GRADE (A.PERSON_ID ORDER BY A.LAST_UPDATE_DATE DESC, A.LOC_START_DATE DESC, ASC A.LOC_END_DATE PARTITION)
FROM APPS. TCS_MIS_EIT_LOCATION_EX HAS
WHERE A.TRAVEL_TYPE = 'B'
AND LD_START_DATE BETWEEN A.EFFECTIVE_START_DATE AND A.EFFECTIVE_END_DATE
AND LD_START_DATE BETWEEN A.LOC_START_DATE AND A.LOC_END_DATE)
WHERE RANK = 1 AND PERSON_ID = DAST. PERSON_ID)
AND DAST. ENTRY_DATE = LD_START_DATE
ERRORS in the LOG IN STG_ERR ('ErrLine->' |) ERR_LINE | 'Date->' | To_char(sysdate, 'DD-mon-yyy hh:mi:SS am')) DISMISS LIMIT UNLIMITED;
ERR_LINE: = 4.3;
UPDATE STG DAST SET TRAVEL_COUNTRY = *(SELECT TERRITORY_SHORT_NAME*)
FROM APPS. FND_TERRITORIES_TL FTT
WHERE FTT. TERRITORY_CODE = DAST. LOCATION_COUNTRY),.
TRAVEL_TYPE = "LT."
WHERE DAST. LOCATION_COUNTRY <>DAST. BASE_COUNTRY
AND NOT EXISTS
(SELECT 1 FROM APPS. TCS_MIS_EIT_LOCATION_EX EIT
WHERE DAST. PERSON_ID = EIT. PERSON_ID
AND LD_START_DATE BETWEEN EIT. LOC_START_DATE AND EIT. LOC_END_DATE
AND LD_START_DATE BETWEEN EIT. EFFECTIVE_START_DATE AND EIT. EFFECTIVE_END_DATE)
AND DAST. ENTRY_DATE = ERRORS IN THE LD_START_DATE LOG IN
STG_ERR ('ErrLine->' |) ERR_LINE | 'Date->' | To_char(sysdate, 'DD-mon-yyy hh:mi:SS am')) DISMISS LIMIT UNLIMITED;
ERR_LINE: = 4.4;
UPDATE STG DAST
SET TRAVEL_COUNTRY = DAST. BASE_COUNTRY_NAME, TRAVEL_TYPE = "n/a"
WHERE DAST. LOCATION_COUNTRY = DAST. BASE_COUNTRY
AND NOT EXISTS
(SELECT 1 FROM APPS. TCS_MIS_EIT_LOCATION_EX EIT
WHERE DAST. PERSON_ID = EIT. PERSON_ID
AND LD_START_DATE BETWEEN EIT. LOC_START_DATE AND EIT. LOC_END_DATE
AND LD_START_DATE BETWEEN EIT. EFFECTIVE_START_DATE AND EIT. EFFECTIVE_END_DATE)
AND DAST. ENTRY_DATE = ERRORS IN THE LD_START_DATE LOG IN
STG_ERR ('ErrLine->' |) ERR_LINE | 'Date->' | To_char(sysdate, 'DD-mon-yyy hh:mi:SS am')) REJECT
LIMIT UNLIMITED;
COMMIT;
LD_START_DATE = LD_START_DATE + 1
End loop;
-------------------------------------------------------------------------------------------------
This loop takes about 1 hour to full. My job is to reduce the time.
I think we can do after getting there:
1 club updates multiple in an update. If not all four statemnts can be clubbed into a single statement, at least the first two and final two update statements can easily be clubed as conditions are used to reduce the four day in two (I hv fact "BOLD" the parts of the query differ from each other). I think it might help, but not sure. If Yes please let me know how club updated multiple into one (Please give the new query).
Note: Both updates using first clause EXISTS and updates two past uses NOT EXISTS.
2. as above uses ineffective FOR loop, can we use BULK Collect. How to on this subject? (Please give the new query).
3. also I hv COMMIT inside the loop. IF Commit is done 60 times. What happens if move validation outside of the LOOP.
All other things that can be done, please suggest.
Published by: J2EE_Life on December 1st, 2011 12:58
Published by: J2EE_Life on December 1st, 2011 13:01Perhaps using just two updates should get fact
combining the first two queries and join the date rangeUPDATE STG DAST SET (TRAVEL_COUNTRY,TRAVEL_TYPE) = (SELECT TRAVEL_COUNTRY_FULL,CASE A.TRAVEL_TYPE WHEN 'S' THEN 'ST' ELSE 'B' END FROM (SELECT TRAVEL_COUNTRY_FULL, PERSON_ID, RANK() OVER (PARTITION BY A.PERSON_ID ORDER BY A.LAST_UPDATE_DATE DESC, A.LOC_START_DATE DESC, A.LOC_END_DATE ASC ) RANK FROM APPS.TCS_MIS_EIT_LOCATION_EX A, (select :begin_date + level - 1 the_date from dual connect by level <= :end_date - :begin_date + 1 ) l WHERE A.TRAVEL_TYPE in ('B','S') AND l.the_date BETWEEN A.EFFECTIVE_START_DATE AND A.EFFECTIVE_END_DATE AND l.the_date BETWEEN A.LOC_START_DATE AND A.LOC_END_DATE ) WHERE RANK = 1 AND PERSON_ID = DAST.PERSON_ID ) WHERE DAST.ENTRY_DATE = LD_START_DATE AND EXISTS(SELECT null FROM (SELECT TRAVEL_COUNTRY_FULL, PERSON_ID, RANK() OVER (PARTITION BY A.PERSON_ID ORDER BY A.LAST_UPDATE_DATE DESC, A.LOC_START_DATE DESC, A.LOC_END_DATE ASC ) RANK FROM APPS.TCS_MIS_EIT_LOCATION_EX A, (select :begin_date + level - 1 the_date from dual connect by level <= :end_date - :begin_date + 1 ) l WHERE A.TRAVEL_TYPE in ('B','S') AND l.the_date BETWEEN A.EFFECTIVE_START_DATE AND A.EFFECTIVE_END_DATE AND l.the_date BETWEEN A.LOC_START_DATE AND A.LOC_END_DATE ) WHERE RANK = 1 AND PERSON_ID = DAST.PERSON_ID ) LOG ERRORS INTO STG_ERR('ErrLine-->'||ERR_LINE||' Date-->'||TO_CHAR(SYSDATE,'DD-MON-YYY HH:MI:SS am')) REJECT LIMIT UNLIMITED;
and combining the last two queries and join wit the rage of the dates
UPDATE STG DAST SET TRAVEL_COUNTRY = case when DAST.LOCATION_COUNTRY = DAST.BASE_COUNTRY then DAST.BASE_COUNTRY_NAME else (SELECT TERRITORY_SHORT_NAME FROM APPS.FND_TERRITORIES_TL FTT WHERE FTT.TERRITORY_CODE = DAST.LOCATION_COUNTRY ) end, TRAVEL_TYPE = case when DAST.LOCATION_COUNTRY = DAST.BASE_COUNTRY then 'N/A' else 'LT' end WHERE DAST.ENTRY_DATE in (select :begin_date + level - 1 from dual connect by level <= :end_date - :begin_date + 1 ) AND NOT EXISTS(SELECT null FROM APPS.TCS_MIS_EIT_LOCATION_EX EIT, (select :begin_date + level - 1 the_date from dual connect by level <= :end_date - :begin_date + 1 ) l WHERE DAST.PERSON_ID = EIT.PERSON_ID AND l.the_date BETWEEN EIT.LOC_START_DATE AND EIT.LOC_END_DATE AND l.the_date BETWEEN EIT.EFFECTIVE_START_DATE AND EIT.EFFECTIVE_END_DATE ) LOG ERRORS INTO STG_ERR('ErrLine-->'||ERR_LINE||' Date-->'||TO_CHAR(SYSDATE,'DD-MON-YYY HH:MI:SS am')) REJECT LIMIT UNLIMITED;
Concerning
Etbin
-
I have this situation: I have generate a code (this happens through a database function) when a new record is saved. This code comes from another field of this record (parameter passed to the function). I (have to) use Apex 3, so I can't use the functionality of the Apex 4.
To be specific: I have a recording of books program. Every book has a unique library code (this isn't the PK). Labrary code is based on the year of publication (e.g. B2010-00035). So after entering a new book, prior to registration, the year of publication (e.g., 2010) is checked, and throug a database function (for example f_get_new_library_code (2010) returns "B2010-00036") library code must be completed.
How can I do this in the best way, taking into account, I can't use dynamic measurements of Apex 4 (unfortunately).Hello
If you had specified the type of form the response would have been more precisely!
If it's a form of a row, then you can write a calculation OnSubmit where you call your function.
If it's a tabular form you will need to write a process OnSubmit after Comp & Val you through the bays of apex_application.g_f and update the necessary tables.Kind regards
Maybe you are looking for
-
Using the drive 100% running 8.1 Win
Help me please, What can I do on this 100% disk usage?It is going on all the time... I added the photo, so that you can see. Sometimes he says that the system is the problem, sometimes programs like utorrent or firefox,Other times it's simply nothing
-
CTRL + F is out of use in my Firefox 5.0
Whenever I press Ctrl + F or edit > find in my Firefox 5.0 cope, nothing happens.
-
I hope that they solve the problem of wifi
Update my iPad Air. 9.2.1 now, I lose my wifi constantly. I hope that they address it quickly. I wish they gave us an option to return to 8.1, it worked perfectly.
-
My T420 has an element in the device manager that I can't find a driver for. He called the 'Base system device', and he has this hardware id: VEN_1180 & DEV_E823 & SUBSYS_21CE17AA & REV_05 PCI Where is this driver available?
-
When you are working in photoshop, a message telling me that I need to delete my "scratch disk" appears. What and how can I do this?