Saving the result set in a Search page
Hi ,
We have a manual search page where the results are displayed in the form of 10 columns. The first 5 are read only fields whereas rest 5 are editable checkboxes.
There is no Query region created in our page.
Suppose, fields a, b, c are search parameters and the results are as :
| A | B | C| D |E | F | G | H | I | J |
1
2
3
4
5
6
7
7 records are retrieved. Columns A to E are read only text fields whereas columns F to J are check boxes. The user can update the checkboxes. We have a Save button below the result set region. This button on being pressed invokes a stored PL/SQL Procedure which does some validations on the result set so obtained.
Our requirement is to dump all the 7 records (after the modifications are made to any number of result records) into a temporary table . The procedure will then pick the records from this temporary table and do the required validations.
Question is :
1. How to store the result set so obtained into a table after some (or all) records are modified once Save is pressed ?
We do not have any EO created in our page. The VO for obtaining the Result set is a combination of many tables.
Any help would be greatly appreciated.
Thanks,
Neha
River_Plate wrote:
root cause
java.lang.NullPointerException
org.apache.jsp.tablasUF_jsp._jspService(tablasUF_jsp.java:68)Do you understand anyway when a NullPointerException would be thrown? Those kind of RuntimeExceptions are basic Java knowledge.
If an object is null while you want to access it, then a NPE would be thrown. Check the line of the cause which objects could be null and fix it accordingly.
Similar Messages
-
Is column visibility based on the first page of the result set or the entire result set?
I have tried, in vain, to play with the column visibility expression in my report. So where my Business Unit is "MC" or "FM", then I want to display column "HCFA Number"...otherwise hide it. If I run strictly for "MC"
it works! If I run simply for "CO" it works! And doesn't show! But if I combine "CO" and "MC", it is hidden and I would expect it to be visible since "MC" is part of my entire report.
Here's the expression I came up with for Column Visibility...
=IIf((Fields!BUSINESS_UNIT.Value = "MC") OR
(Fields!BUSINESS_UNIT.Value = "FM"),FALSE,TRUE)
Am I missing something here or just being dense late on a Friday???
Thanks for your review and am hopeful for a reply.Hi ITBobbyP,
It seems you have add parameter based on the "Business Unit" which is multiple values and when you select the "CO,MC" the entire column "HCFA Number" is hide, but what you want is to hide the CO related "HCFA Number"
and show the MC related "HCFA Number", right?
The expression you are using to show/hide the column visibility will based on the current filtered entire result set. That is mean the entire column "HCFA Number" will be show when the result set contains "MC" or "FM"
or both, otherwise, it will always hide.
In your scenario, you can set the row visibility using the expression and you will get the result like below:
You can set the visibility of the textbox "[HCFANumber]", but the CO related "HCFANumber" will be blank:
If I have some misunderstanding, please try to provide more details information about the expect result you want.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support -
JSP Servlet and convert the result set of an SQL Query To XML file
Hi all
I have a problem to export my SQL query is resulty into an XML file I had fixed my servlet and JSP so that i can display all the records into my database and that the goal .Now I want to get the result set into JSP so that i can create an XML file from that result set from the jsp code.
thisis my servlet which will call the jsp page and the jsp just behind it.
//this is the servlet
import java.io.*;
import java.lang.reflect.Array;
import java.sql.*;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.*;
import javax.sql.*;
public *class *Campaign *extends *HttpServlet
*private* *final* *static* Logger +log+ = Logger.+getLogger+(Campaign.*class*.getName());
*private* *final* *static* String +DATASOURCE_NAME+ = "jdbc/SampleDB";
*private* DataSource _dataSource;
*public* *void* setDataSource(DataSource dataSource)
_dataSource = dataSource;
*public* DataSource getDataSource()
*return* _dataSource;
*public* *void* init()
*throws* ServletException
*if* (_dataSource == *null*) {
*try* {
Context env = (Context) *new* InitialContext().lookup("java:comp/env");
_dataSource = (DataSource) env.lookup(+DATASOURCE_NAME+);
*if* (_dataSource == *null*)
*throw* *new* ServletException("`" + +DATASOURCE_NAME+ + "' is an unknown DataSource");
} *catch* (NamingException e) {
*throw* *new* ServletException(e);
protected *void *doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
Connection conn = *null*;
*try* {
conn = getDataSource().getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select post_id,comments,postname from app.posts");
// out.println("Le résultat :<br>");
ArrayList <String> Lescomments= *new* ArrayList<String>();
ArrayList <String> Lesidentifiant = *new* ArrayList<String>();
ArrayList <String> Lesnoms = *new* ArrayList <String>();
*while* (rs.next()) {
Lescomments.add(rs.getString("comments"));
request.setAttribute("comments",Lescomments);
Lesidentifiant.add(rs.getString("post_id"));
request.setAttribute("id",Lesidentifiant);
Lesnoms.add(rs.getString("postname"));
request.setAttribute("nom",Lesnoms);
rs.close();
stmt.close();
*catch* (SQLException e) {
*finally* {
*try* {
*if* (conn != *null*)
conn.close();
*catch* (SQLException e) {
// les paramètres sont corrects - on envoie la page réponse
getServletContext().getRequestDispatcher("/Campaign.jsp").forward(request,response);
}///end of servlet
}///this is the jsp page called
<%@ page import="java.util.ArrayList" %>
<%
// on récupère les données
ArrayList nom=(ArrayList)request.getAttribute("nom");
ArrayList id=(ArrayList)request.getAttribute("id");
ArrayList comments=(ArrayList) request.getAttribute("comments");
%>
<html>
<head>
<title></title>
</head>
<body>
Liste des campagnes here i will create the xml file the problem is to display all rows
<hr>
<table>
<tr>
</tr>
<tr>
<td>Comment</td>
<td>
<%
for( int i=0;i<comments.size();i++){
out.print("<li>" + (String) comments.get(i) + "</li>\n");
}//for
%>
</tr>
<tr>
<td>nom</td>
<td>
<%
for( int i=0;i<nom.size();i++){
out.print("<li>" + (String) nom.get(i) + "</li>\n");
}//for
%>
</tr>
<tr>
<td>id</td>
<td>
<%
for( int i=0;i<id.size();i++){
out.print("<li>" + (String) id.get(i) + "</li>\n");
}//for
%>
</tr>
</table>
</body>
</html>
This is how i used to create an XML file in a JSP page only without JSP/SERVLET concept:
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%
// Identify a carriage return character for each output line
int iLf = 10;
char cLf = (*char*)iLf;
// Create a new empty binary file, which will content XML output
File outputFile = *new* File("C:\\Users\\user\\workspace1\\demo\\WebContent\\YourFileName.xml");
//outputFile.createNewFile();
FileWriter outfile = *new* FileWriter(outputFile);
// the header for XML file
outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
try {
// Define connection string and make a connection to database
Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/SAMPLE","app","app");
Statement stat = conn.createStatement();
// Create a recordset
ResultSet rset = stat.executeQuery("Select * From posts");
// Expecting at least one record
*if*( !rset.next() ) {
*throw* *new* IllegalArgumentException("No data found for the posts table");
outfile.write("<Table>"+cLf);
// Parse our recordset
// Parse our recordset
*while*(rset.next()) {
outfile.write("<posts>"+cLf);
outfile.write("<postname>" + rset.getString("postname") +"</postname>"+cLf);
outfile.write("<comments>" + rset.getString("comments") +"</comments>"+cLf);
outfile.write("</posts>"+cLf);
outfile.write("</Table>"+cLf);
// Everything must be closed
rset.close();
stat.close();
conn.close();
outfile.close();
catch( Exception er ) {
%>Please state your problem that you are having more clearly so we can help.
I looked at your code I here are a few things you might consider:
It looks like you are putting freely typed-in comments from end-users into an xml document.
The problem with this is that the user may enter characters in his text that have special meaning
to xml and will have to be escaped correctly. Some of these characters are less than character, greater than character and ampersand character.
You may also have a similiar problem displaying them on your JSP page since there may be special characters that JSP has.
You will have to read up on how to deal with these special characters (I dont remember what the rules are). I seem to recall
if you use CDATA in your xml, you dont have to deal with those characters (I may be wrong).
When you finish writing your code, test it by entering all keyboard characters to make sure they are processed, stored in the database,
and re-displayed correctly.
Also, it looks like you are putting business logic in your JSP page (creating an xml file).
The JSP page is for displaying data ONLY and submitting back to a servlet. Put all your business logic in the servlet. Putting business logic in JSP is considered bad coding and will cause you many hours of headache trying to debug it. Also note: java scriptlets in a JSP page are only run when the JSP page is compiled into a servlet by java. It does not run after its compiled and therefore you cant call java functions after the JSP page is displayed to the client. -
Restricting the no. of entries in the result set iView
Hi,
Is there a way to restrict the no. of entries in the Result set iView.
Whenever I create a result set iView , it gets loaded with all the entries of the search table it is associated with.
Is there a way to restrict to say 5 or 6 entries.
Best Regards
Sidk
-
Why to need close the result set and statement
why to need close the result set and statement
It's best to explicitly close every ResultSet, Statement, and Connection in the narrowest scope possible.
These should be closed in a finally block.
Since each close() method throws SQLException, each one should be in an individual try/catch block to ensure that a failure to close one won't ruin the chances for all the others.
You can capture this in one nice utility class, like this:
package db;
import java.sql.*;
import java.util.ArrayList;
import java.util.Map;
import java.util.LinkedHashMap;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
* Created by IntelliJ IDEA.
* User: MD87020
* Date: Feb 16, 2005
* Time: 8:42:19 PM
* To change this template use File | Settings | File Templates.
public class DatabaseUtils
* Logger for DatabaseUtils
private static final Log logger = LogFactory.getLog(DatabaseUtils.class);
/** Private default ctor to prevent subclassing and instantiation */
private DatabaseUtils() {}
* Close a connection
* @param connection to close
public static void close(Connection connection)
try
if ((connection != null) && !connection.isClosed())
connection.close();
catch (SQLException e)
logger.error("Could not close connection", e);
* Close a statement
* @param statement to close
public static void close(Statement statement)
try
if (statement != null)
statement.close();
catch (SQLException e)
logger.error("Could not close statement", e);
* Close a result set
* @param rs to close
public static void close(ResultSet rs)
try
if (rs != null)
rs.close();
catch (SQLException e)
logger.error("Could not close result set", e);
* Close both a connection and statement
* @param connection to close
* @param statement to close
public static void close(Connection connection, Statement statement)
close(statement);
close(connection);
* Close a connection, statement, and result set
* @param connection to close
* @param statement to close
* @param rs to close
public static void close(Connection connection,
Statement statement,
ResultSet rs)
close(rs);
close(statement);
close(connection);
* Helper method that maps a ResultSet into a map of columns
* @param rs ResultSet
* @return map of lists, one per column, with column name as the key
* @throws SQLException if the connection fails
public static final Map toMap(ResultSet rs) throws SQLException
List wantedColumnNames = getColumnNames(rs);
return toMap(rs, wantedColumnNames);
* Helper method that maps a ResultSet into a map of column lists
* @param rs ResultSet
* @param wantedColumnNames of columns names to include in the result map
* @return map of lists, one per column, with column name as the key
* @throws SQLException if the connection fails
public static final Map toMap(ResultSet rs, List wantedColumnNames)
throws SQLException
// Set up the map of columns
int numWantedColumns = wantedColumnNames.size();
Map columns = new LinkedHashMap(numWantedColumns);
for (int i = 0; i < numWantedColumns; ++i)
List columnValues = new ArrayList();
columns.put(wantedColumnNames.get(i), columnValues);
while (rs.next())
for (int i = 0; i < numWantedColumns; ++i)
String columnName = (String)wantedColumnNames.get(i);
Object value = rs.getObject(columnName);
List columnValues = (List)columns.get(columnName);
columnValues.add(value);
columns.put(columnName, columnValues);
return columns;
* Helper method that converts a ResultSet into a list of maps, one per row
* @param rs ResultSet
* @return list of maps, one per row, with column name as the key
* @throws SQLException if the connection fails
public static final List toList(ResultSet rs) throws SQLException
List wantedColumnNames = getColumnNames(rs);
return toList(rs, wantedColumnNames);
* Helper method that maps a ResultSet into a list of maps, one per row
* @param rs ResultSet
* @param wantedColumnNames of columns names to include in the result map
* @return list of maps, one per column row, with column names as keys
* @throws SQLException if the connection fails
public static final List toList(ResultSet rs, List wantedColumnNames)
throws SQLException
List rows = new ArrayList();
int numWantedColumns = wantedColumnNames.size();
while (rs.next())
Map row = new LinkedHashMap();
for (int i = 0; i < numWantedColumns; ++i)
String columnName = (String)wantedColumnNames.get(i);
Object value = rs.getObject(columnName);
row.put(columnName, value);
rows.add(row);
return rows;
* Return all column names as a list of strings
* @param rs query result set
* @return list of column name strings
* @throws SQLException if the query fails
public static final List getColumnNames(ResultSet rs) throws SQLException
ResultSetMetaData meta = rs.getMetaData();
int numColumns = meta.getColumnCount();
List columnNames = new ArrayList(numColumns);
for (int i = 1; i <= numColumns; ++i)
columnNames.add(meta.getColumnName(i));
return columnNames;
}Anybody who lets the GC or timeouts or sheer luck handle their resource recovery for them is a hack and gets what they deserve.
Do a search on problems with Oracle cursors being exhausted and learn what the root cause is. That should convince you.
scsi-boy is 100% correct.
% -
Can i store the Result set values as a Session variable
hai,
I want the result set values of a query to be used many times and I want the same resultset between different page calls.
I want all those records fetched from the database to be available in the next page with out refetching from the database.
can any one help me out. its very urgent.....
Thanks and regards,
Ravikiran
mail to me at : [email protected]"can i store the Result set values as a Session variable "
Practically Yes u can
but u want be able to accesses it in other pages
u can try it and see
the other thing u can do is store the values from the resultset in a object say vector and put vector in seesion and u can use this any where
for e.g
Vector v=new Vector();
While(rs.next())
v.addElement(rs.getString(1));
v.addElement(rs.getString(2));
session.putValue("myVector",v);
now where u want to get it do this
Vector myvec=(Vector)session.getValue("myVector");
do do futher -
OBIEE Answers does not display the result set of a report query
Hi,
We have a pivot table type of report in Oracle Business Intelligence Enterprise Edition v.10.1.3.3.2 Answers that has the following characteristics:
3 Pages
3 Sections , 4 Columns
18363 Rows in the result set
As per the NQQuery.log, the query for this report executes successfully resulting in 18363 rows. However, nothing comes up in the display on Answers. Moreover, no error is reported. The instanceconfig.xml file has the following setting:
<PivotView>
<CubeMaxRecords>30000</CubeMaxRecords>
<CubeMaxPopulatedCells>300000</CubeMaxPopulatedCells>
</PivotView>
Even with these settings, Answers just returns a blank page - nothing is displayed in the name of the result set of the report query. Has anyone encountered this problem scenario before?
Any help is much appreciated.
Thanks,
PiyushHi Fiston / Pradeep,
Thanks for your inputs. A few points to note:
-> I am actually not getting any error message in answers or the NQQuery log. Moreover I am not getting any errors related to "query governor limit exceeding in cube generation" also.
-> I have other pivot table type of reports in the same repository that work fine. In fact the report which has this issue even works sometimes - what actually is happening is that if I alter the number of sections from 3 to 4, then the result set changes from 14755 Rows to 18363 Rows and as per the NQQuery.log in both cases the query completes successfully. However, when the result set has 14755 rows, I get to see the output in Answers; however when the result set is 18636 rows, the Answers screen just goes blank and does not show any output or error. This makes me believe that there is some parameter in instanceconfig or the NQSconfig file - I have tried a lot of changes but nothing works !
Any help is much appreciated.
Best Regards,
Piyush -
RIDC api: The result set 'content' was not found or is empty
Hi,
I am trying to add a revision using COLLECTION_CHECKIN_REVISION. The content which I want to add a revision has only one revision i.e. 1,
and its dID is 3746 and is already checked out.
<code>
binder.putLocal ("IdcService", "COLLECTION_CHECKIN_REVISION");
// get the binder
binder.putLocal ("dDocTitle", "Html file");
binder.putLocal ("dDocName", "SUN00100");
binder.putLocal ("dDocType", "Document");
binder.putLocal ("dSecurityGroup", "Public");
binder.putLocal("hasCollectionID", "true");
binder.putLocal("dID", "3746");
binder.putLocal("dRevLabel", "2");
binder.putLocal("dCollectionID", this.getFolderIdFromPath(idcClient, userContext, PATH));
System.out.println("dCollectionID###############################" +binder.getLocal("dCollectionID"));
binder.addFile ("primaryFile", new TransferFile(new File("D:\\P6WS\\RIDC Test\\src\\com\\oracle\\ridc\\poc\\2.html")));
// checkin the file
response = idcClient.sendRequest(userContext, binder);
System.out.println("response "+response.getResponseAsString());
</code>
And the output is as follows
dCollectionID###############################739373434448003784
response <?hda version="11gR1-11.1.1.5.0-idcprod1-110413T184243" jcharset=UTF-8 encoding=UTF-8?>
@Properties LocalData
deleteCompleteInCollections=true
dDocType=Document
refreshSubMonikers=
dUser=sysadmin
anyState=true
primaryFile=2.html
StatusMessage=<strong>The result set 'content' was not found or is empty.</strong>
UserTimeZone=UTC
localizedForResponse=1
dDocName=SUN00100
changedMonikers=
I want to understand which content is being referred. The primaryFile is existing in the same location.
Did I missed out any required parameter.
regards,
Sunil Kumar Dhage
Edited by: 881595 on Aug 26, 2011 4:18 AMLike last time: documentation is not a big help here, so you have to do a bit of investigation yourself.
In order to understand result sets, check this link: http://download.oracle.com/docs/cd/E17904_01/doc.1111/e10726/c04_master_usage.htm#CSIDO249
('content' is the name of the result set)
I can't imagine why you would need such a result set while checkin in a new revision to a folder, but the documentation (http://download.oracle.com/docs/cd/E17904_01/doc.1111/e11011/c08_folders.htm#i1082329) advices that some sub services are called, so it might actually be an error coming from these subservices. I'd suggest to narrow down the search first - turn on requestaudit in server-wide tracing (see here: http://download.oracle.com/docs/cd/E17904_01/doc.1111/e10792/c02_processes.htm#CSMSP536).
Alternatively, you could also perform your service call from GUI and trace what parameters are provided. I guess something will be missing. -
Limiting the result set?
How can I limit the result set of query without inventing a cursor, e.g. Select * from foo order by date desc LIMIT TO 5 rows
Is there a statment in Oracle 8i enabling such a query (like in Oracle RDB)?To limit the result set use rownum. Here is an example:
select * from tab where rownum <=5;
I found this on another technet forum when I search on limiting query rows returned. -
How to send email using pl/sql containing the result set as the msg body
Hi.. im using Pl/SQL code to send emails to the users from a dataset that is obtained in a databse table. i have used utl_smtp commands to establish the connection with the smtp mail server. im stuck at the logic when i have to include the message body which is actually the result set of a table.. For instance
IF (p_message = 0) THEN
UTL_SMTP.write_data(l_mail_conn, 'There is no mismatch between the codes' || UTL_TCP.crlf);
ELSE
UTL_SMTP.write_data(l_mail_conn, 'The missing codes are ' || UTL_TCP.crlf);
for s in (select * from temp)
loop
UTL_SMTP.write_data(l_mail_conn, ' ' ||s || UTL_TCP.crlf);
end loop;
END IF;
UTL_SMTP.close_data(l_mail_conn);
UTL_SMTP.quit(l_mail_conn);
END;
***p_message is a prameter passed to this procedure..
Can i obtain the result in the form i have it in my table. which has three columns. I want to display the three columns as it is with teh records. ?this is not related about this forum but you can use below,
CREATE OR REPLACE PROCEDURE SEND_MAIL (subject varchar2,mail_from varchar2, mail_to varchar2,mail_msg varchar2)
IS
mail_host varchar2(30):='XXXXX';
mail_conn utl_smtp.connection;
tz_offset number:=0;
str varchar2(32000);
BEGIN
begin
select to_number(replace(dbtimezone,':00'))/24 into tz_offset from dual;
exception
when others then
null;
end;
mail_conn:=utl_smtp.open_connection(mail_host, 25);
utl_smtp.helo(mail_conn,mail_host);
utl_smtp.mail(mail_conn,'[email protected]');
utl_smtp.rcpt(mail_conn,mail_to);
utl_smtp.open_data(mail_conn);
utl_smtp.write_data(mail_conn,'Date: '||to_char(sysdate-tz_offset,'dd mon yy hh24:mi:ss')||utl_tcp.crlf);
utl_smtp.write_data(mail_conn,'From: '|| mail_from ||utl_tcp.crlf);
utl_smtp.write_data(mail_conn,'To: "'|| mail_to ||'" <'||mail_to||'>'||utl_tcp.crlf);
utl_smtp.write_data(mail_conn,'Subject: '||subject||utl_tcp.crlf);
utl_smtp.write_data(mail_conn,utl_tcp.crlf);
utl_smtp.write_data(mail_conn,replace_turkish_chars(mail_msg)||utl_tcp.crlf);
utl_smtp.write_data(mail_conn,utl_tcp.crlf);
utl_smtp.close_data(mail_conn);
utl_smtp.quit(mail_conn);
END;
Edited by: odilibrary.com on Jun 12, 2012 5:26 PM -
Whenever I open a new tab, I want the new page to open to the same setting as my Home Page (in my case, Google). Instead it takes me to Bing. Even my Home Page reverts to Bing after I've set it to Google.
The default New Tab in Firefox is a blank page and there is no built-in option to change that.
*CTRL+left-click the Home icon will open a new tab to your set home page.
**See --> http://support.mozilla.com/en-US/kb/How+to+set+the+home+page
*This Add-on will open a new tab when clicking the new tab "+" icon (or when clicking New Tab from the menu) to whatever page you set in the options for the add-on:
**'''''New TabURL''''': https://addons.mozilla.org/en-US/firefox/addon/newtaburl/
'''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.''' -
We are unable to open a Pages 5.0.1 document in Pages 4.2 and retain ability to edit all aspects of the document. I have tried saving the 5.0.1 version in Pages '09 but am still unable to open it in the earlier version of pages. Help?
No, it isn't. Pages 5 isn't compatible with Pages 4.3 as it is lacking more than 90 features that Pages 4 has. So when you open a Pages 4 document in Pages 5 only the simplest documents will look the same in Pages 5.
Pages 4 can't open Pages 5 documents at all!! You have to export back to Pages 09 as I said above.
You probably will be more happy if you just use Pages 4 (Pages 09). There are many threads in this forum that describes the lack of compatibility between the two versions. Pages 5 is in my view not Pages anymore.
If you don't desperately need Pages 5 for moving documents over iCloud to new iOs devices don't use it. -
I am using Lightroom 5 and am hapy about it, but recently I hav encountered a problem when trying to edit an image in another program, i.e. Elements. I used the clone tool, saved the result and went back to Lightroom to open the image there. I did find a second copy, but this is identic with the one I already had in Lightroom, and I can see noe result of the clone process.
At the moment I would say it is uncertain whether Acrobat is completely ignoring the change, or whether the changes you are making aren't affecting the ink density. I have a suggestion for a test you could make to see which is the case.
When editing in Photoshop just add a box or mark on the image, for your tests.
- If this box does not appear in Acrobat, you know Acrobat is not seeing the edit
- If this box does appear in Acrobat, you know the problem is that your tool for changing ink densities is not taking effect. -
How to add a dummy row in the result set of a SELECT statement.
Hello Everyone -
I have requirment to add a dummy row in the result set of a SELECT statement.
For e.g. lets say there is a table Payment having following colums:
Payment_id number
status varchar2(10)
amount number
payment_date date
so here is the data :-
Payment_id Status Amount payment_date
1 Applied 100 12/07/2008
2 Reversed 200 01/ 06/2009
3 Applied 300 01/ 07/2009
Here is my SQL
Select * form payment where payment_date >= 01/01/2009
Output will be
2 Reversed 200 01/ 06/2009
3 Applied 300 01/ 07/2009
My desired output is below
2 Reversed 200 01/ 06/2009
3 Applied 300 01/ 07/2009
2 Reversed -200 01/ 06/2009 ------(Dummy Row)
Thrid row here is the dummy row which I want to add when status is "Reversed"
I would be very thankful for any kind of help in this regard ...
Thanks,
GauravCartesion joining against a dummy table is a useful method of creating a dummy row:
with my_tab as (select 1 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
select 1 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
select 1 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 1 Payment_id, 'Applied' Status, 100 Amount, to_date('12/07/2008', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 2 Payment_id, 'Reversed' Status, 200 Amount, to_date('01/05/2009', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 3 Payment_id, 'Applied' Status, 300 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 4 Payment_id, 'Reversed' Status, -400 Amount, to_date('01/06/2009', 'mm/dd/yyyy') payment_date from dual union all
select 2 cust_id, 5 Payment_id, 'Applied' Status, 500 Amount, to_date('01/07/2009', 'mm/dd/yyyy') payment_date from dual),
--- end of mimicking your table
dummy as (select 'Reversed' col1, 1 rn from dual union all
select 'Reversed' col1, 2 rn from dual)
select mt.cust_id,
mt.payment_id,
mt.status,
decode(dummy.rn, 2, -1*mt.amount, mt.amount) amount,
mt.payment_date
from my_tab mt,
dummy
where mt.status = dummy.col1 (+)
order by mt.cust_id, mt.payment_id, dummy.rn nulls first;
CUST_ID PAYMENT_ID STATUS AMOUNT PAYMENT_DATE
1 1 Applied 100 07/12/2008
1 2 Reversed 200 06/01/2009
1 2 Reversed -200 06/01/2009
1 3 Applied 300 06/01/2009
2 1 Applied 100 07/12/2008
2 2 Reversed 200 05/01/2009
2 2 Reversed -200 05/01/2009
2 3 Applied 300 06/01/2009
2 4 Reversed -400 06/01/2009
2 4 Reversed 400 06/01/2009
2 5 Applied 500 07/01/2009Edited by: Boneist on 07-Jan-2009 23:10
NB. You may have to mess around with the ordering if that's not come back in the order you wanted. You didn't mention what the rules were for any expected ordering though, so I've made up my own *{;-)
Also, I added an identifier (cust_id) to differentiate between different sets of payments, since that's usually the case. Remove that if it's not applicable for your case. -
How to get the result set in batches
I have a query which results into large data. This data i want to display in a group of 20. After every 20 records i want to add header and footer to it.
Is it possible to get the result set data into batch of 20 ? means can i specify start and end index of query ?
regards
ManishaWhat I am saying is that a big query with lots of
joins will probably be slow, and as such would be a
ripe candidate for batching the responses, if it were
not possible to speed/optimize it. Batching is nice
to look at for the user, but is not a solution for
performance problems. In essence it is irrelevant
that it adds a little performance deficit, as it
appears to be running a lot quicker, and gives more
feedback to the user.Then let me say it again....
- "Join" is a term that applies to a method of doing queries in the database....
- Query 1 which uses a join and returns 15 rows
- Query 2 which does not use a join and returns 1500 rows.
Given the above then Query 1 will provide better overall performance for the system than Query 2 in a properly configured database.
If it doesn't then the database is not set up correctly.
And again this will be irrespective of whether the query is scrollable or not.
Maybe you are looking for
-
PLEASE HELP!! SOMEONE - ANYONE RE: ZEN VISION M 30GB PR
Has NO one had their Zen Vision M 30 GB or 60GB get stuck in the ON position at the CREATIVE screen and not reset with a paperclip?If ANYONE else has had this happen...PLEASE HELP !!! HOW DO YOU RESET IT? It won't turn off and the Recovery program wo
-
IPod is recognized in Windows, but not in iTunes.
Ive followed the support site on what to do if the iPod is recognized in Windows but not iTunes... but to no avail. ive had a 20GB photo thats been working o.k. (need to send it in) but now neither it nor my new 30GB Video will appear on iTunes... ju
-
When I go into the export dialogue and select a portion of a file naming scheme, I cannot get it into the clipboard. I had wanted to cut a portion of the specification, export with an amended name, and then paste the original back. I am running the
-
Hiii guru's, How to do netting of GL in F.01 report. In F.01 we get GL P & L statement.i want total of group of GLs. System should not show individual GLs. Total of the Group should appear. Subcontracting group. GL XXXXX 1111
-
Display menu in Forms10g 10.1.2
Hi is the popup menu is suported in Forms10g , if it's yes i alwayes got the error FRM-92010 whenever i called the forms taht hold the menu any suggestion's please Thank's alot