Update column using a calculation based on a query
HelloI need to update an empty column, that I created in my table. I created a query that returns the variables I need in the calculation, but I don't know how to link.
This query works very well.
Select z.seq_no
, z.Day_X
, z.Day_Y
, x.Night_X
, x.Night_Y
from
(select seq_no, ga.centre_x Day_X, ga.centre_y Day_Y
from MICHAELC_Nov_01_final ff, rbn_gis_area ga
where ff.day_addr_code = ga.sp_code) z
,(select seq_no, ga.centre_x Night_X, ga.centre_y Night_Y
from MICHAELC_Nov_01_final ff, rbn_gis_area ga
where ff.risk_addr_code = ga.sp_code) x
where z.seq_no = x.seq_no
What I'm asking, is my column called Distance_to_work be calculated as follows:Distance_to_work = (100 * sqrt (power ( (Day_X - Night_X), 2) + power ( (Day_Y - Night_Y), 2)))
That's what I tried without success:UPDATE MICHAELC_Nov_01_final ff
SET
Distance_to_work = (select (100 * sqrt (power ( (Day_X - Night_X), 2) + power ( (Day_Y - Night_Y), 2))))
from
(Select z.seq_no
, z.Day_X
, z.Day_Y
, x.Night_X
, x.Night_Y
from
(select seq_no, ga.centre_x Day_X, ga.centre_y Day_Y
from MICHAELC_Nov_01_final ff, rbn_gis_area ga
where ff.day_addr_code = ga.sp_code) z
,(select seq_no, ga.centre_x Night_X, ga.centre_y Night_Y
from MICHAELC_Nov_01_final ff, rbn_gis_area ga
where ff.risk_addr_code = ga.sp_code) x
where z.seq_no = x.seq_no) w
where ff.sp_code = w.sp_code
Any help would be appreciated.Banner:
Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production."
AMT for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
Hello
885178 wrote:
... with Temp_table as ( select 77317027 sp_code, 28.137 x_day, 28.244 x_night, -26.179 y_day, -26.092 y_night, 13.7905 distance_to_work from dual union all select 57218000 sp_code, 30.897 x_day, 30.851 x_night, -30.022 y_day, -29.884 y_night, 14.54647 distance_to_work from dual union all select 70406009 sp_code, 28.131 x_day, 28.192 x_night, -26.316 y_day, -25.837 y_night, 48.28685 distance_to_work from dual ) select * from Temp_table
What is temporary_table? What is the role in this problem?
with michaelc_nov_01_final2 as ( select 77317027 sp_code, 77317029 risk_addr_code, 77303000 day_addr_code, 1274799 seq_no, 13.7905 distance_to_work from dual union all select 57218000 sp_code, 57271032 risk_addr_code, 57218000 day_addr_code, 1624223 seq_no, 14.54647 distance_to_work from dual union all select 70406009 sp_code, 77603008 risk_addr_code, 77301006 day_addr_code, 2240402 seq_no, 48.28685 distance_to_work from dual ) select * from michaelc_nov_01_final2
What is micahealc_nov_01_final2? Do you want to micahealc_nov_01_final be changed so that it's like micahealc_nov_01_final2? Can't you just after the desired results, like this:
` SP_CODE RISK_ADDR_CODE DAY_ADDR_CODE SEQ_NO DISTANCE_TO_WORK
---------- -------------- ------------- ---------- ----------------
77317027 77317029 77303000 1274799 13.7905765
57218000 57271032 57218000 1624223 14.5464772
70406009 77603008 77301006 2240402 48.2868512
?
The above data, it is what michaelc_nov_01_final looks like after executing the MERGE statement below. Distance_to_work is exactly what it is in michaelc_nov_01_finalw, but looks like you're just rounded differently.
The rbn_gis_area is created. There is a column called version and the latest version = 10. This will bring unique lines.
There is no version column in the code above.
with rbn_gis_area as ( select 77303000 sp_code, 28.137 centre_x, -26.179 centre_y from dual union all ...
Also note that a sp_code may be day_addr_code as seen in the example above. SEQ No. is not unique. There is a column in michaelc_nov_01_final called cla_case which is unique.
There is no column cla_case in the code above.
with michaelc_nov_01_final as ( select 77317027 sp_code, 77317029 risk_addr_code, 77303000 day_addr_code, 1274799 seq_no, '' distance_to_work from dual union all ...
What follows assumes that seq_no is unique:
MERGE INTO michaelc_nov_01_final dst
USING (
SELECT ff.seq_no
, MIN (d.centre_x) AS day_x
, MIN (d.centre_y) AS day_y
, MIN (n.centre_x) AS night_x
, MIN (n.centre_y) AS night_y
FROM michaelc_nov_01_final ff
JOIN rbn_gis_area d ON ff.day_addr_code = d.sp_code
JOIN rbn_gis_area n ON ff.risk_addr_code = n.sp_code
GROUP BY ff.seq_no
) src
ON (src.seq_no = dst.seq_no)
WHEN MATCHED THEN
UPDATE SET dst.distance_to_work = 100 * SQRT ( POWER (src.day_x - src.night_x, 2)
+ POWER (src.day_y - src.night_y, 2)
)
;
If only cla_case in your real of the table, and then use cla_case instead of seq_no above.
I used a line of GROUP of to get (maximum) in src for each line of the dst. If you have a version column, you can use instead, or GROUP, just make sure that each line of the CBC (at most) corresponds to a line in dst.
Tags: Database
Similar Questions
-
Basic information. on my computer. >
Right to copy of WINDOWS 7 HOME PREMIUM 2009 SERVICE PACK 1
System =
Model = HP PRO DESK GI 400 MT
Processor = Intel Core i5 - 4690 S CPU @ 3.20 GHz 3,20 GHz
Installed memory (RAM): 8.00 GB
System type = 64 - bit Operating System
--------------------------------------------------------------------------
Purpose of the computer is a home PC used for e-mails, Internet, surfing, composition in WORD, EXCEL, etc.. Not used for business at all. No SKYPE or any other communication, has just written Communications
-----------------------------------------------------------------------------
Currently, SELECT THE UPDATES YOU WANT TO INSTALL watch >
Skype for Windows 7.3 desktop (KB2876229)
Update for Windows 7 for x 64-based systems (KB3080079)
Update for Windows 7 for x 64-based systems (KB3102429)
Update for Windows 7 for x 64-based systems (KB3123862)
Update for Windows 7 for x 64-based systems (KB3139923)
Update for Windows 7 for x 64-based systems (KB3140245)
Update for Windows 7 for x 64-based systems (KB3156417)----------------------------------------------------------------------------- I know that some the updates affect Windows 10 loading, I want any. I'll stick with Windows 7.
-----------------------------------------------------------------------------
Issues related to the:
1 should. what updates I really low charge based on my use now and in the future?
2 is it too late to perform a WINDOWS ANYTIME UPGRADE?
a. Research on the web, seems to come into conflict if it is still possible to do so.
b. I see there are sites indicating WINDOWS ANYTIME UPGRADE FREE KEYS. Is it "FREE" and at what price?
c. I see that Microsoft will stop supporting Windows 7 completely in a few years. What are the options to replace my current WINDOWS 7 HOME PREMIUM?
Thank you for any assistance that you can share.
RT
Hi Roger,
With the description, I understand that you have a few questions about Windows Anytime Upgrade and Windows updates on your Windows 7 machine. I will certainly help you to the query.
I would like to inform you that mentioned updates are recommended and are important for maintaining the operating system up-to-date. You can see below the article for more details:
Updates: frequently asked questions
http://Windows.Microsoft.com/en-us/Windows/updates-FAQ#1TC=Windows-7
In addition, if you do not want to install the Windows 10 operating system, then you can refer to the below section mentioned to cancel the upgrade.
Upgrade Windows 10: practical information on planning and notifications
https://support.Microsoft.com/en-us/KB/3095675
However, you can run Windows Anytime Upgrade in the following operating system until the product operating system becomes obsolete you can buy the upgrade button. I would also like to inform you that the operating system Windows 10 is free upgrade until July 29, 2016. So you can also choose the latest version of Windows before windows gets obsolete for support.
Hope this information is useful. Please come back to write to us if you need more help, we will be happy to help you.
Concerning
Ravi Kumar
-
updating columns by using variables substitiution dataform
Hi all
I would like to know if there is any chance to update columns in the form of data using proxy.
As if I need to create a form of data from jan to & currmonth. (June), so changing the value subvar say August, I'll be able to get the columns dynamically in the change of form of data until August. ?
Thank youHi, yes you can create a hierarchy of alternative for periods. For more information, see rolling forecast Web Form
You can then use the descendants function of your other rollups
Another way to define your period as sparse. Periods a link to an attribute fades with 1... 12 for the month and try to use fewer function selector Member dataform
As you can see, none of them is easy
-
Entre-Filtre on the column using calculated values of presentation-variable
Hi all
I would like to know if it is possible to filter a column with an entre-declaration using two calculations on an single variable of presentation in Oracle BI answers
What I have:
-OBIEE 10 g
A line chart that shows the revenue over a period of several years: in 1999, there could be € 100,000 in 2000, it could be € 80,000,..., in 2009, it might be €95,000 and so on.
What I want:
Now, I would like to create a dashboard can quickly choose a given year, for example, 2006.
The table should then display the data for the year given (2006-...) and two years more early (2004, 2005) and two years after the year (2007,2008) chosen.
Example:
If 2006 is chosen, then the data from 2004 to 2008 should be indicated in the table
If 2000 is chosen, then 1998 to 2002 data should be included in the table.
[...]
What I did:
-J' created the prompt, set its presentation to var_yearvariable.
-J' then I created a filter on my years column, choose "between" in the drop-down list.
-J' added two 'Variable-fields in the filter dialog', each filled with var_year and a default value.
-J' tried to add a + 2 or - 2 in the field of variable expression, but (of course) has been a mistake.
Thanks in advance and greetings from the Germany,
Chris
Edited by: user12288481 the 04.08.2010 13:18Just reverse the filter:
@{var_year} {2009} BETWEEN "-Dates. "" Date ISO year '-2 AND "-Dates. "" Date ISO year ' + 2
concerning
John
http://www.obiee101.blogspot.com/ -
How to replace the value of a column in a table based on the value in the second column?
Hi, I would like to find in a table 2D for values that meet certain criteria (for example, a column< 0.98).="" based="" on="" which="" rows="" meet="" this="" criteria,="" i="" want="" to="" replace="" the="" values="" in="" a="" different="" column="" of="" the="" array="" (change="" to="" 'nan'="" so="" that="" the="" values="" will="" not="" be="" included="" in="" any="" calculations="" on="" that="" column,="" for="" example="" the="" finding="" the="" mean).="" i've="" attached="" a="" sample="" .csv="" file.="" if="" the="" values="" in="" column="" 3="" (index="" 2)="" are="" less="" than="" 0.980="" (or="" some="" other="" user="" defined="" value),="" then="" the="" value="" in="" column="" 2="" (index="" 1)="" should="" be="" replaced="" with="" nan.="" can="" someone="" help="" out="" with="" this="" search="" and="" replace="">
Thank you
Keith
(using LV 2009 SP1)
A few quick hits.
You can merge the two for loops
You have not need one of the constants 1 and 2 in the index table. They will solve automatically when you expand on the index picture, once you have wired to 0 in the column index.
It seems a lot of handling additional table spent unnecessarily.
See below. I did not try to duplicate your code to see how it actually works, but I believe that I have attached will give the same result with less steps.
-
How create/update files when the original Version is based on a query of outer join?
Hi gurus,
I created a custom page where I use a table-style area where I question my VO records, based on a query of outer join. This query contains my table looks, where I would like to insert/update records, and joined the table of standard elements, which is external with my custom table.
When I now question my files in the t, I have a record for each record in the table section, which is ok, but when I 'Refresh' some fields of my custom table and attempt to commit, I get the message "unable to complete the transaction on record. Cause: The record has been deleted by another user. "Action: cancel the transaction and re - query records to get new data.
The reason why because a record is to be inserted rather than updating because in fact there is not yet in my custom table.
The reason why I'm using the outer join, is because I don't want the user to create a record for each item one by one.
There is no work around for this?
Thanks in advance!
BR
GuyHello
You can try this.In your EntityImpl.java to extend OAPlsqlEntityImpl.
Override the updateRow() method and coding your insert statement to insert into a table custom here.
Don't forget, you must ignore the lines for which your custom table columns are null-Idris
-
Update column as a popup LOV with dynamic action
I'm trying to update a column in a tabular form, based on a change in column LOV in this tabular form. It is not just id/description, I need another column.
I can get the change event is triggered, it is the javascript code to change the value of the field, that I can't go to work. I tried a number of solutions forum, but could not get to work. The LOV field is F07, the update field based on a query if F05.
I tried this technique but could not go beyond "closer", which did not work.
var line, priceelement, testelement, getpriceajax, price;
TestElement = apex.jquery('#'+this.triggeringElement.id);
line = testelement.closest ('tr');
priceelement = row.find ('[name = 'PRICE']');
getpriceajax = new htmldb_Get (null, $v ('pFlowId'), 'APPLICATION_PROCESS is get_price', $v ('pFlowStepId'));
getpriceajax.addParam ('x 01', $V (this.triggeringElement.id));
price = getpriceajax.get ();
priceelement. Text (Price);
I tried this kind of reference that did not work:
$("td [headers = 'SAL'] input: visible: eq (2)")
var line
bliId
bliNbr
getBliNbr;
bliId = apex.jQuery (this.triggeringElement);
Console.log (bliId);
line = bliId.closest ('tr');
Console.log (Row);
bliNbr = row.find ('input [name = f05]');
getBliNbr = new htmldb_Get (null, $v ('pFlowId'), 'APPLICATION_PROCESS is GET_BLI_NBR', $v ('pFlowStepId'));
getBliNbr.addParam ('x 01', $v (this.triggeringElement.id));
var ajaxResult = getBliNbr.get ();
Alert (ajaxResult);
bliNbr.val (ajaxResult);
1 / testelement = apex.jquery('#'+this.triggeringElement.id);
There is no need that you already have a reference to this point with this.triggeringElement. Effectively, you take the ID of it and re - get.
2 / bliNbr = row.find('input[name=f05]');
In your code example, the element is f05 and not 6
3 / var ajaxResult = getBliNbr.get ();
do it once only, the get() method. If you call it several times, then the call also will be several times. Because the get() method is synchronous means also that it locks the browser to the top, and so several calls cause longer periods of absence of response.
I also did an example of apex.server.process, who is currently in your demo application. You can find documentation about it here: The JavaScript API
var line
bliId
bliNbr
getBliNbr;
bliId = apex.jQuery (this.triggeringElement);
Console.log (bliId);
line = bliId.closest ('tr');
Console.log (Row);
bliNbr = row.find ('input [name = f05]');
/*
getBliNbr = new htmldb_Get (null, $v ('pFlowId'), 'APPLICATION_PROCESS is GET_BLI_NBR', $v ('pFlowStepId'));
getBliNbr.addParam ('x 01', $v (this.triggeringElement.id));
var ajaxResult = getBliNbr.get ();
Alert (ajaxResult);
bliNbr.val (ajaxResult);
*/
Apex. Server.Process ("GET_BLI_NBR",
{' x 01 ": $v (this.triggeringElement.id) '},
{the data type: 'text', success: {function (pData)}}
Alert ("complete:" + pData);
bliNbr.val (pData);
}});
-
Updated column by max - not where it is null
Hi all
I have the following table and the date with I want to update the column containing NULL values
different date, these data are the maxmium number in the same column.
I used this but this update columns with same value. So, it's not what I wantcreate table test (id number(9), name number(9)); insert into test values(1,2); insert into test values(2,2); insert into test values(3,2); insert into test values(4,2); insert into test values(5,2); insert into test values(6,null); insert into test values(7,null); insert into test values(7,null);
I want the result like thisupdate test set name=(select max(name)+1) from test) where name is null;
Note: the Id column may doubleid name 1 2 2 2 3 2 4 2 5 2 6 3 7 4 7 5
Thanks in advance
Published by: Isabelle November 23, 2012 23:51SQL> select * 2 from test 3 / ID NAME ---------- ---------- 1 2 2 2 3 2 4 2 5 2 6 7 7 8 rows selected. SQL> update test t1 2 set name = ( 3 select name 4 from ( 5 select rowid rid, 6 max(name) over() + row_number() over(order by name nulls first,id,rowid) name 7 from test 8 ) t2 9 where t2.rid = t1.rowid 10 ) 11 where name is null 12 / 3 rows updated. SQL> select * 2 from test 3 / ID NAME ---------- ---------- 1 2 2 2 3 2 4 2 5 2 6 3 7 4 7 5 8 rows selected. SQL>
SY.
-
massive many update column of the cursor?
I have the problem of finding how to make an update of several columns using the update statement block (if possible). I know how to do it using merge or correleated update, I just want to know how to write using features in bulk by pl/sql. Here's the code for the sample tables:
Now, I want to update original emp table with job, sal, comm emp_tmp table for some empnos. So I write:create table emp_tmp as select empno, job, sal, comm from emp where deptno = 30; update emp_tmp set sal=1000, comm=200, job='CLERK'; commit;
I can't understand the syntax above idea in bulk using statements. Could you give me some advice about this? How it should be written?declare cursor c is ( select e.empno, t.job, t.sal, t.comm from emp e, emp_tmp t where e.empno = t.empno and e.empno > 7700 ); begin -- ... here I would like to use bulk feature for update statement on emp end;
Thank youA sample:
declare cursor csr is ( select t.empno, t.job, t.sal, t.comm from emp_tmp t where t.empno > 7700 ); type t_emp is table of csr%rowtype; t_emp1 t_emp; begin open csr; loop fetch csr bulk collect into t_emp1 limit 100; forall i in 1..t_emp1.count update emp set sal = t_emp1(i).sal where empno = t_emp1(i).empno; exit when csr%notfound; end loop; close csr; end;
-
View the columns in your report based on the command prompt
Hello gurus,
I have a report (pivot View) with the following dimensions and facts
1 country (Dimension)
2. the dealer group (Dimension)
3. name (Dimension) of the region from the sale of parts
4. parts name (Dimension) sales representative
5 dealer account (Dimension)
6 heart FY purchases (Fact)
7. purchases of fiscal Prv (Fact)
8% change (Fact)
I have all the dimensions of filters (as guest)
The requirement is now
When I select the country from the prompt and click on go. the report is expected to show only dealer group and measures 3.
When I choose the dealer group from the prompt and press go. the report should appears with the name of parts sales region and the corresponsing measures
So I intend to use the command prompt to display the columns according to me
from now my report shows the entire column irrespective of what I select in the command prompt. (such as the report displays all my dimensions and facts). I should be able to restrict the column in the reprot based on what the user, select the prompt for
Is this possible?
Appreciate your thoughts.
Published by: 872290 on July 13, 2011 10:04Read my response here:
-
A drop-down list can do the calculation based on the value selected in a drop down list?
Form Acrobat X Pro Adobe
Can I have a drop down list create a calculation based on the value selected in the menu drop-down?
We have a set lunch and want the user to choose to be "A lunch', 'Lunch B'"C Lunch"or"just the milk. "
It is for each of the 5 days of the week. There are therefore 5 drop downs, which have all the same 4 above choice.
If the user chooses among the 3 lunches and then put $2.00 in the total box at the end of the line. If 'Just the milk' may put 0.50 in the box.
The total area at the end of the line must keep a record of all 5 days and give a total.
So if someone chooses lunch A LUN, sea and Sun and just milk for Tuesday and Thursday and then the total for this week must be $7,00
Is it possible by using code or something?
I did it in Excel, but we need it is an Adobe pdf file.
TIA
OK the total box has a 10 all the time to make it look like $ 2.00 for
everything.
Before even that I chose something there are 10 in the box.
I am a newbie to Adobe scripting Total used VB/A .NET etc ' 1980
However.
Can you do any debugging in code?
Initialize the sum
var sum = 0;
Make a loop on the drop-down list boxes and add the cost of the invoice sum
for (var i = 1; i)< 6;="" i="" +="1)">
Sum += getField("Week1Day"_+_i).value == 'just milk? 0.50: 2,00;
}
Set this field to the amount
Event.Value = sum;
-
You will need to insert update column with the username?
Hi all
I'm new to this forum of the apex. New to apex as well.
My question is do we have a form and a single column is editable by the user. whenever an update to this column, I need to write their name in the update column.
I heard that we can do with trigger using the variable app_user. But in our project, they made authentication ldap for this form and when an employee login with their company login id they can see only this form of apex. no other option.
In the same form, they were able to show the user name. I checked how they did it. they used * & user * variable for this. , It makes sense for you gentlemen?
all I have to do is insert this & user in the column value.
How to do this. I'm started working in the apex for the past four days alone. willing to bare with me if im a very stupid question.
Thank you
knani
PS: I know that what im asking is the user name for the Web page the user name of the apex.
Published by: kart on May 26, 2010 11:45Hello
You can use: APP_USER substitution string.
If you like to use that in the syntax of database trigger is v('APP_USER') for example:NEW.CHANGED_BY := NVL(v('APP_USER'), user);
BR, Jari
-
Equium L40: After bad Bios update cannot use the WLan
Hi there hope someone can help.
I've updated the Bios as tempo toshiba said, but I have not read the last piece. Who was that it is not for mine which is the model L40.
I have now tried to put the right pair, but he says he can't. As I'm putting that has an earlier date.
My main problem now is that my wireless stopped working, it says its there and so to work, I put the switch on, but he can't find any networks he used to find approximately 4 in my area
Do I have to restore my entire system :(?
I'm really confused about your message because the European Toshiba page provides drivers and BIOS for one Equium L40 series m.
I found 2 different versions of the BIOS for Equium L40; a BIOS for XP and a BIOS for Vista.In my opinion it of almost not possible to update the BIOS with the wrong version
However, it you have updated and used the wrong BIOS, then you must contact the ASP to help
But first, I recommend a check of the WLan configuration
-
BlackBerry Smartphones how to use the calculator to divide the numbers
How can I use the calculator to divide a number?
RamsesVI wrote:
How can I use the calculator to divide a number?
Hi RamsesVI
Open the calculator application and use the / symbol of division.
-
I use LR5.7 based on Windows 7 and got a few pictures 150 000 in a catalugue. Could import, export and rendering speed be increased, if I store the LR catalog on the same drive as my photos? Today, the program, the catalog and photos are all on different drives.
Import and export and rendering speed depends on the CPU. The disk contributes only a negligible amount to import and export and rendering speed. You would spend more time to pass the photos that you would gain in speed.
Maybe you are looking for
-
I am a filmmaker and still editing on my Mac Pro 2008 (with a MacBook Pro 3 years). I was considering the upgrade because my old computer fails and because it looks like 4 k editing will be important in my world in the coming years. In research on
-
I'm trying to implement a yEnc decoder in LabView. The attached solution seem to work most of the time with txt files small, but when I'm trying to decode larger files, i.e. with the extension .rar. usenet groups, the encoder does not work completely
-
Hello I developed an application of built-in-Self-Test for our company product. Use of the Application generator, I have an executable that runs on our machine in the Windows environment. The Government has serious problems with what either under Win
-
The configuration in the registry information is incomplete or damaged (Code 19)
I bought a laptop (e machines D525) recently, and last month the CD/DVD-ROM has stopped working. I always get this message "Windows cannot start this hardware device because its information for configuration (in the registry) is incomplete or damaged
-
ISDN bind-l3-Manager of ccm for the PRI is not taken in charge - MGCP Gateway
Dear all, Ive tried to get my (Voice Gateway) VGW recorded with my CUCM_7.1 I must add ISDN bind-l3-Manager of ccm in my serial interface. BUT THIS COMMAND IS NOT SUPPORTED The only similar to this command is bind-l3 ISDN q931. I tried to change IOS