Showing posts with label function. Show all posts
Showing posts with label function. Show all posts

Wednesday, March 21, 2012

Microsoft Great Plain integration application and new tables on sql

In dexterity iam using table_compare() function to check if tables in datasource and dictionary are same but its not picking up the primary key change but it does pick up the column change

any suggestion

thanks

This forum is for SQL Server Integration Services. Are you trying to integrate Great Plains with another system via SQL Server Integration Services? I read your question as being about Great Plains only, so this is probably not a good forum, you may have better luck on a Great Plains specific forum.

Friday, March 9, 2012

Method/Definition inside T-SQL

Did anybody hear if it's possible to define something like a
method/function/macrodefinition inside T-SQL? Particularly I have a few
SELECTs inside one T-SQL script and in most of them the WHERE CLAUSE is
absolutely same, but the retrieving results should be different and
according to these results the data flow should be different, so I can't
merge all these queries into one because the logic depends on the previous
results. The idea was to define this WHERE (...) as something to use it in
all queries inside this T-SQL. But I'm afraid that the standard T-SQL
doesn't allow us to do that because there are column names in this WHERE
clause. Temporary table? It will be huge and makes no sense.
Just D.Results from one table depending on results from another table sounds like a
join or union to me. Can you provide a more concrete example, e.g. table
structure, sample data, desired results?
"Just D." <no@.spam.please> wrote in message
news:nR6af.65318$WR2.43229@.fed1read03...
> Did anybody hear if it's possible to define something like a
> method/function/macrodefinition inside T-SQL? Particularly I have a few
> SELECTs inside one T-SQL script and in most of them the WHERE CLAUSE is
> absolutely same, but the retrieving results should be different and
> according to these results the data flow should be different, so I can't
> merge all these queries into one because the logic depends on the previous
> results. The idea was to define this WHERE (...) as something to use it in
> all queries inside this T-SQL. But I'm afraid that the standard T-SQL
> doesn't allow us to do that because there are column names in this WHERE
> clause. Temporary table? It will be huge and makes no sense.
> Just D.
>|||You could wrap your SQL inside a stored procedure, or even a user-defined
function. It's possible to parameterize either to make them flexible, and a
n
sp or udf is roughly equivalent to a method.
It's even possible to schedule a SQL script as a job; your DBA will be able
to help you with that.
Tell us a bit more about what you want to do and we'll try and help.
Damien
"Aaron Bertrand [SQL Server MVP]" wrote:

> Results from one table depending on results from another table sounds like
a
> join or union to me. Can you provide a more concrete example, e.g. table
> structure, sample data, desired results?
>
> "Just D." <no@.spam.please> wrote in message
> news:nR6af.65318$WR2.43229@.fed1read03...
>
>

method call works from .Net form and not from SQL CLR - EnterpriseLibrary used

Hello

I created a wrapper class for a function, and exposed it through CLR. However, if I call this function form SQL it blows up but if I call directly from a test Windows Form the call works fine.

The blow up is related to EnterpriseLibrary.Data, where my Queue class uses that library to do all data access call ops

Here's my wrapper class:

namespace inlineCLRsql{

public static class Wrapper{

public static void CallQueueEntry(int queueId, int deskNo, int missed){

inLineLib.Queue oQueue;

inLineLib.QueueEntry oQueueEntry;

oQueue = new inLineLib.Queue(queueId);

oQueueEntry = oQueue.callQueueEntry(deskNo, false);

Microsoft.SqlServer.Server.SqlContext.Pipe.Send(oQueueEntry.queueNum.ToString());

}

}

And this is my CLR SQL creation code:

CREATE PROC sp_CallQueueEntry

@.queueId int,

@.deskNo int,

@.missed int

AS

EXTERNAL NAME inLineLib.[inlineCLRsql.Wrapper].CallQueueEntry

GO

sp_CallQueueEntry 4,2,0

Here is what I get as a result

System.NullReferenceException: Object reference not set to an instance of an object.

System.NullReferenceException:

at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseConfigurationView.get_DefaultName()

at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseMapper.MapName(String name, IConfigurationSource configSource)

at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfigurationNameMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id)

at Microsoft.Practices.ObjectBuilder.BuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)

at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies)

at Microsoft.Practices.ObjectBuilder.BuilderBase`1.BuildUp[TTypeToBuild](IReadWriteLocator locator, String idToBuild, Object existing, PolicyList[] transientPolicies)

at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IReadWriteLocator locator, IConfigurationSource configurationSource)

at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUp[T](IConfigurationSource configurationSource)

at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.NameTypeFactoryBase`1.CreateDefault()

at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase()

at inLineLib.Queue.getNextQueueEntry(Int32 servedBy)

at inLineLib.Queue.callQueueEntry(Int32 servedBy, Boolean callMissed)

at inlineCLRsql.Wrapper.CallQueueEntry(Int32 queueId, Int32 deskNo, Int32 missed)

What can I do to fix this?

Cheers

M

This is almost a total guess - I've never used EntLib. However, I found some one else hit this issue when EntLib was not able to find the database in the application config file: http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21833370.html

This is likely to be the same problem you're facing. I believe you can solve this by running the Enterprise Library Config tool and specify your config file as sqlservr.exe.config in the same directory as sqlservr.exe. Or you can try copying and renaming the config file your Windows Form app is using.

Hope this works.

Steven

Monday, February 20, 2012

Message Box In Reporting services

Hello,

I am using sql reporting services 2000. I have tried to put a message box in my reports using a VB function. If the report contains 10 pages, the message box pops up 10 times. What do i need to do to make the message box pop up only once during the start of the report? Also, if I click CANCEL(vbOkCancel), the cursor should go back to the parameter box prompting me to enter a parameter again. In this case, I enter a date and check whether it is a MONDAY or not. VB function is as below...

Function CheckDay(ByVal S As DateTime) As Integer
Dim GivenDate as Date
Dim GivenDay as Integer
Dim intMsg as Integer
GivenDate = S
GivenDay = WeekDay(GivenDate)
If NOT GivenDay = 2
intMsg = MsgBox("The selected day is not a Monday", VbOKCancel, "The selected date is not a Monday.")
End IF

Return GivenDay
End Function

Thanks......

I recommend to use the ReportViewer control (www.gotreportviewer.com) of VS 2005 instead and build your own parameter user interface to perform the validation. Once, the validation succeeds, you would use the ReportViewer control to display the report.

The approach you are currently trying won't work. Also keep in mind that the message box pop up will only work when running that report in preview. It won't work for reports deployed on a report server.

-- Robert