Function to convert a string to character [closed] - oracle

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
select 'open' as "documentno" from c_order
union all
select documentno as "documentno" from c_invoice
.This is not working in oracle.
i need a query that works in both oracle and postgres

You have not provided enough information to answer your question.
My guess is that you want to include columns in a union that do not have the same data type and are looking for a way to cast a number to a character value (again I'm guessing because you didn't tell us what data type documentno is).
The following works in Oracle and Postgres:
select 'open' as "documentno" from c_order
union all
select cast(documentno as varchar(20)) as "documentno" from c_invoice;
However: the first part of the union does not make sense. Why are your retrieving the same constant value for each and every row in c_order without any additional information from that table?

Related

Create a column with dollar sign in Oracle SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am wondering whether I can create a column with dollar sign? The output should look like the area marked by red line. But the column can still be calculated like number.
I am not sure whether it is capable.
You can try this:
select to_char(500, '$999') from dual
Column-Name with Dollar:
CREATE TABLE t1 (ID int, "$Sal" int);
INSERT INTO t1 values(1,100);
SELECT id, "$Sal" * 10 FROM t1;

How do you remove duplicate rows in Access? [closed]

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

Oracle pl/sql check if number starts with 9 or 8 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
i am trying to validate data inside my database that is number.
Am i able to detect the retrieved data whether it starts with 8 or 9?
For example:
8999999 is valid
9999999 is valid
7000000 is invalid
Thanks
You can try checking the first character of the field using SUBSTR():
SELECT field_value
FROM your_table
WHERE SUBSTR(TO_CHAR(field_value), 1, 1) IN ('8','9')
The following query will return all records where column data begins with an 8 or 9:
SELECT data
FROM your_table
WHERE REGEXP_LIKE (CAST(data AS varchar2(30)), '^(8|9)(*)');
I assume here that data is a numeric type, and so I cast it to varchar before using REGEXP_LIKE.

How can I take substring in Oracle [closed]

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

How to mask particular column of a table for particular user in Oracle [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Oracle Data masking. How do I mask the data by XXX of a particular column of Table.
RLS policy doesn't work for me.
For security reasons the value is replaced by XXX, so actual value should remain same, and it should be automated for the user
Revoke select on your_table from particular_user;
create view view_on_table as
select col1, col2, 'xxx' as particular_column, col3
from your table;
grant select on view_on_table to particular_user;
:)
Oracle's Virtual Private Database is the only way I know of to make this happen, given your constraint that this must be a direct query against the table: http://www.oracle.com/technetwork/database/security/index-088277.html

Resources