Bapi call returns first row?? Please help
After an "execute()" call is made on the model , the return structure shows only first row.
The context picks it up and shows the first row.
Have you faced this issue before.
Can you give some pointer(s)?
Thanks a bunch.
Hi,
1. Try executing BAPI in R/3 with the same parameters that you provide from your web application and see how many rows it return. Also check the size of the output node in WD to confirm that it returns exactly the same number of rows for same parameters using wdContext.node<outputnode>().size();
2. Also invalidate the node after executing the BAPI using wdContext.node<outputnode>().invalidate();
Regards,
Murtuza
Similar Messages
-
SQL Query returning no rows, please help!!
I have a table that contains user audits for a particular procedures alongwith the date stamp. Now, I want to list all the procedures not accessed by the users within the last 6 months. Or, all the procedures that have not been used/accessed during the last 6 months.
This is what I am trying but is not returning any rows:
SELECT DISTINCT proc_name,
TRUNC (entry_date)
FROM log_web
WHERE proc_name NOT IN (SELECT proc_name
FROM log_web
WHERE TRUNC (entry_date) > TRUNC (SYSDATE - 180))
ORDER BY 2 DESC
Please advise.
Thank you in advance.Two possibilities leap to mind.
First, are you sure that there are any prodcedures not accessed in the last six months?
Second, is there a chance that there could be records with a null value in proc_name? If the sub-query used in a NOT IN predicate returns even one null value, the query will return no rows.
Does this return rows?
SELECT DISTINCT proc_name, TRUNC(entry_date)
FROM log_web
WHERE proc_name NOT IN (SELECT proc_name
FROM log_web
WHERE TRUNC (entry_date) > TRUNC (SYSDATE - 180) and
proc_name IS NOT NULL)
ORDER BY 2 DESCJohn -
hi can anyone help me im using my iphone to make a call to a number that has been changed two days ago but it automatically says 'called failed' why? please help!
Here's a nifty agorithm to fill an array of primes, using a forever loop with a labeled continue statement, from Horton's Beginining Java:public class MorePrimes
public static void main(String[] args)
long[] primes = new long[20]; // Array to store primes
primes[0] = 2; // Seed the first prime
primes[1] = 3; // and the second
int count = 2; // Count of primes found - up to now,
// which is also the array index
long number = 5; // Next integer to be tested
outer:
for( ; count < primes.length; number += 2)
// The maximum divisor we need to try is square root of number
long limit = (long)Math.ceil(Math.sqrt((double)number));
// Divide by all the primes we have up to limit
for(int i = 1; i < count && primes[i] <= limit; i++)
if(number%primes[i] == 0) // Is it an exact divisor?
continue outer; // yes, try the next number
primes[count++] = number; // We got one!
for(int i=0; i < primes.length; i++)
System.out.println(primes); // Output all the primes -
If i want to learn unix-HP for SAP at first stage, please help me.
Dear Friend,
If i want to learn unix-HP for SAP at first stage, please help me.
Thanks,
Regards,
sachinHi Sachin,
please go thru the following url
http://www.uga.edu/~ucns/wsg/unix/gstart/
and
http://whitepapers.techrepublic.com.com/whitepaper.aspx?&docid=10197&promo=100511
happy learning!
with BR,
Raj
<i> award points, plz </i> -
My iPhone 4 screen is on existent (Blank, looks like it turned off but not as it rings when calls come thru) I can't turn it off and turn it on- this usually fixes all problems. I can't take calls at all. Please help?
Have you tired a reset?
A restore? -
Oracle:JDBC Call returns no results, SQL*Plus returns 1 record, Please help
Any help would be greatly appreciated.
Running 9.2.0.5.0, and using latest 9.2 JDBC 1.4_g drivers in thin mode.
Execute the following query from SQL*Plus and it returns one row, from JDBC using a PreparedStatement, I get no results. Here's the query, table def, record, etc.:
Query:
SELECT
ID_WEB_FRM,ID_WEB_SIT,CDE_LVL_1_FUNC,
CDE_LVL_2_FUNC,NUM_WEB_FUNC_PG,NUM_WEB_PG_ID
FROM
WEB_FRM
WHERE
ID_WEB_FRM = ' '
OR
(ID_WEB_SIT = 'test' AND CDE_LVL_1_FUNC = ' '
AND CDE_LVL_2_FUNC = 'u2T' AND NUM_WEB_FUNC_PG = 1
AND NUM_WEB_PG_ID = 0)
Record returned from SQL*Plus:
ID_WEB_FRM ID_WEB_SIT CDE CDE NUM_WEB_FUNC_PG NUM_WEB_PG_ID
NfRRmc5XZu test u2T 1 0
Both in the data returned and the query, there are no blanks, but they are a single space instead (hard to see in message here).
Java code:
int count = 1;
findDBNameStatement.setString(count++," ");
findDBNameStatement.setString(count++,form.getSiteID());
findDBNameStatement.setString(count++," ");
findDBNameStatement.setString(count++, form.getFunctionID());
findDBNameStatement.setInt(count++,form.getPageNumber());
findDBNameStatement.setInt(count++,form.getSectionNumber());
ResultSet resultSet = findDBNameStatement.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();
resultSet.next() returns false
DB table:
CREATE TABLE web_frm (
ID_WEB_FRM varchar2(10) NOT NULL,
ID_WEB_SIT varchar2(20) NOT NULL,
NAM_WEB_FRM varchar2(40),
TXT_EMAIL_SUBJ varchar2(50),
CDE_LVL_1_FUNC char(3),
CDE_LVL_2_FUNC char(3) NOT NULL,
NUM_WEB_FUNC_PG int NOT NULL,
NUM_WEB_PG_ID smallint NOT NULL,
DTE_WEB_FRM_EFF date NOT NULL,
DTE_WEB_FRM_TRM date,
CDE_VLDT_RUL char(3),
DTE_LAST_EXPRT date,
TXT_CNFRMN_MSG varchar2(4000),
IND_UPDT_ALWD char(1) NOT NULL,
TXT_RECAP_HDR varchar2(4000),
TXT_RECAP_FTR varchar2(4000),
CDE_WEB_OBJ char(3),
NUM_MAX_FRM_WIDTH number(4,0),
IND_RECAP_PG char(1) NOT NULL,
IND_CNFRM_PG char(1) NOT NULL,
IND_DSPL_CNFRM_NUM char(1) NOT NULL,
CNT_SUBM_MAX int,
TXT_CHCE_ADD_MSG varchar2(255),
TXT_CHCE_MOD_MSG varchar2(255),
TXT_WEB_HDR varchar2(4000),
TXT_WEB_FTR varchar2(4000),
TXT_WAIT_LIST_MSG varchar2(255),
FORMOBJECTHEIGHT int NOT NULL,
FORMOBJECTWIDTH int NOT NULL
ALTER TABLE web_frm ADD ( CONSTRAINT PK_web_frm PRIMARY KEY (ID_WEB_FRM));
ALTER TABLE web_frm ADD ( CONSTRAINT UK_web_frm UNIQUE (ID_WEB_SIT,CDE_LVL_1_FUNC,CDE_LVL_2_FUNC,NUM_WEB_FUNC_PG,NUM_WEB_PG_ID)) ;
Thanks,
MattThat's not quite right. From the javadocs:
next
public boolean next()
throws SQLException
Moves the cursor down one row from its current position. A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on.
If an input stream is open for the current row, a call to the method next will implicitly close it. A ResultSet object's warning chain is cleared when a new row is read.
Returns:
true if the new current row is valid; false if there are no more rows
Throws:
SQLException - if a database access error occurs -
JDBC Call returns no results, SQL*Plus returns 1 record, Please help!
Any help would be greatly appreciated.
Running 9.2.0.5.0, and using latest 9.2 JDBC 1.4_g drivers in thin mode.
Execute the following query from SQL*Plus and it returns one row, from JDBC using a PreparedStatement, I get no results. Here's the query, table def, record, etc.:
Query:
SELECT
ID_WEB_FRM,ID_WEB_SIT,CDE_LVL_1_FUNC,
CDE_LVL_2_FUNC,NUM_WEB_FUNC_PG,NUM_WEB_PG_ID
FROM
WEB_FRM
WHERE
ID_WEB_FRM = ' '
OR
(ID_WEB_SIT = 'test' AND CDE_LVL_1_FUNC = ' '
AND CDE_LVL_2_FUNC = 'u2T' AND NUM_WEB_FUNC_PG = 1
AND NUM_WEB_PG_ID = 0)
Record returned from SQL*Plus:
ID_WEB_FRM ID_WEB_SIT CDE CDE NUM_WEB_FUNC_PG NUM_WEB_PG_ID
NfRRmc5XZu test u2T 1 0
Both in the data returned and the query, there are no blanks, but they are a single space instead (hard to see in message here).
Java code:
int count = 1;
findDBNameStatement.setString(count++," ");
findDBNameStatement.setString(count++,form.getSiteID());
findDBNameStatement.setString(count++," ");
findDBNameStatement.setString(count++, form.getFunctionID());
findDBNameStatement.setInt(count++,form.getPageNumber());
findDBNameStatement.setInt(count++,form.getSectionNumber());
ResultSet resultSet = findDBNameStatement.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();
resultSet.next() returns false
DB table:
CREATE TABLE web_frm (
ID_WEB_FRM varchar2(10) NOT NULL,
ID_WEB_SIT varchar2(20) NOT NULL,
NAM_WEB_FRM varchar2(40),
TXT_EMAIL_SUBJ varchar2(50),
CDE_LVL_1_FUNC char(3),
CDE_LVL_2_FUNC char(3) NOT NULL,
NUM_WEB_FUNC_PG int NOT NULL,
NUM_WEB_PG_ID smallint NOT NULL,
DTE_WEB_FRM_EFF date NOT NULL,
DTE_WEB_FRM_TRM date,
CDE_VLDT_RUL char(3),
DTE_LAST_EXPRT date,
TXT_CNFRMN_MSG varchar2(4000),
IND_UPDT_ALWD char(1) NOT NULL,
TXT_RECAP_HDR varchar2(4000),
TXT_RECAP_FTR varchar2(4000),
CDE_WEB_OBJ char(3),
NUM_MAX_FRM_WIDTH number(4,0),
IND_RECAP_PG char(1) NOT NULL,
IND_CNFRM_PG char(1) NOT NULL,
IND_DSPL_CNFRM_NUM char(1) NOT NULL,
CNT_SUBM_MAX int,
TXT_CHCE_ADD_MSG varchar2(255),
TXT_CHCE_MOD_MSG varchar2(255),
TXT_WEB_HDR varchar2(4000),
TXT_WEB_FTR varchar2(4000),
TXT_WAIT_LIST_MSG varchar2(255),
FORMOBJECTHEIGHT int NOT NULL,
FORMOBJECTWIDTH int NOT NULL
ALTER TABLE web_frm ADD ( CONSTRAINT PK_web_frm PRIMARY KEY (ID_WEB_FRM));
ALTER TABLE web_frm ADD ( CONSTRAINT UK_web_frm UNIQUE (ID_WEB_SIT,CDE_LVL_1_FUNC,CDE_LVL_2_FUNC,NUM_WEB_FUNC_PG,NUM_WEB_PG_ID)) ;
Thanks,
MattI have verified the parameters and such, and if I run as a Statement instead of a PreparedStatement, the query works fine. After some more troubleshooting, I narrowed the problem down, but not sure of the fix.
If I eliminate teh extra parameters and simplify things to:
SELECT ID_WEB_FRM FROM WEB_FRM WHERE ID_WEB_SIT = 'test' AND CDE_LVL_2_FUNC = 'u2T' AND NUM_WEB_FUNC_PG = 1 AND NUM_WEB_PG_ID = 0
The code works. But if I add the additional WHERE clause of CDE_LVL_1_FUNC = ' ' (has single space), it returns no data (record in the DB has single space in this new column. Query that does not work:
SELECT ID_WEB_FRM FROM WEB_FRM WHERE ID_WEB_SIT = 'test' AND CDE_LVL_1_FUNC = ' ' AND CDE_LVL_2_FUNC = 'u2T' AND NUM_WEB_FUNC_PG = 1 AND NUM_WEB_PG_ID = 0
It appears the JDBC Driver is trimming the parameter when it is a space when set through a PreparedStatement.setString(2," ") -
Variable calling not working. please help
Hi there,
I am trying to include a nslookup utility I have, to run with my messenger server proxy below.
The idea is, is that the address lookup found is saved to a string, which is called dottedQuad, and then using string variable name, I just put that in the consturctor of the socket below.
No matter what I try, I cannot get access to that variable from the try/catch block where that socket declaration is????? please help!!
cheers
// MultiThreadsServer.java: The server can communicate with
// multiple clients concurrently using the multiple threads
import java.io.*;
import java.net.*;
public class MultiThreadServerRead
String result;
MultiThreadServerRead server;
// Main method
public static void main(String[] args)
try
System.out.println("Messenger Server proxy");
System.out.println("Please enter the PC name of the user you wish to talk to:");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String host = in.readLine();
System.out.println(lookup(host));
catch (IOException ex){
System.err.println(ex);
try
// Create a server socket
ServerSocket serverSocket = new ServerSocket(8000);
// To number a client
int clientNo = 1;
while (true)
// Listen for a new connection request
Socket connectToClient = serverSocket.accept();
// Print the new connect number on the console
System.out.println("Start thread for client " + clientNo);
// Find the client's hostname, and IP address
InetAddress clientInetAddress = connectToClient.getInetAddress();
System.out.println("Client " + clientNo + "'s hostname is "
+ clientInetAddress.getHostName());
System.out.println("Client " + clientNo + "'s IP Address is "
+ clientInetAddress.getHostAddress());
// Create a new thread for the connection
HandleAClient thread = new HandleAClient(connectToClient, clientNo);
// Start the new thread
thread.start();
// Increment clientNo
clientNo++;
catch(IOException ex)
System.err.println(ex);
} //end catch
}//end main
public static String lookup(String host )
InetAddress thisComputer;
byte[] address;
//get the bytes of the IP address
try
thisComputer = InetAddress.getByName(host);
address = thisComputer.getAddress();
catch
(UnknownHostException e)
return "Cannot find host " + host;
if( isHostName(host))
MultiThreadServerRead server = new MultiThreadServerRead();
//print the IP address
String dottedQuad = "";
for (int i = 0 ; i< address.length; i++)
int unsignedByte = address[i] < 0 ? address[i] + 256 : address;
dottedQuad += unsignedByte;
if (i != address.length-1) dottedQuad += ".";
server.result = dottedQuad;
return dottedQuad;
else
{ //this is an IP address
return thisComputer.getHostName();
} // end lookup
public static boolean isHostName(String host)
char[] ca = host.toCharArray();
//if we see a character that is neither a digit nor a period
// then host is proberbly a host name
for (int i = 0; i < ca.length; i++)
if (!Character.isDigit(ca[i]))
if ( ca[i] != '.') return true;
//Everything was either a digit or a period
//so host looks like an IP address in dotted quad format
return false;
} //end isHostName
} //end class
// Define the thread class for handling a new connection
class HandleAClient extends Thread
String timeString ;
private Socket connectToClient; // A connected socket
private int clientNo; // Indicate client no
// Construct a thread
public HandleAClient(Socket socket, int clientNo)
connectToClient = socket;
this.clientNo = clientNo;
// Implement the run() method for the thread
public void run()
try
// Create data input and output streams
InputStream isFromClient = connectToClient.getInputStream();
//OutputStreamWriter osToClient = new OutputStreamWriter(connectToClient.getOutputStream());
StringBuffer time = new StringBuffer();
int c;
while ((c = isFromClient.read()) != -1) time.append((char) c);
timeString = time.toString().trim();
System.out.println("it is " + timeString + " at " );
catch(IOException ex)
System.err.println(ex);
} //end catch
try
// Create data input and output streams
StringBuffer time = new StringBuffer();
int c;
Socket connectToServer = new Socket("192.168.0.3", 8001);
OutputStreamWriter osToServer = new OutputStreamWriter(connectToServer.getOutputStream());
// Continuously serve the client
// while (true)
// System.out.println(lookup(host));
osToServer.write("WRITE BACK TO CLIENT " + timeString + "\r\n" );
osToServer.flush();
connectToServer.close();
catch(IOException ex)
System.err.println(ex);
} //end catch
} //end run
} // end classIf you want to access a variable from outside of a block, then don't declare it inside the block.
-
PROBLEM WITH NEW ROW --- PLEASE HELP
Hello,
I've had it with the framework. It's been 20 hours and counting that I am trying to insert/validate a new record.
Things just don't work as advertised.
Here's the situation:
I have an entity object with various validation rules in the validate() method.
Then I have a simple JSP page to insert new records.
At submit of button, I follow the framework's default
create new row and fill it up, with the difference
that i need to validate the row as soon as I fill it up
with data from the http request:
<jbo:OnEvent name="Create">
<jbo:Row id="newrow" datasource="ds" action="CreateInRange" >
<% try { %>
<jbo:SetAttribute dataitem="*" />
<%
newrow.validate(); //******* NOTICE HERE THAT I VALIDATE
} catch (JboException ex) {
newrow.remove();
throw ex;
} %>
</jbo:Row>
</jbo:OnEvent>
Unexpected behavior 1: If the validation fails,
newrow DOES NOT GET REMOVED!!!! I know this
since when I view data thru a data table component,
the row is there WITH THE ERROR INFORMATION set!!.
If I do a commit transaction, then the erroneous information ENDS UP IN THE DATABASE!!!!!
Unexpected behavior 2: If I do a rollback, every
call to subsequent pages results in a jsp error:
java.lang.ClassCastException: oracle.jbo.html.jsp.datatags.OnEventTag
PLEASE HELP.
Chris LambrouI have (hopefully) found a solution to my part of this problem. I was getting the ClassCastExceptions on any page with a <jbo:row> tag after doing a failed DML action. I have tested this with the delete event. (btw, I am using jdev9.0.3.3 w/ BC4J/JSP) Before what I was doing was this:
<% try { %>
<jbo:Row id="delrow" datasource="ds" rowkeyparam="jboRowKey" action="Delete" />
<% } catch (JboException jboEx) { %>
do something
<% } catch (Exception ex) { %>
uh-oh, this is bad
<% } %>
If I removed the try/catch block everything worked fine. Unfortunatlely, I need to try/catch block here. To work around the problem I changed the code to this:
<% Row rowDelete = ds.getRowFromKey(params.getParameter("jboRowKey")); %>
<% try { %>
<%
rowDelete.remove();
%>
<% } catch (JboException jboEx) { %>
do something
<% } catch (Exception ex) { %>
uh-oh, this is bad
<% } %>
The second bit of code does the same thing (but it doesn't use a bean like I think <jbo:Row> does) and it doesn't cause the ClassCastError on subsequent errors.
I really hope this helps someone else because it took me forever to get a workaround!
~Rob Lundeen -
64-bit driver only returns first row of table
I have a C++ application using ADO (the MSADO COM components) and the Oracle OLEDB provider for database access. The application works fine on a 32-bit computer using the 32-bit Oracle client and driver. However, when I run a 64-bit build of the application, running on a 64-bit computer (Windows Server 2008 x64), using the 64-bit Oracle client and driver, a SELECT operation returns only the first row of the table.
Note that this is only happening with the ActiveX ADO components. ADO.NET is not having a problem.
In both cases I am connecting to the same database, which is Oracle 10.2 (32-bit) running on a different server. I have tested with Oracle client 10.2.0.4 and 11.1.0.7 and got the same result in both cases.
I have reproduced the issue with a simple table (one column, NVARCHAR2(255)) and simple code.
In the code, I execute "select count(*) from tablename" and get the correct record count (more than one record). But when I then open the recordset ("select columnname from tablename"), ADO reports EndOfFile after I have read the first row and called MoveNext on the recordset.
My Oracle knowledge is limited so I don't know if there are driver properties I should be checking.
Anyone have ideas?
Thanks in advance.For 10.2 it's fixed in 10204 Patch 21 and higher.
For 11.1 it's fixed in 11107 Patch 12 and higher.
Cheers,
Greg -
First "compilation"- please, help
ok-
so i'm starting with the latest SDK, on my Windows XP laptop.
i'm trying to compile my very first, helloworld program. and all i get is the following error:
"The name specified is not recognized as an internal or external command, operable program or batch file"
now, i've loaded the SDK into the following directory: c:\j2sdk1.4.0
and, i see that to correct this problem, i can either permanantly set the path (help??!) or, just type the following in the DOS prompt:
C:\>j2sdk1.4\bin\javac HelloWorldApp.java
when i try to compile this, i get:
"The system cannot find the path specified"
(is this becuase of that stupid '>' character in the DOS prompt that i can't get rid of?)
please, help.i have done as you suggested, saving the file as "all files", putting it in double quotes, making sure to call it "HelloWorldApp.java"
and when i try to compile it, i still get the "can't read" error.
i have cut and pasted my DOS session here-
can you take a look at it and see what is wrong?(when i select the "HelloWorldApp.java" file, and choose properties, it says it is this kind of document: File for Forte for Java
(is this my problem?)
(at the end of this, i have put the text of the HelloWorldApp document)
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\default>cd C:\javatest
C:\javatest>dir
Volume in drive C has no label.
Volume Serial Number is 07D0-0A0D
Directory of C:\javatest
04/05/2002 12:23 PM <DIR> .
04/05/2002 12:23 PM <DIR> ..
04/05/2002 12:28 PM 291 HelloWorldApp.java
1 File(s) 291 bytes
2 Dir(s) 63,762,006,016 bytes free
C:\javatest>cd C:\
C:\>J2SDK_Forte\jdk1.4.0\bin\javac HelloWorldApp.java
error: cannot read: HelloWorldApp.java
1 error
C:\>
HelloWorldApp document:
* The HelloWorldApp class implements an application that
* displays "Hello World!" to the standard output.
public class HelloWorldApp {
public static void main(String args [] ) {
// Display "Hello World!"
System.out.println("Hello World!"); -
Mac 10.6.8's video calls not working! Please help!
Reposting the text below because there was no reply to the last message. Ack! Please help. Skype, is there a solution yet? Or even just an explanation and a time frame so we know when we can expect video calls to work again? Thanks! ---------------I have a Mac laptop, version 10.6.8. I have the most updated version of Skype available for my computer, Skype version 6.15. For the past few months, I've been unable to use video chat or file sharing. I can receive some files, but cannot send files. Other people can video chat with me and I can see them, but they can't see me. My built-in camera works just fine for other purposes, so I know it's not an issue with my camera. I've also noticed that a lot of Mac users seem to be having trouble with Skype lately. I've checked my audio/video preferences for Skype and my computer's camera preferences, and everything is as it should be. Does anyone know how to fix this?
Thanks in advance for any help!See: How to perform a "clean install" of Flash Player in Mac OS X
In addition to these steps, I recommend, BEFORE emptying the trash:
Go to: [User]/Library/Preferences (hold the "Option" key when clicking "Go" from the Finder menu to reveal the hidden Library folder)
Trash the ENTIRE Macromedia folder from there
Aside from that additional step, follow the rest of the instructions to the letter and you should be back up and running. -
I just updated my iPhone 4s to iOS 5.1. Since the update, I am not able to make calls or send sms. I reset network settings several times but not luck. I have also turned off data and 3G but no luck.
Could anyone please help me? Right now, my iPhone 4s is use-less.
thanks
terryhomeI have a similar problem...iMessage is not working for me. I can only send SMS and when I try to activate it an error will come up. It won't even let me use my Apple ID.
Does anyone know how to fix this? I've already tried resetting everything and it just won't work! -
Problem compiling my first program; Please Help me!
Please HELP, what am I doing wrong?
For over 5hours I have been trying to figure out how to compile a simple Hello world program using sdk1.3.1_02/j2re1.3.1_02 and I am getting the following errors: helloworld.java:2 cannot resolve symbol
symbol : class string
location : class helloworld
cannot reolve the string symbol
symbol : class out
location : package system
I want to program in java so badly but I am trying to get my environment set so that I can take off. To compile my first program has been a disaster!!
This is my path:
SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK1.3.1_02\BIN
Thanks very much in advance
::(Java is case sensitive,
use String instead of string. and System.out instead of system.out
Sudha -
Return first row entered based on date column
I'm trying to select the first entered row in a table, as judged by the datetime column. If more than one row has the same date and time, then only one row should be returned (any row having that datetime is fine). Some processing will occur on that row and then it will be deleted. The select statement is used thereafter to select the next (first) entered row in the table, etc. This way, the rows are processed first-in first-out (FIFO) style. Here's my example table:
create table my_table
datetime date,
firstname varchar2(50)
insert into my_table(datetime, firstname) values(to_date('2012-04-02 11:00:00', 'YYYY-MM-DD HH24:MI:SS'),'ken');
insert into my_table(datetime, firstname) values(to_date('2012-04-02 11:00:00', 'YYYY-MM-DD HH24:MI:SS'),'john');
insert into my_table(datetime, firstname) values(to_date('2012-04-02 11:00:00', 'YYYY-MM-DD HH24:MI:SS'),'sue');
commit;
Here's my example select statement, which returns simply one row of the above, since all are the same date and time:
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table )
AND rownum = 1;
My question is, if I use the following
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table );
It returns all 3 rows:
DATETIME FIRSTNAME
02-APR-12 11:00:00 ken
02-APR-12 11:00:00 john
02-APR-12 11:00:00 sue
So, wouldn't setting rownum = 2 return john, and rownum = 3 return sue? For example,
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table )
AND rownum = 2;
return no rows. I just want to make sure I'm understanding how the select statement above works. It seems to work fine for returning one row having the minimum date and time. If this is always the case, then everything is fine. But I wouldn't have expected it not to return one of the other rows when rownum is 2 or 3, which makes me question why? Maybe I can learn something here. Any comments much appreciated.
Edited by: tem on Apr 2, 2012 2:06 PMHi,
tem wrote:
... So, wouldn't setting rownum = 2 return john, and rownum = 3 return sue? For example,, ROWNUM
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table )
AND rownum = 2;
return no rows. I just want to make sure I'm understanding how the select statement above works. It seems to work fine for returning one row having the minimum date and time. If this is always the case, then everything is fine. But I wouldn't have expected it not to return one of the other rows when rownum is 2 or 3, which makes me question why? Maybe I can learn something here. Any comments much appreciated.ROWNUM is assigned as rows are fetched and considered for inclusion in the result set. If the row is not chosen for any reason, the same ROWNUM will be reused with the next row fetched. ROWNUM=2 will not be assigned until a row with ROWNUM=1 has been included in hte result set.
So, in your example:
SELECT *
FROM my_table
WHERE datetime = ( select min(datetime) from my_table )
AND rownum = 2;Say the first row that happens to be fetched has firstname='ken'. It is assigned ROWNUM=1, and fails the WHERE clause condition "WHERE rownum = 2".
Say the next row fetched has firstname='john'. ROWNUM=1 hasn't been used yet, so this row is also assigned ROWNUM=1, and it fails the WHERE clause for the same reason. Likewise with the next row; it also is assigned ROWNUM=1, and it also fails.
When using ROWNUM in a WHERE clause, you almost always want to say "ROWNUM = 1" or "ROWNUM <= n".
You could also use the analytic ROW_NUMBER function:
WITH got_r_num AS
SELECT datetime, firstname
, ROW_NUMBER () OVER (ORDER BY datetime) AS r_num
FROM my_table
SELECT datetime, firstname
FROM got_r_num
WHERE r_num = 1
;Here, all values of r_num are available, so it would make sense to say things like "WHERE r_num = 2" or "WHERE r_num >= 2".
Edited by: Frank Kulash on Apr 2, 2012 5:31 PM
Added to explanation.
Maybe you are looking for
-
I have money from gift cards on my account do i need credit card?
I have 64$ on my account when i try to download music it asks me to put in a credit card information why can't i use the money i already put in?
-
Unable to display employee image in pdf forms from webdynpro?
hi friends, i am using webdynpro application and ADOBE forms. i designed adobe form with 3 fields. IM_VORNA, IM_NACHN, IM_PHOTO. I created one interface of adobe form also with the 3 fields of which specified above. And i am using webdynpro applicati
-
5508 WLC on 7.4MR2- Clients getting Disconnected using CWA
We are experiencing an issue with clients getting disconnected/time out from a wlan doing CWA. The clients are iphones. A debug client shows the error(Unknown Policy Timeout). This particular WLAN is used for provisioning with ISE. ISE shows the us
-
How to make our own Ajax based custom compnent
hi i want to make my own Ajax based custom compnent. i know JSF custom comppnents, but dont know how to add Ajax functionality in it. what should i have to learn for this. can any one guide me. if some one have code example it will be appreciated br,
-
I do not see the word that i have to type in to prove i am not a robot what do i do on my laptop
I do not see the word that i have to type in to prove i am not a robot what can i do on my laptop to setup firefox sync