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
Tony
You 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
Similar Messages
-
Hi I am looking to create a view that needs based on a table.
Table:
Roll, Code, Qual, Date
1 05 KO 112010
1 35 01 112010
1 98 01 132011
etc.....
I need only the row(roll) that has code 05 and ko but that roll has to have had a row with Code 35 Qual 01 with the same Date. I am able to get all the rows the have the correct Codes (05 and KO along with 35 and 01). I am not sure how I can then join it on itself to give me just the 05/ko row where the rolls and date match.Hi,
Here's one way, using the analytic COUNT function:
CREATE OR REPLACE VIEW view_y
AS
WITH got_cnt_35 AS
SELECT roll, code, qual, dt -- DATE is not a good column name
, COUNT ( CASE
WHEN code = 35
AND qual = '01'
THEN 1
END
) OVER ( PARTITION BY roll
, dt
) AS cnt_35
FROM table_x
WHERE (code, qual) IN ( ( 5, 'KO')
, (35, '01')
SELECT roll, code, qual, dt
FROM got_cnt_35
WHERE code = 5
AND qual = 'KO'
AND cnt_35 > 0
;You could do it with a self-join, also, but I think this way is simpler.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
Always say which version of Oracle you're using.
See the forum FAQ {message:id=9360002} -
Dear Experts,
I need to create two derived fields in the View.Iam a Newbie.
I initially created a View from a Table. How should I go about
creating the Derived columns?
Column 1 In The Table Contains an ID.
Derived Column in the View Must be having the following
Condition.
1) ID in table =
14853 AMS
10511 AMS
13625 AMS
8245 AMS
12675 AMS
Derived Column1 (Code) in the view must See If the Value in the
ID as AMS if the part of the value in ID is AMS it must be
Populated AMS in the Derived field else it must be set to PVT
2) One More Column with another Derived Condition
ID in the Table
13449 AMS
12196 AMS
5055 AMS
13647 AMS
6927 AMS
19243 AMS
6057 AMS
703 AMS
29 AMS
Resultant Derived Column2 (RNO) must be a 8 Digit field.
If 29 AMS is there it must be 00000029
IF 703 AMS is there it must be 00000703
IF 19243 AMS is there it must be 00019243
Here the AMS word must be removed and Prefixed with Zero’s to
make it a 8 Digit
Request you to Please help.
Thanks and regards,
GayathriThis..?
sql>
with qry as(
select '14853 AMS' id from dual union all
select '10511 AMS' id from dual union all
select '13625 TXT' id from dual union all
select '29 AMS' id from dual union all
select '703 AMS' id from dual union all
select '8245 XXX' id from dual union all
select '12675 AMS' id from dual)
select id,decode(instr(id,'AMS'),0,'PVT','AMS') code,
decode(instr(id,'AMS'),0,null,lpad(trim(replace(id,'AMS','')),8,'0')) RNO
from qry;
ID COD RNO
14853 AMS AMS 00014853
10511 AMS AMS 00010511
13625 TXT PVT
29 AMS AMS 00000029
703 AMS AMS 00000703
8245 XXX PVT
12675 AMS AMS 00012675
jeneesh -
Cannot create Materialized View using PL/SQL procedure
Hello,
I have a question related to Materialized View creation.
I have a stored procedure that creates materialized view. When trying to run this procedure I get insufficient privileges error: ORA-01031.
When I run content of this procedure as anonymous PL/SQL block them materialized view is created without any complications.
Can you please advice me on that topic?
Is it even possible to create materialized view in stored procedure as I haven't found an info on it.
Thanks
PetrHi chudapet,
Whenever you do operation in procedure you need to have direct grants and not via a role.
Most probably the grant to create materialized view is available via a role to your user.
Assign direct grant to the user:
grant create materialized view to scott;
{code} -
Creating a user with "create user" privilege using PL/SQL?
I have managed to use the PL/SQL DBMS_LDAP package to create and modify OID users (DBMS_LDAP.add_s and DBMS_LDAP.modify_s).
The question is: How can I use DBMS_LDAP to assign privileges to OID users? By "privileges" I mean options like the following (i.e. the options you can enable/disable for any OID user if you login to OIDDAS and click the "privileges" button for a particular user):
Allow user creation
Allow user editing
Allow user deletion
Allow group creation
Allow group editing
Allow group deletion
Allow privilege assignment to users
Allow privilege assignment to groups
AndySolution found.
In case anyone comes back to this thread in the future looking to achieve a similar thing: Metalink 205315.1 contains details. -
Help with creating basic menu using AS
i am working on a portfolio site for my friend who is a
photographer and am looking to create a basic menu that when any
menu item is moused over it enlarges and the other menu items move
to make room for this enlarged menu item. i have tried to show this
in the attached image.
it would be much appreciated if someone could offer me some
assistance or tips. thank you.
Link
to preview exampleHello and welcome to the forums,
What I would do there is use something like "Tweener", found
at
http://code.google.com/p/tweener/.
This is built to work with AS 2.0 and 3.0. You could also use Mc
Tween, found at
http://hosted.zeh.com.br/mctween/.
I am most comfortable with Mc Tween, I just haven't had time to
look at Tweener. Basically it would work something like the
following....
What the code does is when you rollover the menu item, it
will scale to 110% of its original size and when you rollout it
scales to 100%...
In order to use mc tween, you have to download and install
the extenstion first.
Once you've done that you will be all set... but if you plan
on eventually using AS 3.0, check out Tweener.
HTH,
Doug -
I need your help with a decision to use iPhoto. I have been a PC user since the mid 1980’s and more recently have used ACDSee to manage my photo images and Photoshop to edit them. I have used ProShow Gold to create slideshows. I am comfortable with my own folder and file naming conventions. I currently have over 23,000 images of which around 60% are scans going back 75 years. Since I keep a copy of the originals, the storage requirements for over 46,000 images is huge. 180GB plus.
I now have a Macbook Pro and will add an iMac when the new models arrive. For my photos, I want to stay with Photoshop which also gives me the Bridge. The only obvious reason to use iPhoto is to take advantage of Faces and the link to iMovie to make slideshows. What am I missing and is using iPhoto worth the effort?
If I choose to use iPhoto, I am not certain whether I need to load the originals and the edited versions. I suspect that just the latter is sufficient. If I set PhotoShop as my external editor, I presume that iPhoto will keep track of all changes moving forward. However, over 23,000 images in iPhoto makes me twitchy and they are appear hidden within iPhoto. In the past, I have experienced syncing problems with, and database errors in, large databases. If I break up the images into a number of projects, I loose the value of Faces reaching back over time.
Some guidance and insight would be appreciated. I have a number of Faces questions which I will save for later.Bridge and Photoshop is a common file-based management system. (Not sure why you'd have used ACDSEE as well as Bridge.) In any event, it's on the way out. You won't be using it in 5 years time.
Up to this the lack of processing power on your computer left no choice but to organise this way. But file based organisation is as sensible as organising a Shoe Warehouse based on the colour of the boxes. It's also ultimately data-destructive.
Modern systems are Database driven. Files are managed, Images imported, virtual versions, lossless processing and unlimited editing are the way forward.
For a Photographer Photoshop is overkill. It's an enormously powerful app, a staple of the Graphic Designers' trade. A Photographer uses maybe 15% to 20% of its capability.
Apps like iPhoto, Lightroom, Aperture are the way forward - for photographers. There's the 20% of Photoshop that shooters actually use, coupled with management and lossless processing. Pop over to the Aperture or Lightroom forums (on the Adobe site) and one comment shows up over and over again... "Since I started using Aperture/ Lightroom I hardly ever use Photoshop any more..." and if there is a job that these apps can do, then the (much) cheaper Elements will do it.
The change is not easy though, especially if you have a long-standing and well thought out filing system of your own. The first thing I would strongly advise is that you experiment before making any decisions. So I would create a Library, import 300 or 400 shots and play. You might as well do this in iPhoto to begin with - though if you’re a serious hobbyist or a Pro then you'll find yourself looking further afield pretty soon. iPhoto is good for the family snapper, taking shots at birthdays and sharing them with friends and family.
Next: If you're going to successfully use these apps you need to make a leap: Your files are not your Photos.
The illustration I use is as follows: In my iTunes Library I have a file called 'Let_it_Be_The_Beatles.mp3'. So what is that, exactly? It's not the song. The Beatles never wrote an mp3. They wrote a tune and lyrics. They recorded it and a copy of that recording is stored in the mp3 file. So the file is just a container for the recording. That container is designed in a specific way attuned to the characteristics and requirements of the data. Hence, mp3.
Similarly, that Jpeg is not your photo, it's a container designed to hold that kind of data. iPhoto is all about the data and not about the container. So, regardless of where you choose to store the file, iPhoto will manage the photo, edit the photo, add metadata to the Photo but never touch the file. If you choose to export - unless you specifically choose to export the original - iPhoto will export the Photo into a new container - a new file containing the photo.
When you process an image in iPhoto the file is never touched, instead your decisions are recorded in the database. When you view the image then the Master is presented with these decisions applied to it. That's why it's lossless. You can also have multiple versions and waste no disk space because they are all just listings in the database.
These apps replace the Finder (File Browser) for managing your Photos. They become the Go-To app for anything to do with your photos. They replace Bridge too as they become a front-end for Photoshop.
So, want to use a photo for something - Export it. Choose the format, size and quality you want and there it is. If you're emailing, uploading to websites then these apps have a "good enough for most things" version called the Preview - this will be missing some metadata.
So it's a big change from a file-based to Photo-based management, from editing files to processing Photos and it's worth thinking it through before you decide. -
Creating a view using With causes ORA-00600 Error
Hello Ladies and Gents,
I've been trying to deploy a recursive query as a view in Oracle XE and Standard Edition, neither to much success.
The query is located in this question here: http://stackoverflow.com/questions/17358109/how-to-retrieve-all-recursive-children-of-parent-row-in-oracle-sq
with recursion_view(base, parent_id, child_id, qty) as (
-- first step, get rows to start with
select
parent_id base,
parent_id,
child_id,
qty
from
md_boms
union all
-- subsequent steps
select
-- retain base value from previous level
previous_level.base,
-- get information from current level
current_level.parent_id,
current_level.child_id,
-- accumulate sum
(previous_level.qty + current_level.qty) as qty
from
recursion_view previous_level,
md_boms current_level
where
current_level.parent_id = previous_level.child_id
select
base, parent_id, child_id, qty
from
recursion_view
order by
base, parent_id, child_id
The query itself works and returns results. However, when I try to create a view with that query, I receive errors.
I've posted two screenshots: http://www.williverstravels.com/JDev/Forums/StackOverflow/17358109/ViewError.jpg and http://www.williverstravels.com/JDev/Forums/StackOverflow/17358109/InternalError.jpg The first one with the ! and * is when I am using JDeveloper 11g, using the Database Navigator, right-click on View and select "New View". I receive the error when I click OK. I can indeed create the view through a sql script, but when I attempt to view the data, I receive the ORA_00600 error.
I've tried this on both my local machine for XE (version 11.2.0.2.0) and on 11g Standard Edition (11.2.0.2.v6) via Amazon Web Services. The result is the same.
Does anyone know how to get around this?Not 5 minutes after I post this, I decide not to use JDev's graphical editor, and simply write
SELECT * FROM BOMS_VIEW;
And it works like a charm. I just can't use data tab to view the records in the editor. Wish I had known that 5 hours ago. -
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.
-
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 -
Help for creating classification view in mm01
hi guys can anybody help on creating classification views in mm01 using bdc recording i need a step by step procedure . since when i tryed in mm01 there are filds like class name i dont know where all these data's to find one more thing is i was asked to create classification view using bdc recording ...please help me with some programs if u have
Hi,
You need to use the BAPI 'BAPI_OBJCL_CREATE' to create characteristics for a material.
The characteristics are need to be passed in the table ALLOCVALUESCHAR.
If you do not know the values for a particular characteristics then you canmake use of FM
BAPI_CLASS_GET_CHARACTERISTICS and BAPI_CHARACT_GETDETAIL to get the values.
Regards,
Ankur Parab -
I need help with Creating Key Pairs
Hello,
I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
the class is :
import java.io.*;
import java.math.BigInteger;
import java.security.*;
import java.security.spec.*;
import java.security.interfaces.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import au.net.aba.crypto.provider.ABAProvider;
class CreateKeyPairs {
private static KeyPair keyPair;
private static KeyPairGenerator pairGenerator;
private static PrivateKey privateKey;
private static PublicKey publicKey;
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
return;
createKeys();
saveKey(args[0],publicKey);
saveKey(args[1],privateKey);
private static void createKeys() throws Exception {
Security.addProvider(new ABAProvider());
pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
pairGenerator.initialize(1024, new SecureRandom());
keyPair = pairGenerator.generateKeyPair();
privateKey = keyPair.getPrivate();
publicKey = keyPair.getPublic();
private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
out.writeObject(key);
out.close();
private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
out.writeObject(key);
out.close();
the public key is:
�� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�| xpt Javaur [Ljava.lang.String;��V��{G xp q ~ ur [B���T� xp ��ccR}o���[!#I����lo������
����^"`8�|���Z>������&
d ����"B��
^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
How i can generated the key pairs in base 64 or binary????
Thanxs for help me
Luis Navarro Nu�ez
Santiago.
Chile.
South America.I don't use ABA but BouncyCastle
this could help you :
try
java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
java.security.KeyPair kp = kg.generateKeyPair();
java.security.Key pub = kp.getPublic();
java.security.Key pri = kp.getPrivate();
System.out.println("pub: " + pub);
System.out.println("pri: " + pri);
byte[] pub_e = pub.getEncoded();
byte[] pri_e = pri.getEncoded();
java.io.PrintWriter o;
java.io.DataInputStream i;
java.io.File f;
o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
o.println(new sun.misc.BASE64Encoder().encode(pub_e));
o.close();
o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
o.println(new sun.misc.BASE64Encoder().encode(pri_e));
o.close();
java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
StringBuffer keyBase64 = new StringBuffer();
String line = br.readLine ();
while(line != null)
keyBase64.append (line);
line = br.readLine ();
byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
keyBase64 = new StringBuffer();
line = br.readLine ();
while(line != null)
keyBase64.append (line);
line = br.readLine ();
byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
System.out.println("pub: " + pubKey);
java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
System.out.println("pri: " + priKey);
catch(Exception e)
e.printStackTrace ();
} -
How to create a counter using Oracle SQL Developer?
Is there any way to create a counter using Oracle SQL Developer to create the below scenario. Meaning it will recorded down the name of user and ID and time and the date they login.
Library portal home statistics shows how many users (outside and within the campus) visit the library portal.
Page Access statistics is recorded on an hourly basis. Users may select the statistics by
yearly (statistics displayed by all months in the selected year)
monthly (statistics displayed by all days in the selected month)
daily (statistics displayed by all hours in the selected day)I'm giving here one basic post - hope this will solve your problem --
SQL>
SQL>
SQL> create table audit_info
2 (
3 usr varchar2(50),
4 log_time timestamp(6)
5 );
Table created.
SQL>
SQL>
SQL> create table err_log
2 (
3 log_cd varchar2(20),
4 log_desc varchar2(500)
5 );
Table created.
SQL>
SQL>
SQL> create or replace procedure ins_err(errcd in varchar2,
2 errnm in varchar2)
3 is
4 pragma autonomous_transaction;
5 begin
6 insert into err_log values(errcd,errnm);
7 commit;
8 end;
9 /
Procedure created.
SQL>
SQL>
SQL> create or replace procedure ins_aud(ud in varchar2,
2 unm in varchar2)
3 is
4 pragma autonomous_transaction;
5 begin
6 insert into audit_info values(ud,unm);
7 commit;
8 exception
9 when others then
10 ins_err(sqlcode,sqlerrm);
11 end;
12 /
Procedure created.
SQL>
SQL>
SQL>
SQL> create or replace trigger log_odsuser1
2 after logon on odsuser1.schema
3 begin
4 ins_aud('ODSUSER1',sysdate);
5 exception
6 when others then
7 ins_err(sqlcode,sqlerrm);
8 end;
9 /
Trigger created.
SQL>
SQL*Plus: Release 9.2.0.1.0 - Production on Tue Jun 12 12:21:09 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
SQL>
SQL>
SQL>
SQL> set serveroutput on
SQL>
SQL>
SQL> select * from audit_info;
USR
LOG_TIME
ODSUSER1
12-JUN-07 12.00.00.00000000 AMHope this will solve your purpose.
Regards.
Satyaki De. -
Hey i need help with creating a quiz with scoring and all.
I need a helping hand so if you can get me started that
would help a lot.
Use the Question class to define a Quiz class. A
quiz can be composed of up to 25 questions. Define the add method
of the Quiz class to add a question to a quiz. Define the giveQuiz
method of the Quiz class to present each question in turn to the user,
accept an answer for each one, and keep track of the results. Define
a class called QuizTime with a main method that populates a quiz,
presents it, and prints the final results.
// Question.java Author: Lewis/Loftus/Cocking
// Represents a question (and its answer).
public class Question implements Complexity
private String question, answer;
private int complexityLevel;
// Sets up the question with a default complexity.
public Question (String query, String result)
question = query;
answer = result;
complexityLevel = 1;
// Sets the complexity level for this question.
public void setComplexity (int level)
complexityLevel = level;
// Returns the complexity level for this question.
public int getComplexity()
return complexityLevel;
// Returns the question.
public String getQuestion()
return question;
// Returns the answer to this question.
public String getAnswer()
return answer;
// Returns true if the candidate answer matches the answer.
public boolean answerCorrect (String candidateAnswer)
return answer.equals(candidateAnswer);
// Returns this question (and its answer) as a string.
public String toString()
return question + "\n" + answer;
}Do you know why this lazy fart-ass is back? Because when he posted his homework last week, some sorry-assed idiot went and did it for him.
http://forum.java.sun.com/thread.jspa?threadID=5244564&messageID=10008358#10008358
He didn't even thank the poster.
It's the same problem over and over again. You feed the bears and it only teaches them to come back for handouts.
My polite suggestion to the original poster: please do your own fucking homework. -
Pls help in creating cluster view
Pls help in creating cluster view
regards
jindowHi,
Please try this and use BSEG as an example.
1. Go to SE12.
2. Enter BSEG
3. Click Display button
4. Go to Delivery and Maintenance' tab.
5. You should be able to see Pool/cluster RFBLG.
6. Double click RFBLG and then click Where-Used list button (CTRLSHIFTF3).
7. Select Table option and click Execute button.
8. System will show all the table that belong to this pool/cluster.
For Pool/Cluster REGUC, it is only used in table REGUP.
Look at the below link
Re: Define view for cluster table?
Regards,
Priyanka.
Maybe you are looking for
-
Is there a way to apply noise reduction based on ISO value?
I shoot a lot of sports using auto ISO which means I get hundreds of images from a day with a variety of different ISO values, including all sorts of intermediate values (like ISO 280, for example). There are times when I'd like to apply LR noise re
-
I'm running Firefox 3.6.13 and Outlook 2010 in Win 7 Home Premium on a Samsung netbook. When a web-site says 'contact us' and opens an e-mail form in Outlook it selects my Orange address and POP3 connection - which doesn't work! I'd like it to select
-
Bapi for Open Projects Cost in PS
HI, I need a bapi or funcation module for Open Projects Cost in PS . thanks.
-
CS6 - need to install on a Mac laptop and Windows desktop
I am entitled to two installations for my CS6; however when I try to use my serial number on my Windows desktop, it says it's invalid.
-
HT1695 Updating APS on the original iPad
When I try to update my APS I get the message, "cannot connect to the iTunes store" even though I am connected to the Internet via Wi-Fi. What are the possible problems?