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
Multiple questions - so please excuse if the post gets long
have a read only access to an Oracle schema where I can see certain views
Say views 'X' and 'Y'
now need to create a View on top of these 2 views
1 >Not sure if from performance perspective this is a good idea ?
( the new view will be used for firing selects only )
The two existing views 'X' and 'Y' are themselves created off some other views 'A' and 'B' !!
The weird thing is I can fire a query like :
select * from <<schema_name>>.X
2 >However I cannot access the view A or B directly - so do I need to have grants to A and B ?
when I look at the DDL statement for View X and View Y I see the following code :
create view <<schema_name>>.X as
select emp_first_name,emp_last_name,
from <<schema_name>>.A
However when I fire a query like this :
select * from <<schema_name>>.X -
I get results like :
first_name,last_name
3 >Confused about why the results show field names like first_name,last_name when the view has it defined as emp_first_name and emp_last_name ?
1> Views on Views might cause some performance issues, deppends mostly on the inner views.
Read more in this AskTom post
2> This is not wierd - that's what views do, instead of letting you select the whole table, they let you select only part of it. So you need grants on A and B.
3> Strange, Try this query and see how it was really created-
select dbms_metadata.get_ddl('VIEW', 'X', '<<schema_name>>')
from dual
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 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?
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 8 years ago.
Improve this question
I have come across a strange requirement, and really haven't a clue where to begin
We have an oracle database table that will be receiving data daily, and a CF application to interface with it
What they would like is for when a user logs in, to show x amount of rows from the table, and essentially "lock" the x amount of rows to that user, so when another user logs in, their x amount of rows are different, so noone is working concurrently on the same row
What i am guessing is a session write to a table, claiming the rows, but any thoughts would be more than welcome
There are a few ways to approach this problem. I will take a nibble here and tell you that you will need to get into Oracle database procedures and requires you to understand locking select for update clauses which you will immerse you in the nuances of sessions and how they work in oracle and you will call it using cfstoredproc.
There is another method. Now I have no idea about your coding environment or restrictions, nor do I know the user/system load considerations so this is just a suggestion. Adding a flag field to the table and make it a bit datatype or int...whatever. You are going to select them in a cfquery, then update the list of ids (setting bitItnFlag=1 ...or whatever you want to name this new field) which will mean 'this record is checked out'. You will still have the group of records in the first query which you will loop out to the end user to work with needing an update query setting them free by setting your bitIntFlag=0. They will be essentially locked. So another user will have to select where bitIntFlag=0 essentially skipping your locked group and setting their selected group (update them equal to 1). You can use cftransaction and two cfqueries like this.
<cftransaction action"begin">
<cfquery name="selectLock" datasource="#application.dsn#">
SELECT *
FROM (
SELECT *
FROM mytable
WHERE bitIntFlag = 0
ORDER BY
dbms_random.value
)
WHERE rownum <= 10
</cfquery>
<!---Now run your update--->
<cftry>
<cfquery name="updateLock" datasource="#application.dsn#">
UPDATE
myTable
SET
bitIntFlag = 1
WHERE
primaryKeyIDthing in #ValueList(selectLock.name)#
</cfquery>
<cfcatch type="database">
<cftransaction action="rollback"/>
</cfcatch>
<cftry>
<cftransaction action="commit"/>
</cftransaction>
<cfoutput query="selectLock">
#primaryKeyIDthing#<br>
</cfoutput>
(this code is untested but should get you started if you go down this route)
When you are done you update your records using cfquery and run your update sql and set the flag to zero to free up the records.
Again this is a simple work around that may or may not work for you. I don't know what kind of transactional intensity you are dealing with in your environment but sometimes making things simple can work!
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 9 years ago.
Improve this question
I have written stored procedure and it takes long time when i call it.
I use temporary table in 'SP'.
it can be reason ??
CREATE OR REPLACE PROCEDURE TEST_SP
IS
BEGIN
INSERT INTO MYTEMP_table (A, B )
( SELECT id AS CUSTOMER_NO,
ACC_NO AS ACCOUNT_NO
FROM myTable );
UPDATE MYTEMP_table
SET MYTEMP_table.A =
( SELECT MIN (BRH_DATE)
FROM CUSTOMER,)
UPDATE MYTEMP_table
SET MYTEMP_table.B =
( SELECT MIN (SUBSTR (ENTRY_DATE, 0, 8))
FROM INFO)
.......
MYTEMP_table is temporary table.
This code snippet looks woefully incomplete. Seems odd that you are filling the temp table with one query:
select id, acc_no from myTable
and then wiping out all columns with a single value:
UPDATE MYTEMP_table
SET MYTEMP_table.A =
( SELECT MIN (BRH_DATE)
FROM CUSTOMER,)
Your post is not clear, but hopefully you are using a global temporary table (Memory based) rather than a physical table meant for temporary storage.
Multiple writes to the same rows is a sure-fire way of slowing down the works (Much more-so in a physical table, but still slow either way). If possible, consider the following:
Use analytic functions or a more complex initial query to get all your writing done up front...
If you're not comfortable/familiar with running/reading explain plans, try running each SQL statement in a SQL Editor manually to assess their individual performance...
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