Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stored Procedure communicating COM and Array declaration in sqlserver

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-12-27 : 11:04:42
ramesh writes "Hi SqlTeam,

I am doing a project on sqlserver and COM communicatoin. I could
not solve the problem that comes by myself. If it is possible
pl. guide me to find the solution.

prob 1:
=======
I have to communicate with COM object in the system. In my COM
object I create a Java Virtual Machine using createJavaVM(...);

when my COM module executes it fails on creating the javaVM. The
same module is woking for COM - COM communication. ( My COM
object works fine for the other communications). How can I
resolve this problem.?


Note :
1. For calling the COM object i have used sp_OACreate,
sp_OAMethod, and sp_OADestroy.
2. Calling the COM object and executing the functions is worked
fine for the normal process.

prob : 2;
========
I want to pass various number of data (different types) to my
COM object. My COM object can receive only VARIANT as a
parameter, and that variable should contain all its requied
values in it (may keep as an array)

ex :

In COM object the function is :

fnSample ([in]VARIANT vInPut, [out]VARIANT vOutPut);

from sqlserver when i call i has int, float , and varchar
values..

int curveId; float curveValue; varchar curveString;

How can i keep all these values to the data type of VARIANT?

Expecting your answer immly.

Thanks in advance."

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2001-12-27 : 13:41:49
OK, why are you doing this? Please don't tell me this is a project for school, because we don't like to do people's homework for them. Otherwise, I find that a lot of people think that just because they CAN instantiate a COM object from within SQL that they SHOULD. This is not necessarily the case, and many people try to get SQL Server to do things it really shouldn't be doing. Regardless, here are some ideas...

Prob 1:
What are you using the JavaVM to do? When you say it "fails" what error message are you getting? Can you successfully instantiate and this COM/JavaVM from an executable instead of from SQL Server? My first guess is that this really has nothing to do with SQL.

Prob 2:
A variant data type should accept any of those types. If you're passing in multiple values like an array, then you'll have to pass it as a comma-delimited string (use varchar in SQL). You might want to search on CSV here on SQLTeam for more info.



--------------------------------------------------------------
1000 Posts, Here I come! I wonder what my new title will be...
Go to Top of Page

nt_ramesh
Starting Member

1 Post

Posted - 2001-12-28 : 01:26:55
Hi Friend,
Thank you for your kind ideas.
Our client has SQL Server, when they insert a record it has to update those details to a COM object (The updated details is used by other application).
For this I have written a Trigger which calls a stored procedure. This sp calls the method available in the COM object and update the details by sending the param from the inserted values.
Our Client had already written the COM object for not only this and also for some other work. So we could not change the syntex.
prob 1:
The same COM object is successfully work on JAVA-COM (JACOB) model. So i want to use the java file invocation from sql server. This can be do by communicating with a COM , which invokes that java file.
process flow is :
PROCESS 1:
.................Thro SP........................createJavaVM()
SQL SERVER -------> COM (DLL FILE) -------------> Java file

The process fails on createJavaVM().
I have tested the process (PROCESS 2) which successfully works,
PROCESS 2:
.....................CALLS.........................createJavaVM()
COM (EXE FILE) -----> COM (DLL FILE) --------------> java File

I had in my mind that if a COM exe works fine, then it must work for SQL SERVER als. and it is not in the real case. I m not getting any error message on PROCESS 1 (at SQL SERVER SIDE). when the createJavaVM comes it hangs up. When I run at the second time the system (SQL SERVER)hangs on.

Prob 2:

I know the method that u have said (sending multiple values by comma separators). It is not possble to use the same here.
I could not change my COM object param, and the process. (My COM object will take VARIANT that should have an array of differant types)
modal is :
VAIRANT ---> ARRAY ( string, int, long)

Shall u tell me how to solve the above two probs?

Thanks in advance for ur answers.

NT.RAMESH
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2001-12-28 : 14:24:50
Hmmm... Well I don't have any new ideas on problem 1. I don't have much experience with the JavaVM myself, so hopefully someone else can jump in on this.

Regarding problem 2, are you saying that the data passed has to be an array? If so, the you're out of luck because SQL Server doesn't have an array type. Maybe a workaround would be to pass the CSV to a new intermediate COM dll that would then build the array and pass that to the pre-existing dll. In SQL 2000 there is a TABLE data type which is about as close to array as you can get, but I don't know if it will pass to COM properly. Give it a try if you have SQL 2000 (it didn't exist in SQL 7.)

--------------------------------------------------------------
1000 Posts, Here I come! I wonder what my new title will be...

Edited by - AjarnMark on 12/28/2001 14:26:09
Go to Top of Page
   

- Advertisement -