How to return in pl/sql the tuples of an sql query comming several tables
I have a select query whose result comes from several tables. The question is how to return the tuples of the select query using a pl/sql function. In othe words, is it possible to define a construct structure to store the values of sql query and return that construct. if yes how to define such a construct where its elements comming from several tables.
I appreciate very much ur help
The way to return a resultset from a function is with a cursor variable. The lazy of doing this is using a weakly-typed ref cursor (in 9i use the predefined SYS_REFCURSOR).
Cheers, APC
Similar Messages
-
Ability to send the results of a report query to a table in the database
Hi Guys
Is it possible to send the results of a report query to a table in the database ?
ThanksYes.
For this purpose, you can use :
* the delivers advanced option
http://gerardnico.com/wiki/dat/obiee/bi_scheduler/advanced_publication_delivers
* the SOA API
http://gerardnico.com/wiki/dat/obiee/obiee_soap_eclipse
This two solutions need some development skills. -
How to return java objects on the button click
hello all,
i wonder if any body let me know ,how to return java objects on button click,
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class base
base()
JFrame frame = new JFrame("Base class Message Dialog Box");
JPanel panel = new JPanel();
JButton buttonchildone = new JButton("Child class one");
buttonchildone.addActionListener(new ActionListener(){
public actionPerformed(ActionEvent e)
childone ch1=new childone();
return ch1;
JButton buttonchildtwo = new JButton("Child class two");
buttonchildtwo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
childtwo ch2=new childtwo();
return ch2;
panel.add(buttonchildone);
panel.add(buttonchildtwo);
frame.add(panel);
frame.setSize(300, 300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
void show()
System.out.println("Base class show() method");
public class mainmethod
public static void main(String[] args)
base baseobj=new base();
here my aim is to achieve dynamic polymorphism by button click's ,where based on the button click i can send back an object of childone or childtwo classes
thanks and regard
Mac
Message was edited by:
LoveOpensourceYou probably need to rethink your design. Where are these child classes going? What is using or consuming them? I agree with the message above about a button instantiating a parent field variable to one child or the other depending on which button is pressed.
Message was edited by:
petes1234 -
Need help with query joining several tables into a single return line
what i have:
tableA:
puid, task
id0, task0
id1, task1
id2, task2
tableB:
puid, seq, state
id0, 0, foo
id0, 1, bar
id0, 2, me
id1, 0, foo
id2, 0, foo
id2, 1, bar
tableC:
puid, seq, date
id0, 0, 12/21
id0, 1, 12/22
id0, 2, 12/22
id1, 0, 12/23
id2, 0, 12/22
id2, 1, 12/23
what i'd like to return:
id0, task0, 12/21, 12/22, 12/22
id1, task1, 12/23, N/A, N/A
id2, task2, 12/22, 12/23, N/A
N/A doesn't mean return the string "N/A"... it just means there was no value, so we don't need anything in this column (null?)
i can get output like below through several joins, however i was hoping to condense each "id" into a single line...
id0, task0, 12/21
id0, task0, 12/22
id0, task0, 12/23
id1, task1, 12/23
is this possible fairly easily?
Edited by: user9979830 on Mar 29, 2011 10:53 AM
Edited by: user9979830 on Mar 29, 2011 10:58 AMHi,
Welcome to the forum!
user9979830 wrote:
what i have:...Thanks for posting that so clearly!
Whenever you have a question, it's even better if you post CREATE TABLE and INSERT statements for your sample data, like this:
CREATE TABLE tablea
( puid VARCHAR2 (5)
, task VARCHAR2 (5)
INSERT INTO tablea (puid, task) VALUES ('id0', 'task0');
INSERT INTO tablea (puid, task) VALUES ('id1', 'task1');
INSERT INTO tablea (puid, task) VALUES ('id2', 'task2');
CREATE TABLE tablec
( puid VARCHAR2 (5)
, seq NUMBER (3)
, dt DATE -- DATE is not a good column name
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 0, DATE '2010-12-21');
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 1, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id0', 2, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id1', 0, DATE '2010-12-23');
INSERT INTO tablec (puid, seq, dt) VALUES ('id2', 0, DATE '2010-12-22');
INSERT INTO tablec (puid, seq, dt) VALUES ('id2', 1, DATE '2010-12-23');This way, people can re-create the problem and test their ideas.
It doesn't look like tableb plays any role in this problem, so I didn't post it.
Explain how you get the results from that data. For example, why do you want this row in the results:
PUID TASK DT1 DT2 DT3
id0 task0 12/21/2010 12/22/2010 12/22/2010rather than, say
PUID TASK DT1 DT2 DT3
id0 task0 12/22/2010 12/21/2010 12/22/2010? Does 12/21 have to go in the first column because it is the earliest date, or is it because 12/21 is related to the lowest seq value? Or do you even care about the order, just as long as all 3 dates are shown?
Always say what version of Oracle you're uisng. The query below will work in Oracle 9 (and up), but starting in Oracle 11, the SELECT ... PIVOT feature could help you.
i can get output like below through several joins, however i was hoping to condense each "id" into a single line... Condensing the output, so that there's only one line for each puid, sounds like a job for "GROUP BY puid":
WITH got_r_num AS
SELECT puid
, dt
, ROW_NUMBER () OVER ( PARTITION BY puid
ORDER BY seq -- and/or dt
) AS r_num
FROM tablec
-- WHERE ... -- If you need any filtering, put it here
SELECT a.puid
, a.task
, MIN (CASE WHEN r.r_num = 1 THEN r.dt END) AS dt1
, MIN (CASE WHEN r.r_num = 2 THEN r.dt END) AS dt2
, MIN (CASE WHEN r.r_num = 3 THEN r.dt END) AS dt3
, MIN (CASE WHEN r.r_num = 4 THEN r.dt END) AS dt4
FROM tablea a
JOIN got_r_num r ON a.puid = r.puid
GROUP BY a.puid
, a.task
ORDER BY a.puid
;I'm guessing that you want the dates arranged by seq; that is, for each puid, the date related to the lowest seq comes first, regardless of whther that date is the earliest date for that puid or not. If that's not what you need, then change the analytic ORDER BY clause.
This does not assume that the seq values are always consecutive integers (0, 1, 2, ...) for each puid. You can skip, or even duplicate values. However, if the values are always consecutive integers, starting from 0, then you could simplify this. You won't need a sub-query at all; just use seq instead of r_num in the main query.
Here's the output I got from the query above:
PUID TASK DT1 DT2 DT3 DT4
id0 task0 12/21/2010 12/22/2010 12/22/2010
id1 task1 12/23/2010
id2 task2 12/22/2010 12/23/2010As posted, the query will display the first 4 dts for each puid.
If there are fewer than 4 dts for a puid, the query will still work. It will leave some columns NULL at the end.
If there are more than 4 dts for a puid, the query will still work. It will display the first 4, and ignore the others.
There's nothing special about the number 4; you could make it 3, or 5, or 35, but whatever number you choose, you have to hard-code that many columns into the query, and always get that many columns of output.
For various ways to deal with a variable number of pivoted coolumns, see the following thread:
PL/SQL
This question actually doesn't have anything to do with SQL*Plus; it's strictly a SQL question, and SQL questions are best posted on the "SQL and PL/SQL" forum:
PL/SQL
If you're not sure whether a question is more of a SQL question or a SQL*Plus question, then post it on the SQL forum. Many more people pay attention to that forum than to this one. -
JAVA&SOAP:how to return a complex object( the object has an object within)
Lets say my Complex object is :
public class PersonWithAddress {
private String name;
private int ssn ;
private Address add;
PersonWithAddress() {
name="Gagan Tandon" ;
ssn =1111;
add = new Address("1113","WestPlum Street");
public String getName() {
return name;
public int getSSN() {
return ssn;
public Address getAddress() {
return add;
This complex object has Address object embedded in it.
public class Address {
private String house;
private String street;
public Address (String myHouse,String myStreet) {
house = myHouse;
street = myStreet;
public String getHouse() {
return house;
public String getStreet() {
return street;
My deployment Descriptor is as following: check the mappings part.
<isd:service xmlns:isd=
"http://xml.apache.org/xml-soap/deployment"
id="urn:xml-soap-person-demo">
<isd:provider type="java"
scope="Application"
methods="getPersonWithAddress">
<isd:java class="PersonServer"/>
</isd:provider>
<isd:faultListener>
org.apache.soap.server.DOMFaultListener
</isd:faultListener>
<isd:mappings>
<isd:map
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:x="urn:xml-soap-person-demo" qname="x:PersonWithAddress"
javaType="PersonWithAddress"
java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
<isd:map
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:x="urn:xml-soap-person-demo" qname="x:Address"
javaType="Address"
java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
</isd:mappings>
</isd:service>
And in my SOAPRPC code at client end calls the following: check the mappingregistry code...
String serverHost = "http://localhost:8082/soap/servlet/rpcrouter";
SOAPMappingRegistry smr = new SOAPMappingRegistry();
Parameter p= null;
try {
System.out.println("here 0");
Response r=null;
Call c=new Call();
Vector parameters = new Vector();
System.out.println("here 1");
c.setTargetObjectURI ("urn:xml-soap-person-demo");
c.setMethodName ("getPersonWithAddress");
System.out.println("here 3");
c.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
// parameters.addElement (new Parameter("name", String.class, "Web Services Client", null));
// c.setParams (parameters);
c.setSOAPMappingRegistry(smr);
BeanSerializer beanSer = new BeanSerializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("urn:xml-soap-person-demo","Address"),Address.class,beanSer,beanSer);
smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("urn:xml-soap-person-demo","PersonWithAddress"),PersonWithAddress.class,beanSer,beanSer);
try
System.out.println("here 4");
r = c.invoke ( new URL(serverHost), "" );
// org.apache.soap.SOAPException can be thrown
catch ( Exception e )
e.printStackTrace();
// Check the response.
if (r.generatedFault ()) {
Fault f = r.getFault();
System.out.println ("Error Occurred: ");
System.out.println (" Fault Code = " + f.getFaultCode());
System.out.println (" Fault String = " + f.getFaultString());
// return f.getFaultString();
// return new String("gagan");
return null;
else {
System.out.println("here 5");
p = r.getReturnValue();
System.out.println("here 6");
// System.out.println( (String)greeting.getValue() );
System.out.println("SSN: " + ((PersonWithAddress)p.getValue()).getSSN());
return (PersonWithAddress) p.getValue();
catch( Exception e ){
e.printStackTrace();
// finally {
// return null;// String("not OK");
if (p==null)
return null;
else
return (PersonWithAddress) p.getValue();
When running this code..
The following error is thrown.
System.out.println("here 4") is printed.
[SOAPException: faultCode=SOAP-ENV:Client; msg=Unable to instantiate 'PersonWithAddress': Class org.apache.soap.encoding.soapenc.BeanSerializer can not access a member of class PersonWithAddress with modifiers ""; targetException=java.lang.IllegalArgumentException: Unable to instantiate 'PersonWithAddress': Class org.apache.soap.encoding.soapenc.BeanSerializer can not access a member of class PersonWithAddress with modifiers ""]
at org.apache.soap.rpc.Call.invoke(Call.java:294)
at PersonClient.getPersonWithAddress(PersonClient.java:92)
at PersonClient.<init>(PersonClient.java:11)
at PersonClient.main(PersonClient.java:20)
java.lang.NullPointerException
at PersonClient.getPersonWithAddress(PersonClient.java:96)
at PersonClient.<init>(PersonClient.java:11)
at PersonClient.main(PersonClient.java:20)
I am here 1
Exception in thread "main" java.lang.NullPointerException
at PersonClient.<init>(PersonClient.java:13)
at PersonClient.main(PersonClient.java:20)
What could be the problem..? Is there any info on net how could i pass complex objects of this type in Java through SOAP RPC.
GAGANHave you managed to sole the problem ? I have got similar one...
[SOAPException: faultCode=SOAP-ENV:Client; msg=Unable to instantiate 'auction.common.Property': auction/common/Property]
at proxy.soap.AuctionHistoryProxy.addAuctionProperty(AuctionHistoryProxy.java:515)
at java.lang.reflect.Method.invoke(Native Method)
(...) -
How to return a different format of datetime type in sql?
hi ,
i think this is a dumb question for all of you guys but since i am new here, hope you can help me. here is my problem i have a column in my table that has a namae Date and a type of datetime, what i want is to display the date in grid(UI) using a different
format, cause right now this is the value returning.
02.11.2011 10:23:02
what i want is to return the value without the time.
please advise thanks!What grid you're talking about? What kind of application is that? I'm quite sure you should be able to format date fields the way you want - your question then has nothing to do with SQL Server.
Of course, you can return dates as character (as Tom suggested) in the predefined format, but I'd rather investigate formatting options of the grid control.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog -
How to return to UWL from the launced web dynpro
Hi guys,
Our UWL can launch a web dynpro program, what we want is a close button in our web dynrpo view which close the web dynpro application and return to the UWL. Now we can close the web dynrpo application but the screen can't return to the UWL, how to do this, thank you!
Regards,
Xiaoming YangHi,
Try to follow the below threads.Hope these might be useful.
Going Back to UWL from WebDynpro Application
Navigate back to UWL from WD Java
Rgds,
Santhosh -
How to return Firefox download to the default
I now have my downloads saved to a file on my computer. Because of that, when I download something, it doesn't show up in Firefox's download window. I have to go to my computer file to install it. I would like to return to Firefox's default window. How do I do that? Thanks.
You can view/change the downloads place in '''Tools''' ('''Alt''' + '''T''') > '''Options''' > '''General''' > '''Downloads'''. You can also mark it to be always visible when downloading. Alternatively you can open the downloads window via '''Tools'' ('''Alt''' + '''T'') > '''Downloads''' (or '''Ctrl''' + '''J''').
[https://support.mozilla.org/en-US/kb/Options%20window%20-%20General%20panel?as=u Options > General] -
How to return order status and the status of the next order
Greetings,
I cannot use the LEAD function.
How do i simulate this in Oracle 8i PE.
I have a table of orders and for each grouping of orders i need the current status and the next status.
Any suggestions?
Thanks,
Craig.Something like:
SELECT i.order_id, i.item, i.status
MAX(i2.status) next_status
FROM incidents i, incidents i2
WHERE i.order_id = i2.order_id(+)
AND i.order_id < i2.order+id (+)
GROUP BY i.order_id, i.item, i.status
ORDER BY i.order_id
Greetings,
I cannot use the LEAD function.
How do i simulate this in Oracle 8i PE.
I have a table of orders and for each grouping of orders i need the current status and the next status.
Any suggestions?
Thanks,
Craig. -
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
namespace
Region_V_project_workshop
publicpartialclassWebForm5:
System.Web.UI.Page
protectedvoidPage_Load(objectsender,
EventArgse)
protectedvoidButton1_Click(objectsender,
EventArgse)
if you need my webpage code please let me knowBelow is an example of executing a parameterized INSERT statement using SqlClient.
protected void Button1_Click(objectsender, EventArgse)
var connection = new SqlConnection(connectionString);
var command = new SqlCommand("INSERT INTO dbo.YourTable (FirstName, LastName) VALUES (@FirstName, @LastName);", connection);
command.Parameters.Add("@FirstName", SqlDbType.VarChar, 50).Value = textBoxFirtName.Text;
command.Parameters.Add("@LastName", SqlDbType.VarChar, 50).Value = textBoxLastName.Text;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
How to return marked values from the FM F4IF_INT_TABLE_VALUE_REQUEST
Hello all.
I'm using the FM F4IF_INT_TABLE_VALUE_REQUEST with multiple choise activated.
My problem is: if I mark, for example - 2 choises from 5, and then press OK.
If i go in to the same F4 button, I what to see the same marks like before..
At the moment, if i go in again to the same F4, nothing is marked, as if i'm going in for the first time.
Can someone help me?Hi Barak,
I don't think you can achieve this functionality using this FM. Even I think this is not there in standard SAP help, please check.
Regards,
Atish -
Sorry, but the new interface sucks and very uncomfortable to work with.
+100500
Please Please Please STOP THIS MADNESS!!!
I'm sick of this fuss with new versions that totally break all my interface!
I realize that you guys want to play and be creative, but STOP DOING THAT AT MY EXPENSE!!!
Let users use their old interface, instead of WITHOUT ANY PERMISSION BREAK IT AGAIN AND AGAIN.
You are totally wrong if you think that a pile of large shit is better than well-structured hierarchical interface. It's better in some respect, may be, but mostly for disorganized people.
What organized people should do? Jump on the trees like you guys?
First - Windows, with that dumb Vista for dumb blondes, now you.
Stop. Before it's too late...
OPERA DIDN'T LISTEN TO MY WORDS. WHERE ARE THEY NOW?
I don't want to live in the world where only stupid spying Chrome exists.
(BTW, it's very bad for you that you without warning send information of user browsing by default, but that's another question. I understand that we love money from Google, FBI, CIA, NSA or whatever from. But, because you spy on me at MY expense, why don't you send me my share?)
Until you stop making FF dumber, I'm going to boycotte new versions. -
Master Detail Form - How 2 update a field in the Detail form using a query?
Hello,
I have a master detail form with, each master record having a fixed(6) number of detail records. One of the fields in the detail record is the PART_DESCRIPTION field. I am trying to update this field by querying Table_X. TABLE_X is in the format of (desciption id, description). Description id runs from 1 to 6.
When the form displays, the PART_DESCRIPTION field for the 6 detail records needs to be automatically populated with the six values of description stored in Table_X. How can this be done?
Tried using session storage objects, but made no headway.
Would greatly appreciate pointers on how to go about doing this.
Thanks.
DevIf you are on a Portal Version lesser than 3.0.9.8.3, then please try the following to populate
the PART_DESCRIPTION field.
Steps:-
1> Edit the form and go to the Additional PL/SQl section and put the following code in the
"...after displaying the page area" :-
declare
type t_vc_arr is table of varchar2(4000) index by binary_integer;
l_arr_desc t_vc_arr;
l_form_name varchar2(200);
l_form_state varchar2(500);
begin
l_form_name := p_session.get_module().get_name();
l_form_state := p_session.get_value_as_varchar2(
p_block_name => 'MASTER_BLOCK',
p_attribute_name => '_FORM_STATE'
if l_form_state = 'QUERY_AND_SAVE' then
select description
bulk collect into l_arr_desc
from <schema>.table_x;
htp.p('
<script>
var descArr = new Array();
var Fidx = 1;
var formObj = document.WWVM'||p_session.get_id()||';
var fieldName = "'||l_form_name||'.DETAIL_BLOCK.PART_DESCRIPTION.0";
for i in 1..l_arr_desc.count loop
htp.p('descArr['||to_char(i-1)||']="'||l_arr_desc(i)||'";');
end loop;
htp.p('
for (var i=0; i < formObj.length; i++){
if (formObj.elements.name == fieldName+Fidx){
formObj.elements[i].value = descArr[Fidx-1];
++Fidx;
htp.p('</script>');
end if;
end; -
How do I get DVD for the Windows 7 that should have come with my new laptop please
This is my first message here so please bear with me. I have just bought a new Lenovo Essentials B570 laptop which has come with Windows 7 pre-installed. Previously I used to buy Dell laptops which used to come with OS Re-installation DVDs which check to see if they are being installed on the hardware it was bought for but would allow us to install the OS on a new hard disk if the original one crashed. Now Lenovo seems to be using a very complicated method to allow buyer's to re-install the OS - they are expected to retain the same hard disk - but what happens is the hard disk crashes and one wants to install the OS along with all the drivers? The Dell DVD allows me to do precisely that. Can I create a similar disk to install the OS on a new hard disk as and when I want/need it please? I have created two sets of DVDs using the OKR software - one set using the 'system presently on disk' and another set for 'resetting to factory defaults' - but from what I have read on these forums these OKR disks would not work if I put a completely new hard disk. So at least if I can get hold of the correct version of the Windows DVD - as I have paid for the license I would be very grateful. Thank you.
Solved!
Go to Solution.yigit wrote:
http://forum.lenovo.com/t5/Lenovo-3000-and-Essential/How-to-create-quot-Factory-Default-Recovery-Dis...
Thanks for the quick reply.
But to me this looks more like a OKR solution and I have already created these Factory Reset discs.
Will these discs work if I have installed a completely new hard disk in the dive? Because that is what I would need to do in the rare event that I have a complete hard disk failure.
What is confusing is the fact that on these forums, I find many messages which indicate that the OKR solution would work only with the original hard disk and it would not work with a completely new hard disk and also that the OKR itself would not be able to change partitions on the hard disk - even when it is the original hard disk. To me this means any disks that are created using the OKR would be useless when the original hard disk has undergone severe change or a completely new hard disk is in its place. Correct me if I am wrong. (In fact I am hoping that I am wrong in that assumption.)
My laptop has a 750GB hard disk and it has Windows 7, 64bit. I actually want to make this into a dual boot machine with KUbuntu. What is stopping me attempting that is the fact that C drive has bigger partition and D drive is a smaller partition (too small in fact - 30GB these days is practically nothing) and I learn that any modifications I do to drive partitions would render the OKR non functional.
I can live without this simplistic one key rescue operation if I have recourse to the Windows 7 DVD and that is why I asked the question. -
How to enter a data into the specified column and row in a created table
Hi,
I want to enter some data to specified column and row in a already created table. Please let me know how to do this.
Regards
Shivakumar SinghA table is just a 2D array of strings. Keep it in a shift register and use "replace array element" to modify the desired entry programmatically.
If you want to modify it manually and directly from the front panel, make it into a control and type directly into the desired element. (In this case your program would need to write to it using a local variable).
Atttached is a simple example in LabVIEW 7.0 that shows both possibilities.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
ChangeTableEntries.vi 41 KB
Maybe you are looking for
-
Manual Duplexing use on a HP Laserjet P1102w printer-Ho​w is it done?
This is a first using a manual duplex option on a printer and I have been unable to print on both sides of an HP Laserjet P1102w printer, despite doing the following: Went to Print Setup Under Finish: chose Print on Both Sides Manually Left edge bind
-
Problem building schema in JDeveloper with user defined complex type.
Hi, I am facing proble in JDeveloper while assigning input. 1. Used Oracle BPEL Database Adaper to access the procedure in Oracle DB which accepts input in the form of record typ in database. 2. XSD file is automatically created. 3. BPEL process WSDL
-
Can anyone help me with this?
-
I'm working on with a customer on a 2106 controller with 1130 series ap's. Everyting seems fine until the client does a reauthentication. At this point the clients send a stream of authentication attempts to the RADIUS server (40 or so a second). The
-
Is it possible to setup a WLS cluster having two WLS boxes seperated by switches/routers ? - Bhupi