update of each line in a column
I have to update only the first letter of all the names in the last_name column used table... Please help me with this issue?You must be more precise, that is what you need:
update mytable set last_name = 'A' || Substr(Last_name,2);
that's really interesting.
Published by: Mustafa KALAYCI on August 10, 2012 10:35
Tags: Database
Similar Questions
-
Each line in individual columns in a SQL query
Hi Experts,
BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production PL/SQL Release 11.1.0.7.0 - Production CORE 11.1.0.7.0 Production TNS for 32-bit Windows: Version 11.1.0.7.0 - Production NLSRTL Version 11.1.0.7.0 - Production
-- DROP TABLE RENDER_VALUES; CREATE TABLE RENDER_VALUES ( ID INTEGER PRIMARY KEY, FIELD_NAME VARCHAR2(1000), FIELD_VALUE VARCHAR2(1000) );
INSERT INTO RENDER_VALUES(ID,FIELD_NAME,FIELD_VALUE)VALUES(1,'CropX','10.31234'); INSERT INTO RENDER_VALUES(ID,FIELD_NAME,FIELD_VALUE)VALUES(2,'CropY','20.31234'); INSERT INTO RENDER_VALUES(ID,FIELD_NAME,FIELD_VALUE)VALUES(3,'Height','100'); INSERT INTO RENDER_VALUES(ID,FIELD_NAME,FIELD_VALUE)VALUES(4,'Width','200'); COMMIT;
SELECT FIELD_NAME,FIELD_VALUE FROM RENDER_VALUES;
I need the output voltage:FIELD_NAME FIELD_VALUE CropX 10.31234 CropY 20.31234 Height 100 Width 200
Just for example... I gave four values in the column field name... There may be values of number (n) to that and to get each lineCropX CropY Height Width 10.31234 20.31234 100 200
in individual columns... How can I do something like that?
V diaHello
Here is an example of a VARCHAR2 variable usage in PL/SQL.
VARIABLE dj REFCURSOR CREATE OR REPLACE FUNCTION dept_by_job RETURN SYS_REFCURSOR IS -- dept_by_job returns a SYS_REFCURSOR that has -- one row for every department in scott.emp and one -- column for every job, showing the number of employees -- in that department with that job. return_csr SYS_REFCURSOR; select_txt VARCHAR2 (5000); BEGIN -- 1st part of query is fixed select_txt := 'SELECT deptno '; -- 2nd part of query depends on what's in the table FOR r IN ( SELECT DISTINCT job FROM scott.emp ORDER BY job ) LOOP select_txt := select_txt || ', COUNT (CASE WHEN job = ''' || r.job || ''' THEN 1 END) AS ' || r.job || '_cnt '; END LOOP; -- Last part of query is fixed select_txt := select_txt || ' FROM scott.emp' || ' GROUP BY deptno' || ' ORDER BY deptno'; OPEN return_csr FOR select_txt; RETURN return_csr; END dept_by_job ; / SHOW ERRORS EXEC :dj := dept_by_job; PRINT :dj
Otherwise, as you have provided a test table, here's an example suitable for your test table:
CREATE OR REPLACE FUNCTION pivot_rv RETURN SYS_REFCURSOR IS return_csr SYS_REFCURSOR; select_txt VARCHAR2 (5000); BEGIN -- 1st part of query is fixed select_txt := 'SELECT '; -- 2nd part of query depends on what's in the table FOR r IN ( SELECT DISTINCT field_name , ROW_NUMBER () OVER (ORDER BY id) AS rnum FROM render_values ORDER BY rnum ) LOOP select_txt := select_txt || CASE WHEN r.rnum > 1 THEN ',' END || 'MAX (CASE WHEN field_name = ''' || r.field_name || ''' THEN field_value END) AS "' || r.field_name || '"'; END LOOP; -- Last part of query is fixed select_txt := select_txt || ' FROM render_values'; OPEN return_csr FOR select_txt; RETURN return_csr; END pivot_rv ;
Published by: Frank Kulash, January 15, 2010 10:42
-
Update of each line of a large table
I have a table with 50 million lines, and the primary key is made up of four columns. I need to make a simple update statement:
Update tmptable set c1 = c1 * 100;
What is the best approach to achieve this?
Thank you!http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:6407993912330
DEC using a parallel query...
-
Each line in a column to an XML conversion
Hello world
With the help of Oracle Database 10 g Enterprise Edition Release 10.2.0.4.0 - 64 bit
I have a table where there is a comments column which is VARCHAR2. This column contains data of type string in the form of XML tags.
As for example. * < tag_name attr_name = "10" / > * (cant sorry give the exact values that I'm not allowed to)
There are as many such lines. Now, I want to use these channels and operated as a XML like the use of XPath to find some attributes etc.
I tried to use the extract function and to use it, I need an XMLType object. So I tried to create one using the XMLType() constructor.
But it gives me error ORA-19032: tag expected, XML had no content
When I looked on the net, I found that this error number does not match the error message I get. The msg of error found on internet, it is should tag XML string as string
I used this query
But when I changed (based on the intuition of someone)SELECT XMLType (<column>) FROM <table>;
The application worked well. That it may take only one line.SELECT XMLType (<column>) FROM <table> WHERE ROWNUM <= 1;
I also tried like this
This worked too well.SELECT XMLType ('<tag_name attr_name="10"/>') FROM DUAL;
So finally he left me completely confused. Is there a way to convert every row in a column to an XMLType object so that I can use the extract function to collect information on this topic.
For now, I used REGEXes to write code. However, with the flexibility of xml is preferable.
Any help would be appreciated.
Kind regards
Aalami
Published by: aalami Kanrar on May 23, 2013 05:27Aalami,
The error message is correct. What you have found, it is simply the generic message with placeholders in the string .
The error message is also pretty explicit: you cannot pass an empty string (NULL) to the XMLType constructor.
SQL> select xmltype('') from dual; ERROR: ORA-19032: Expected XML tag , got no content ORA-06512: at "SYS.XMLTYPE", line 310 ORA-06512: at line 1 no rows selected
You must either add a WHERE clause to filter the columns NULL or use a CASE statement to only convert strings that are not empty:
SELECT XMLType (
) FROM WHERE
IS NOT NULL ; SELECT CASE WHEN
IS NOT NULL THEN XMLType ( ) END FROM ... And do not use EXTRACT if you want access to scalar values, use EXTRACTVALUE instead:
SQL> select extractvalue(xmltype('
'), '/tag_name/@attr_name') from dual; EXTRACTVALUE(XMLTYPE(' '),'/TAG_NAME/@ATTR_NAME') -------------------------------------------------------------------------------- 10 Results not updated for each row in BIpublisher
Hi all I have a Bi publisher report that updates the results of the first line and in the second row to update the results is to choose the values of the first column itself and using the same values for all other lines.
Here is my report format
Months saving altogether, for 30,60,90,120
Jan
Feb
Mar
Total are registered by each month and days shows after 30,60,90,120 how much is still in operation. For example should give an idea of exactly what is happening
For example:
Total 30 days 60 days 90 days 150days 210days 180days 120days
------------------------------------------------------------------------------------------------------------------------------------------------------------ Jan saves 330 287 274 270 263 262 259 257
Feb saves 298 255 242 238 231 230 227 225
Mar saves 291 248 235 231 224 223 220 218
So what happens is lets say for example there is a total of 330 enrolled in January and after 30days 287 are still active and after 60 days 274 are still in business after 90 270... etc.
Get active January values correctly.
But in the future when I see the values for February that the total for February is 298 and after 30 days, that do not operate gives me good.
Is subtracting the same amount as jan. looking at the figures it is subtracting
-43,-13,-4,-7,-1,-3,-2 for Jan who cancel after consecutive days
It is subtracting the same amount for Feb also but my real cancelled for February is different we 45,12,8,9,2,2.
It does the same thing for every month.
There should be a change in the code. Here is the XSL code used in
<? xdoxslt:set_variable($_XDOCTX,_'v_SavesCanceled',_SAVES_CANCELED_COUNT)? >
<? xdoxslt:set_variable ($_XDOCTX, 'v_RtSaves', xdoxslt:get_variable($_XDOCTX,_'v_RtSaves') - xdoxslt:get_variable($_XDOCTX,_'v_SavesCanceled'))? >
<? xdoxslt:get_variable($_XDOCTX,_'v_RtSaves')? >
Effectively cancels it should be updated for each line but his picking cancels it even for each month.
Hope it is clear let me know if you need any additional information
Any help is appreciated.
Thank youCan you send me the xml and RTF to [email protected]? I can take a look and try to help.
Thank you
BipuserA statement UPDATE changes the line if the update changes the column even value?
HI -.
I have a main classification and the corresponding audit table. I have a trigger. I created using the suggestion:http://www.runningoracle.com/product_info.php?products_id=211
Now the problem that I am facing is that: if I run the same query (same value) update on the main table for n times (with the same data)... my audit table is updated with a new record every time. He is not able to determine that the value is the same.
My goal is to load the audit table data if the value in a cell in the main table is really have changed.
A statement UPDATE changes the line if the update changes the column even value?
Best regards
I have a main Table and the corresponding Audit Table. I have a trigger. I created using the suggestion:http://www.runningoracle.com/product_info.php?products_id=211
Why?
You try to resolve what made you what are the PROBLEM that select as the solution?
Now the problem that I am facing is that: if I run the same query (same value) update on the main table for n times (with the same data)... my audit table is updated with a new record every time.
Yes - it is EXACTLY what you say that you wanted to do and EXACTLY what the code does in this article.
He is not able to determine that the value is the same.
I think you mean that the code does NOT check if the value is the same. You can certainly change the code to do this check. But I have a question to start with your need for such a solution.
My goal is to load the audit table data if the value in a cell in the main table is really have changed.
OK - then modify the code to check EACH COLUMN and compare its NEW value to the OLD value and insert only the table of audit if SOME (or columns you care specifically) have changed.
A statement UPDATE changes the line if the update changes the column even value?
It depends on what you mean by 'change the line '. Of course to update a column with the SAME value does not change the resulting data value.
But the physical structure of the line, the location of the pieces of line and information in the header block (YVERT, etc.) will change. And, as others have said Oracle doesn't know and doesn't care, so if the new value of a column is the same as the old value will create redo, undo and the rest.
Start over and tell us what PROBLEM you're trying to solve. Then we can help you find the best way to solve it.
How to calculate and set a value of colunm on each update of the line
Hi all
For example, I have 4 coulmns in a picture and the Col4 must be derived and set on each update of the line operation (irirespective of which column is updated).
The logic for the derivation is not simple, if I prefer it as a separate method (call uses WS).
Anyone can guide me please in this approach. Thank you!
Thank you
-John.Is this must be done on the update or insert also?
If this is to update, you can check the operation if it is updated or insert or delete by substituting the doDML() in your entity impl
doDML (int operation, Transaction e) {}
if(e == DML_UPDATE) {}
/ PIN to call the stored procedure * /.
}}
Kind regards
BriantPublished by: Aline August 4, 2011 21:35
Select or update a field based on a column on another line
Hello
I have some 5000 lines for the following combination of columns. Each combination has two rows. The only difference between these two lines is a flag field. If a line for the same combination indicator mod ' ranks for the same combination should ideally have flag 'R '. But unfortunately the indicator of the other row is null.
That is to say. If the first line for the same combination of fields, indicator is ' Mr. then the other is null, what should have been 'R '. If the first line is 'R', then the other is still null which should have me "."
STATE OF MONTHS PRODUCT_NO INDICATOR
1001 CA 7 M
1001 CA SEVEN null
1002 NY OCT R
Null OCT NY 1002
Here for the first combination indicator M and other is null. But I need to update 'R' other lines being M.
Likewise for the second row of the first combination is second row R then must have M as an indicator.
It fundamentally changes a value based on the value of other indicators of lines for the same combination of columns above.
Please help if anyone has the idea to do a few simple steps
Thank youIs that what you are looking for?
WITH TABLE_A AS ( SELECT '1001' PRODUCT_NO, 'CA' STATE, 'SEPT' MONTH, 'M' INDICATOR FROM DUAL UNION ALL SELECT '1001' PRODUCT_NO, 'CA' STATE, 'SEPT' MONTH, null INDICATOR FROM DUAL UNION ALL SELECT '1002' PRODUCT_NO, 'NY' STATE, 'OCT' MONTH, 'R' INDICATOR FROM DUAL UNION ALL SELECT '1002' PRODUCT_NO, 'NY' STATE, 'OCT' MONTH, NULL INDICATOR FROM DUAL UNION ALL SELECT '1003' PRODUCT_NO, 'LA' STATE, 'NOV' MONTH, 'R' INDICATOR FROM DUAL UNION ALL SELECT '1003' PRODUCT_NO, 'LA' STATE, 'NOV' MONTH, 'M' INDICATOR FROM DUAL ) SELECT PRODUCT_NO, STATE, MONTH, DECODE(A.INDICATOR,NULL,(SELECT DECODE(B.INDICATOR,'R','M','R') FROM TABLE_A B WHERE B.PRODUCT_NO = A.PRODUCT_NO AND B.STATE = A.STATE AND B.MONTH = A.MONTH AND B.INDICATOR IS NOT NULL), A.INDICATOR) INDICATOR FROM TABLE_A A
I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?
Add two new columns after than the original with space separated values column.
Select cell B1 and type (or copy and paste it here) the formula:
= IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
shortcut for this is:
B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")
or
the formula of the C1 could also be:
= IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")
Select cells B1 and C1, copy
Select cells B1 at the end of the C column, paste
Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?
Hello
2796614 wrote:
Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?
Of course, it is possible. According to what the text file looks like to, you can create an external table that treats the text file as if it were a table. Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.
You have problems whatever you wantt? If so, your zip code and explain what the problem is.
Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas. In this case, also post a small sample of the text involved file.
If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: Re: 2. How can I ask a question on the forums?
How to access a column value in a Select list in a tabular presentation for each line
Hello
Environment: Using Oracle APEX v4.2.1 on an Oracle 11 g 2 DB
In a tabular presentation using the following example query, i.e.:
select "EMPNO", "EMPNO" EMPNO_DISPLAY, "ENAME", "HIREDATE", "SAL", "DEPTNO", "MY_LOV" from"#OWNER#"."EMP"
I need access to every line of my sub form of table, the EMPNO of this line value, within a list of selection (query based LOV) in the column "MY_LOV."
So, basically, the MY_LOV column in my table presentation, would be a list of selection (query based LOV) where MY_EMPNO =: EMPNO (first column in the select statement above), for each line of the tabular presentation.
With the help of a picture ( Tom's Blog ) and assuming 'Deptno' column here is actually my new column, i.e. "MY_LOV, I want to know how this list of selection based on lov query would be able to access each EMPNO down in the form of tables, i.e. 7839, 7698, 7782 etc.?
Any help would be appreciated.
Thank you.
Tony.
Hi Tony,.
Take a look at the API APEX_ITEM for LOV
http://docs.Oracle.com/CD/E37097_01/doc/doc.42/e35127/apex_item.htm#AEAPI208
Kind regards
Brad
Get only one line for each type of a column
Hello!
I have a little problem.
I have a table with 10 columns. One of them has repeated values. My goal is to get all the lines with this column only once for each values he holds.
Ex:
Col1 Col2 Col3
A A A A
B B B
C A C
D C D
Column 2 has repeated values. My goal is to get:
A A A A
B B B
D C D
Only once each value in column 2.
Thank you guys! ;)SQL> CREATE TABLE Tbl (col1 VARCHAR2(1),col2 VARCHAR2(1),col3 VARCHAR2(1)); Table created. SQL> INSERT INTO Tbl VALUES ('A','A','A'); 1 row created. SQL> INSERT INTO Tbl VALUES ('B','B','B'); 1 row created. SQL> INSERT INTO Tbl VALUES ('C','A','C'); 1 row created. SQL> INSERT INTO Tbl VALUES ('D','C','D'); 1 row created. SQL> commit; Commit complete. SQL> SELECT * FROM tbl t1 2 WHERE 3 rowid=(SELECT min(rowid) 4 FROM tbl t2 5 WHERE t1.col2=t2.col2); C C C - - - A A A B B B D C D SQL> SELECT * FROM tbl t1 2 WHERE 3 rowid=(SELECT max(rowid) 4 FROM tbl t2 5 WHERE t1.col2=t2.col2); C C C - - - B B B C A C D C D
Published by: Johan August 3, 2010 01:31
Each line in the document is printed on a separate page, IE: ten lines will print 10 separate pages for printing.
Try of the reset described here:
http://KB.mozillazine.org/Problems_printing_web_pages#Reset_printerMake sure that you reset all the print preferences.
Each line belongs to a user?
Hi @ all,
I have a page with a form of report page in my application and I want that if some users create a line on this report page I see who (which user) created this line. So in my application there is a column (creator) and it must be filled with the name of users.
I have created a process from my page: Submit-After comp. and Vali.
BEGIN
UPDATE customer
Creator SET =: APP_USER WHERE the creator IS NULL;
END;
It works, but I don't like that this query IS NULL.
I think that this can be done also with:
INSERT INTO customer (..., creator,...)
Values (...,upper(:APP_USER),...) )
commit;
But my form page was created automatically, so that's " " " Treatment of automatic line (DML)"
And I can't see a query.
Any idea what I can do?
EXAMPLE OF A TRIGGER
CREATE OR REPLACE TRIGGER 'TRIGGER_NAME '.
BEFORE YOU INSERT THE "NAME OF THE TABLE.
FOR EACH LINE
BEGIN
-WHERE PRIV_ID IS THE PRIMARY KEY COLUMN
IF: NEW. PRIV_ID IS NULL THEN
-TEST_SEQ IS THE NAME OF SEQUENCE
SELECT TEST_SEQ. NEXTVAL
IN: NEW. PRIV_ID
FROM DUAL;
END IF;
: NEW. CREATED_ON: = SYSDATE;
IF: NEW. CREATED_BY IS NULL THEN
: NEW. CREATED_BY: = NVL (V ('APP_USER'), USER);
END IF;
END;
/
ALTER TRIGGER 'TRIGGERNAME' ENABLE
/
OR WITHOUT INITAILIZATION PRIMARY KEY
CREATE OR REPLACE TRIGGER 'TRIGGER_NAME '.
BEFORE YOU INSERT THE "NAME OF THE TABLE.
FOR EACH LINE
BEGIN
: NEW. CREATED_ON: = SYSDATE;
IF: NEW. CREATED_BY IS NULL THEN
: NEW. CREATED_BY: = NVL (V ('APP_USER'), USER);
END IF;
END;
/
ALTER TRIGGER 'TRIGGERNAME' ENABLE
/
Add dynamic buttons to each line of the report and bind the data line to this line-specific buttons
I have a page with a form in the upper part and a report at the bottom that is bound to a table. I need to add a pair of buttons for each row in the table and add dynamic actions for these buttons. I need to submit the data corresponding to the line to a REST service and update the table/line. I know that it is possible to add ajax call and refresh the table after receipt of the response. But I don't know how can I dynamically include a pair of buttons on each line and access the data corresponding to the record when a particular button is clicked. I was not able to find such a feature using the help page. Can you please let me know if this is possible. Thanks in advance.
Here is the representation of how I need to the page to look like.
Col 1
Col 2
Col 3
data 1
data 21
data 31
Button 1
Button 2
data 2
data 22
data 32
Button 1
Button 2
data 3
data 23
data 33
Button 1
Button 2
data 4
data 24
data 34
Button 1
Button 2
I should be able to access the data 1, data21, data button 31 11 and button21 etc.
Select data1,
data2,
data3,
......,
Button1 null,
Button2 null,
ROWID r_id
Of...
If you change the column for button1 and navigate to the area of column formatting you can create your button here, in several different ways. You will need to play with the way you prefer. See below:
Maybe you are looking for
-
Change the characters of the language in the old text/edit the document
I have an old 60-page text/edit document that I need to use. It was written in Lithuanian, but now when I open it the Lith print. Letter are random symbols. Is there a way I can easily change everything that the original characters from Lith were?
-
Where can I find the driver for the GPIB-232CV-A.
-
Start with different user name
I use Windows XP, also using a HP hard drive and monitor. As of late, I've noticed that when I go out for a minute or two, a window pops up saying connect, but then I see a 'Switch User'. I don't remember since when I got the HP. How can I get rid of
-
Windows XP NOT automatically reinstall USB controllers after restart.
I am running windows XP. My computer stopped grateful plug-and-play hardware connected via USB and asked drivers to be installed. I tried with the software that came with them (a mouse and a keyboard, and a flash player), but it does not work either.
-
Smartphones blackBerry &; icons mad scary... Pls do sth buddies!
I noticed 3 strange black icons with a question mark on them: music, photos & videos. I can't delete them, but I can hide. I want that they are gone forever! They work like links 2 the app they represent. RIM does a helping hand? Pls HELP! Thanks in