Showing posts with label project. Show all posts
Showing posts with label project. Show all posts

Thursday, March 29, 2012

calling stored procedure in project

hey all

I am very new to stored procedures and would like some clarification please

I have a stored procedure written by someone else

I generally use SQL Server Business Intelligence Studio.

I am designing a report and have called this sp

exec GetTicketsSnapshot (being the name of sp)

1 window only is populated?

if I run this in sql Server Management Studio it populates 3 windows which is what I would expect to see

can someone explain?

thanks

Jewel,

Do you mean that you have 3 different resultset in the same stored procedure? I'm just trying to get a clearer picture of what your issue is.

Ham

|||

hey Ham

Yes that's exactly what I mean.

But it isn't even giving the full result of the first resultset? either

thanks

|||

hey Ham or someone else

Any clues on what I can do here

I have updated since eg I have in my stored procedure above each resultset @.resultset = '0' (// '1' // '2')

I have made three separate datasets to refer to these - and if I run them I get the three separate results

but in my properties of my datasets - the fields are all the same eg they match resultset1

therefore I error in preview - as fields are not there as such.

cheers

|||

Hi,

ok, first of all, only 1 recordset is supported for the reporting services. If you are relying on the logic on the procedure and will not be able to split up the one procedure into three, you will probably have to do the approach you mentioned with providing something like an indexer and giving back only the relevant information to the client / Reporting services. The reporting services interface cannot populate the information for the procedure as it is not aware of the logic that you built in (with selecting one resultset of the three, so for the "discovery of the expected" resultset, the best thing would be to comment out the relevant parts that you do not want to have in the resultset, querying the information from the reporting services interface (that you will have the fields available in the reporting services intefaces) and then set back the procedure to the generic solution. Unfortunately this is the only approach I know. In a former project I had to deal with dynmamic SQL which led me to write the queries in the procedure (without dynamic SQL) querying the meta data of the resultset and the commenting this out to leave the dynamic SQL solution.

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

sql

Tuesday, March 27, 2012

Calling SSRS web services from Java using Axis

Hi,

I'm working on a project where I'll need to call the SSRS web services from a java servlet. We are using the Axis implementation of the SOAP protocol.

I've previously used SSRS web services from C#, but not from Java. Before I start this endeavor does anyone have any bits of wisdom they'd like to share that's going to make this easier?

Also, I've searched for tutorials, samples, source code, etc.. for this situation (that is, using java to call SSRS web services), but can't find anything available. Does anyone know where I can find resources such as these for this particular technology pairing?

Thanks for the help.

-M

Try WSDL2Java tool to create a java proxy to the reporting services.

The WSDL is accessible from one of these url depending on the version(2000 or 2005) and flavor (management or execution) of the service

http://<server>/reportserver/reportservice.asmx?wsdl

http://<server>/reportserver/reportservice2005.asmx?wsdl

http://<server>/reportserver/reportexecution2005.asmx?wsdl

An example on accessing .NET web services (not SSRS specific) from Java is available here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/jdni_ch08.asp

Thursday, March 8, 2012

Calling a child package from the Main Package

I need to pass variables from the parent package to the child package. I got this to work in a small test case. But in the actual project, I get an error when I try to do that. The parent package's log has this error :

Error: Error 0xC0012050 whike loading package file "c:\.......". Package failed validation from the ExecutePackage task. The package cannot run..

There's nothing more to go on here in the log.

Any ideas ?

-chiraj

May be you will have to check the following

1) Check if the child package is working fine - if you execute it separately with the required input parameters.
2) Guess your child package is stored in the filesystem - Check if the calling package's identitiy has got access to the folder where the child package resides.

Thanks,
Sankaranarayanan MG

|||

I got it to work. There were some Script tasks that were not getting the variables. Once I fixed that, it started working. Now I need to make sure it works consistently. I've read elsewhere that it suddenly chokes.

Thanks

-chiraj

|||

I forgot to mention this. The more important reason why it started working is when I set the property "ExecuteOutOfProcess" to true. By default it is false. I guess there are some memory /thread issues and it was choking.

-chiraj

|||For me the package isolation level was "unspecified" and the TransactionOption was "not supported". Changing them to "Serializable" and "Supported" did the job.

Sander

Calling a child package from the Main Package

I need to pass variables from the parent package to the child package. I got this to work in a small test case. But in the actual project, I get an error when I try to do that. The parent package's log has this error :

Error: Error 0xC0012050 whike loading package file "c:\.......". Package failed validation from the ExecutePackage task. The package cannot run..

