Tracing for Oracle package

Posts   
 
    
YvesVD
User
Posts: 177
Joined: 19-Oct-2006
# Posted on: 04-Apr-2011 07:40:03   

Hi,

How can I configure the tracing in order to see info about the in and out parameters from the stored procedure I call ?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 04-Apr-2011 10:25:34   
YvesVD
User
Posts: 177
Joined: 19-Oct-2006
# Posted on: 04-Apr-2011 12:54:03   

Walaa wrote:

Did you check Troubleshooting and debugging?

My config : <switches> <add name="OracleDQE" value="4" /> <add name="ORMGeneral" value="0" /> <add name="ORMStateManagement" value="0" /> <add name="ORMPersistenceExecution" value="0" /> </switches> I see all select, update and inserts but nothing for Stored procedures calls.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 04-Apr-2011 16:35:41   

You are correct.

The DQE switches only show the queries formulated by the LLBLGen Pro Frameworl, which can't be traced by code otherwise.

Calling an SP, there is not query get to be formulated by LLBLGen Pro, and hence you can add your own tracing in your code which calls the SPCall method, to send parameter values to the trace output.

YvesVD
User
Posts: 177
Joined: 19-Oct-2006
# Posted on: 05-Apr-2011 09:08:33   

Walaa wrote:

You are correct.

The DQE switches only show the queries formulated by the LLBLGen Pro Frameworl, which can't be traced by code otherwise.

Calling an SP, there is not query get to be formulated by LLBLGen Pro, and hence you can add your own tracing in your code which calls the SPCall method, to send parameter values to the trace output.

Do you have a sample how I can modify the template for ActionProcedures and RetrievalProcedures in order to produce the tracing ? It would be nice to integrate that in the next patch.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Apr-2011 10:00:32   

Stored proc tracing isn't currently available. In v3.1, stored procedures are executed using DataAccessAdapterBase.CallActionStoredProcedure and CallRetrievalStoredProcedure. These methods get the stored proc name, parameters and what to fill passed in (in the case of a retrieval proc).

To add the tracing, you could override these two methods in a partial class of the dataaccessadapter and add the tracing calls there. You can trace easily with TraceHelper.WriteLineIf(<switch>.<flag>, caption, message), see the TraceHelper class in the runtime lib for details.

Frans Bouma | Lead developer LLBLGen Pro
YvesVD
User
Posts: 177
Joined: 19-Oct-2006
# Posted on: 05-Apr-2011 13:10:07   

Otis wrote:

Stored proc tracing isn't currently available. In v3.1, stored procedures are executed using DataAccessAdapterBase.CallActionStoredProcedure and CallRetrievalStoredProcedure. These methods get the stored proc name, parameters and what to fill passed in (in the case of a retrieval proc).

To add the tracing, you could override these two methods in a partial class of the dataaccessadapter and add the tracing calls there. You can trace easily with TraceHelper.WriteLineIf(<switch>.<flag>, caption, message), see the TraceHelper class in the runtime lib for details.

Thanks. I added my code here under. Which method should I override for Retrieval Procude fetched into TypedViews ?

adapter.FetchTypedView(typedView,
 RetrievalProcedures.Get...CallAsQuery(...));

Do you plan to integrate SP tracing into the future ?

        public override int CallActionStoredProcedure(string storedProcedureToCall, System.Data.Common.DbParameter[] parameters)
        {
            var trace = new StringBuilder();
            trace.AppendLine("Procedure name: " + storedProcedureToCall);
            if (parameters != null)
                foreach (var param in parameters)
                {
                    if (param.Direction == ParameterDirection.Input || param.Direction == ParameterDirection.InputOutput)
                        if (param.Value == null || param.Value == DBNull.Value)
                            trace.AppendLine("Input parameter " + param.ParameterName + ": null");
                        else
                            trace.AppendLine("Input parameter " + param.ParameterName + ": " + param.Value);
                }

            var stopwatch = Stopwatch.StartNew();

            try
            {
                return base.CallActionStoredProcedure(storedProcedureToCall, parameters);
            }
            finally
            {
                stopwatch.Stop();

                if (parameters != null)
                    foreach (var param in parameters)
                    {
                        if (param.Direction == ParameterDirection.Output || param.Direction == ParameterDirection.InputOutput)
                            if (param.Value == null || param.Value == DBNull.Value)
                                trace.AppendLine(string.Format("Output parameter {0}: null", param.ParameterName));
                            else
                                trace.AppendLine(string.Format("Output parameter {0}: {1}", param.ParameterName, param.Value));
                    }

                trace.AppendLine(string.Format("Call duration (milliseconds): {0}", stopwatch.ElapsedMilliseconds.ToString()));

                TraceHelper.WriteLineIf(true, trace.ToString(), "DataAccessAdapterBase.CallActionStoredProcedure");
            }
        }

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 05-Apr-2011 21:23:16   

It should be CallRetrievalStoredProcedure. I don't think we have any plans at present to add tracing to the stored proedure calls, but we have noted it as a feature request.

Matt

YvesVD
User
Posts: 177
Joined: 19-Oct-2006
# Posted on: 20-Feb-2012 09:21:27   

Hi,

In attachment you will find an implementation of tracing for stored procedures. You can use it in the next version or every body could integrate it in their own projects.

Regards.

Attachments
Filename File size Added on Approval
DataAccessAdapter.custom.cs 7,713 20-Feb-2012 09:21.43 Approved
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 20-Feb-2012 15:28:41   

Thanks for sharing simple_smile Tracing for proc calls hasn't been on the table for v3.5 (and we had to move many features back already for this release). Everyone who wants to add it can use the attached code indeed or of course use our profiler.

Frans Bouma | Lead developer LLBLGen Pro