473,839 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OracleConnectio n not returning correct number of rows

39 New Member
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 1753
Plater
7,872 Recognized Expert Expert
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
BiffMaGriff
39 New Member
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
BiffMaGriff
39 New Member
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 Recognized Expert Expert
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
BiffMaGriff
39 New Member
Ok, I think perhaps it might be a commit type issue.
Sep 15 '09 #6
BiffMaGriff
39 New Member
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
BiffMaGriff
39 New Member
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
1703
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 records, say the first 300?
4
7258
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 to make ODBC calls to the db. The particular system I'm working with, will not work with an Oracle stored procedure I'm told. However, it
4
5445
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; Of course, I get completely the wrong row of data if the user has sorted the table by clicking any of the column headers.
4
2843
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 bc; string s; bc = Request.Browser; ....
0
895
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 - 2
7
2200
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 another. I have tried declaring them as shared, public, friend, etc and I always get an error stating that something is not valid on a local variable declaration. For example, in the following code for Sub DataGrid_Select, I have CurrentID and...
11
2058
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 determined that in c, it is better to just pass the array in the function. Since arrays are passed by reference, I expected for the updated array to be passed back with the correct values filled in, however, only the first row of the array is returned...
6
4507
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()) { using (OracleTransaction tx = conn.BeginTransaction()) { using (OracleCommand command = conn.CreateCommand())
3
4393
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 nested stored procedures and returning the result in a temporary table. However the scope of the temporary table seems to be limited to the stored procedure its created in so unless I create the temporary table in every stored
0
9855
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9697
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10907
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10586
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10293
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7828
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.