call sub procedure for updating the table - need help
Hi allI have a scneario wherein I get three values 0,2.5 and 57.
For each value, I'll call another procedure that updates a table "sample_dest".
The "sample_dest" table has a column "dest_nbr."
Now, for each three values I get,
I want to update only one record in the table 'sample_dest '.
for example, I want to update the column "dest_nbr" with a value of 59.5 (0 + 2.5 + 57).
I am unable to do this, because every time the procedure is called,
the previous values are not stored. 57 is the last value I get,
I am able to store only 57. But I want 59.5 to be updated in the table.
How can I achieve this.
Help, please.
Concerning
Rambeau.
This should be done in a single sql statement, not in a loop of cursor (which is what it looks like you're doing). If sample_desc already contains records for samples, so it should look like:
UPDATE sample_desc sdesc
SET desc = (SELECT AVG(code) FROM sample_dest sdest
WHERE sdesc.sample = sdest.sample)
WHERE EXISTS (SELECT 1 FROM sample_dest sdest
WHERE sdesc.sample = sdest.sample)
If sample_desc does not already contain records (unknown from your description), then it would be an insert as:
INSERT INTO sample_desc
SELECT sample, AVG(code)
FROM sample_dest sdest
GROUP BY sample
John
Tags: Database
Similar Questions
-
Change in the merger of insert and create a procedure for updating the records after
Hello
I have a table that contains about 50 M lines of partition, and every day I have an application that performs a merge to insert records statement about 100 k per day and it's 300 M updates a day.
Because I both update and insert the application performs a merge.
I need to make at least 500 M, updated day by day, and for this reason this solution doesn't have enough performance for what I'm asking.
I think another solution that I will try to implement now, and I just posted this in an attempt to get help on the option that I may have to do.
I want to start putting in place:
-Locations is updated 'last_record_date' using 'KEY1' and 'Key2' "KEY3";
-Change the application to only inserts into a temporary table.
-Have two procedures, one that takes the new records from the temporary table and inserts it into the final table, and another that selects records which is updated and perform an update.
-This two procedures will choose the records and delete them from the temporary table (or mark them as updated\inserted).
The volume is very large, so performance is a challenge! That's why I'm writing this, because a solution with enough performance for the intermediate stage will be difficult.
My final table is partitioned by date and the date is the area that I need to update (instead of create daily partitions in order to reduce the frequency of the movement of the line, I create monthly partitions)!
It is currently my table definition:
Thank youCREATE TABLE MY_TEST_TABLE (KEY1 VARCHAR2(50 BYTE) , KEY2 VARCHAR2(50 BYTE) NOT NULL, KEY3 VARCHAR2(50 BYTE) , last_record_date VARCHAR2(50 BYTE) NOT NULL) PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( BUFFER_POOL DEFAULT ) NOCACHE MONITORING ENABLE ROW MOVEMENT PARTITION BY RANGE (last_record_date) ( PARTITION MY_TEST_TABLE_201112 VALUES LESS THAN ('20120101') PCTFREE 10 INITRANS 1 MAXTRANS 255 NOLOGGING, PARTITION MY_TEST_TABLE_201201 VALUES LESS THAN ('20120201') PCTFREE 10 INITRANS 1 MAXTRANS 255 NOLOGGING, PARTITION MY_TEST_TABLE_201202 VALUES LESS THAN ('20120301') PCTFREE 10 INITRANS 1 MAXTRANS 255 NOLOGGING, PARTITION def VALUES LESS THAN (MAXVALUE) PCTFREE 10 INITRANS 1 MAXTRANS 255 NOLOGGING ) NOPARALLEL / -- Constraints for MY_TEST_TABLE ALTER TABLE MY_TEST_TABLE ADD CHECK ("KEY1" IS NOT NULL) / ALTER TABLE MY_TEST_TABLE ADD CHECK ("KEY2" IS NOT NULL) / ALTER TABLE MY_TEST_TABLE ADD CHECK ("KEY3" IS NOT NULL) / ALTER TABLE MY_TEST_TABLE ADD CONSTRAINT pk_MY_TEST_TABLE PRIMARY KEY (KEY1, KEY2, KEY3) USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 /
Ricardo Tomasnaoseionome wrote:
HelloMy version is:
Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit ProductionIt's the DOF I used to create the database.
The merger is common during every day for about 10 M records.
There are several methods to do the update, but they do sequencially to avoid deadlocks (because I can't control the source and each process can update the same keys.
The update uses "KEY1, KEY2, KEY3" to update the value 'LAST_RECORD_DATE' have impact by being date or varchar2?
I'm still waiting to receive permissions in order to follow up the matter, but in the meantime, in that I am trying to implement this work around in order to accelerate a development in the case where it would be necessary! Comments only I have at the moment, it is that he is not able to process the total amount of records timely (order book is generated).
Thank you
RicardoWell, the first thing we do is to change the type of data type varchar to a date. The main impact is that a date is not a string, it's a date. If you are adding data processes in different date formats (which is possible when you use a character to store information) you're going to be very sad (good luck converting back an effective date).
An example of how this can happen easily.
ME_TUBBZ?select to_char(sysdate) from dual; TO_CHAR(SYSDATE) ----------------------------- 12-jan-2012 10 55:33 1 row selected. Elapsed: 00:00:00.01 ME_TUBBZ?alter session set nls_date_format = 'yyyy-mon-dd'; Session altered. Elapsed: 00:00:00.01 ME_TUBBZ?select to_char(sysdate) from dual; TO_CHAR(SYSDATE) -------------------- 2012-jan-12 1 row selected. Elapsed: 00:00:00.00
Assuming that the client passes the column as an Oracle DATE will make an (implicit) conversion to store the data as a string, which will be based on the current settings of the NLS for the session. This allows also for someone to completely non-jour the information in the column (super bad). It's just really bad form to use strings to store dates, numbers, anything that is not naturally a string.
Based on the description of your problem, I can't imagine how your partitioning scheme performs one action in another that require more work in order to process the updates (which are most of your needs). Partitioning does not equate to increase performance. It is a tool that, like every tool has its place, but I do not think that this is justified for what you do (certainly not how you currently use it anyway).
I say no partitioning can not be useful for you, but I don't think that on the column that you are currently using is 'good '.
Something I would like to personally study (must be able to compare this approach to your course, if you need parameters for comparison) if I were you would be using a Table Index organized for it. It will take more time to perform the operations insertion, but that is a small part of all the work that you do for this process. For updates, it should eliminate a lot of IO, assuming that you are doing an INDEX seek followed by a table access by ROWID to perform updates. This recommendation assumes that everything you said is true. You have 4 columns in your table, of which 3 are components of the primary key and the 4th is a date (note I did not string :)) and that you refresh mainly, not fit.) Also that you have no 'secondary' on this entity index (and none are needed).
I would investigate this approach before the solution of temporary table that you are currently studying.
See you soon,.
-
Form of ADE for updating the table
Jin
I have a requirement where I have to create a form of the ADF that contains a reading only a table contains data from the xml support.
and there are 3 buttons
(1) Insert = to add a new row to the table
(2) edit to edit a line =
(3) = save to save the changes.
Here the first button is to create an Insert button but when it is pressed a new editable table should appear on the same page (just below the single table reading). and after inserting the details when I press on save, it should update the single table reading.
same way when I press the button to change the line that is selected should appear in the editable table. and press save update read only files...
If anyone has an idea please do not answer...Hello
Try this
NCCC = (DCBindingContainer) DCBindingContainer, BC.
DCIteratorBinding iter = dcBc.findIteratorBinding("EditPageiterator");
iter.setCurrentRowWithKey (key); set the key to the line,
-
Update the table using discoverer
Hello
I'm trying to update a table whenever the user runs a report of the Office of the discoverer. I tried to use a function to do the job, but I get the error below.
ORA-14551: cannot perform the DML operation within a query.
I also tried to
1. create a procedure and update the table in this procedure.
2. function to create and call the procedure created earlier in this function and use it in the discoverer, but still does not work and I get the same error ORA-14551.
Please let me know if this is possible at all the. If SO, let me know the steps to do so.
Thank you.Hello
Yes you can update the discoverer dashboards using a PL/SQL function. You must make the function a standalone transaction. for example
FUNCTION update_record (key_field VARCHAR2) RETURN VARCHAR2
IS
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
..
UPDATE your_table
..
COMMIT;
..Rod West
-
Update my application. What is the proper procedure for updating an app/folio?
I designed a folio in Indesign CS6 and created a folio application in adobe dps and downloaded successfully on the app store. Now, I want to update my application. What is the proper procedure for updating an app/folio?
If it's a simple editing application, you will have to recreate the whole thing and
submit an Apple update for approval.
-
What API can be used to update the table cs_estimate_details (repair)
I need to update the columns 'pricing_context' and 'pricing_attribute1' in the cs_estimate_details table.
Which API can be used to update the columns. Where can I update the table directly?
Try to use this "CS_Charge_Details_PVT" which in turn call "CS_ESTIMATE_DETAILS_PKG".
-
Using the procedure to display the table of multiple data
Hi, I need help for the procedure in oracle
I want to create the procedure to display the table of multiples with sample plan
with a parameter imployee_id to display an employee_id, name, function, start_date, end_date
IAM using this query to select more than one table
SELECT e.employee_id, e.first_name, j.job_title, h.start_date, h.end_date
E EMPLOYEES
JOIN j jobs
ON j.job_id = e.job_id
JOIN the job_history:
ON h.employee_id = e.employee_id
WHERE e.employee_id = 200;
Thanks for the help
Blu and Billy showed you the 'real' solution. You can display the data returned by a cursor ref in SQL Developer, too:
http://www.thatjeffsmith.com/archive/2011/12/SQL-Developer-tip-viewing-refcursor-output/
Yet as a duty for a beginner is generally do not have the expected solution. Usually, teachers want to see you using a LOOP and dbms_output. something like
DECLARE
Xy CURSOR IS
SELECT whatever
As much as;
BEGIN
FOR r IN xy LOOP
dbms_output.put_line (r.col1 |' # ' | r.col2);
END LOOP;
END;
Of course this suggestion will inaugurate a discussion abusing DBMS output but I keep my position that it is authorized to use it for learning the basics.
-
How to update the table with the number management
Hello
I need as there is a loc_tab of the created table as below,
CREATE TABLE loc_tab
(
Country_ID NUMBER,
country_code VARCHAR2 (3),
country_name VARCHAR2 (50).
State_ID NUMBER,
state_code VARCHAR2 (3),
state_name VARCHAR2 (50).
city_id NUMBER,
city_code VARCHAR2 (3),
city_name VARCHAR2 (50)
);
I inserted records like below,
Now, I wanted to update the table such that all ID columns are updated with running number.COUNTRY_ID COUNTRY_CODE COUNTRY_NAME STATE_ID STATE_CODE STATE_NAME CITY_ID CITY_CODE CITY_NAME IND INDIA TN TAMIL NADU CHN CHENNAI IND INDIA TN TAMIL NADU TRI TRICHY IND INDIA TN TAMIL NADU CMT COIMBATORE IND INDIA TN TAMIL NADU MDU MADURAI IND INDIA AP ANDHRA PRADESH HYD HYDERABAD IND INDIA AP ANDHRA PRADESH SEC SECUNDRABAD AUS AUSTRALIA QLD QUEENSLAND BRI BRISBANE AUS AUSTRALIA TAS TASMANIA HB HOBART AUS AUSTRALIA TAS TASMANIA CCE CITY OF CLEARANCE AUS AUSTRALIA TAS TASMANIA BUR BURNIE
Each ID columns should get incremented so that, for Country_ID column corresponding to "India" If country_id is 1, that there must be one for all the lines with the name as "India". Likewise for "Australia".
In the case of State, she also has the same logic with numbers repeated until the very name of the State comes.
For the city, it of course will hold separate ID only because the name of the city will not get duplicated.
This update must be done in the normal way using simple SQL such as no PLSQL don't like looping, etc... is involved.
Here are the contents of the table, and that's how the table should be updated,
Thank you and best regards,COUNTRY_ID COUNTRY_CODE COUNTRY_NAME STATE_ID STATE_CODE STATE_NAME CITY_ID CITY_CODE CITY_NAME 1 IND INDIA 1 TN TAMIL NADU 1 CHN CHENNAI 1 IND INDIA 1 TN TAMIL NADU 2 TRI TRICHY 1 IND INDIA 1 TN TAMIL NADU 3 CMT COIMBATORE 1 IND INDIA 1 TN TAMIL NADU 4 MDU MADURAI 1 IND INDIA 2 AP ANDHRA PRADESH 1 HYD HYDERABAD 1 IND INDIA 2 AP ANDHRA PRADESH 2 SEC SECUNDRABAD 2 AUS AUSTRALIA 1 QLD QUEENSLAND 1 BRI BRISBANE 2 AUS AUSTRALIA 2 TAS TASMANIA 1 HB HOBART 2 AUS AUSTRALIA 2 TAS TASMANIA 2 CCE CITY OF CLEARANCE 2 AUS AUSTRALIA 2 TAS TASMANIA 3 BUR BURNIE
Shiva
-
procedure for updating records
I want to write a procedure.
I have directed that is created after an interface table. He has a * decode _status * column that has a value either 'P' or 'NP '.
Now I reprocess all records with 'NP' and update status using another table DECODE
Staging table and decode table has a relationship.
Put in scene table has columns SNO and SCODE where as DECODE table has columns SERIAL_NO and CODE
Now. I have a join here staged. SNO = DECODE. SERIAL_NO. By using this join I get SCODE value as being code.
Now can you please tell me how to upgrade these files which have 'NP' as DECODE_STATUS.
I'm writing a procedure that gives me an error.
Start
so that S.DECODE_STATUS = 'NP'
loop
update of staging all SCODE = (case when (SNO) in (select S.SNO SCENE S layout, DECODER D WHERE D.SERIAL_NO = S.SNO) THEN D.CODE)
OTHERWISE NULL TERMINATOR)
end loop;
end;
Edited by: Chhatar on Sep 18, 2012 11:38
Edited by: Chhatar on Sep 18, 2012 11:39It is ok for the source and target are the same.
Do drag your staging tables and DECODE in the source of the interface box.
Join the two tables on STAGING.sno = DECODE.serial_no
Apply a filter to the table of staging STAGING.decode_status = 'NP '.In the target box, drag the staging table.
Map the fields you want to update, as well as the join (serial_no) fieldIn KM controls, select INSERT = FALSE & UPDATE = TRUE
When you run this interface, ODI fills a flow table with the results of the join logic and source table filter (i.e. those which records where decode_status = 'NP'). It will then update the table setting with these results.
-
Update the table on the dialog flow back task...
Hi all
I have a table. In a context menu of the table, a user uses a menu command to launch a workflow task merely as inline popup dialog box, which allows them to alter certain data associated with the selected line. It all works very well.
What I'm trying to understand, that's how I trigger a refresh of partial page on the table once the workflow returned and the dialog box closes. I tried to call a support as target bean method of the "listener after" for the call activity of workflow that call the stubborn workflow, which calls AdfFacesContext.getCurrentInstance () .addPartialTarget (table), but which did not cause a refresh of the table. I waited a bit that would be the case.
So, what event can I link at the right time in order to update the table?
Thank youHello
When you open a workflow bounded in a small popup, then you use the earpiece back on the component that runs the pop-up window to refresh the table. On http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html, see example #69
Frank
-
How do I update the table in Jdev
Hello
I use Jdev 11.1.1.7.1.
The control of data, I added that ADF only read the table. When I click on the button create and return to the report screen, highlight lines are added.
Highlighted those who is not inserted into the DB table but he showed in the report. How to remove it. How can I update the table?
Kindly advice me.
Thank you
Swathi
That's what I got:
-You have a table read-only, and a link to create.
-When you press the link create a popup will be launched with a new record (may be a form in the same table iterator).
-When you press save to save the changes validation triggers, stop you to insert the record.
-After the fire of validation you will close the pop-up window (by pressing icon or by pressing Cancel).
-After closure of the pop-up window, you will find that reading one table has some blank lines.
If it is your problem if you have 2 choices:
1. in the AppModule you can make a new instance on the view object (to which redirect the table) If your view object called 'EmployeesView', so, in AppModule, you should have EmployeeView1 and EmployeeView2 and your table may point to EmployeeView1, and when you create new line create in EmployeeView2 and after completing the creation you can run the query and then refresh the table (as shown in the following code).
2 - the second option in the popup cancelListener link at the rear bean method then you can update the table by program as:
DCIteratorBinding iter = (DCIteratorBinding) BindingContext.getCurrent().getCurrentBindingsEntry().get("TableIteratorName"); // from pageDef. iter.getViewObject().executeQuery(); RequestContext.getCurrentInstance().addPartialTarget(getTableComponent());// from table Binding property bind it to object in back bean
-
Hi all
I have a page jspx, with a table and a button.
Create the table data control, and it contains 4 columns
(Name, card student, asked (Question or answer)).
I create the code for the button to work
1. Select a record
2 send email
3. when I send the request goes from Q to A
All work fine. The mail has been sent. The demand for DB password Q has. But in my jspx table refreshes.
Until I close and open again, it displays all the data.
How cal I solve it?
Thanks in advance
Christos.
Simply add partialTrigger on table pointing to the button.
It will update the table when the button is clicked.
-
How to update the table when change list item in the classic report
Hello
I worked with apex 4.2 and I create normal classic report with list (named loved) select a column, now I want to update the table when the user changes the list with the new value, I can't create a dynamic action to do this, I create checkbox with the primary key and the loop for check point to update the table but I can not get the value of the list item. and for more speed, the user want to do it when changing the value from the list.
My question
1. how to do it in javascript and get the value of the list item and update the table with the new value
2. do I have to use the API to create the list item so I can get the value of the report item or what.
Thank you
AhmedYou can find a lot of information in this forum (and outside in google) when you search for AJAX processes and demand. However, the tutorial in the link below should be useful:
http://www.Oracle.com/WebFolder/technetwork/tutorials/OBE/DB/hol08/apexweb20/ajax_otn.htmBTW, if we answer your question, don't forget to mark the appropriate post as correct. It will help all of us in the forum.
-
Update the table of contents, errors in bookmarks
When I update my table of contenst, it creates errors in my favorites. I have a hierarchy of level three with my titles of paragraph in my table of contents. When I update the table of contents, it takes the last item in my lowest level and a level higher than it is actually.
Any ideas of what is happening and how can I fix?
OK, thanks to your last message, I began to explore the Table of contents dialog box and understood what the problem was. It had to do with the levels that I had assigned to the table of content items, which I was incompatible. Now I have the right levels assigned to the table of content items and it updated bookmarks perfectly!
Thanks for your help.
-
Hello
How can I use statistics for all the tables in a schema in SQL Developer? and how long will it take on average?
Thank you
Jay.
Select the connection and right-click on it and select schema statistics collection
Maybe you are looking for
-
How to make my user scripts work again
I have a user scripts that I use for my zoo game I play a they worked fine until yesterday. I get the shield who told me this page, I is not course when I mark it dangerous by firefox one do a refresh still can not get my user script
-
Uninstall the software - HP Officejet K8600 (Mac)
I just replaced my Officejet K8600 with the Officejet Pro 8600 Plus. I would like to delete the HP software for the other printer that no longer works. How to do that on a Mac?
-
I'm running an all in one HP PSC 2410 (since 2003) with Windows XP SP 3, current Firefox & IE8. My HP Director stopped opening after I upgraded from IE 6 to IE8 it several months ago. While looking for help on HP, I came across a patch drivers XP 200
-
Windows will not use the disks of backup file to restore, get "unknown error."
Backup done recently will not work when you try to restore the files. System indicates an "unspecified error" has occurred. No clue on what is blocking recovery? Thank you
-
Windows key on microsoft umniversal folding keyboard
I saw the post on the keys F to the MUFK., anyone know the Windows key mapping?