updated two fields with a form
I'm trying to update two tables mysql to a form. The page includes the following:
"A stock" quantity (from table A)
A text form field (where I entered the used inventory)
A drop-down list of article for "the inventory B' (from table B)
I want to be able to enter a quantity in the text field and subtracts it A inventory and added to the inventory B.
For example:
Apples. (Table A)
Quantity: 10
Applesauce. (Table B)
Total used: 3
Used: 2 (from text form field)
.. .to present, 2 will be subtracted from apples on site and added to... applesauce 8 apples and Apple Sauce 5
A little more than you probably think Compliated. Here is an example of using mysqli that is much easier to work with and understand that code spewed out by Dreamweaver - more mysql code, it produces should not now be used because it is not supported in newer versions of php.
connect to the database using mysqli
<>
get the id of the link and assign it to a variable - $apple_id
$apple_id = $_GET ['id'];
Get information about the dessert apples to apples
$apple_information = $conn-> query ("SELECT * FROM apples WHERE id ="$apple_id"" ") or die ($conn-> error);
$apple_information = $apple_information-> fetch_assoc();
Get the recipe from the recipes table names
$recipes = $conn-> query ("SELECT * from recipes") or die ($conn-> error);
number of rows returned no
$numRows = $recipes-> num_rows;
Click on the submit form button, process the form information
If (isset($_POST['USE'])) {}
Get the amount of apples of form field
$apples_used = $_POST ['apples_used'];
If the QTY field blank form to print an error
If (empty ($apples_used)) {}
$error ["apples_used"] ="
Please provide amount of apples required
";}
get the recipe of the revenue table selection
$recipe_choices = $_POST ['Recipe_Choices'];
If no recipe printing and error
If ($recipe_choices == 'Select recipe') {}
$error ["recipe_choices"] ="
Please select a recipe
";}
are no errors of process information
{if (! isset ($Error))}
get the number of apples in the field quantity of stock and update
$apples_in_stock = $conn-> query ("' quantity SELECT FROM apples WHERE id = ' $apple_id '" ") or die ($conn-> error);
$apples_in_stock = $apples_in_stock-> fetch_assoc();
$new_apple_total = $apples_in_stock ['quantity'] - $apples_used;
$conn-> query ("UPDATE Apple SET quantity = ' $new_apple_total ' WHERE id = ' $apple_id '");
get recipe update and quantity field name
$apples_recipes = $conn-> query ("" SELECT id, amount OF revenue WHERE Name = ' $recipe_choices ' "") or die ($conn-> error);
$apples_recipes = $apples_recipes-> fetch_assoc();
$recipe_id = $apples_recipes ['id'];
$new_recipes_total = $apples_recipes ['quantity'] + $apples_used;
$conn-> query ("UPDATE revenue SET quantity = ' $new_recipes_total ' WHERE id = ' $recipe_id '");
Get information from update on apples
$apple_information = $conn-> query ("SELECT * FROM apples WHERE id ="$apple_id"" ") or die ($conn-> error);
$apple_information = $apple_information-> fetch_assoc();
}
}
?>
Tags: Dreamweaver
Similar Questions
-
How to subtract two fields in a form?
I am working on a form of spending and I everything works except one thing.
Subtract all on payments reports on previous expenditures on the State of current spending. I'm looking at the tab to calculate the properties of text field. But I don't see a way to remove my two fields.
Then, I set up a field that contains a negative, except when I display the field in the form, the negative is positive. I enter-1 as a default value to my field of 'subtraction '. I was then several 1 negative against most of payment the amount so I can get a negative on the amount of the payment. I was then going to add the negative on the amount of the payment for the total amount to pay and arrive at a net due, but it does not work.
Here is the calculation I'm doing:
Total spending (field calculated from all previous fields.)
Deductible expense (entered by the user)
NET check fresh (Total expenses - deductible).
Can someone tell me how to proceed?
Thank you
Dennis
With Acrobat, there are 3 options of calculations.
"The field is the _____ of the following fields:" options are for the sum, product, average, min and max operations or actions that could be repeated on several fields. We do generally not subtract or divide several fields in action.
'Simplified field notation' uses only the field names and values. The field names must begin with an alphabetic character and has no spaces or special characters. Cannot perform conditional control statements or functions. Special characters or spaces may be in domain names, if the JavaScript escape character precedes the special character or a space. 4 arithmetic operations can be performed.
'Calculation of custom JavaScript' has no restrictions on field names, control statements, functions or mathematical operations. We have access to the field object and the value property of the field object.
-
Trying to update a field with the RANK function
Hello world
I'm trying to update a field using a PL/SQL function rank. When I'm doing it, I get a "+ ORA-01427: einreihig subquery returns more than one row +", and it's just that sometimes I have the same value more than once.
All the world is facing this issue before? I mean try to update a field using the RANK function?
Please don't hesiate to contact me, if any additional information is required.
Best regards.
UPDATE spd_f_mkt_DC_2
SET RANKING_ID =)
SELECT PLUS RANK()
(
KPI_MKT_ID PARTITION
ORDER BY F_MKT_KPI DESC
)
OF SPD_F_MKT_DC_2
)UPDATE spd_f_mkt_DC_2 a SET RANKING_ID = ( SELECT rnk FROM ( SELECT ROWID rid, RANK() OVER(PARTITION BY KPI_MKT_ID ORDER BY F_MKT_KPI DESC) rnk FROM SPD_F_MKT_DC_2 ) WHERE a.ROWID = rid ) /
SY.
-
The two problems with sub form of table, associated with check boxes
Hi all -
Jari already helped me thereby once last week, but I'm running into some new questions.
http://Apex.Oracle.com/i/index.html
workspace: Leppard
username: Guest
PW: app_1000
Application: MyTestApp
Maybe I need to split these into two questions, if so just let me know.
Question 1: On the first tab (tab 1 report) I have a simple tabular presentation based on the EMP table. The column of the box on the far right, when checked restores the Ename column readonly. The problem is that it only works one way. Unchecking the checkbox is not cancel the read-only.
It is javascript code that I have on the page:
The attribute of the element on the checkbox column isfunction test(pThis) { //get the current row index on change var currIndex = $('input[name="'+pThis.name+'"]').index(pThis); // check current items value (return value of lov) if (pThis.value=='Y') { $('input[name="f02"]')[currIndex].style.backgroundColor = "LightGrey"; $('input[name="f02"]')[currIndex].readOnly=true; } else if (pThis.value=='N') { $('input[name="f02"]')[currIndex].style.backgroundColor = "Red"; $('input[name="f02"]')[currIndex].readOnly=false; } }
(It seems to work although I use onClick or onChange so I don't know if that makes a difference).onClick="javascript:test(this);"
But the main problem is that the code does not recognize the value of "n" in the column. I checked with firebug and columns I have untick are definitely on 'n', but I can't get javascript code to recognize this value. Even if I take the "ElseIf" code and just change the first part to (pThis.value ==' no) still does not work. There seems to be something with the value "n" recognize themselves do not, but I can not understand.
Question 2: on the second tab - tab report 2. The same report but this time, I use a javascript character counter similar to that described in the sample application of the Dene (page 276 > http://apex.oracle.com/pls/otn/f?p=31517:276:19207673535900:NO). The counter of characters on the Ename field include javascript and an expression of HTML on the Ename column. The counter works fine, but now, the javascript code to make the column readonly work over all.
Any ideas on these are much appreciated!
Thanks in advance,
John- Please please understand what HTML is generated and how to inspect. Once you do this, you can easily eliminate many problems with selectors not seeming to work. A text box is not an input for example element.
- Boxes rely on the checked, not the value property. Apex circumvents this by creating a hidden extra element which will get the value based on the checked property of the visible checkbox
- Do not use these horrible onchange and onclick attributes :( Use a dynamic action or jQuery to bind events.
- Do not apply a style via javascript. Use CSS for this drive as with jQuery, you can easily add, remove, or toggle the classes too. And if you know jQuery selectors, you can understand css selectors because they are substantially the same.
- I don't know why people insist on using rowIndex or substringing ID. I find it unnecessary and more complex that the alternative (crosses with jQuery)
- The difficulty also in things into action through pagination. Running on just the visible page it of a trifle, but through paging requires more work than just check "fire on loading the page" is not enough. I'm sure you'd want your ENAME either red or gray column and readonly as soon as the page is loaded, and not when you start typing in the box...
- Please please understand what HTML is generated and how to inspect. Once you do this, you can easily eliminate many problems with selectors not seeming to work. A text box is not an input for example element.
Form 1 tab: copied to Page 12 and made my changes here:_
- OnChange on ENAME. This removed. No idea why you would need it there seems a crutch for not having the field in the desired state when the page is loaded.
- OnClick on CHECKBOX. Removed what I hate these attributes. Replaced by a dynamic action.
- Dynamic action "checkbox: ENAME readonly value."
- Event: After refresh
- Selection type: region
- Region: Form of tab 1
- No condition
- Scope of the event: static
- Real Action
- Run the JavaScript Code
- Fire on loading the Page: YES
- Code:
//at page load and after each region refresh: //each: check all checkboxes and set readonly on ename accordingly //click: when the checkbox changes, change ename accordingly $("td[headers='CHECKBOX'] input[type='checkbox']:visible") .each(function(){checkReadonly(this);}) .click(function(){checkReadonly(this);});
- Run the JavaScript Code
- Event: After refresh
function checkReadonly(pCheck){
var lCheck = $(pCheck);
lCheck.closest("tr")
.find("td[headers='ENAME'] input:visible").each(function(){
$(this).prop("readonly", lCheck.prop("checked"));
});
};
td[headers='ENAME'] input{
background-color: red;
}
td[headers='ENAME'] input[readonly]{
background-color: lightgrey;
}
CSS works so much better for this than the application of style through js...
Form 2 tab: copied to Page 13 and made my changes here:_
- OnChange on ENAME. This removed. No idea why you would need this.
- OnClick on CHECKBOX. Removed what I hate these attributes. Replaced by a dynamic action.
- Dynamic action: identical to page 12, just modified trigger area
- Changed input to TEXTAREA when it is required:
- Page > function and global variables declaration
function checkReadonly(pCheck){ var lCheck = $(pCheck); lCheck.closest("tr") .find("td[headers='ENAME'] textarea:visible").each(function(){ $(this).prop("readonly", lCheck.prop("checked")); }); };
- Page > CSS Inline
td[headers='ENAME'] textarea{ background-color: red; } td[headers='ENAME'] textarea[readonly]{ background-color: lightgrey; }
- The f_set_counter function, I changed a bit: there are 2 straps too, put a semicolon at the end of each line.
-Change $x (node) .value $s (node, value) and $v (node)
-changed $x (node) .innerHTML to $(node) .text)
I know: it worked. I like this better. OCD? :/
function f_set_counter(pThis,pLength,pMaxLength,pReset)
{
if (pLength>pMaxLength){
alert('The maximum length of '+pMaxLength+' exceeded.');
$s(pReset, $v(pReset).substring(0,pMaxLength));
$("#"+pThis).text(pMaxLength);
}else{
$("#"+pThis).text(pLength);
};
};
Published by: Tom on February 15, 2013 12:48
Made a mistake in the case of dynamic action :->, click after refresh!
Two fields with accent... at the same time.
Yes, I know, it will not be possible, but I'm the see.
Literally have a training log with calls to isFocus() to the two different fields in two different frames and both return true.
The problem, it seems that one of the field is undefined fuzzy after that setFocus is called on another field, thus they refer both they bear!
Has anyone seen anything like this before?
Was about to write that the setFocus() method manager not was not correctly propagated to the field focusable child.
The substitution of the setFocus() manager 2 with a call directly to the field focusable setFocus() fixed this problem.
setFocus() doc manager says he'll try to setFocus on the first field in the Manager. Of course, this does not work (the focus field was the first field) and caused a track weird behavior of collage.
Update a field with different values of several tables
HelloI have a table named AAA with 2 fields id and structure.
And then I have other 3 tables with 2 fields id1 and structure1 id2, table1 and table2, id3 and structure3 to table3 organized.2.
The number of AAA id is equal to the sum of the IDS of table1, table2, table3: #id = #id1 + id2 # + #id3).
I want to update the structure of AAA table with values as well as field:
where AAA.id = table1.id1-> AAA.structure = table1.structure1
where AAA.id = table2.id2-> AAA.structure = table2.structure2
where AAA.id = table3.id3-> AAA.structure = table3.structure3
Can someone help me?
I have Oracle11gR2.
Thank you in advance.
Oops...
update AAA
set structure = (select structure1 from table1 where aaa.id = table1.id1)
where aaa.id in (select id1 from table1)
Update one field with another (which contains a timestamp)
HelloI try to do what I thought, it was a simple task to update my db using the content of another, a field
in my tbl_profiles I have:
key | penSignedIn | lastSignedIn
73. 2006-05-19 21:14:56.0
I'm trying to update my table for the tbl_profiles.penSignedIn field is populated with the contents of tbl_profiles.lastSignedIn
< cfquery datasource = "nya" >
UPDATE tbl_profiles
SET PenSignedIn = #rs_user.lastSignedIn #.
WHERE profileID = 73
< / cfquery >
I get this error SEE "syntax error (missing operator) in query expression ' 2006-05-19 21:14:56.0'.»»
and says CF "" SQL: UPDATE tbl_profiles SET PenSignedIn = 2006-05-19 21:14:56.0 WHERE profileID = 73 ".
that looks ok to me! I have attached different formats such as
SET PenSignedIn = {ts ' #MM_rsUser.lastSignedIn # '}
SET PenSignedIn = #MM_rsUser.lastSignedIn #.
SET PenSignedIn = ' #MM_rsUser.lastSignedIn # '.
but none seem to not work that leads me into the wall! -can someone please point me in the right direction please
Thank you so much.
I have CF7 and database access
If you try just to update the content of the column penSignedIn with the contents of the lastSignedIn column in the same table, follow these steps:
UPDATE tbl_profiles
SET PenSignedIn = lastSignedIn
WHERE profileID = 73
Otherwise, if you try to use the value of a variable, maybe you create a date/time object:
UPDATE tbl_profiles
SET PenSignedIn = #createodbcdatetime (rs_user.lastSignedIn) #.
WHERE profileID = 73
Phil
Receive error message when calculating the two fields with different date format
I'm more familiar with SQL Server and Oracle, then after a search online without success, I ask here.
I use developer PL/SQL with DB Oracle 11g Release 11.2.0.2.0 Enterprise 64-bit
MyTable:
ID_Number VarChar2
Date of Date_Received
Select ID_Number,
Date_Received,
To_Date (substr (ID_Number, 1.6), "YYMMDD") SentDate,.
Date_Received - NumDays To_Date (substr (ID_Number, 1.6), "YYMMDD")
FROM MyTable
Where substr (ID_Number, 7.3) in ('ABC', 'ABD')
and length (Trim (translate ((substr (ID_Number, 1,6)), '0123456789',' '))) a null value
ID_Number Date_Received SentDate NumDays
131002ABC1654106 10/16/10/2013-2013 14 2
131004ABD8813899 4/12/2013-4/8/2013 4
131014ABD1844832 10/16/10/14 OF 2013-2013 2
Sometimes the first 6 characters in the ID_Number aren't the numbers and length (Trim (translate deletes records))
I want just the records where NumDays > 2
I tried to put the request in a subquery and using where NumDays > 2 outside. I also tried using the calculation directly in the Where clause. Without it in Where clause it works very well, with him in a place, I get the following error:
ORA-01931: Date format picture ends before converting all of the input string
I don't know how to put the two dates in the same format. I tried to declare the format without result. I don't understand how I can calculate in the selection, but do not use the same calculation in Where clause.
Thank you for your help.
Hello
SQL is a language to describe the desired results. How the system gets these results belongs to you don't have much say about which conditions will be applied when.
One place where you can control the order of things is a CASE expression. When you say
CASE
WHEN condition_1
THEN expression_1
END
You can be sure that expression_1 will be evaluated only when cond_1 is set to TRUE.
Try something like this:
WITH got_sent_date AS
(
SELECT id_number, date_received
CASE
WHEN the TRANSLATION (SUBSTR (id_number, 1, 6)
, 'x' 0123456789 '.
, 'x'
) IS NULL
THEN TO_DATE (SUBSTR (id_number, 1-6)
, "YYMMDD".
)
END AS sent_date
FROM MyTable
WHERE (id_number, 7, 3) SUBSTR ("ABC", "ABD")
)
SELECT id_number
date_received
sent_date
, date_received - sent_date AS num_days
OF got_sent_date
WHERE date_received > sent_date + 2
;
If you would care to post some sample data (CREATE TABLE and INSERT statements) and the results desired from this data, I was able to test this.
Of course, you'll still errors of execution if id_number starts with 6 digits, but they do not have to be valid, for example '131100' or '130229'. This is one of the reasons why the date information storage in VARCHAR2 columns are a bad idea. To work around this problem, see
How to join two fields with slightly different data
I have two columns, I need joined, both keep the columns of numeric data, but are of type varchar2 (6). The problem is that one of the columns keeps leading zeros to ensure that all 6 characters are used, but not the other. And columns preserve leading zeros may vary how many zeros are in the number-based computing.For example, the column with zeros can contain the number 4200, which would mean that he would remain with 2 zeros as 004200. Or it could contain 320, which means that he would remain with 3 zeros as 000320.
The other column that does not have leading zeros not only keeps the number, so, in the example above, it would keep 4200 and 320 respectively.
Can someone help on how to join these columns so that they match? I guess I have to delete the zeros in one or add zeros in the other? I tried to use the trunc with zeros on the ground, but it did not work...
The following sql code:
M06.mbr06_prv_id has no zeros, prv647.provider_id zeros. See bold below...
SELECT
M06.mbr06_prv_id,
prv647.Site_ID
Of
Odw.mbr06_mbr_elig m06
JOIN THE
Odw.prv647_prov_exp prv647
WE
M06.mbr06_prv_id = prv647.provider_id
WHERE
M06.mbr06_subs_id = "999999999 '
BTW, I have no control on how this data is represented in a table... !
Hello
user12296489 wrote:
... I guess I have to delete the zeros in one or add zeros in the other?
Yes, this is how I see.
LTRIM removes given characters from the beginning of a string. LPAD adds characters at the beginning of a string. I would use LTRIM in this case, because if you use LTRIM, you probably need to handle a single column. If you use LPAD, you have to play with the two columns, as one of them still has the extra 0, and it sometimes needs them.
I tried to use the trunc with zeros on the ground, but it did not work...
TRUNC is working on the kinds or DATEs; you have VARCHAR2s. You can convert them to numbers, but then you risk of errors to cause bad data (and it linked to the wrong data).
>
The following sql code:
M06.mbr06_prv_id has no zeros, prv647.provider_id zeros. See bold below...
SELECT
M06.mbr06_prv_id,
prv647.Site_ID
Of
Odw.mbr06_mbr_elig m06
JOIN THE
Odw.prv647_prov_exp prv647
WE
M06.mbr06_prv_id = prv647.provider_id
WHERE
M06.mbr06_subs_id = "999999999 '
If you are certain that m06.mbr06_prv_id never has extra characters, whereas the join condition can be
ON m06.mbr06_prv_id = LTRIM ( prv647.provider_id
, '0'
)
If this isn't the case, CUT then the two columns.
BTW, I have no control on how this data is represented in a table... !
Report a bad design is for people who don't have not this control. Numbers are the number of columns, not VARCHAR2. If the ID really needs to be strings, they should be validated and standardized once, when they are placed in the table, no more, and more, in all queries that use these columns.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
1. the user must be able to upload a document to a certain object in the application. There is a table of documents, but it is also used by other applications, were other objects can bind to these documents. So there is a linking table that links a document to objects in one or more.
2. in an application, the link between the downloaded document and the object should be done directly.
3. in the screen where the objects are managed on the basis, so it is a button 'Add document', which connects to one where of document can be downloaded and where the object_id of the previous page.
Now, I think calling a stored procedure that connects the object_id and document_id, after the user uploaded and saves the document. Is this a good method? What happens to the document is saved, but the stored procedure fails for some reason any? in this case, I have a 'orphan document' in the database which is too much space, but is never used. Recommendations to this effect? Add object_id of the table of documents is not an option. This was the situation of previeous, but that is changed now, just for the fact that one or several objects can bind to one or more documents.
Tom,
Take a look at the process DML - get back key in the article.
Kind regards
Dan
Blog: http://DanielMcGhan.us/
Work: http://SkillBuilders.com/
How to carve, and concatenate the two text fields in a form
Hi people,
Newbie here... have two fields in a form: FirstName and LastName. Want to have these appear later as: name, first name.
For example: 'Rick' "Stockstill" should later manifest as: 'Stockstill, Rick' with a comma separating the names and trailing blanks removed.
It is a piece of cake in Excel, but have not figured out how to do the same with Acrobat. My first try at a script looks like this:
(Recipient.rawValue = trim (LastName.rawValue) +","+ FirstName.rawValue);
The field 'Recipient' is a standard text field which I am filling using the property to 'calculate '. The good news is that I get no error message, but the bad news is that the field recipient does not get filled.
Any help is greatly appreciated.
At the latest,
Rick Stockstill
North East Independent School District
San Antonio, TX
210-407-0317.
[email protected]
OK, in this case you can use this code as the custom recipient field calculation script:
event.value = trim(this.getField("LastName").valueAsString) + ", " + trim(this.getField("FirstName").valueAsString); function trim(s) { return s.replace(/^\s+/,"").replace(/\s+$/,""); }
How to make a form field validate that it is the sum of the other two fields?
Hello
I'm creating a form, and I'd like one of the fields to validate by making sure that this field is the sum of the other two fields of the form. Anyone have any ideas on how to go about it? I know that I need to run a custom validation script, but I don't know where to start - I have never made one for before validation.
Thanks for any help!
OK, here's a sample script that I hope will clearly demonstrate the general approach. It is intended to be the validation script custom field that the user enters the value which is supposed to be equal to the sum of the other two.
Custom validation script
(function () {}
Get the value that the user entered
sVal var = event.value;
If it is empty, do nothing else
If (! sVal) {}
return;
}
Converts a string to a number
nVal = + sVal;
Get the values of the fields in the form of numbers
var v1 = + getField("text1").value;
var v2 = + getField("text2").value;
Add them together, rounded to two decimals, converting to the number
var sum = + util.printf ("%.2f", v1 + v2);
Compare the value of the sum of the other two fields
Change the user if they do not match
If (nVal! == $) {}
App.Alert ("the value entered does not equal to the sum of text1 and text2. Please correct. «, 3) ;
If you want the value entered was rejected, include the following
Event.RC = false;
}
})();
Replace "text1" and "text2" with real field names.
update the text with xml, DDL data fields a selection of an identification number
Hi guys,.
It should be simple, but I can't seem to find a straight answer. In short:
The XML file contains the ID, name, location (so 3 extreme records in the example xml file)
Form contains a dynamic drop-down list to allow the selection of ID and text fields to display the names of the partners and the location of this ID. The setting of the drop-down list works fine, however I need to update the associated name and location if different from the other ID's fields are selected. I guess I'll need some sort of event on the menu drop down update other fields with the name and location of the selected ID, but I don't know enough to have a stab at him.
Please, please, please help, Im starting to pull my hair.
James.
Sorry, looking at him again I could have given a better description of what is happening.
Have a look at this sample https://acrobat.com/#d=NO5o6NhPTQgSYu3SVoN7rQ and data to go with her https://acrobat.com/#d=jN * pRT4uGg05VU * sGWvjcA
The thing I should have said and I guess that's your problem is the the Data property, I used in $data. Data.resolveNode (...) must match the item parent of the element of your event if xml looks like
It should be $data.events.resolveNode (...) Maybe I should have used "itemGroup var = $data.resolveNode ("events.event.» (()_eventId.value_===_«_«_+_xfa.event.change+_»_») "); "in this case, but I try and do the resolveNode go as low as possible. Concerning Bruce
Update from the field with consecutive number according to the number of entries
HelloI need to update a field with a consecutive number according to the number of lines where the entries are made which go hand in hand. What it means:
I have
SYSAUSPR AREA SYSGEBIET TYP RANG
182925 600003 4 1 PERSON
1 600004 4 1 PERSON
2 600004 4 1 PERSON
3 600004 4 1 PERSON
17 600004 4 1 PERSON
18 600022 4 1 PERSON
182864 600079 4 1 PERSON
184082 600092 4 1 PERSON
182774 600143 4 1 PERSON
PERSON 183237 600165 4 1
NO 7 600169 4 1
8 600169 4 1 PEOPLE
9 600169 4 1 PERSON
12 600169 4 1 PEOPLE
14 600169 4 1 PERSON
184309 600179 4 1 PERSON
23 600182 4 1 PERSON
I need to change column "RANK" of 1 the number of records that have the same id in the "SYSGEBIET" column (from this example with 600) so that it looks like
SYSAUSPR AREA SYSGEBIET TYP RANG
182925 600003 4 1 PERSON
1. NOBODY 600004 4 * 1 *.
2. PERSON 600004 4 * 2 *.
3. PERSON 600004 4 * 3 *.
17. NO 600004 4 * 4 *.
18. NO 600022 4 * 1 *.
Does anyone has an idea how to solve this problem in an update statement?
Thanks for your help
Best regards
Carsten
SQL> select *
2 from tbl
3 /
SYSAUSPR GEBIET SYSGEBIET TYP RANG
---------- ------ ---------- ---------- ----------
1 PERSON 600004 4 1
2 PERSON 600004 4 1
3 PERSON 600004 4 1
17 PERSON 600004 4 1
18 PERSON 600022 4 1
182864 PERSON 600079 4 1
184082 PERSON 600092 4 1
182774 PERSON 600143 4 1
183237 PERSON 600165 4 1
7 PERSON 600169 4 1
8 PERSON 600169 4 1
SYSAUSPR GEBIET SYSGEBIET TYP RANG
---------- ------ ---------- ---------- ----------
9 PERSON 600169 4 1
12 PERSON 600169 4 1
14 PERSON 600169 4 1
184309 PERSON 600179 4 1
23 PERSON 600182 4 1
16 rows selected.
merge
into tbl t
using (
select sysgebiet,
sysauspr,
row_number() over(partition by sysgebiet order by sysauspr) rang
from tbl
where sysgebiet like '600%'
) u
on (
u.sysgebiet = t.sysgebiet
and
u.sysauspr = t.sysauspr
)
when matched
then update set t.rang = u.rang
/
16 rows merged.
SQL> select *
2 from tbl
3 /
SYSAUSPR GEBIET SYSGEBIET TYP RANG
---------- ------ ---------- ---------- ----------
1 PERSON 600004 4 1
2 PERSON 600004 4 2
3 PERSON 600004 4 3
17 PERSON 600004 4 4
18 PERSON 600022 4 1
182864 PERSON 600079 4 1
184082 PERSON 600092 4 1
182774 PERSON 600143 4 1
183237 PERSON 600165 4 1
7 PERSON 600169 4 1
8 PERSON 600169 4 2
SYSAUSPR GEBIET SYSGEBIET TYP RANG
---------- ------ ---------- ---------- ----------
9 PERSON 600169 4 3
12 PERSON 600169 4 4
14 PERSON 600169 4 5
184309 PERSON 600179 4 1
23 PERSON 600182 4 1
16 rows selected.
SQL>
SY.
Join two fields in a field for a view
I am trying to create a view based on several tables.I have all the joins and everything that does very well and functioning properly.
However, when I get to this step, it's when I start to run into problems.
I want to just join (or concatenate) two fields with a period of characters between them.
For example, if I take FirstName and LastName, then I want them to become a field called name, appearing as 'JOHN. DOE. "
When I try to bring together them, the problem happens with the comma.
An example of code that I did is here:
BEGIN
EXECUTE IMMEDIATE ' create view VIEW_LALALA
like SOME t1. FirstName + "." + t2. Name, t1.something as something like OOO t2.ooo
OF (tableFirstNames t1 t2 on t1.nameID = t2.nameID inner join tableLastNames)
END;
832667 wrote:
I am trying to create a view based on several tables.
I have all the joins and everything that does very well and functioning properly.
However, when I get to this step, it's when I start to run into problems.I want to just join (or concatenate) two fields with a period of characters between them.
For example, if I take FirstName and LastName, then I want them to become a field called name, appearing as 'JOHN. DOE. "
When I try to bring together them, the problem happens with the comma.An example of code that I did is here:
BEGIN
EXECUTE IMMEDIATE ' create view VIEW_LALALA
like SOME t1. FirstName + "." + t2. Name, t1.something as something like OOO t2.ooo
OF (tableFirstNames t1 t2 on t1.nameID = t2.nameID inner join tableLastNames)
END;
to concatenate two string together do not use '+', but ' |. '
SELECT FIRST_NAME: '. ' || LAST_NAME FROM EMP;
Maybe you are looking for
-
Today, I downloaded an update of Adobe and attached to it was a MacKeeper program as well as a kind of cloud storage. I'm not one of them, and it is almost impossible to remove. Thought they were gone, but continued to receive sporadic popups telling
-
Pages and Numbers came on my iPad Air when I bought it, but I never use them. Is there a reason I shouldn't remove them? If I do not delete them, can I still add them again just like any other app I bought?
-
HP Compaq DC5800: No. - Pci simple communication controller
All hell After doing some maintenance my device manager is displayed. PCI simple communication controller The drivers for this device are not installed. (Code 28) There is no compatible driver for this device. PCI bus 0, device 3, function 0 PCI\VEN_
-
What are the conditions for launching a server active directory?
I need to install a server from domain to employees on my business what should I need? My information is that I need a server such as a hardware and Windows Server software. Should I have any other license to connect all computers exist to this serve
-
I installed zuma deluxe 1.0, it will not display properly and I get the error message can't find bass.dll