Josh-CO Dev

Solving the worlds problems one line of code at a time.


Leave a comment

ORA-24338: Statement Handle Not Executed

I ran into some problems yesterday when I recompiled an application for the first time in a few months. I started getting an Oracle error stating: Statement handle not executed. Simple enough. My concern was that my database code had not changed since March, only my application code. This code is pretty complex anyway.

I have to fire off a thread that runs a big process that takes about 15 minutes and dumps the data into a table. Another thread then monitors the table and waits for the datadump to finish. After staring at my code for a while, I found this:

 PROCEDURE createReportingData (
pYear IN NUMBER,
pMonth IN NUMBER,
pDay IN NUMBER,
pUnitID IN VARCHAR2,
pGenerate IN NUMBER,
pDaily IN NUMBER)
presults OUT treturncursor)
IS
statusout INTEGER;
error_msg VARCHAR2(1000);
v_strSql VARCHAR2(4000);
v_strSql2 VARCHAR2(500);
BEGIN

The problem is the presults OUT treturncursor. My logic was expecting to output a cursor, which it used to do before the change in March. I simply commented out this line in the spec and body, and now everything works like a champ.

Advertisements


Leave a comment

Developer Learning Program – First Meeting

Apparently our first meeting instituting the developer learning program was a huge success. We gave a quick overview on LINQ and presented a live demo where we wrote a linq query, did some conditional statements, a few joins, and showed off some of the LINQ extensions. It was well received by both developers and management and really seemed to open up some eyes. Be it for better or worse, this may get us too much attention!

 

The only issues we really ran into is that it is really a change in thinking for our devs. We do things the old way. We pass all db calls through a webservice and into a data layer where stored procs are called and returned via a dataset. Honestly, LINQ is near useless in this type of environment. We explained how this methodology is pretty “chatty” and will result in slower response times. Unless you are posting data frequently or have a real time app, you can generally pull larger sets of data one time and then filter the data via LINQ. This is where it will fit in with our organization.


Leave a comment

Developer Learning Program – LINQ

Well, today marks the launch of our Developer Learning Program. My colleague and I have chose LINQ for our first topic and he will be giving a quick presentation and providing a real-time demo through Live Meeting. It will be given to our team, plus some management and our architect. With any luck, things will go smoothly and we can continue these training sessions every two weeks.

Here is some information my colleague wrote up as a handout:

LINQ is used to run queries against data sources such as lists, collections, relational data bases, xml, and entities (business objects) to name a few. The .NET objects representing the data sources must implement the IEnumerable<T> interface (or any derived interfaces such as IQueryable<T>) in order to run a LINQ query against them.

 

Key Programming Concepts desired to use LINQ proficiently:

  • SQL Syntax – .NET Generics – .NET Extension Methods – .NET Lambda Expressions & Anonymous Functions

 

CurrentOrders = List<Order> 
OrderId Customer DateEntered
1 ABC-Manufacturing 06/15/2010
2 Prime Time-Studios 09/29/2011
3 ABC-Manufacturing 01/25/2011

 

CurrentOrderDetails = List<OrderDetail>
OrderDetailId OrderId Product
9000 1 iPad 2
9101 2 2TB Hard drive
9102 3 Monitor

 

Exercise 1: Select OrderId “2” from the list.

Option 1:where” Clause

var order = (from ord in CurrentOrders where ord.OrderId == 2 select ord).FirstOrDefault();

var listOfOrders = (from ord in CurrentOrders where ord.OrderId == 2 select ord).ToList();

 

Option 2:Where” Extension with Lambda expression

var order = CurrentOrders.Where(ord => ord.OrderId == 2).FirstOrDefault();

 

Note: “ord” refers to the current order while enumerating the list as it does in a foreach loop.

foreach (Order ord in CurrentOrders) {

   if(ord.OrderId == 2) {…};

}

 

Exercise 2: If list is a datatable instead, return the rows where the customer is ABC-Manufacturing

Option 1: Projection with Anonymous type

var rows = (from ord in CurrentOrders.AsEnumerable()

                  where ord.Field<string>(“Customer”) == “ABC-Manufacturing”

                   select new {OrderId = ord.Field<int>(“OrderId”),

                                        Customer = ord.Field<string>(“Customer”),

                                        DateEntered = ord.Field<DateTime>(“DateEntered”)});

 

Exercise 3: Return the Customer, Product, & DateEntered order for customer Prime Time -Studios

Option 1: Projection with “join” clause and Anonymous type

var orders = (from ord in CurrentOrders

                          join d in CurrentOrderDetails on ord.OrderId equals d.OrderId

                     where ord.OrderId = 2

                      select new {ord.Customer, d.Product, ord.DateEntered});

 

Good Sites:

The Basics: http://msdn.microsoft.com/en-us/library/bb397906.aspx

101 LINQ Samples: http://msdn.microsoft.com/en-us/vcsharp/aa336746