Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a table that contains more than 4 thousand rows. Suppose I have a column named columnname that has values for all rows but each value may have leading and/or trailing blank characters. So, it might look like this
columname
"value "
"value "
"value "
...
And I need a query or technique that removes the leading and/or trailing spaces, like this:
columname
"value"
"value"
"value"
How can I achieve this? (I use oracle 11g)
UPDATE table SET columnname = TRIM( columnname );
followed by
DELETE FROM table WHERE columnname IS NULL;
Just this:
Update table set columnname = trim(columnname)
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I want to remove duplicate rows within my database.
I only want them removed if each field within that row matches another within the same table.
I've researched how to use the Query wizard to find duplicate fields, but I haven't found a way to match the entire row.
Are you able to perform queries?
DELETE FROM table_name
LEFT OUTER JOIN (
SELECT
MIN(RowId) as RowId,
column_name1,
column_name2,
column_name3
FROM
table_name
GROUP BY
column_name1,
column_name2,
column_name3
) as nonDuplicates ON
table_name.RowId = nonDuplicates.RowId
WHERE
nonDuplicates.RowId IS NULL
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
This is the code that produces that error:
create or replace trigger "T4"
AFTER
update of "VALORE" on "OFFERTA"
for each row
DECLARE
cs Inserzione.PrezzoF%TYPE;
BEGIN
SELECT I.PrezzoF INTO cs
FROM Inserzione I JOIN Offerta O ON I.Codice = O.Codice
WHERE O.Codice = :old.Codice;
IF (cs!=NULL AND new.Valore >= cs) THEN
UPDATE Inserzione
SET Stato = 'OFF';
ENDIF;
END;
I don't understand why, because it seems correct.
The error is: 13 4 PLS-00103: Encountered the symbol ";" when expecting one of the following: if
There are a few syntax errors.
The one that is throwing the error is, as #Multisync points out in the comments, that ENDIF should be END IF.
Beyond that, though, there are a couple of other issues.
new.Valore should be :new.Valore-- the :new and :old pseudorecords need to be prefixed with a colon.
cs!=NULL will always return FALSE even if cs is actually NULL (technically, it will always return "unknown" which will be interpreted as false). You would need to use cs IS NOT NULL if you want to check to see if cs is NULL.
I'll strongly wager that your UPDATE statement is missing a WHERE clause-- I don't believe that you really want to update every row of the Inserzione table. Most likely, you'd need to add WHERE codice = :old.codice.
Updated UPDATE
UPDATE Inserzione i
SET Stato = 'OFF'
WHERE i.codice = :old.codice;
You cannot generally SELECT from the table that the trigger is defined on in a row-level trigger. That will generally raise a mutating table exception. I suspect that the join to offerta in your SELECT statement isn't needed. You probably just want something like
Updated SELECT
SELECT i.prezzoF
INTO cs
FROM inserzione i
WHERE i.codie = :old.codice;
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
how can I convert rows of my table as column value
for eg I have a table a
emp id
1
2
3
4
and I want my output as
1 2 3 4
i am also using pivot in oracle and crosstab in postgres but not able to get desired solution as shown above.
Check the listagg function. Note you need at least Oracle 11 for this.
Use this script and change it to your values to get desired results
SELECT * FROM (SELECT emp_id, emp_points
FROM emp_data)
PIVOT (
SUM(emp_points) AS sum_emp_points
FOR (emp_id) IN (1 AS [1], 2 AS [2],3 AS [3],4 AS [4])
);
select * from (select empno from t7) pivot(min(empno) for empno in (1,2,3,4));
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a row string in oracle table.
Some text № 3694452 from 31.08.2013, stilltext 02.09.2013 18:16:27
How can I take "02.09.2013 18:16:27" (from the end of row and after stilltext)
for converting it to date.
Assuming that the date string always positioned at the end of text,
you can use regular expression like this:
select
to_date(
regexp_substr(your_column_name, '\d{2}.\d{2}.\d{4} \d{2}:\d{2}:\d{2}$'),
'dd.mm.yyyy hh24:mi:ss')
from you_table_name;
This assumes that the date is always at the end of the string and is fixed in format.
with dummy as
(select '3694452 from 31.08.2013, stilltext 02.09.2013 18:16:27' data
from dual)
select to_date(substr(data,length(data)-19), 'MM.DD.YYYY HH24:MI:SS')
from dummy
There are more elegant ways to do this with regular expressions, but I am assuming this will suffice.
SQL Fiddle demo here
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm trying to create an index in Oracle on table QueueData and on field XYZ which is one of the nodes of XMLTYPE column TEXT.
My query is:
CREATE INDEX IX_QUEUE_XYZ ON QUEUEDATA (extractValue(TEXT, '//XYZ')) TABLESPACE "PSAPD"
But it is giving me following error:
ORA-19025: EXTRACTVALUE returns value of only one node
I can't understand what is wrong here. Can anyone explain?
The second argument of the extractValue points to more then one node, it should return only one node, so if you have multiple tags "XYZ" it will return all of them if you use XYZ[1] only the first will be returned.
See:
http://www.w3schools.com/xpath/xpath_syntax.asp