473,382 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

OracleConnection not returning correct number of rows

I have an query I run against an Oracle Connection.
I have these objects, an event table and a table to map my objects to my events.
My select statement selects the most recent event for each object and if it meets certain requirements then the object's id is returned.

something like
Expand|Select|Wrap|Line Numbers
  1. select o.id from
  2. objects o, events e, objecteventmap oem,
  3. (select max(date), o.id from events e, objects o, objecteventmap oem 
  4. where e.id = oem.eventid and o.id = oem.objectid) ss
  5. where
  6. o.id = oem.objectid and
  7. e.id = oem.eventid and
  8. o.id = ss.id and
  9. e.date = ss.date and
  10. <more where clause stuff>
  11.  
The problem is when I run the query in Oracle SQL Developer I get 42 rows (the correct result set) and when I create an OracleCommand object and put that in as my query in my C# I get 30 rows (a reduced result set).

Help!

Edit:
Ok so I broke apart my query to get a better look at the data. In .net for some reason my Max date is getting the wrong date for some events. I am getting the ides of march instead of the correct date for a bunch of them. The weird thing is I do not have March 15th entered in my data anywhere....
Sep 15 '09 #1
7 1718
Plater
7,872 Expert 4TB
Have you checked to see if more then one table is being returned?
Edit: Oh it was date trouble. Are you making sure your date formats come out correctly?
Sep 15 '09 #2
I had a look into the ungrouped data. In SQL Developer I'm getting 193 rows in .Net I'm getting 239 rows :(
Could this be a driver issue? It is like my join is all messed up.
Sep 15 '09 #3
Ok, the select * on my mapping table gives different row counts .Net than when in SQl Developer.

Could this be a garbage collection issue?
Sep 15 '09 #4
Plater
7,872 Expert 4TB
Have you tried making the SQL code into stored procedure? (Oracle has those right? I never got to in-depth with oracle)
Sep 15 '09 #5
Ok, I think perhaps it might be a commit type issue.
Sep 15 '09 #6
My co-worker says it is a pain in the butt to get a result set returned from an oracle sp.
Sep 15 '09 #7
Ok I think I solved it... it just took 2 days...
I don't think my deletes were being committed to the DB. At some point I started getting the correct rows in .Net. I think this happened because I was not putting my OracleCommand object within a transaction... I hope.
Anyways to prevent this use this from happening again I am doing this.
Expand|Select|Wrap|Line Numbers
  1.         OracleCommand com = GetCommand(myCommand);
  2.             com.Connection.Open();
  3.             OracleTransaction ot = com.Connection.BeginTransaction();
  4.             com.Transaction = ot;
  5.             try
  6.             {
  7.                 com.Prepare();
  8.                 com.ExecuteNonQuery();
  9.                 com.Transaction.Commit();
  10.             }
  11.             catch
  12.             {
  13.             }
  14.             finally
  15.             {
  16.                 com.Connection.Close();
  17.             }
Sep 15 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mike | last post by:
I have a view that will return say 5000 records when I do a simple select query on that view like. select * from vw_test_view How can I set up my query to only return a certain # of...
4
by: Roger Redford | last post by:
Dear Experts, I'm attempting to marry a system to an Oracle 817 datbase. Oracle is my specialty, the back end mainly, so I don't know much about java or javascript. The system uses javascript...
4
by: Randy | last post by:
I have a DataTable in a DataGrid. If I click on the DataGrid, HitTestInfo in dataGrid1_MouseDown returns a Row and Column number. I can use the Row number to say: DataRow dr = dataTable.Rows;...
4
by: Earl T | last post by:
When I try to get the netscape version for version 7, I get the HttpBrowserCapabilities class returning the version as 5 and not 7. (see code and output below) CODE HttpBrowserCapabilities...
0
by: Sparky Arbuckle | last post by:
The function below works in that it returns the correct data back to the dataset for 2 of the rows in my datalist: A1 - A - 1 A1 - A - 2 A1 - A - 3 A1 - B - 1 A1 - B - 2 A1 - C - 1 A1 - C -...
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
11
by: jza | last post by:
Hello all, I am fairly new to c, coming from a Java background. I am working on a mathematical program and I have a function that needs to return a 2-d array. After some web searching, I have...
6
by: Peter K | last post by:
Hi - is it the case that OracleConnection does not call close when the connection is disposed? For example, I use this sort of construct: using (OracleConnection conn = GetConnection()) {...
3
by: codefragment | last post by:
Hi I have a chunky bit of sql that I will want to call from a number of places. It will return a few thousand rows. Whats the best way of structuring this? 1) I initially thought of using...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.