There's nothing more to go on here in the log.

Any ideas ?

-chiraj

May be you will have to check the following

1) Check if the child package is working fine - if you execute it separately with the required input parameters.
2) Guess your child package is stored in the filesystem - Check if the calling package's identitiy has got access to the folder where the child package resides.

Thanks,
Sankaranarayanan MG

|||

I got it to work. There were some Script tasks that were not getting the variables. Once I fixed that, it started working. Now I need to make sure it works consistently. I've read elsewhere that it suddenly chokes.

Thanks

-chiraj

|||

I forgot to mention this. The more important reason why it started working is when I set the property "ExecuteOutOfProcess" to true. By default it is false. I guess there are some memory /thread issues and it was choking.

-chiraj

|||For me the package isolation level was "unspecified" and the TransactionOption was "not supported". Changing them to "Serializable" and "Supported" did the job.

Sander

Calling a .Net application via a COM wrapper in SQL Server 2005

I have a .Net 1.1 assembly (written using C# in VS2003). This assembly has
the option COM Interop set to True. Once built, the VS2003 project solution
produces a .tlb file. A setup is produced (from within VS2003) that includes
the dll and tlb files. These are installed on a PC (running on Windows
2000/2003 server/Windows XP Pro) that has SQL Server 2000 running on it (with
the latest SQL Server 2000 Service Pack). A trigger fired from one of the
tables in our own database (within SQL Server 2000) makes the calls to the
COM wrapped assembly.
CREATE TRIGGER [UserProfile_Trigger1] ON [UserProfile]
FOR INSERT, UPDATE,DELETE
AS
DECLARE @.hr int
DECLARE @.factory int
DECLARE @.xalert int
DECLARE @.response int
DECLARE @.errMsg varchar(8000)
DECLARE @.success bit
EXEC @.hr = sp_OACreate 'csSOAPClient2.CXalertsApiSoapClient', @.factory OUTPUT
select @.hr
IF (@.hr <> 0 )
BEGIN
EXEC sp_displayoaerrorinfo @.factory , @.hr
RETURN
END
EXEC @.hr = sp_OAMethod @.factory, 'getXalertsInstanceUsingSOAPDefaults',
@.xalert OUTPUT, 'rmi://localhost:50001/com/xalert/server/api/XAlertsFactory',
'http://localhost:8080/axis/services/xalertsport'
IF (@.hr <> 0 )
BEGIN
EXEC sp_displayoaerrorinfo @.factory , @.hr
RETURN
END
EXEC @.hr = sp_OAMethod @.xalert, 'queueByID', @.response OUTPUT, 1, '',
'MyXalerts55_030506_ss', 1100
IF (@.hr <> 0 )
BEGIN
EXEC sp_displayoaerrorinfo @.xalert , @.hr
RETURN
END
EXEC @.hr = sp_OAGetProperty @.response, 'Success', @.success OUT
IF (@.hr <> 0 )
BEGIN
EXEC sp_displayoaerrorinfo @.response , @.hr
RETURN
END
IF (@.success = 0)
BEGIN
EXEC @.hr = sp_OAGetProperty @.response, 'ErrorText', @.errMsg OUT
IF (@.hr <> 0 )
BEGIN
EXEC sp_displayoaerrorinfo @.response , @.hr
RETURN
END
END
EXEC @.hr = sp_OADestroy @.xalert
EXEC @.hr = sp_OADestroy @.response
EXEC @.hr = sp_OADestroy @.factory
This works fine and we are able to create the objects and make the method
calls on it.
We have now taken that .Net 1.1 project and recompiled it in .Net 2.0 and
VS2005, using the same settings as before. A new setup was created and
installed on a PC running on Windows 2000 Server and has SQL Server 2005 SP1
installed. "CLR integration" and "xp_cmdshell" have been enabled. Master
database and our own databse have been made "trustworthy". The assembly
created above (with .net 2,.0) has been created within SQL Server, setting
External_acesss (tried unsafe as well) permissions on it.
We are using the same trigger as above and the same code within the trigger.
The trigger fails on the sp_oacreate line with the following error.
OLE Automation Error
HRESULT: 0x80131700
Source: ODSOLE EXtended Procedure
We have tried to put more COM Wrapper around the generated tlb , but that
has not worked - giving the same error. Using .net 1.1 assembly (same one as
used for SQLServer 2000) , we get the same error. However, It is possible to
create other standard COM objects (like the SQLDMO objects), using the
sp_oacreate. So, it may be something particular to .net assemblies being
called (via the COM interop wrapper) from SQL Server 2005.You should really go another route. Having SQL Server execute code hosted by CLR was never supported
though spOACreate nor xp_cmdshell. I'd consider re-writing that com object as a CLR stored procedure
and you are in a supported environment. Below is my general "canned" response:
It is not supported for extended stored procedures or sp_OA procedures to call .NET code in CLR;
hosted within SQL Server's adress space..
See:
http://support.microsoft.com/default.aspx?scid=kb;en-us;322884
Also, below is witnh permission from David Browne, explaining how you can have SQL Server execute
CLR code executing in its own process:
"
Short answer: Don't do it.
Calling managed code inside a stored procedure is not supported.
http://support.microsoft.com/default.aspx?scid=kb;en-us;322884
At least not directly. You need some sort of unmanaged proxy to communicate
with your component running in another process.
For instance, http, or, drum roll, a COM+ Server Application.
This will cause COM+ to load an unmanaged proxy object in the SqlServer
process and will load the CLR into a COM+ surrogate process (dllhost.exe).
Which somebody here mentioned last week, and I just got around to testing.
It's all perfectly transparent to you, but you have to set up the COM+
server application.
Remember this is something different from .net remoting. With .NET remoting
you have a _managed_ proxy object in the local process, and so you load the
CLR in the local process as well as the remote process.
Anyway here's what I did:
I created this VB class
comTest.vb listing:
Imports System.Runtime.InteropServices
<ClassInterface(ClassInterfaceType.AutoDual),
ProgId("comTest.comTestClass")> _
Public Class comTest
Public Function Hello() As String
Return "hello"
End Function
End Class
build comTest.dll and registered it with
regasm /codebase comTest.dll /tlb:comTest.tlb
(complains that I haven't strong-named my assembly, which you should do.)
created an empty COM+ server application, set to run under a local
administrator account, and dragged comTest.dll into its components folder.
created an unmanaged host (vbscript will do), and invoked the component
using IDispach just like SQLServer.
test.vbs listing
Set d = CreateObject("comTest.comTestClass")
MsgBox d.Hello
Then I used the .net command line debugger cordbg.exe's 'pro' command to
list the processes hosting the CLR. And procexp.exe from
www.sysinternals.com to verify that the CLR's dll's were not loaded in my
unmanaged process. My unmanaged host did not load the CLR, although it
loaded "comsvcs.dll", and the CLR was loaded by the dllhost.exe process.
Then in sql I ran
declare @.object int
declare @.msg varchar(50)
declare @.rc int
declare @.hr int
declare @.source varchar(1000)
declare @.description varchar(1000)
exec @.rc = sp_oacreate 'comTest.comTestClass', @.object output
if @.rc <> 0
begin
EXEC @.hr = sp_OAGetErrorInfo @.object, @.source OUT, @.description OUT
print 'create failed ' + @.description
return
end
exec @.rc = sp_oamethod @.object, 'Hello', @.msg output
if @.rc <> 0
begin
EXEC @.hr = sp_OAGetErrorInfo @.object, @.source OUT, @.description OUT
print 'method failed ' + @.description
return
end
print 'return: ' + @.msg
exec @.rc = sp_oadestroy @.object
if @.rc <> 0
begin
EXEC @.hr = sp_OAGetErrorInfo @.object, @.source OUT, @.description OUT
print 'destroy failed ' + @.description
return
end
Ran fine, and still only one CLR loaded into dllhost.exe's process. So
think we can safely conclude that COM+ server applications do not violate
the prohibition against running managed code in SQLServer's process and
provide a convenient mechanism for interoperating with managed code from
TSQL.
David
"
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Ian" <Ian@.discussions.microsoft.com> wrote in message
news:EC73FFA6-3F3E-47EE-809E-18BF1D60A88E@.microsoft.com...
>I have a .Net 1.1 assembly (written using C# in VS2003). This assembly has
> the option COM Interop set to True. Once built, the VS2003 project solution
> produces a .tlb file. A setup is produced (from within VS2003) that includes
> the dll and tlb files. These are installed on a PC (running on Windows
> 2000/2003 server/Windows XP Pro) that has SQL Server 2000 running on it (with
> the latest SQL Server 2000 Service Pack). A trigger fired from one of the
> tables in our own database (within SQL Server 2000) makes the calls to the
> COM wrapped assembly.
> CREATE TRIGGER [UserProfile_Trigger1] ON [UserProfile]
> FOR INSERT, UPDATE,DELETE
> AS
> DECLARE @.hr int
> DECLARE @.factory int
> DECLARE @.xalert int
> DECLARE @.response int
> DECLARE @.errMsg varchar(8000)
> DECLARE @.success bit
> EXEC @.hr = sp_OACreate 'csSOAPClient2.CXalertsApiSoapClient', @.factory OUTPUT
> select @.hr
> IF (@.hr <> 0 )
> BEGIN
> EXEC sp_displayoaerrorinfo @.factory , @.hr
> RETURN
> END
> EXEC @.hr = sp_OAMethod @.factory, 'getXalertsInstanceUsingSOAPDefaults',
> @.xalert OUTPUT, 'rmi://localhost:50001/com/xalert/server/api/XAlertsFactory',
> 'http://localhost:8080/axis/services/xalertsport'
> IF (@.hr <> 0 )
> BEGIN
> EXEC sp_displayoaerrorinfo @.factory , @.hr
> RETURN
> END
> EXEC @.hr = sp_OAMethod @.xalert, 'queueByID', @.response OUTPUT, 1, '',
> 'MyXalerts55_030506_ss', 1100
> IF (@.hr <> 0 )
> BEGIN
> EXEC sp_displayoaerrorinfo @.xalert , @.hr
> RETURN
> END
> EXEC @.hr = sp_OAGetProperty @.response, 'Success', @.success OUT
> IF (@.hr <> 0 )
> BEGIN
> EXEC sp_displayoaerrorinfo @.response , @.hr
> RETURN
> END
> IF (@.success = 0)
> BEGIN
> EXEC @.hr = sp_OAGetProperty @.response, 'ErrorText', @.errMsg OUT
> IF (@.hr <> 0 )
> BEGIN
> EXEC sp_displayoaerrorinfo @.response , @.hr
> RETURN
> END
> END
> EXEC @.hr = sp_OADestroy @.xalert
> EXEC @.hr = sp_OADestroy @.response
> EXEC @.hr = sp_OADestroy @.factory
>
> This works fine and we are able to create the objects and make the method
> calls on it.
> We have now taken that .Net 1.1 project and recompiled it in .Net 2.0 and
> VS2005, using the same settings as before. A new setup was created and
> installed on a PC running on Windows 2000 Server and has SQL Server 2005 SP1
> installed. "CLR integration" and "xp_cmdshell" have been enabled. Master
> database and our own databse have been made "trustworthy". The assembly
> created above (with .net 2,.0) has been created within SQL Server, setting
> External_acesss (tried unsafe as well) permissions on it.
> We are using the same trigger as above and the same code within the trigger.
> The trigger fails on the sp_oacreate line with the following error.
> OLE Automation Error
> HRESULT: 0x80131700
> Source: ODSOLE EXtended Procedure
>
> We have tried to put more COM Wrapper around the generated tlb , but that
> has not worked - giving the same error. Using .net 1.1 assembly (same one as
> used for SQLServer 2000) , we get the same error. However, It is possible to
> create other standard COM objects (like the SQLDMO objects), using the
> sp_oacreate. So, it may be something particular to .net assemblies being
> called (via the COM interop wrapper) from SQL Server 2005.|||"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:e$J%23mTUmGHA.1896@.TK2MSFTNGP05.phx.gbl...
> You should really go another route. Having SQL Server execute code hosted
> by CLR was never supported though spOACreate nor xp_cmdshell. I'd consider
> re-writing that com object as a CLR stored procedure and you are in a
> supported environment. Below is my general "canned" response:
> It is not supported for extended stored procedures or sp_OA procedures to
> call .NET code in CLR; hosted within SQL Server's adress space..
> See:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;322884
> Also, below is witnh permission from David Browne, explaining how you can
> have SQL Server execute CLR code executing in its own process:
>
Thanks,
But if I understand the question, the OP has compiled and installed the
assembly in SQL CLR. If so, he just needs to issue write a CLR stored
procedure in .NET that implements the trigger logic. Accessing the assembly
the OLE Automation stored procedures is no longer necessary. The trigger
body just needs to invoke a CLR stored procedure.
David|||Yes, I fully agree. However, the first post indicates that this isn't what the OP had in mind. Or
perhaps the first post seemed a bit ambiguous on this:
> We are using the same trigger as above and the same code within the trigger.
> The trigger fails on the sp_oacreate line with the following error.
> OLE Automation Error
> HRESULT: 0x80131700
> Source: ODSOLE EXtended Procedure
Thanks for making that option explicit, though. :-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in message
news:%23Hf3w3dmGHA.4536@.TK2MSFTNGP04.phx.gbl...
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
> news:e$J%23mTUmGHA.1896@.TK2MSFTNGP05.phx.gbl...
>> You should really go another route. Having SQL Server execute code hosted by CLR was never
>> supported though spOACreate nor xp_cmdshell. I'd consider re-writing that com object as a CLR
>> stored procedure and you are in a supported environment. Below is my general "canned" response:
>> It is not supported for extended stored procedures or sp_OA procedures to call .NET code in CLR;
>> hosted within SQL Server's adress space..
>> See:
>> http://support.microsoft.com/default.aspx?scid=kb;en-us;322884
>> Also, below is witnh permission from David Browne, explaining how you can have SQL Server execute
>> CLR code executing in its own process:
> Thanks,
> But if I understand the question, the OP has compiled and installed the assembly in SQL CLR. If
> so, he just needs to issue write a CLR stored procedure in .NET that implements the trigger logic.
> Accessing the assembly the OLE Automation stored procedures is no longer necessary. The trigger
> body just needs to invoke a CLR stored procedure.
> David

Sunday, February 12, 2012

Calculating average from a number of records

I have a table in my database that records project details.
Two fields that I have are DateOpened & DateClosed.

I need to be able to calculate the average of the total time in days projects have been opened
.
This will give me the days opened for one project (DateClosed-DateOpened)
I am not able to calculate this for a number of projects.

Also, if the date closed field is blank then this project should not be calculatedYou must have first the total of days & of course the total of proyects, to count the total of proyects that I suppouse that you have in a group just type this formula:

NumberVar Count;
If Not OnFirstRecord Then
If previous (id_proyect_field) = id_proyect_field Then
Count:= Count + 1
Else
Count:= 1
Else
Count:= 1

Lay this formula in detail section and type the next formula to put it in the group footer

NumberVar Count;
WhilePrintingRecords;
Count:= Count;
Count

Those tow easy formulas give you the number of proyects, on the other side, take the diference between your openday and closeday fields and sum them.

To finish, do it: TotalOfDays / Count

This last action is in the report footer.

I hope this help you

Friday, February 10, 2012

Calculated member question

I have a problem creating a calculated member correct.

Business problem: I have an organisation using MS Project and registering their project time against different projects (cube 1). Every organisation unit part of a project will be charged cost internally based on an agreement with a percentage split (write enabled cube 2). The project "customers" are the same organisation units as the participant organisation units.

Cube 1: Projects and customer cost

Cust1 Cust2
Proj1 100 200 (total project cost:300)
Proj2 10 50 (total project cost: 60)

Cube 2: Project charging %

Cust 1 Cust2
Proj1 50% 50%
Proj2 40% 60%

Now I want cube 3 (virtual cube) calculate how much each customer should be charged;

Cube3: Project cost "invoice"

Cust 1 Cust 2
Proj1 150 150 (50% of 300)
Proj2 24 36

But if I in cube 3 add a custom member like this:

[Measures.Cost] x ([Measures.Percentage] / 100)

I end up with the wrong result:

Cust 1 Cust 2
Proj1 50 100 (50% of 100 and 200 from cube 1, not based on 300)
Proj2 4 30


Can anyone help? How should I write the formula?

/Erik

Try somehting like this...

([Measures.Cost],[Customers].[Customers].[All]) x ([Measures.Percentage] / 100)

...basically telling the MDX to get the Cost for All customers, not to use the current customer context.

Calculated Member Issue

Dear all,

My project running on AS2005 contains a dimension with 5 values in its table.

The fact table contains values for 4 of the values of the dimensions (the last one has not value yet).

When I browse the cube, if I display a calculated member (a sum) as measure and the dimension, I can see the measures for the 4 values of the dimension (the last value is not displayed).

But if I display a calculed member (done with "CALCULATIONS and which correspond to Measure.A/Measure.B), I see the measures for the 5 values of the dimension (the last value is displayed even if it has no value in the fact table). The fifth one is blank.

How can I avoid this ?

Thanks in advance for your support.

Juan

Hi Juan,

I'm assuming that you meant to say: "..if I display a sum measure and the dimension, I can see the measures for the 4 values of the dimension..".

So, if your issue occurs only with the calculated measure, not with measure group measures, you could try specifying Non Empty Behavior, like:

Create Member CurrentCube.[Measures].[RatioAB]

As [Measures].A /[Measures].B,

Non_Empty_Behavior = [Measures].B;