I am having to fix another developes code who left and I am consused as to how to do so... here is the issue

He gets the employee id from the Report Menu table. Right now a bunch of users have the same employee id because they are contractors. He grabs the login id from their session, uses it to get the employee id from ReportMenu, then uses that employee id to grab their first and last name from the EMPLOYEE table. The first and last name for the generic employee id is Dummy Contractor. However, in the report menu table, there is an EmpName field that we can use instead for the dummy contractor employee id. It has the person's real last and first name.

So I think I need to do an if statement in the second set of sql statements, though it was mentioned that I might need to create a method or something for the first select statement and call that unconditionally at first, and then in the second select statement call that method condtionally... if this is correct, how do I do that???

btw... you can ignore the middle select because that has to be there between the two other select statements to allow permission into Lawson.
---- (SELECT RTRIM(AcctUnit)"; sQuery += " FROM RptRollupMaintenance)

It is just the first and third select that I am having the conundrum with...

Oh, and when you catch an exception you really ought to log the stack trace.

After those changes ( and the code tags) we might actually be able to see what's going on.

03-31-2010, 10:02 AM

RamyaSivakanth

Another suggestion here is ,if we want to debug easily always use column names for retrieval instead of index...

03-31-2010, 10:33 AM

masijade

Quote:

Originally Posted by RamyaSivakanth

Another suggestion here is ,if we want to debug easily always use column names for retrieval instead of index...

No, that is more of a "personal style" suggestion than it is any kind of valid "best practice" suggestion. In performance, using the index is actually quicker (there is no name lookup to determine the index, which is what is used when the retreival is actually made). Not that it is enough to have any impact except under the "heaviest" of use conditions.

03-31-2010, 11:35 AM

Tolls

Quite, if you've listed your returned values (as you should) rather than simply done "SELECT *" then there's no reason not using the index for the column.

03-31-2010, 12:39 PM

RamyaSivakanth

might be index wise performance wise some benefit will be there,but if we have n number of columns in table,then name wise retreival is always better for a new person to debug the code.

04-10-2010, 03:19 PM

j2me64

Quote:

Originally Posted by Steffi1013

He gets the employee id from the Report Menu table. Right now a bunch of users have the same employee id because they are contractors. He grabs the login id from their session, uses it to get the employee id from ReportMenu, then uses that employee id to grab their first and last name from the EMPLOYEE table. The first and last name for the generic employee id is Dummy Contractor. However, in the report menu table, there is an EmpName field that we can use instead for the dummy contractor employee id. It has the person's real last and first name.

why don't you solve the above problem through a view that joins the reportmenu with the employee table? this view could give you back the first and last name from the report menu table if the id exists or Dummy Contractor if the id doesn't exist.