Retrieving SQL server global variable values

Posts   
 
    
imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 20-Jul-2011 16:19:26   

LLBL Gen Pro v 2.6/SQL Server 2008/.net 3.5/Self Servicing

I need to extract values for some of the SQL Server global variables (like @@VERSION). Can this be done via LLBL? Thank you

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Jul-2011 17:39:43   

Do you need to extract these independant of any query? Or retrieved along some queries?

You can have either a database function that return these variables and use DBFunctionCalls within a DynamicList to retrieve them.

Or a Stored Procedure, and map it to SPCall in LLBLGen.

imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 20-Jul-2011 18:02:36   

Hi Walaa,

Some place I will do independent but i may have to retrieve it along some query too. I tried to add a new EntityField calling DbFunction for global variable but the query seem to ignore that particular EntityFiled because when I look at SQL Profiler, it does not have column (containing global variable) in SELECT clause of query.

Can you show an example using DynamicList? Hopefully that will help me determine what I may be missing.

imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 20-Jul-2011 20:04:40   

Actually using DbFunction seem to append paranthesis with the global variable name @@VERSION which SQL Server does not seem to like

This is how I am setting up DbFunction in code

DbFunctionCall FCall = new DbFunctionCall("@@VERSION", new object[0]);

below is the query that is been triggered that give me error from SQL Server

SELECT DISTINCT @@VERSION() AS VersionNo, ClientName FROM Client

I have also tried below without any luck.

DbFunctionCall FCall = new DbFunctionCall("@@VERSION", null);

Any ideas how to tell LLBL not to add paranthesis here?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 20-Jul-2011 20:52:16   

Maybe my words were not clear, sorry. I meant you should have a database function that returns the parameter required. Then use a DBFunctionCall for it.

imakimak
User
Posts: 62
Joined: 18-Mar-2010
# Posted on: 20-Jul-2011 22:39:49   

Got you. No worries