Create a view using a select statement
Hi
I need to create a view using a select statement to view details from 2 different tables which will only show data where the holidays commence after june.
I am new to oracle so any help will do.
Thanks
Hi
I need to create a view using a select statement to view details from 2 different tables which will only show data where the holidays commence after june.
I am new to oracle so any help will do.
Thanks
Similar Messages
-
Hi,
I am working on a report what has 10 datasets derived from 10 different select statements.
Is it possilbe to save those 10 select statements as a macro / stored procedure and then use that macro to generate those dataset in the ssrs report builder ?
AshishSinghalHi AshishSinghal84,
According to your description, you want to write multiple select statements in a procedure, then use the procedure as dataset in the report, right?
According to my knowledge, when we write multiple select statements in a procedure, we have to create relationship between these select statements, otherwise it will only return the first one query's fields. If you are using SSRS 2008 R2, you can use Lookup
function to display these fields from different datasets on one data region control, but the prerequisite is that you must have one common field. For more information about lookup function, please see:
http://msdn.microsoft.com/en-us/library/ee210531.aspx
If all these solution you cannot achieve due to your special condition, the last workaround is to use subreport to display all the fields together.
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
Query to create a view using the following tables
Hi,
I am struggling to write the proper query to create a view using three tables.
I would really be thankful if anyone can help me.
I am pasting the following script to create the required tables and also insert appropriate data in each of the table.
create table HR.STUDENT_DETAILS (
STUDENT_ID NUMBER(10),
STUDENT_NAME VARCHAR2(50),
DOB DATE,
SEX CHAR(1),
ACTIVE CHAR(1),
CONTACT_NUMBER NUMBER(20),
primary key(STUDENT_ID)
create table HR.PAYMENT_HEADER (
PAY_HEADER_ID NUMBER(10),
DOC_NUM NUMBER(5),
MONTH_NAME VARCHAR2(10),
primary key(PAY_HEADER_ID)
create table HR.PAYMENT_DETAILS (
HEADER_ID NUMBER(10),
LINE_ID NUMBER(10),
STUDENT_ID NUMBER(10),
CUM_AMOUNT NUMBER(10),
primary key(HEADER_ID,LINE_ID)
INSERT ALL
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1112,'James','17-JUN-05','M','Y',23674378)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1113,'David','21-SEP-05','M','Y',24565457)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1114,'Michael','13-JAN-06','M','Y',25436784)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1115,'Joseph','03-JAN-06','M','Y',23435673)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1116,'Juliet','21-MAY-05','F','Y',23234527)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1117,'Monica','25-JUN-05','F','Y',24873245)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1118,'William','05-FEB-05','M','Y',23623245)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1119,'Karen','07-FEB-06','F','Y',26757543)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1120,'Erika','17-AUG-05','F','Y',25435465)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1121,'Noah','16-AUG-05','M','Y',23457645)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1122,'Angelina','28-SEP-05','F','Y',26456787)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1123,'Gabriela','30-SEP-05','F','Y',29767543)
INTO HR.STUDENT_DETAILS (STUDENT_ID,STUDENT_NAME,DOB,SEX,ACTIVE,CONTACT_NUMBER) VALUES (1124,'Sofia','07-MAR-06','F','Y',27656578)
SELECT * FROM DUAL;
INSERT ALL
INTO HR.PAYMENT_HEADER (PAY_HEADER_ID,DOC_NUM,MONTH_NAME) VALUES (305,1,'JAN')
INTO HR.PAYMENT_HEADER (PAY_HEADER_ID,DOC_NUM,MONTH_NAME) VALUES (306,2,'FEB')
INTO HR.PAYMENT_HEADER (PAY_HEADER_ID,DOC_NUM,MONTH_NAME) VALUES (307,3,'MAR')
INTO HR.PAYMENT_HEADER (PAY_HEADER_ID,DOC_NUM,MONTH_NAME) VALUES (308,4,'APR')
INTO HR.PAYMENT_HEADER (PAY_HEADER_ID,DOC_NUM,MONTH_NAME) VALUES (309,5,'MAY')
SELECT * FROM DUAL;
INSERT ALL
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (305,12,1112,40)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (305,13,1113,40)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (305,14,1114,40)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (306,15,1112,80)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (306,16,1113,80)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (306,17,1114,80)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (306,18,1115,40)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (306,19,1116,40)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (307,20,1112,120)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (307,21,1113,120)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (307,22,1114,120)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (307,23,1115,80)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (307,24,1116,80)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (307,25,1117,40)
INTO HR.PAYMENT_DETAILS (HEADER_ID,LINE_ID,STUDENT_ID,CUM_AMOUNT) VALUES (307,26,1118,40)
SELECT * FROM DUAL;
The above table STUDENT_DETAILS stores the details of all the students and each student has a unique student id.
Another table PAYMENT_HEADER saves the payment details as a document for each month which has a header id.
In the PAYMENT_DETAILS table, payment details are stored for the students (who made the payment for that month). This table does not save the data for a student if he has not paid on that month. This table is connected to the PAYMENT_HEADER table through a header Id.
The view should be such that when I pass the document number, it shall show the names of all the students, but shall show payment amount only for those students who had paid under the selected document number, for other it should show null.
I tried the following query:
select * from (
select sd.student_name,sd.DOB,sd.sex,sd.contact_number,pd.doc_num,pd.month_name,pd.cum_amount
from hr.student_details sd left join
(select hdr.doc_num,hdr.month_name,det.student_id,det.cum_amount
from hr.payment_header hdr, hr.payment_details det
where hdr.pay_header_id = det.header_id) pd on sd.student_id = pd.student_id)
But when I pass the filtering values like document number, it does not show some students with null values.
select * from (
select sd.student_name,sd.DOB,sd.sex,sd.contact_number,pd.doc_num,pd.month_name,pd.cum_amount
from hr.student_details sd left join
(select hdr.doc_num,hdr.month_name,det.student_id,det.cum_amount
from hr.payment_header hdr, hr.payment_details det
where hdr.pay_header_id = det.header_id) pd on sd.student_id = pd.student_id)
where doc_num = 1 or doc_num is null;
My requirement is that, every time I use a document number in the where clause for the view it should show the paid amount against the student names who has paid on that month and for all other student it should null. Total student number is 13. So every time it should show 13 students only even when I pass document No 2 or 3.
Seeking your help.
Regards
HawkerHi Frank,
as per your advice, I am omitting the 'DOB', 'GENDER','ACTIVE','CONTACT_NUMBER' fields from the 'STUDENT_DETAILS' table.
I shall create separate tables and insert the desired output from the view for each where clause.
First let us create three tables each for the desired out put:
1) For the desired output I want to see when I pass doc_num as 1
create table HR.SDT_PAY_DET_DOC_ONE (
STUDENT_ID NUMBER(10),
STUDENT_NAME VARCHAR2(50),
DOC_NUM NUMBER(5),
C_AMOUNT NUMBER(10),
primary key(STUDENT_ID)
2) For the desired output I want to see when I pass doc_num as 2
create table HR.SDT_PAY_DET_DOC_TWO (
STUDENT_ID NUMBER(10),
STUDENT_NAME VARCHAR2(50),
DOC_NUM NUMBER(5),
C_AMOUNT NUMBER(10),
primary key(STUDENT_ID)
3) For the desired output I want to see when I pass doc_num as 3
create table HR.SDT_PAY_DET_DOC_THREE (
STUDENT_ID NUMBER(10),
STUDENT_NAME VARCHAR2(50),
DOC_NUM NUMBER(5),
C_AMOUNT NUMBER(10),
primary key(STUDENT_ID)
Now I shall insert values in each of the above three tables:
INSERT ALL
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1112,'James',1,40)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1113,'David',1,40)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1114,'Michael',1,40)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1115,'Joseph',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1116,'Juliet',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1117,'Monica',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1118,'William',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1119,'Karen',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1120,'Erika',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1121,'Noah',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1122,'Angelina',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1123,'Gabriela',null,null)
INTO HR.SDT_PAY_DET_DOC_ONE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1124,'Sofia',null,null)
SELECT * FROM DUAL;
INSERT ALL
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1112,'James',2,80)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1113,'David',2,80)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1114,'Michael',2,80)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1115,'Joseph',2,40)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1116,'Juliet',2,40)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1117,'Monica',null,null)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1118,'William',null,null)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1119,'Karen',null,null)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1120,'Erika',null,null)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1121,'Noah',null,null)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1122,'Angelina',null,null)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1123,'Gabriela',null,null)
INTO HR.SDT_PAY_DET_DOC_TWO(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1124,'Sofia',null,null)
SELECT * FROM DUAL;
INSERT ALL
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1112,'James',3,120)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1113,'David',3,120)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1114,'Michael',3,120)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1115,'Joseph',3,80)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1116,'Juliet',3,80)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1117,'Monica',3,40)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1118,'William',3,40)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1119,'Karen',null,null)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1120,'Erika',null,null)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1121,'Noah',null,null)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1122,'Angelina',null,null)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1123,'Gabriela',null,null)
INTO HR.SDT_PAY_DET_DOC_THREE(STUDENT_ID,STUDENT_NAME,DOC_NUM,C_AMOUNT) VALUES (1124,'Sofia',null,null)
SELECT * FROM DUAL;
Thanks & Regards
Hawker -
Creating Object views using XSU PL/SQL.Please SEE.
Hi,
I am presently using XSU PL/SQL utility with Oracle 9i and using the
DBMS_XMLQuery.newContext(<My Select clause goes here>,and the
DBMS_XMLQuery.getXML()which generates an XML document.
My query is:
I have 2 tables (One master and the other detail table.).
Table : DI_Master
di_num
00001
Table: DI_Details
di_num di_act
00001 ABCD
00001 ANCF
00001 IOPP
Now the XML I'd like is :
<di_num>00001</di_num>
<di_act>
<val>ABCD</val>
<val>ANCF</val>
<val>IOPP</val>
</di_act>
Do I need to create object tables for this,insert data into object tables
and then read this table? It will become an extremely tedious process
I guess an OBJECT view can do what I want.Can anyone please tell me how
to write an object view for the 2 tables please and the get the output as
desired.?Supposing you have further
nesting of the tables.Then how will you go about doing that.You can have multiple levels of CURSOR expressions (see an example below, not a real-life example, but illustrates the point).
SQL> set long 4000
SQL> select dbms_xmlquery.getXML('select deptno,' ||
2 'cursor(select empno, cursor(select losal, hisal from salgrade) salgrades '||
3 'from emp e where e.deptno = d.deptno and rownum < 3) EMPLOYEES ' ||
4 'from dept d where d.deptno = 10')
5 FROM DUAL;
DBMS_XMLQUERY.GETXML('SELECTDEPTNO,'||'CURSOR(SELECTEMPNO,CURSOR(SELECTLOSAL,HIS
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPTNO>10</DEPTNO>
<EMPLOYEES>
<EMPLOYEES_ROW num="1">
<EMPNO>7782</EMPNO>
<SALGRADES>
<SALGRADES_ROW num="1">
<LOSAL>700</LOSAL>
<HISAL>1200</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="2">
<LOSAL>1201</LOSAL>
<HISAL>1400</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="3">
<LOSAL>1401</LOSAL>
<HISAL>2000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="4">
<LOSAL>2001</LOSAL>
<HISAL>3000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="5">
<LOSAL>3001</LOSAL>
<HISAL>9999</HISAL>
</SALGRADES_ROW>
</SALGRADES>
</EMPLOYEES_ROW>
<EMPLOYEES_ROW num="2">
<EMPNO>7839</EMPNO>
<SALGRADES>
<SALGRADES_ROW num="1">
<LOSAL>700</LOSAL>
<HISAL>1200</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="2">
<LOSAL>1201</LOSAL>
<HISAL>1400</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="3">
<LOSAL>1401</LOSAL>
<HISAL>2000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="4">
<LOSAL>2001</LOSAL>
<HISAL>3000</HISAL>
</SALGRADES_ROW>
<SALGRADES_ROW num="5">
<LOSAL>3001</LOSAL>
<HISAL>9999</HISAL>
</SALGRADES_ROW>
</SALGRADES>
</EMPLOYEES_ROW>
</EMPLOYEES>
</ROW>
</ROWSET>
1 row selected.
SQL>
Also,isnt it a better option to create a VIEW of the
Select clause and pass a view to the select clause? At the end of the day, you could use whatever you feel comfortable with, provided that it produces your expected output and looks clean. We are just giving you the ideas, how you implement it actually in your situation, depends upon a lot of factors, that only you know about. -
Problem in Creating a view using infotypes PA0001,PA0002,...
Hi,
Can anybody please help me how to create a Maintainence view using PA0001,PA0002,PA0003,PA0006,PA0032.
I tried to create it using se54.
when i use PA0003 as check table, i am not able to create relations with PA0001,PA0002,PA0032,PA0006.
Thanks in Advance.
Vinay.BRYou can create a view using SE11 as mentioned in the previous answer. Once you created, you can use SE16 to display the content of the view table. However, this does not serve much because you can also see the original table using SE16. Unless you want to generate screen dialog so that the view table can be used in SM30. This method can be done while editing the table in SE11. Click on Utilities->Table maintenance generator. However, this will be considered as a repair (modification to SAP standard) and you need repair key.
-
How to use the select statement in for loop
Hi All,
my question is can we use select statement in for loop like as follows .
for key in select key from one_table.
when i am using this am getting an error like Found select invalid i identifier
how to make use of select statement in for loop
please suggest me .
Thanks
SreeSQL>set serveroutput on;
SQL> DECLARE
BEGIN
FOR Cur_Rec IN (SELECT dname FROM dept) LOOP
DBMS_OUTPUT.PUT_LINE(Cur_Rec.dname);
END LOOP;
END;
SQL>
ACCOUNTING
RESEARCH
SALES
OPERATIONSAs per your requirement always filter the Query beforehand
Like
FOR Cur_Rec IN (SELECT key FROM <table> WHERE key=1) LOOP
END LOOP;Edited by: Lokanath Giri on १ दिसंबर, २०११ ३:५६ अपराह्न -
How to join THREE different tables into internal table using one select statement .
How to join THREE different tables into internal table using one select statement .
Hi experts,
I would like to request your guidance in solving the problem of joining the data from three different database tables into one internal table
Scenario:
Database tables:
SPFLI
SFLIGHT
SBOOK.
Table Fields:
SPFLI - CARRID CONNID COUNTRYFR CITYFRM COUNTRYTO CITYTO
SFLIGHT - CARRID CONNID FLDATE SEATSMAX SEATSOCC SEATSMAX_C
SEATSOCC_C SEATSMAX_F SEATSOCC_F
SBOOK - CARRID CONNID CLASS
MY INTERNAL TABLE IS IT_XX.
Your help much appreciated.
Thanks in advance.
Pawan.Hi Pawan,
please check below codes. hope it can help you.
TYPES: BEGIN OF ty_xx,
carrid TYPE spfli-carrid ,
connid TYPE spfli-connid ,
countryfr TYPE spfli-countryfr,
cityfrom TYPE spfli-cityfrom ,
countryto TYPE spfli-countryto,
cityto TYPE spfli-cityto ,
fldate TYPE sflight-fldate ,
seatsmax TYPE sflight-seatsmax ,
seatsocc TYPE sflight-seatsocc ,
seatsmax_b TYPE sflight-seatsmax_b,
seatsocc_b TYPE sflight-seatsocc_b,
seatsmax_f TYPE sflight-seatsmax_f,
seatsocc_f TYPE sflight-seatsocc_f,
class TYPE sbook-class,
END OF ty_xx,
t_xx TYPE STANDARD TABLE OF ty_xx.
DATA: it_xx TYPE t_xx.
SELECT spfli~carrid
spfli~connid
spfli~countryfr
spfli~cityfrom
spfli~countryto
spfli~cityto
sflight~fldate
sflight~seatsmax
sflight~seatsocc
sflight~seatsmax_b
sflight~seatsocc_b
sflight~seatsmax_f
sflight~seatsocc_f
sbook~class
INTO TABLE it_xx
FROM spfli INNER JOIN sflight
ON spfli~carrid = sflight~carrid
AND spfli~connid = sflight~connid
INNER JOIN sbook
ON spfli~carrid = sbook~carrid
AND spfli~connid = sbook~connid.
Thanks,
Yawa -
How to create MRP view using BO BUS1001006 & Method CreateViews.
Guys,
I need to create MRP view using BO BUS1001006 & Method CreateViews.
i am not able to unterstand, what i need to specify to create MRP view, other than material number.
what field i need to send for MRP view.
Regards.
santosh.
Edited by: santosh koraddi on Jun 23, 2010 6:14 PMHi,
I have a similar question, have done a search and I see this sort of thing has come up a few times but with no definitive answer.... this thread seems close but don't really understand the solution (I'm not an ABAPER)
I have a material master creation workflow under construction, it uses BUS1001006 and method createviews.
The issues is that I want to restrict creation of certain views to certain agents, I have a fork in my workflow and its meant to split up the various views for various agents.
The problem is that if an agent in one of the forks completes their views the workflow tries to get them to completes teh other views which they do not have authoisation to do... anyway the end result is that the workflow thinks all teh views have been created and the workflow items dissappear from the others inboxes.
How do I setup my workflow such that each agent in each fork only has to complete the views they have authorisation to maintain and leaves work items in the inboxes of other agents for them to complete? -
Cannot create a server using the selected type
Hi,
I'm trying to integrate tomcat 6.0 with Eclipse. But when I try to add Tomcatv6.0 Server,
it is sowing an error message " Cannot create a server using the selected type ".
Can anyone tell me why?
Thanks in advanceIn order to solve the problem you need to
* close eclipse
* go to ~/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings
* remove the files org.eclipse.wst.server.core.prefs and org.eclipse.jst.server.tomcat.core.prefs
* solve the problem with the permissions of the policy files or the personal instance of tomcat6
* start eclipse
In order to be able to use the tomcat6 server the proper solution is to have a personal instance of the tomcat6 server as described in the section "Advanced Configuration - Multiple Tomcat Instances" of the file RUNNING.txt (and the problems that have been reported about this ;-) )
My configuration: Debian/Sid, Eclipse 3.4.1. Ganymede
george -
Index not being used in Select statement
Friends
I have the following SQL statement:
SELECT
a.acct,
a.date_field,
UPPER(b.feegroup) feegrp,
SUM (a.fee1) fee1,
SUM (a.fee2) fee2,
SUM (a.fee3) fee3
FROM table1 a, table2 b
WHERE 1 = 1
AND a.fee_id = b.fee_id
GROUP BY a.acct, a.date_field, b.feegroup;
Both the tables have index on fee_id column. When I run the explain plan for this statement, I am getting the following output:
Operation | Option | Object Name | Position
SELECT STATEMENT | | | 560299
HASH | GROUP BY| |1
TABLE ACCESS | FULL| table2 | 1
TABLE ACCESS | FULL| table1 | 2
Why Oracle is not using the index?
Edited by: darshilm on Dec 10, 2009 3:56 PMThe proposed plan is the optimal according to your current conditions in the "where clause" where you have only the equality join condition and therefore the CBO can use HASH JOIN. Using any kind of index access would just increase the amount of required work unless you would add some very restrictive conditions which will select rows from relatively small amount of blocks. Here I have to mention that what really counts in the CBO cost calculation is the amount of blocks accessed and not the number of rows. The "currency" for I/O in Oracle is a block and not a row. CBO always uses an assumption that there is nothing in the buffer cache and it will have to perform a physical read for every block.
How many blocks will actually be accessed depends on the data distribution. It can happen that every single row that you have to retrieve resides in a different block and although you access only 1000 rows out of a million row table you would have to visit almost every block of that table. For such a situation a FULL TABLE SCAN is the best access path and Oracle will use multiblock I/O for that. On the other side you can have those 1000 rows only in a few blocks and then the index access would be the most appropriate one. For index access Oracle uses single block I/O. Usually the actual situation is somewhere between this two extreme situations. But you can run some tests by yourself and see when an index access will be replaced by a full table scan while you will make your predicates less selective.
HTH, Joze
Co-author of the forthcoming book "Expert Oracle Practices"
http://www.apress.com/book/view/9781430226680
Oracle related blog: http://joze-senegacnik.blogspot.com/
Blog about flying: http://jsenegacnik.blogspot.com/
Blog about Building Ovens, Baking and Cooking: http://senegacnik.blogspot.com -
How to use a select statement with chinese characters?
I am currently developing a java servlet<using tomcat 4.x> which allows me to use select statement to retrieve results from the Microsoft SQL Server 2000 database. I am using a simple form to get the parameter for querying. The main problem i'm facing is that there are chinese information in the SQL database, but i can't retrieve it through the sql statement with the chinese characters input<thru the form with the help of NJ STAR>in the WHERE condition. When i execute the statement, it returns me no results even though the rows are present in the database.
Does anyone have the solution to using chinese words in the WHERE clause of the select statement to retrieve results with columns which contains chinese characters? Please help me. Thanks everyone. :)
PS: when i cut and paste those characters in the sql database and paste onto java.. it is ??? in questionmarks.. but when i paste them into excel 2000.. its shown as chinese chars again..
please heelppp~~Greetings,
PS: when i cut and paste those characters in thesql
database and paste onto java.. it is ??? in
questionmarks.. but when i paste them into excelThis is why the SELECT is not returning any results.
You need to set the character encoding set on your
statement and parameters for the characters to be
properly translated. Refer to the charsetName
parameter in the String class constructor in your API
docs and also to
$JDK_DOCS/guide/intl/encoding.doc.html in your JDK
documentation.
2000.. its shown as chinese chars again..Because Office programs are performing the same kind
of character translation with the appropriate MS APIs.
please heelppp~~Regards,
Tony "Vee Schade" Cookis it possible for you to show me some coding examples? i don't really understand what is to be done in order to set the char set and what does it really do.. tried reading up but still dun understand.. :(
pardon my shallow knowledge of java..
ok..
The thing is when i used an insert statement with chinese characters of GBK format hardcoded into the java servlet and then i use the insert statement to insert the chars into the database, it cannot be seen as a chinese word when i off the NJStar. and then it can be searched out with my current form of servlet.. below is my coding of the servlet..
note: i've set my html file to charset = GBK
//prototype of Search engine...
//workable for GBK input and output...
import java.io.*;
import java.io.OutputStream;
import java.io.IOException;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.util.*;
import java.sql.*;
import java.nio.charset.Charset;
public class SearchBeta extends HttpServlet {
private Vector musicDetails = new Vector();
private String query = "";
public void service (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException, UnsupportedEncodingException {
query = req.getParameter ("T1");
System.out.println("before:"+query);
String type = req.getParameter ("D1");//type
query = req.getParameter ("T1");
//query = "������";
System.out.println("after:"+query);
getResults(type,query);
System.out.println("locale = :"+req.getLocale());
res.setContentType ("text/html;charset=GBK");
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<body bgcolor = \"black\">");
out.println("<font face = \"comic sans ms\" color=\"Cornsilk\">");
if (query.length()==0)
out.println ("Please key in your search query.");
else if (musicDetails.size()==0)
out.println ("Sorry, no results matching your search can be found.");
else {
out.println("<center>");
out.println("<table cellspacing = \"50\">");
int i = 0;
//Display the details of the music
while (i<musicDetails.size()) {
Results details = (Results)musicDetails.get(i);
String dbArtist = "";
String dbAlbum = "";
String dbTitle = "";
String dbCompany = "";
dbAlbum = details.getAlbum();
dbTitle = details.getTitle();
dbCompany = details.getCompany();
dbArtist = details.getArtist();
try{
dbAlbum = new String(dbAlbum.getBytes("ISO-8859-1"),"GBK");
dbTitle = new String(dbTitle.getBytes("ISO-8859-1"),"GBK");
dbCompany = new String(dbCompany.getBytes("ISO-8859-1"),"GBK");
dbArtist = new String(dbArtist.getBytes("ISO-8859-1"),"GBK");//correct translation.
catch(UnsupportedEncodingException e){
System.out.print(e);
e.printStackTrace();
String dbImage_loc = details.getImage();
out.println("<tr>");
out.println("<td><table>");
out.println("<img src=C:\\Program Files\\Apache Group\\Tomcat 4.1\\webapps\\examples\\ThumbNails\\"+dbImage_loc+">");
out.println("<tr>");
out.println("<th><font color=\"violet\"> Artist: </font></th>");
out.println("<td><font color=\"Cornsilk\">"+dbArtist+"</font></td>");
out.println("</tr>");
out.println("<tr>");
out.println("<th><font color=\"violet\"> Title: </font></th>");
out.println("<td><font color=\"Cornsilk\">"+dbTitle+"</font></td>");
out.println("</tr>");
out.println("<tr>");
out.println("<th><font color=\"violet\"> Company: </font></th>");
out.println("<td><font color=\"Cornsilk\">"+dbCompany+"</font></td>");
out.println("</tr>");
System.out.println("album: "+ dbAlbum);
out.println("<tr>");
out.println("<th><font color=\"violet\"> Album: </font></th>");
out.println("<td><font color=\"Cornsilk\">"+dbAlbum+"</font></td>");
out.println("</tr>");
System.out.println("company: "+ dbCompany);
out.println("</table></td>");
out.println("</tr>");
i++;
out.println("</table>");
out.println("</center>");
out.println("</font>");
out.println("</body>");
out.println("</head>");
out.println("</html>");
out.close();
//to remove all the elements from the Vector
musicDetails.removeAllElements();
//get Searched Music Details and store in Results object which is stored in musicDetails vector
public void getResults (String type, String searchQuery) {
try {
Class.forName ("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=music","sa","kokkeng");
Statement stmt = con.createStatement();
String query = "SELECT * FROM MusicDetails WHERE "+type+" = '"+searchQuery+"'";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
String artist = rs.getString("Artist");
String title = rs.getString("Song");
String company = rs.getString("Company");
String album = rs.getString("Album");
String image_loc = rs.getString("Image");
Results details = new Results (artist,title,company,album,image_loc);
musicDetails.add(details);
stmt.close();
con.close();
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
with the above servlet i created, i can search out the data in the database which i've inserted through the insert statement. I still can't search for things i've keyed into the database directly using NJStar..
thank you so much for helping.. really hope any one else who knows the answer to this will reply too... thank you all so much...
-KK -
How can I create "Sub Queries" in a select statement?
Hi all,
I need to create reports, which are not based on a single table but on several "sub-queries".
This would be the code, but I don't know how to solve that problem...
SELECT OGBI.*
FROM
(((select "OSSRALL"."FORECAST_OWNER", sum
("OSSRALL"."TOTAL_OPPORTUNITY_AMOUNT")
from "#OWNER#"."OSSRALL" "OSSRALL",
"#OWNER#"."TEAM_MAIN" "TEAM_MAIN",
"#OWNER#"."MA_MAIN" "MA_MAIN"
group by "OSSRALL"."FORECAST_OWNER")OGBI.APPSME1)
where "OSSRALL"."OPP_CLASS" = (EX_OTHERS)),
-- more are following
"#OWNER#"."OSSRALL" "OSSRALL",
"#OWNER#"."TEAM_MAIN" "TEAM_MAIN",
"#OWNER#"."MA_MAIN" "MA_MAIN"
WHERE
("MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"||' Mr'
like "OSSRALL"."FORECAST_OWNER" or
"MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"||' Mrs'
like "OSSRALL"."FORECAST_OWNER" or
"MA_MAIN"."MA_NAME"||', '||"MA_MAIN"."MA_FIRST_NAME"
like "OSSRALL"."FORECAST_OWNER") and
("OSSRALL"."SALES_GROUP"="TEAM_MAIN"."NAME") and
("MA_MAIN"."MA_ID"=:P17_VB1)
thx a lot for your help.
kind regards Jan
Message was edited by:
Jan RabeJan
Please can you post the full select statement and the DDL to create the tables? Or, provide someone access to the app on the Oracle server.
We can probably make these much more readable using table aliases and removing the owner unless you are doing this across schemas or via a wizard?
It looks like you are missing joins in your query - is this what you mean by subqueries? It is a good idea to move the join up before the WHERE clause if you can as this makes the query easier to manage.
Phil -
Function returning cursor to be used in select statement
I have written a function which returns a cursor. I want to use this in a select statement to display rows. How to do this.
Eg : function - test_fn return sys_refcursor. (returns empno, empname, deptname)
select test_fn from dual
This should return
empno empname deptno
1 name1 dept1
2 name 2 dept2
....Try This::
SCOTT@xe_144>variable c refcursor
SCOTT@xe_144>CREATE OR REPLACE FUNCTION get_nm
2 RETURN sys_refcursor
3 AS
4
5 c sys_refcursor;
6 BEGIN
7
8 open c for 'SELECT ENAME , SAL FROM EMP';
9
10 RETURN c;
11 END;
12 /
Function created.
SCOTT@xe_144>select get_nm into :c from dual;
GET_NM
CURSOR STATEMENT : 1
CURSOR STATEMENT : 1
ENAME SAL
SMITH 800
ALLEN 1600
WARD 1250
JONES 2975
BLAKE 2850
CLARK 2450
KING 3000
AKASH2 5000
TURNER 1500
ADAMS 1100
JAMES 950
MILLER 1300
ABC 2000
13 rows selected.Let me know if its works for you. -
Question on Updating the rows of a table using a SELECT Statement
Hi,
I am trying to set all of the R_IDs in one table to the ID from another table using a join.
Here is the SQL I came up with. I don't this is correct though.
UPDATE TABLEA A
SET R_ID=(Select Id from TABLEB B
WHERE A.DEE=B.DEE AND
B.RNUM=1);
Does this make sense?You can try the join view.
UPDATE ( SELECT table_a.id AS a_id,
table_b.id AS b_id,
table_a.col1 AS a_col1,
table_b.col1 AS b_col1,
table_a.col2 AS a_col2,
table_b.col2 AS b_col2,
table_a.col3 AS a_col3,
table_b.col3 AS b_col3
FROM table_a,
table_b
WHERE table_a.id = table_b.id)
SET a_col1 = b_col1,
a_col2 = b_col2,
a_col3 = b_col3;
However it may result in
ORA-01779: cannot modify a column which maps to a non key-preserved tableThis is because the key-preserving property of a table does not depend on the actual data in the table. It is, rather, a property of its schema. For example, if in table_b there was at most one record for each id value, then table_a.id would be unique in the result of a join of table_a and table_b, but table_a would still not be a key-preserved table. By adding the unique/primary key on the id column of table_b we can assure that if table_b.id were part of the result set of the join view then it would be unique. This makes table_a key preserved.
Thus, in order to update a join view we must assure that the columns involved in the join view from the source table are unique. We do this by creating a unique or primary key on those columns.
However, if you do not mind taking responsibility for making sure that there is one-to-one cardinality between the source and destination rows, then you might try the correlated subquery
UPDATE table_a
SET (col1, col2, col3 ) =
( SELECT col1, col2, col3
FROM table_b
WHERE table_b.id = table_a.id )
WHERE EXISTS
( SELECT col1, col2, col3
FROM table_b
WHERE table_b.id = table_a.id ) -
HELP WITH CREATING A VIEW USING PL/SQL
Hello,
I have two tables, one is simply an audit version of the other and anytime data is updated, modified, or deleted the data is copied to the audit table (via a trigger) and the audit table records who made the changes and when.
Here is the description of one of the archive tables:
AUD_OBLIGATION_ID NOT NULL NUMBER(10)
OBLIGATION_ID NUMBER(10)
COMMUNICATION_ID NUMBER(10)
COMMUNICATION_ID_OLD NUMBER(10)
OBL_DESC VARCHAR2(4000)
OBL_DESC_OLD VARCHAR2(4000)
OBL_TYPE VARCHAR2(20)
OBL_TYPE_OLD VARCHAR2(20)
ORIGINAL_TARGET_DATE DATE
ORIGINAL_TARGET_DATE_OLD DATE
TARGET_DATE DATE
TARGET_DATE_OLD DATE
ACTUAL_DATE DATE
ACTUAL_DATE_OLD DATE
STATUS VARCHAR2(20)
STATUS_OLD VARCHAR2(20)
DOCLINK VARCHAR2(200)
DOCLINK_OLD VARCHAR2(200)
SERIAL_NUMBER NUMBER(10)
SERIAL_NUMBER_OLD NUMBER(10)
REMARKS VARCHAR2(200)
REMARKS_OLD VARCHAR2(200)
CREATED_BY VARCHAR2(10)
CREATED_BY_OLD VARCHAR2(10)
CREATION_TS DATE
CREATION_TS_OLD DATE
MODIFIED_BY VARCHAR2(10)
MODIFIED_BY_OLD VARCHAR2(10)
MODIFICATION_TS DATE
MODIFICATION_TS_OLD DATE
UPDATED_BY VARCHAR2(10)
UPDATED_TS DATE
ACTION_TYPE VARCHAR2(10)
I now need to create a view of this audit table, but do not want to list all the columns from the audit table, instead I would like it to look like this:
Modification_TS ** Action_Type ** Updated_By ** CHANGES
Where CHANGES would be a variable that stores the concatenated new & old values (if they are different).
I assume I need to create a stored procedure using PL/SQL to find these values then insert the values into a view...but all of my efforts do not seem to work.
Here is the procedure I've written:
CREATE OR REPLACE PROCEDURE proc_AUD_OBLIGATIONS AS
modData VARCHAR2(2000) :=' ';
emp VARCHAR2(200);
actType VARCHAR2(100);
actDate DATE;
obUser VARCHAR2(500);
CURSOR cur_AUD_OBLIGATION IS
SELECT o.UPDATED_TS, o.UPDATED_BY, o.OBLIGATION_ID, o.COMMUNICATION_ID,o.COMMUNICATION_ID_OLD,o.OBL_DESC,o.OBL_DESC_OLD,
o.OBL_TYPE, o.OBL_TYPE_OLD, o.ORIGINAL_TARGET_DATE,o.ORIGINAL_TARGET_DATE_OLD,o.TARGET_DATE,o.TARGET_DATE_OLD,
o.ACTUAL_DATE,o.ACTUAL_DATE_OLD,o.STATUS,o.STATUS_OLD,o.DOCLINK,o.DOCLINK_OLD,o.SERIAL_NUMBER,o.SERIAL_NUMBER_OLD,
u.FNAME || ' ' ||u.LNAME AS EMPLOYEE,o.ACTION_TYPE
FROM AUD_OBLIGATION o, TRAC_USER u, OBLIGATION_USER ou
WHERE o.OBLIGATION_ID = ou.OBLIGATION_ID
AND
ou.TRAC_USER_ID = u.TRAC_USER_ID;
i_AUD_OBLIGATION cur_AUD_OBLIGATION%rowtype;
BEGIN
for i_AUD_OBLIGATION in cur_AUD_OBLIGATION loop
actType := i_AUD_OBLIGATION.ACTION_TYPE;
actDate := i_AUD_OBLIGATION.UPDATED_TS;
emp := i_AUD_OBLIGATION.UPDATED_BY;
IF i_AUD_OBLIGATION.OBL_DESC != i_AUD_OBLIGATION.OBL_DESC_OLD
THEN modData := 'OBL. DESC. was: ' || i_AUD_OBLIGATION.OBL_DESC_OLD
|| 'It is now: ' ||i_AUD_OBLIGATION.OBL_DESC;
ELSE modData := modData;
END IF;
IF i_AUD_OBLIGATION.OBL_TYPE != i_AUD_OBLIGATION.OBL_TYPE_OLD
THEN modData := modData || 'OBL. TYPE. was: ' ||i_AUD_OBLIGATION.OBL_TYPE_OLD
|| 'It is now: ' ||i_AUD_OBLIGATION.OBL_TYPE;
ELSE modData := modData;
END IF;
IF i_AUD_OBLIGATION.ORIGINAL_TARGET_DATE != i_AUD_OBLIGATION.ORIGINAL_TARGET_DATE_OLD
THEN modData := modData || 'ORIG.TRGT DATE was: ' || i_AUD_OBLIGATION.ORIGINAL_TARGET_DATE_OLD
|| 'It is now: ' ||i_AUD_OBLIGATION.ORIGINAL_TARGET_DATE;
ELSE modData := modData;
END IF;
INSERT INTO vw_AUD_OBLIGATIONS VALUES
(actDate,actType, emp,modData);
END LOOP;
END;
Here is the view I've created, based on this procedure (it does not compile):
CREATE OR REPLACE VIEW vw_AUD_OBLIGATIONS
(Action_Date, Action_Type, Action_User, Modified_Data)
AS
SELECT actDate,actType, emp,modData
FROM proc_AUD_OBLIGATIONS
END;
Any thoughts on how to make this work - it seems like such a simple concept....
Thanks in advance
TonyYou have a couple of misconceptions here. First, you cannot SELECT from a procedure. You need to write a PROCEDURE that INSERTs these columns into a TABLE, then simply SELECT from the TABLE. There are of course many variations, but I hope you get the general idea here.
Greg
Maybe you are looking for
-
Looking for help need to know how to turn group message of in iOS 7.0.6
How do I turn off group message in ios7.0.6
-
Error 10401 occurred at AI Hardware Config, when using AI Acquire Waveform vi
I can successfully run applications that use the AI Sample Channel vi, however when I use the AI Acquire Waveform vi the following errors are generated:- Error -10401 occurred at AI Hardware Config, followed by Error -10401 occurred at AI SingleScan.
-
Perchased songs, how to re-download?
I perchased some songs on my iphone. I accidently deleted the songs on my macbook pro. How can I re-download them on my macbook pro? When I go to the songs on iTunes Store, they show perchased but I can't download them again. I did authorize this com
-
Error in BusinessRootBjectCore.login in MSA during writing in Outboundqueue
Hello CRM Gurus, i need your help. We use CRM5 clients in the field. And we use the save-method for an specific user to create entries in the outboundqueue. It works all fine. But now I have a client, which get the error "BusinnesRootObjectCore.Logi
-
Discrepancy while finding the t code through user id in SUIM
Hi While finding out the particular t code like MIRO from SUIM -> Trancation code ->User i m unable to find the same in the list but if i search through the role through PFCG its been displaying the same but not through SUIM -> Transaction code by us