Pl/sql block to retrieve information from three tables.
Hi Everyone,
I have three tables. Student table, bookDetails table and bookIssue records table.
This is my question
Write a plsql block that has to display bookid, booktitle, student_name, earliest issue date and recent issue date taking the input of Student id.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Thank you,
Bala
Why the duplicate post?
Similar Messages
-
Getting information from three tables
I have three tables, FIRST, SECOND and THIRD. There are other columns
than the ones I show here, so the tables are not union compatible
FIRST
(VALUE_TWO , VALUE_ONE)
SECOND
(VALUE_TWO, VALUE_THREE)
THIRD
(VALUE_THREE, VALUE_FOUR)
How can I display: all VALUE_THREE's from THIRD
where VALUE_FOUR = 'x'
as well as
all VALUE_TWO's from SECOND where VALUE_THREE
is equal to the list of VALUE_THREE's I got in the first step
as well as
all VALUE_ONE's from FIRST where VALUE_TWO
is equal to the list of VALUE_TWO's I got in the second step
If I run the following
SELECT VALUE_ONE
FROM FIRST
WHERE VALUE_TWO IN
(SELECT VALUE_TWO
FROM SECOND
WHERE VALUE_THREE IN
(SELECT VALUE_THREE
FROM THIRD
WHERE VALUE_FOUR = 'x'))
This just displays VALUE_ONE.is this what you are looking for
select value_three
from third
where value_four='X'
union all
select value_two
from second
where value_three in (select value_three from third where value_four='X')
union all
select value_one
from first
where value_two in (select value_two from second where value_three in (select value_three from third where value_four='X'))
if so and you happen to be on 10 g you can do it this way too
SELECT A
FROM (
select value_one A,value_two B from first
union all
select value_two,value_three from second
union all
select value_three,value_four from third)
CONNECT BY PRIOR A=B
START WITH B='X' -
how can i retrieve information from time machine if my computer has less storage capacity? How can I access data that is on my time machine but can not be copied to a computer with less storage capacity? I used to have 180 GB, now I have 128 GB.
Plug an external drive into the computer and use that to expand data onto.
http://pondini.org/TM/16.html -
Hi,
I am working on a report where I have to retrieve data from 3 tables(marc,mara,makt).For this I have used 3 select statements for retriving data from 3 tables.There r some fields which r not present in marc table where as present in mara and makt tables.So added thos fields in marc internal table t_marc.I have looped at marc table and used the read statement to read the data from mara table using the key field matnr from both the tables.This read statement is giving the sy-subrc value as 4.Could u pls tell me why this is happening?I am sending my code.
SELECT matnr
werks
pstat
lvorm
FROM marc
INTO TABLE t_marc
PACKAGE SIZE 500
WHERE matnr IN s_matnr
AND werks IN s_werks.
IF NOT t_marc[] IS INITIAL.
SELECT matnr
ersda
laeda
meins
FROM mara
INTO TABLE t_mara
FOR ALL ENTRIES IN t_marc
WHERE matnr = t_marc-matnr
AND ersda IN s_ersda
AND laeda IN s_laeda.
IF NOT t_mara[] IS INITIAL.
SELECT matnr
maktx
FROM makt
INTO TABLE t_makt
FOR ALL ENTRIES IN t_mara
WHERE matnr = t_mara-matnr.
LOOP AT t_marc INTO wa_marc.
READ TABLE t_mara INTO wa_mara WITH KEY matnr = t_marc-matnr.
IF sy-subrc IS INITIAL.
wa_marc-meins = wa_mara-meins.
MODIFY t_marc.
APPEND wa_marc TO t_output.
ENDIF.
READ TABLE t_makt INTO wa_makt WITH KEY matnr = t_marc-matnr.
IF sy-subrc IS INITIAL.
wa_marc-maktx = wa_makt-maktx.
MODIFY t_marc.
APPEND wa_marc TO t_output.
ENDIF.
ENDLOOP.hi hema,
Dont use three select stements for this scenario.
Just use innerjoin and join all the three tables.
Three tables should contain MATNR (material number).
By using that retrieve data from 3 tables by using a single select statement.
Eg:
SELECT DISTINCT a~matnr "MATERIAL NUMBER
a~ersda "CREATED ON
a~mtart "MATERIAL TYPE
a~meins "BASE UNIT OF MEASURE
a~bstme "ORDER UNIT
b~maktx "MATERIAL DESCRIPTION
c~bwkey "VALUATION AREA
c~lbkum "TOTAL VALUED STOCK
c~salk3 "VALUE OF TOTAL VALUED STOCK
c~stprs "STANDARD PRICE
c~peinh "PRICE UNIT
c~bklas "VALUATION CLASS
INTO TABLE it_matdetails
FROM mara AS a INNER JOIN makt AS b ON a~matnr = b~matnr
INNER JOIN mbew AS c ON a~matnr = c~matnr
INNER JOIN marc AS d ON a~matnr = d~matnr
INNER JOIN mard AS e ON a~matnr = e~matnr
WHERE b~spras = sy-langu AND a~matnr IN matnr AND d~werks IN werks AND e~lgort IN lgort.
pls reward if helpful. -
Retrieve data from nested tables
Hi All,
I have big trouble to retrieve data from nested tables..
From java code developer are passing struct data type to Oracle procedure.. So equal data type in oracle has been created as created as object
CREATE OR REPLACE TYPE TXNDATA AS OBJECT
TRAN_ID NUMBER ,
EVENT_ID NUMBER ,
EVENT_CD VARCHAR2(10 BYTE))and create a procedure which has a IN parameter as TXNDATA
now i need to retrieve the column data's through SELECT clause such as
TYPE Proc_txn IS TABLE OF TXNJOURNALDATA;
EVENT_JOURNAL_SEQ Proc_txn;
select * from table(cast(EVENT_JOURNAL_SEQ));but above SQL will give all column data's but i need to retrieve only 2 column values such as
select EVENT_ID , EVENT_CD from table(cast(EVENT_JOURNAL_SEQ))how can i achieve the above result set?
Thanks & Regards
Sami.use a table alias in your query
SQL> set serveroutput on
SQL> create TYPE TXNDATA AS OBJECT
2 (
3 TRAN_ID NUMBER ,
4 EVENT_ID NUMBER ,
5 EVENT_CD VARCHAR2(10 BYTE));
6 /
Type created.
SQL>
SQL> create type txnjournaldata
2 as table of txndata;
3 /
Type created.
SQL>
SQL> declare
2 txn txnjournaldata := txnjournaldata (
3 txndata(10, 20, 'One')
4 ,txndata(10, 20, 'Two')
5 );
6 begin
7 for rec in (select tx.event_id
8 , tx.event_cd
9 from table (txn) tx
10 )
11 loop
12 dbms_output.put_line (rec.event_id||' - '||rec.event_cd);
13 end loop;
14 end;
15 /
20 - One
20 - Two
PL/SQL procedure successfully completed.Edited by: Alex Nuijten on Oct 24, 2011 12:24 PM -
Retrieve data from oracle table, table name passed in runtime into JSP
Hello All,
I am new to JSP, i have a requirement,
I need to retrieve data from oracle table, here table is passed at random. how to get the data displayed in JSP page.
can any one help me in that
thanks1) Learn SQL.
2) Learn Java.
3) Learn JDBC.
4) Learn DAO.
5) Learn HTTP.
6) Learn HTML.
7) Learn JSP/Servlet.
8) Learn JSTL.
9) Apply learned things and develop.
Whenever you stucks, please come back and post the specific coding/technical problem here. -
How to retrieve data from edcauditentity table?
Hello!
I am interested how to connect to edcauditentity table and retrieve data from this table.
I have sql query but i don't have idea how to start. For now i can connect to LiveCycle and retrieve policy name.
Thank in advance!Hello Mohan,
if u already have data and u want to populate it in F4 help then use below code -
u Have to make use of FM - 'F4IF_INT_TABLE_VALUE_REQUEST'
REPORT ZGILL_VALUE_REQUEST .
data: begin of lt_all occurs 0.
include structure DYNPREAD.
data end of lt_all.
data: begin of lt_selected occurs 0.
include structure DDSHRETVAL.
data: end of lt_selected.
DATA: BEGIN OF lt_code OCCURS 0,
code LIKE zgill_main-PERNR,
END OF lt_code.
data no_dyn like sy-dynnr.
Parameters : ECODE like zgill_main-PERNR.
*parameters: pernr like pa0001-pernr .
no_dyn = sy-dynnr. "give the scren no directly or sy-dynnr in case of report.
At selection-screen on value-request for ECODE.
select PERNR into table lt_code from zgill_main.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ECODE'
dynpprog = sy-repid
dynpnr = no_dyn
dynprofield = 'ECODE'
window_title = 'Employee Details'
value_org = 'S'
DISPLAY = 'F'
TABLES
value_tab = lt_code
RETURN_TAB = lt_selected.
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
*if sy-subrc eq '0' .
write: 'success'.
*endif.
read table lt_selected index sy-tabix.
move lt_selected-fieldval to ECODE. -
How can i get all the records from three tables(not common records)
Hi
I have four base tables at R/3-Side. And i need to extract them from R/3-Side.
And i dont have any standard extractor for these tables .
If i create a 'View' on top of these tables. Then it will give only commom records among the three tables.
But i want all the records from three base tables (not only common).
So how can i get the all records from three tables. please let me know
kumarYou can create separate 3 datasources for three tables and extract data to BW. There you can implement business login to build relation between this data.
-
Create a procedure which requires displaying information from two tables
What if we want to create a procedure which requires displaying information from two tables. In this situation,
I need to display all the details of an employee from an 'emp' table based on the deptno. and also their salary information which is
stored in "Salgrade" Table. Is the use of "And" the correct way of using it?
Do I need to declare all the attributes before begin or I can just access them directly? Thanks
Create Procedure findDept
( I_deptno IN number
) As
Begin
Select Ename, Job, MGR, Hiredate, Sal, Comm, Dept_no from emp and exp, grade , location from salgrade where dept_no
= I_Deptno;
Exception
When NO_Data_Found then
DBMS_Output.Put_Line(' Department not found"|| I_deptno);
End findDept;Hi,
Besides Qwerty's remark, you've also got a quoting error:
Change
DBMS_Output.Put_Line(' Department not found"|| I_deptno);
{code}
into
{code}
dbms_output.put_line(' Department not found: '|| i_deptno);
{code}
Which leads to the question:
What do you want to do when a record is found?
Display it? -
How to Retrieve data from Variant Table
Can anyone help me by telling how to retrieve data from variant table which was created by user. I am able to see data of variant table only thru cu60 transaction but not se11. I s there any function module to do this?
Hello Mohan,
if u already have data and u want to populate it in F4 help then use below code -
u Have to make use of FM - 'F4IF_INT_TABLE_VALUE_REQUEST'
REPORT ZGILL_VALUE_REQUEST .
data: begin of lt_all occurs 0.
include structure DYNPREAD.
data end of lt_all.
data: begin of lt_selected occurs 0.
include structure DDSHRETVAL.
data: end of lt_selected.
DATA: BEGIN OF lt_code OCCURS 0,
code LIKE zgill_main-PERNR,
END OF lt_code.
data no_dyn like sy-dynnr.
Parameters : ECODE like zgill_main-PERNR.
*parameters: pernr like pa0001-pernr .
no_dyn = sy-dynnr. "give the scren no directly or sy-dynnr in case of report.
At selection-screen on value-request for ECODE.
select PERNR into table lt_code from zgill_main.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'ECODE'
dynpprog = sy-repid
dynpnr = no_dyn
dynprofield = 'ECODE'
window_title = 'Employee Details'
value_org = 'S'
DISPLAY = 'F'
TABLES
value_tab = lt_code
RETURN_TAB = lt_selected.
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3
*if sy-subrc eq '0' .
write: 'success'.
*endif.
read table lt_selected index sy-tabix.
move lt_selected-fieldval to ECODE. -
How to retrieve data from catsdb table and convert into xml using BAPI
How to retrieve data from catsdb table and convert into xml using BAPI
Points will be rewarded,
Thank you,
Regards,
Jagrut BharatKumar ShuklaHi,
This is not your requirment but u can try this :
CREATE OR REPLACE DIRECTORY text_file AS 'D:\TEXT_FILE\';
GRANT READ ON DIRECTORY text_file TO fah;
GRANT WRITE ON DIRECTORY text_file TO fah;
DROP TABLE load_a;
CREATE TABLE load_a
(a1 varchar2(20),
a2 varchar2(200))
ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY text_file
ACCESS PARAMETERS
(FIELDS TERMINATED BY ','
LOCATION ('data.txt')
select * from load_a;
CREATE TABLE A AS select * from load_a;
SELECT * FROM A
Regards
Faheem Latif -
Retrieve data from cluster tables
hi
can any one explain me how to retrieve data from cluster tables
Regards
sachinyou can write a select
select * from KONV
into table it_konv
where <condition>
you cant join.. cluster tables.. -
Hi, experts. I want retrieve data from 8 tables
Hi, experts. I want retrieve data from 8 tables.
On which table i have to write for all entries query.
Thanks in advance.Hai Reddy,
Actually IF we Use Join's Actually The Performance Will Be Good For 4 tables.
So It Is Better To Create Two Joins With 4 Tables Each.
First Retrive The Data For First View.
Then Use For ALL Entries For First Table And Then Get Data For Second data.
Reward If Found usefull.
Regards.
Eshwar. -
How do i retrieve information from the JSP into my SELECT statements?
I need to retrieve the information that is being entered into JSP page.. So that i can use them to do an SQL statement.. but im not very sure if my codes are correct.. Following are my codes.. Pls help.. thx
MyJSPPage.jsp
<jsp:useBean id="user" class="user.User" scope="session"/>
<form name="loanItem" method ="POST" action="user">
<input type="hidden" name="userID" value="<jsp:getProperty name="user" property="userID"/>">
<tr><td align=left height="34"> <b> <font size="4">Member ID:</font>
</b> </td>
<td height="34">
<jsp:getProperty name="user" property="userID"/></td>
</tr>
==================================================================================
MyManager.java --> this file is where all my SQL statements are ..
[l]String itemType = session.getParameter("itemType");[l] (--->> is how i retrieve info from the JSP page?)
if (itemType.equals("Book"))
String sqlQuery1 = "select loanDuration from ItemPolicy where itemType ='" + itemType+ "'";
System.out.println(sqlQuery1);
ItemPolicy itempolicy = null;
try {
db = new Database();
rs = db.readRequest(sqlQuery1);
if (rs != null && rs.next()) {
itempolicy = new ItemPolicy();
itempolicy.setLoanDuration(Integer.parseInt(rs.getString("loanDuration")));
db.close();
} catch (SQLException se) {
se.printStackTrace();
throw (new UserException("Unable to retrieve from Database!"));
} catch (Exception e) {
e.printStackTrace();
throw (new UserException("Unknow error encountered!"));
String dueDate = util.getDueDate(itempolicy.getLoanDuration());
else if (itemType.equals("Magazine"))
==================================================================================
Thanks in advance...you should change to request.getParameter("itemType").
or just System.out.print the itemType to see it got the value.
Hope it helps. -
How to retrieve information from iCloud (earlier than the 3 most recent backups) ?
I had to restore my iPod 4th generation to factory settings and I'm trying to get all the information back from iCloud backup. The thing is that I had waited about a week or two(instead of right away) to try to put the information back into the iPod. And when I restored it again(for the second time) it only had the choice of retrieving informaiton from the 3 most recent iCloud backups but those were too recent for the information I wanted to get back. Is there any way, ANY WAY AT ALL that I can get access to earlier iCloud backups? Like maybe all the iCloud backups that have happened so far?
I've done some research and it doesn't say there is a way but there doesn't seem to be a lot of people with this problem. :( Please if you know a way, let me know.Welcome to the Apple Community.
Unfortunately, you cannot go back further than the three backups that you already have.
Maybe you are looking for
-
How do i take my music, apps, and photos from one ipod and put it on another ipod?
I got a new ipod but still have my old one, how do i take everything from my old one and put it on the new one?? please help me!! thanks
-
EPS to PDF: Smooth Shades, Bug in Acrobat?
Hello! I encountered a really weird feature/bug in Acrobat. I have a very simple EPS file which draws 2 x 5 = 10 adjacing black squares. (EPS file below and attached) When I drag it into Acrobat 8.1.5 and save it as PDF, and then try to open this PDF
-
How to set user flag for a local windows user account.
In my C# client I am getting the directory entry of the user in the following way : DirectoryEntry userDE = new DirectoryEntry("WinNT://machinename/User12", "MachineName\\Administrator", "Password"); I want to add a userflag to this user. I tried the
-
Migration from of database and app from SQL server 2005 to Oracle 10g
Hello Every body, Lately, I have been requested to migrate one inhouse developed hub application from SQL server 2005 to Oracle 10g. The objective is to move application and also the database to Oracel 10g. Here is the current platform: OS Win 2008 6
-
Is it possible to create irregular shaped navigation buttons, such as a cloud, in Muse. I don't want to be limited to a box shape, if possible. If possible, how is it done?