Calling Oracle & MySQL Stored Procedures from Virtual Stored Procedure - teiid

All,
I am new to TeiiD. I have Oracle and MySQL stored procedures (inserting records into tables) executing successfully from TeiiD VDB as separate procedures using call commands. I am using SquIrrel tool to execute them independently from Active VDB.
Now, is it possible using Teiid CREATE VIRTUAL PROCEDURE to call both procedures in one go? Something like..
CREATE VIRTUAL PROCEDURE myProc () RETURN ()
BEGIN
Call MyOracleProc();
Call MySQLProc();
END
I am not getting any example or syntax to handle this requirement. I am also trying to use Eclipse Teiid designer plugin for same.
Appreciate help.
Thanks,

I am not getting any example or syntax to handle this requirement
Yes, you can call source stored procedures just like any other statement in a Teiid virtual procedure using the CALL or EXEC keyword: CALL proc()
See more under http://teiid.github.io/teiid-documents/13.1.x/content/reference/DML_Commands.html and http://teiid.github.io/teiid-documents/13.0.x/content/reference/Procedure_Language.html#_command_statement

Related

How do I get information about the Startup Type of a service in c++?

I'm looking for a way to get the Startup type of a service using c++. I am able to get the SERVICE_STATUS data from a ControlService() call, but the data does not include the startup type. I'm aware there is a way to get the Startup Type using windows power shell, maybe I should make a c++ method that makes that power shell call? Is that the best way to do it?
You need to open the service with OpenService() requesting SERVICE_QUERY_CONFIG access, and then you can use QueryServiceConfig(). dwStartType is one of the available fields of the returned QUERY_SERVICE_CONFIG structure data.

Returning output in stored procedures call using LiveCode

I have been trying to run stored procedures in LiveCode to return data based on parameters passed to the stored procedure, but I never get anything back when I run with LiveCode's built-in database library. I have also not seen any third-party plug-ins targeted at stored procedures for returning data from MS SQL Server 2008 R2 (also doesn't work for any other DB servers for that matter).
Is there a way to run stored procedures in LiveCode?
If there are no ways to run stored procedures in LiveCode, can someone point me in the direction of (or help out) writing a LiveCode external for stored procedure calls as a plug-in for LiveCode?.
LiveCode does have an SDK for building externals in C++ and Object-C, but I do not have the required expertise to do that, hence the second question.

How to call an exe on an insert event in a table

On an insert event in a table, i need to fetch some data in a file using C++ API and send that file to client.
So currently my plan is to Check the " After insert" event using a sql trigger and call the C++ exe from the trigger.
I found in many places that its not advisable to call an exe from a trigger. But i believe in my case it should not be a big issue as my exe is not going to update anything, rather it will just fetch some data and generate a pipe delimited file having those data.Please let me know if this has any limitations.
Question:
What are the steps i should follow to call an exe from a trigger?
If i call my exe from the trigger, should it cause any types of issues in database like database hang?
Note: A better approach comes to my mind is:
We have our own C++ APIs using which i can connect to Database.So i can put a logic in C++ which should have a daemon logic to check the table every time and generate the file once an insertion happens in table.But the problem here is , my client don't want to have a daemon process which needs constant monitoring and increase the maintenance work.They are suggesting to go with an approach where it should run the application only when the insertion event happens.
Please help me on this whether i should go for trigger approach to call the exe from there. Also please let me know for any better approach.
I think a better approach would be to use a DBMS_SCHEDULER call in the trigger to create or schedule a job that will invoke your external application. This way you will decouple your database operation from the external call and yet you will be able to trigger the program when necessary instead of polling the table.

Ways to communicate between JScript and Windows service

I have a Windows local service that may spawn off a process to execute a JScript script (in a .js file) via the Windows Script Host. The issue is that I need to notify my service of the results generated by the script in the .js file. A transfer or a simple 32-bit integer, or a string would suffice. What would be the way to do this?
PS. The code must run on Windows XP SP3 or later OS.
Your best bet is to create an out of process COM object that executes within your service. Just implement the necessary scripting interfaces and provide a member function to match the notification and call it from your script as such:
newObj = new ActiveXObject("localserver.mynotify");
newObj.Notify("finished");
Would the exit code of the process be enough?
Windows Scripting host has has a .Quit(errorCode) method that allows you to set the exit code.
You should be able to call WSH directly from the service and get the return code with GetProcessExitCode() by passing the process handle that you received after spawning it.
Note that almost everything you can do from a JScript file can also be done with native code.
Do you have to execute the .js file as an external process? Windows Scripting has COM objects that an app can use to run scripts within its own process. I use this to execute script files within my service processes, and it works fine. The hosting process can even implement its own IDispatch-based classes and pass them to the scripting engine to expose to scripts as global objects so the scripts can communicate with the hosting process without having to use new ActiveXObject or CreateObject() to access those objects.
I see your script is written in JScript and your app in C++.
Perhaps the easiest way to accomplish what you want is by writing a file, say, to programdata folder which your service should have access to. Maybe use a GUID for the particular request, pass that to the JScript so it's guaranteed to be a unique file. Not ideal.
Another way to get JScript output ... Can you call out to managed code (C#)? If so, you could use a .NET-based or .NET-callable JavaScript compiler/interpreter. This would allow you to avoid IActiveScript and also to grab the values right out of the script context or from function return. I've used Jurassic and JavaScriptDotNet, both very easy to use and extend.
This might open a problem if you heavily rely on ActiveXObject calls (ie: FileSystemObject) and don't want to write components. JuraScript wraps the Jurassic engine and add ActiveXObject support to it for COM automation.
I am a C++ newb, so I don't know how much of a leap this is for you although I know it's possible to interop between managed/C++.
Just thought I'd mention these scenarios as I didn't see them listed in answers.

Function is calling before service loaded

I am using blazeDS in my web application. I am facing issue with Java and flex.
I have used function to load service in creation complete event of application. And I need to get value in combo box and do some manipulation. But my function which will trace the value, is being called before service is loading. for that reason function is not returning any value.
you can overcome by doing following changes
1) call webservice in Application initizlize event
2) Call your method in ResultEvent triggers on result of Webservice
or
3) IF Still you face same issue you can call it using callLater()
or
4)IF callLater() wont work to, then you can use Event collectionchange of ListCollectionView a Parent Class of ArrayCollection, XMLListCollection
I personaly recommend DO Steps 1 and 4 Only.
Hopes that helps