How to run a stored procedure as Siebel Server Job - database

Can I define a Server Job as Oracle Database Procedure?
I will need to schedule running a database procedure using Siebel Server Jobs.
Thanks in Advance.

No you cannot do that. If you are asking something like triggers that is a separate thing.

There is currently no Direct Method to run a DB stored procedure. The common way of implementing this is through the command line and calling SQL Plus. In this tutorial it's explained in a step-by-step way. This will allow you to create a business service and use it in a workflow that can then be used to power a Siebel Job.

You can do this way on Unix servers:
1.Create a SQL script file on Siebel server(s) depending on your component definition on a particular server.
exec my_package.MY_STORED_PRC;
2.Call the file inside your BS:
Clib.system(“sqlplus $my_user/$my_password#dbname #//SBA_81/siebsrvr/bin/my_stored_proc_caller.sql”);
3.Define an RCR template, calling the BS/WF RunProcess:
4.Create RCR with scheduling time & start it.
You can also call the sql file inside a shell script file & invoke shell script file
Shell script file: my_shell_file.sh
sqlplus -S $my_username/$pwd#db_instance "#"my_stored_proc_caller.sql"
Give execute permission to the file.
Then execute it inside BS:
Clib.system(“/sieb/server/path/my_shell_file.sh")

Hi Please try this option by executing OOB BS "EAI ODBC Service" method "Execute Procedure". Hope it will help you

Related

alternative to xp_cmdshell bcp?

Is there an alternative to xp_cmdshell BCP to write to a file from MSSQL?
Some context: This is to be built into a stored procedure called by an external program. I do not have the luxury to work through executable files, export functions of ssms, or any such things which require more than the calling of this stored procedure.
The reason; there's a lot of odd stuff on this server to do with user rights, and I'm not the SA. I cannot create the ##xp_cmdshell_proxy_account## (let alone assign credentials to it), and xp_cmdshell 'whoami' returns a user noone has ever seen or heard from. I've tried creating a new user based on an existing windows user and granting xp_cmdshell execute rights to it, but this still did nothing. I'm not sure if I don't have the rights or if it's something else.
So long story short, I'm fed up with trying to get this to work on this environment and am looking for an alternative. Is there one?
Write a SQL Agent Job and kick it off with sp_start_job. You can control the identity the job uses with a SQL Agent Proxy.
Or write an SSIS package, deploy it to the SSIS Catalog and run it from your stored procedure.

Run batch file from SQL

I want to run batch file from SQL Job without using exec xp_cmdshell.
Any idea?
Thanks
You could use a SQL Server Job, otherwise i cannot think of a way you could without xp_cmdshell.
Take a look at this
I want to run batch file from SQL Job without using exec xp_cmdshell.
Any idea?
Worth to mention that you can also leverage SQLCLR.
Example: CLR Stored procedure to execute command
Some other googlable threads:
How to execute a DOS command when xp_cmdshell is disabled in SQL Server
Executing an external process() in SQLCLR Project
Such approach introduces severe risks like memory leaks, crashing of underlying .net app pool etc
Therefore another link: Security in the CLR World Inside SQL Server
Instead of running batch file, i have created power shell and ran it from SQL job. It satisfy my requirement and resolved my issue.
Do it like the picture: like this image.
The drive containing the batch file should be other than the C drive, to avoid trouble.
Add execute, read and write permissions for the user, which you are using to run the batch file, to get the username run this query: EXEC master..xp_cmdshell 'whoami', get the name after the \ sign. For example "nt service\mssqlserver". Add permission for this user: mssqlserver
Finally make sure you put the batch file on the same server as where you execute your Job.

SQL Server to check for files in directory

I was wondering if it is possible for SQL Server to check a directory for files and run a stored procedure. I did some research and found this, but I am wondering if there is a way to do what I want WITHOUT SSIS.
EDIT: After reading my post, I realized I should have been more specific. Is there a way to AUTOMATICALLY or set SQL Server to check for files in a directory and run a stored procedure?
You can use xp_cmdshell to run file related commands. To get a directly listing:
exec xp_cmdshell 'dir *.csv';
You can also use bulk insert to load a file from disk into a table and take actions based on the loaded contents.
Normally you'd use the File Watcher Task with SSIS. But you can also use SQL Server Agent to schedule a task for periodic execution, schedule a task with Windows Task Scheduler, or configure a stored procedure to runs at startup with sp_procoption that pauses (using waitfor) between processing times.

create Scheduler task to invoke SQLCMD

I have a Requirement where i have to run a SQL Script in SQL server on a weekly basis .Result of this script has to be mailed.I want to automate this process.I don't want to go with SSIS Jobs. I have searched i have found few options like Creating a Windows Scheduler task to invoke a SQLCMD.Can Someone Assist on how to create Scheduler task to invoke SQLCMD
Your best bet would be to create a Console Application which executes the SQL Command and performs the email.
You can then use setup a task under Task Scheduler to use the Start a program option and run it on the schedule you prefer.
sqlcmd is just a command line tool. Put your SQL in a script file, and call it from the tool with right DB server and credentials. We can help you to figure how to make it work if you have a specific problem, but you should make your own tries before and tell us what goes wrong.
You will easily find examples on how to run a script :
http://msdn.microsoft.com/en-us/library/ms170572.aspx
More details on parameters :
http://msdn.microsoft.com/en-us/library/ms162773.aspx
example :
sqlcmd -S myServer\instanceName -i C:\myScript.sql -o C:\EmpAdds.txt
For task scheduler, it's easy to use but beyond SO scope, and it depends heavily of your version of windows, so (again), try yourself first.
Please note that you can also use SQL Server Agent to schedule your jobs.

How do I call a web page from an SQL Stored Proc?

I would like to write a sqlserver stored procedure that calls a web page, but I cant figure out how to do this.
Does anyone have an example?
Thanks
The easiest way is if you are using CLR integration
http://www.databasejournal.com/features/mssql/article.php/3821271/Calling-a-Web-Service-from-within-SQL-Server.htm
I think this is a very bad design to run external programs from SQL Server
However, you could use extended procedure xp_cmdshell to open a web browser with parameter.
EXEC xp_cmdshell
'"C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.bing.com'
Be aware that it will execute Internet Explorer on the db server. I am not sure if it is what you want. It will also block the rest of the script from running until the IE process is killed.
Short of using a CLR Stored Procedure, I think you're out of luck.
I would also question what you're doing with the markup you get back from fetching the web page....
SQL CLR is the easiest way to perform and HTTP Get request from a SQL Server stored procedure, as noted by other responses to this question. If you want something more robust, I would recommend you take a look at the Service Broker External Activator.

Resources