Query on Views
Hello everyone,
Can someone please explain me why cant we delete a row from a view that has some group function or group by clause or ROWNUM column or DISTINCT Keyword or any columns defined by expressions
I understand that it doesnt make sense for insert and update operations, but I'm confused why delete operation is not allowed
Can someone please throw some light on this
Thanks for your help
Thanks
Ravi
If I were to turn this into a delete, which of the six rows of source data would you want to be deleted and why?
SQL> with test_data as
2 (
3 select 1 id, 'red' color, 'delete' status from dual union all
4 select 1 id, 'red' color, 'keep' status from dual union all
5 select 1 id, 'blue' color, 'delete' status from dual union all
6 select 1 id, 'blue' color, 'keep' status from dual union all
7 select 2 id, 'blue' color, 'delete' status from dual union all
8 select 2 id, 'blue' color, 'keep' status from dual
9 )
10 select distinct id, color from test_data;
ID COLO
1 blue
1 red
2 blue
Similar Messages
-
Query to view the support group of a generated ticket in the Database, not the Data Warehouse
Hi,
I need a query to view the support group of a generated ticket, but the query must be useful in the only Database (I don't know what happened in the DW, could be a issue).
Please help me,
Greetings!it's "possible", in the same way that low temperature fusion and space elevators are "possible". There's nothing conclusively ruling it out, but not something you want to attempt on your own under a time constraint.
The "Active" ServiceManager database is a 5th or 6th normal form dynamic software defined snowflake schema representitive object database. Updating the database directly is strictly unsupported, and
Travis has discouraged people from even trying to read from it. a college of mine does service manager and operations manager databases at a 400+ level full time, and after 2+ years of doing it, he
almost understands the operational database. it's WELL beyond me, and I do Service Manager basically full time.
That being said, if you are brave and only looking for some basic data, you might be able to tease some things out with the SQL management studio and a good grasp of SQL syntax.
for a production environment, you're much better off fixing the DW. -
SQL query or view used internally by Discoverer Open Workbook from Database
Hi Experts,
I am involved in developing a web application wherein I have to display the 'All Workbooks' similiar functionality in the 'Open Workbook from Database' dialog box of Discoverer. Can anybody provide me with the background query or view that Discoverer uses to retrieve this data for workbook listing? Please let me know if my question is confusing and requires more details.
Thanks
ThomasHi,
If you just need the list of workbooks then you need to use the EUL_DOCUMENT table:
SELECT u.User_Name Owner_Name
*,Doc.Doc_Name Workbook_Name*
*,Doc.Doc_Updated_Date Last_Update_Date*
FROM Eul_Us.Eul5_Documents Doc
*,Eul_Us.Eul5_Eul_Users Own_Usr*
*,Fnd_User u*
WHERE Own_Usr.Eu_Id = Doc.Doc_Eu_Id AND
To_Char(u.User_Id(+)) = Substr(Own_Usr.Eu_Username
*,2*
*,10);*
If you want the exact same list then you need to do the above along with the sharing :
SELECT DISTINCT
case when instr(disco_docs.doc_created_by,'#')=0 then disco_docs.doc_created_by
when instr(disco_docs.doc_created_by,'#')>0 and instr(disco_docs.doc_created_by,'#',2)=0 then (select fu.user_name from fnd_user fu where fu.user_id=substr(disco_docs.doc_created_by,2,5))
else NULL
end "Workbook Owner/Creator",
disco_docs.doc_name "Workbook Name",
disco_docs.Doc_Updated_Date "Last Update Date",
case when instr(disco_users.eu_username,'#')=0 then disco_users.eu_username
when instr(disco_users.eu_username,'#')>0 and instr(disco_users.eu_username,'#',2)=0 then (select fu.user_name from fnd_user fu where fu.user_id=substr(disco_users.eu_username,2,5))
else (select resp.responsibility_name from fnd_responsibility_tl resp where resp.responsibility_id=substr(disco_users.eu_username,2,5))
end as "Shared Name / Responsibility"
FROM
eul_us.eul5_documents disco_docs,
eul_us.eul5_access_privs disco_shares,
eul_us.eul5_eul_users disco_users
WHERE
disco_docs.doc_id = disco_shares.gd_doc_id (+)
and disco_users.eu_username(+) NOT IN ('EUL5', 'PUBLIC')
AND disco_users.eu_id(+) = disco_shares.ap_eu_id;
* Change the EUL_US to your discoverer schema...
Then you will need to compare the current user with the sharing list or creator
Good luck
Tamir -
Is it possible the query in view object is dynamic?
Is it possible the query in view object is dynamic?
Generally, make the column list dynamic.
I think this is related to whether view object can be assembled at runtime based on a dynamic cursor in a procedure?
I ask this because I would like to know how we can use OA framework to simulate crosstab workbook in Discoverer?
Anybody has some clues, please advise.
Thanks.Hi Shay,
Let me tell you briefly... I am sending input as customerId,customerNumber,CustomerName to the web service, if the record is available i am getting the response and i am displaying those records on page as a table. Now when i click a row i need to populate another table with all sale orders of that customer. From webservice datacontrol i have only customer object, I dont have Sales Order Object. For this i need master detail relation. In this case how to proceed. Thats why i am thinking to create a vO and EO object for sales orders table and i want to create view link for this sales order and customers. As i don't have customer VO and EO object to create view link. -
How to build sql query for view object at run time
Hi,
I have a LOV on my form that is created from a view object.
View object is read-only and is created from a SQL query.
SQL query consists of few input parameters and table joins.
My scenario is such that if input parameters are passed, i have to join extra tables, otherwise, only one table can fetch the results I need.
Can anyone please suggest, how I can solve this? I want to build the query for view object at run time based on the values passed to input parameters.
Thanks
Srikanth AddankiAs I understand you want to change the query at run time.
If this is what you want, you can use setQuery Method then use executeQuery.
http://download.oracle.com/docs/cd/B14099_19/web.1012/b14022/oracle/jbo/server/ViewObjectImpl.html#setQuery_java_lang_String_ -
Problems in creation of workbook using Change query local view.
Hi Experts,
I have created a Multiprovider by using union of two infocubes and created a Query based on Multiprovider. I want to restrict one infocube in Change Query local view for creating new workbooks. In Query global view we drag and drop the Infocube under Filters, but in the Query local view Filter panel is in disable mode. (My requirement is to create the workbooks using change query local view only)
How can I restrict the one Infocube values in the workbooks by using Change query local view?
Thanks in advance.
Venkat.Hi Venkat Prasad
As you told that the query is on multi provider and the view is not allowing to declare/define filter value
Just drag the infoprovider info object avilable under packet dimension to rows and right click on it restrict by selecting the name of the info provider when u right click it will show you the option of restrict once u click on it,it will takes to u a pop up where you can able to see the name of info providers and you specify according to it and finally in the display of results if you dont want to to display the info provider name then just right click on the 0infoprovider object under rows go to properties then choose hide option under display.
Hope its clear a little..!
Thanks
K M R
**Assigning points is the only way of saying thanks in SDN***
>
venkata prasad wrote:
> Hi K M R,
>
> Thanks for ur quick response. Most of the Infoobjects are common for both infocubes. I didn't understand this sentense "retrict the value with the infoprovider which values you are trying to view".
> Please explian elaborately how to restrict the values speicfic to infoprovider under rows. -
Options to control display performance of CLOBs, etc. in Query Result view?
Whenever I attempt to query a table that contains LOBs (e.g. a CLOB or XMLTYPE), the lack of performance pretty much makes the "Query Result" view (from F9) unusable. Any time I attempt to scroll the results, SQL developer apparently continues to query the database for the additional characters to populate the view.
Resizing the columns containing the LOB to only a few characters almost solves the issue. Unfortunately, the size of the columns showing the LOBs apparently attempt to resize to the length of the LOB, making the column several pages long - and the same performance issue prevents resizing it smaller.
Ideally, there would be some way to resize a column to a given or even a predefined and small size, without having to drag the resize handle the entire width of the desired resize amount. Alternatively, there could be a user preference to never set default column widths above a given number of pixels or characters. Another option would be a user preference to disable the in-line display of LOB contents, displaying only and requiring a click on the "..." (or pencil icon) button to open the "View Value" dialog. Ideally, all 3 of these options could be implemented.
One crude work-around I'm using for now is to exclude the LOB columns from the results, requiring me to make secondary queries to see the LOB contents when necessary, and doesn't allow for scrolling through and viewing the LOB contents at all. Another work-around is to run the query as a script (F5) instead of a query (F9), and view the results in the "Script Output" view instead.
I'm currently using SQL Developer 2.1.0.63, but experienced this same issue with all previous versions, including 1.5.5.
Thanks!I agree.
When I requested to auto-width the columns, I said to build in a maximum, but apparently they didn't.
I suggest you log 2 feature requests on the SQL Developer Exchange; 1 for the maximum width, 1 for the CLOB contents/performance. Like this others can vote too and add weight for future implementation (I will).
Have fun,
K. -
Column alias error in a query of views
Hi
I was trying to workout this query
create view dept_sal as
select d.department_name,sum(e.salary)
from departments d left outer join employees e
on d.department_id= e.department_id
group by d.department_name;
and i recieved this error message .............
Error at Command Line:2 Column:25
Error report:
SQL Error: ORA-00998: must name this expression with a column alias
00998. 00000 - "must name this expression with a column alias"
*Cause:
*Action:
I tried to put an alias for sum(e.salary) function and it worked but i dont understand why it is required or is the problem somewhere else and why an alias is needed here ???
Actually the book hasnt specfied the need for an alias at this place ...so i wanted to know why am getting this error ..
create or replace view dept_sal as
select d.department_name,sum(e.salary) as d_sal
from departments d left outer join employees e
on d.department_id= e.department_id
group by d.department_name;
view DEPT_SAL created.
Also i wanted to know if i can start a thread each time i want have a problem or can i add my questions to somebody
else's thread ..
Thanks
JayshreeHi, Jayshree,
to_learn wrote:
Hi
I was trying to workout this query
create view dept_sal as
select d.department_name,sum(e.salary)
from departments d left outer join employees e
on d.department_id= e.department_id
group by d.department_name;
and i recieved this error message .............
Error at Command Line:2 Column:25
Error report:
SQL Error: ORA-00998: must name this expression with a column alias
00998. 00000 - "must name this expression with a column alias"
*Cause:
*Action:
I tried to put an alias for sum(e.salary) function and it worked but i dont understand why it is required or is the problem somewhere else and why an alias is needed here ???Every column in a table or view must have a unique name. If you don't explicitly specify a name for the output column, Oracle will try to generate one based on the input expression. If the name does not follow the normal rules for identifiers (one of which is that the name can't contain special symbols, like parentheses) then the name must be enclosed in double-quotes.
Notice that these rules are a little different from the rules about result sets. In the result set of a main query, for example, column names do not have to be unique, and a system-generated name like 'SUM(E.SALARY)" is acceptable.
Actually the book hasnt specfied the need for an alias at this place ...so i wanted to know why am getting this error ..I can't see which book you're reading. Post a quote. If the book is available on line, post a link, too.
create or replace view dept_sal as
select d.department_name,sum(e.salary) as d_sal
from departments d left outer join employees e
on d.department_id= e.department_id
group by d.department_name;
view DEPT_SAL created.That's the right way to do it.
Also i wanted to know if i can start a thread each time i want have a problem or can i add my questions to somebody
else's thread ..It's better to start your own thread. -
Viewlink between Custom VO "Cannot set user query to view"
We have an application where we have extended custom VO and EO’s to get data from flat files. It all looks fine till we create a viewlink for a LOV with two related VO’s. The viewlink VO fails we get message of the form -Cannot set user query to view "CustomVO1" because it is a destination in a view link”. Are there any methods to override in the custom VO/EO or any parameter to be added to configs. Has someone tried this out
Thanks for the update and for sharing the solution!
Regards,
Hussein -
Report Not apperaing in User's Query Report Viewer Menu
Hello There!
Continuing with below thread
Report Category not Appearing in Report Definition
When i search for a report i created, i'm(as a normal user) not able to find any report after searching.(assigned to me or to my role.)
The view PSXPRPTSRCH_VW has two tables PSXPRPTDEFN and PSXPDATASRC .Both have oprid column which is blank and the above view's first where clause is asking for oprid.
I don't understand how then all the doc./papers on internet i read, to create Report using XML Publisher says/shows the report appears in user menu(query report viewer). May be they still using PS login to show the output?
Anybody have any idea where am going wrong?
The category,datasource,Definition,query tree all set properly. Do user need any special role/permission assigned?
BTW user can see the query report viewer menu.
Regards!
Edited by: user10569054 on Sep 27, 2012 2:32 PM
Peoplesoft Version 9.00
Database Oracle 10.2Thanks for the Reply.
from the doc. you gave, this is what i found.
Home > PeopleBooks > PeopleTools 8.52: BI Publisher for PeopleSoft > Running, Locating, and Viewing BI Publisher Reports
The Query Report Viewer allows selection and online viewing of those reports that have a data source type of PeopleSoft Query. Existing Query security applies so that each user has access to run only the reports to which he or she has qualified Query access to the data source.
The PS query and the data source is created by user PS then how can a normal user will have access to that?
I'm bit confused here.
Regards! -
Problems with query in view object
I have create query form view object that is render on a jsp. The dynamic generate query leaves out "'" single quotes on string 'not assigned' which is selected from a lov.
Does anyone no how I might fix this?
Thanks.Greg:
Please provide further details. How are you creating the dynamically generated query? Could you show the original query vs. what is executed?
Thanks.
Sung -
How do I query changed view object attribute in another view object
Jdeveloper 10.1.3.4
My requirement is that I want to be able to query a view object (based on entity) on a non-key attribute where the value I am searching on may either be in the database on an existing record or, have just been recorded by updating a different view object based on the same entity (and yet to be committed).
When querying the second view object for a value just updated via a different view object, the second view object always returns no rows. I had expected the process to be :
EntityA
ViewObjectA based on EntityA
ViewObjectB based on EntityA
ViewObjectA - query row with key = 123. update attribute Y with value 456 (attribute Y in database null). Entity cache for EntityA, key 123, atttribute Y updated with value 456
ViewObjectB - query row with attribute = Y. expect record in EntityA cache just updated to be returned. Instead, nothing is returned
Here is the code I was using (where RandScheduleEdit and RandScheduleSearch are identical view objects based on entity object RandSchedule)
public static void main(String[] args) {
String amDef = "test.cache.model.AppModule";
String config = "AppModuleLocal";
ApplicationModule am = Configuration.createRootApplicationModule(amDef,config);
ViewObject rsEdit = am.findViewObject("RandScheduleEdit");
Key rsKey = new Key(new Object[]{40});
Row[] rsEditRows = rsEdit.findByKey(rsKey,1);
Row rsEditRow = rsEditRows[0];
rsEditRow.setAttribute("SId", new Number(7827));
ViewObject rsSearch = am.findViewObject("RandScheduleSearch");
rsSearch.setWhereClause("S_ID = :SId");
rsSearch.defineNamedWhereClauseParam("SId", null, null);
rsSearch.setNamedWhereClauseParam("SId",new Number(7827));
rsSearch.executeQuery();
Row rsSearchRow = rsSearch.first();
Configuration.releaseRootApplicationModule(am, true);
}Why does rsSearch not find the record S_ID = 7827 ? It seems to only be querying new records in the database and ignoring the cached record just updated ?
Any help greatly appreciated.
Cheers,
BrentrsSearch.setNamedWhereClauseParam("SId",new Number(7827));This might help:
rsSearch.setQueryMode(ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS);
rsSearch.executeQuery(); -
How to view complete date stamp in query result view in sql developer?
Hi,
In the query result, the date present in db is shown as DD-MM-YYYY format but I want to view the complete date stamp. When I view the same data in aqua data studio, I see the complete time stamp. Please let me know if I need to do some settings in Oracle SQL Developer so that complete date is shown?
How to view complete date stamp in query result view in sql developer?
Thanks in advance,
Vineet864793 wrote:
Hi,
In the query result, the date present in db is shown as DD-MM-YYYY format but I want to view the complete date stamp. When I view the same data in aqua data studio, I see the complete time stamp. Please let me know if I need to do some settings in Oracle SQL Developer so that complete date is shown?
How to view complete date stamp in query result view in sql developer?
Thanks in advance,
VineetAlternatively you can execute below
set nls_date_format='DD-MM-YYYY HH24:MI:SS';Regards,
Achyut K -
I'm using the Query Selection View web item on one of my web templates. The issue is related to the Create and Delete command buttons not being displayed even though the Create/Delete - Display Button property has been selected for this control.
ThanksDid you ever figure this out? I am having the same problem now
-
Implementing History types on query based view object attributes
Hi All,
I have to implement the history types
created on,
created by,
modified on,
modified by
in my application, but I have all the Query based view objects in my work space, but according to my research History types can only be implemented on the Entity Objects attributes. So how can I do this for my application ? Any Solution ? Any alternative please ?
(NOTE: I have all the entity objects available in my common Model work space ).@TimoHahn, I have the following master view object query, which i can not generate by using the Entity objects, Basically I am transforming an oracle form base ERP into Oracle ADF application, so I have available all the quries , Please let me know if i can have any alternative solution ?
SELECT NVL(A.STYP,0) STYP,A.DAT,C.BATNO,C.ITST, B.DEMNO,B.ITEM,LTRIM(RTRIM(D.ITEMNAME))ITEM_NAME,0 TRINQ,D.UOM ABRV,P.DAT DDAT,
A.CSNO,PARTY,NVL(CSRAT,0)+(NVL(CSRAT,0)*NVL(B.GST,0))/100 GSTCSRAT,CSRAT,
A.PDAYS DAYS, DECODE(C.CSTERM,1,'CASH',2,'CREDIT',3,'DD',4,'PAY ORDER',5,'ADVANCE%',6,'CHEQUE') ,B.GST,E.MASTDS PNAME,NVL(SUM(B.RQTY),0)DRQTY,DEPT.SEC_NAME DEPTDS,SUM(STOK.QTY) BAL,P.TRNO,C.EBY, C.SYSIP, C.TDAT
FROM ACCSTORE.STAC_CSM A, ACCSTORE.STAC_CSD B,ACCSTORE.ST_STAC_DEM_APRVD C,ACCSTORE.VITEMS D, ACC_MAST E,ACCSTORE.PRE_DEMANDM P,ACCSTORE.VSECTIONS DEPT,
(SELECT STYP,ITEMID,SUM(BALANCE) QTY FROM ACCSTORE.VITEMSTOCK GROUP BY STYP,ITEMID) STOK
WHERE A.CSNO=B.CSNO AND B.CSNO=C.CSNO AND B.DEMNO=C.DEMNO AND B.ITEM=C.ITEM AND B.STYP=C.STYP AND C.PDEMNO=P.TRNO(+) AND P.DEPT=DIVNO AND P.SEC_NO=DEPT.SECNO(+)
AND C.STYP=STOK.STYP AND C.ITEM=STOK.ITEMID
AND C.STYP=D.STYP AND C.ITEM=D.ITEMID AND C.PARTY=E.MASTCD AND B.APP=1 AND NVL(C.PONO,0)=0
AND C.ITST=DECODE(C.STYP,0,11,14)
GROUP BY NVL(A.STYP,0),A.DAT,C.BATNO,C.ITST,B.DEMNO,B.ITEM,D.ITEMNAME,A.CSNO,PARTY,P.DAT,DEPT.SEC_NAME,P.TRNO,C.EBY, C.SYSIP, C.TDAT,
CSRAT,A.PDAYS,C.CSTERM,B.GST,E.MASTDS,D.UOM ORDER BY A.CSNO,D.ITEMNAME
ORDER BY "DAT" DESC
which i can not generate by using the Entity objects, Basically I am transforming an oracle form base ERP into Oracle ADF application, so I have available all the quries , Please let me know if i can have any alternative solution ? -
Expert mode query in View objects and appended where clause
My company is Oracle Member Partner and we are developing enterprise web applications using Oracle database and BC4J.
I have the following problem...
When I enable EXPERT MODE option in View Object I have trouble appending to query statement in my client code.
I need expert mode because I must use "SELECT DISTINCT" insted of "SELECT" in my query.
It looks something like this:
viewObject.setWhereClause("CLA_ID = " + claId);
viewObject.executeQuery();
SQL query from View Object becomes sub-query and fails to execute:
select * from (original view object query) where (... appended where clause)
Order by part of the query causes sql errors because original query is now sub-query.
Is there any way around this?I tried creating an expert mode SQL query:
SELECT DISTINCT EMPNO, ENAME FROM EMP.
Then at runtime I do:
vo.setWhereClause("ENAME LIKE '%'||?||'%');
vo.setWhereClauseParam(0,'A');.
and this works fine. The trick is that since expert-mode view objects get wrapped as inline views (to allow runtime appending of WHERE clause, actually), you need to select any column in the select statement to which you want to later refer in a dynamically-appended where clause.
If you want to prevent the inline-view wrapping, you can write the following code in your view object's ViewObjectImpl subclass to force the VO to NOT be treated as an expert-mode SQL VO.
// Goes in your view object impl subclass
public void create() {
// Force this VO to NOT be treated as an expert-mode SQL, so that
// its query does not get wrapped as an inline view.
getViewDef().setFullSql(false);
}I used this trick above to create an expert mode query like:
SELECT DISTINCT deptno FROM empand then at runtime I add a dynamic where clause that refers to a column
in EMP that is not in the select list like this:
ViewObject vo = am.findViewObject("View1");
vo.setWhereClause("ename like '%A%'");
vo.executeQuery();
System.out.println(vo.first().getAttribute(0));and this causes the query to come out as:
SELECT DISTINCT deptno FROM emp WHERE ename like '%A%'.
instead of:
SELECT * FROM (SELECT DISTINCT deptno FROM emp) QRSLT WHERE ename like '%A%'which would cause an error due to the fact that ename is not in the select list of the original (wrapped, inline) query.
Maybe you are looking for
-
Hi, Am doing payment document reversal for normal company code.document using function module Point1; CALL_FBRA (am passing BUKRS,AUGBL,GJAHR) executing fine but unable to grap the REVERSE / RESET fields) please let know we will i get reverse aand re
-
Using A JTree Model to Open Files
Hello all, How can I open the files that are displayed in the JTree? I have a JTree with names of the files that are saved on my hardesk, but I can't use the JTree to open these files. I have already implemented the TreeSelectionListener.
-
NWBC opens GUI in the wrong system
Hi all, I have a problem with GUI transactions opening in the wrong system. The description for the logonpad in the NWBC system connection is correct, but i do have multiple definitions for the same systems (e.g. different cockpits, etc). In short I
-
Hi, My redo log backup failed and I've no clue on the errors. Below is the job log. Please advise. TIA ! Job started Step 001 started (program RSDBAJOB, variant &0000000000064, user ID BACKUP_USER) No application server found on database host - rsh/g
-
FWSM logging from a transparent context with more bridge-group.
When I'm using FWSM in transparent mode and with more than one bvi what is the source IP of syslog messages? Is it the IP of bvi that it uses to reach the syslog server? Thanks.