Process Exit error : Oracle Stored Procedure - stored-procedures

I tried to execute a stored procedure from SQL developer but I get an error:
Process exited - disconnecting database
How to solve this error?
I tried to run the query from SQL Plus but SQL Plus is not installing into my machine. Please help. How to run the stored procedure from SQL developer?
Error
Connecting to the database XYZ.
Process exited.
Disconnecting from the database XYZ.
I tried to run this stored procedure from sql developer by right click ---> run and put values like '2019-05-12' = StartDate and '2019-05-13' = StopDate . StartDate and StopDate are datetime . Please help . I'm searching through net but can't find proper solution for this .

Related

SQL Plus with error error checking directory existence during ADR initialization but directory exists

I'm new to Oracle. I have installed it and I'm trying to Create a user in SQL plus. I used the following instructions:
-- 1. In The SQL Plus command prompt, enter user-name as sqlplus / as sysdba.
-- 2. Press Enter.
-- 3. In the Enter Password prompt, press Enter to log in without a password.
-- Note: The Connected to 19c database: message appears.
But then I restarted my computer because I was at the same time installing another software.
After that, trying to continue with SQL plus, I did the same procedure and got the following message: Connected to an idle instance. Instead to Connected to 19c database.
Then I read that shouting down the database and starting it up again would work. And I shouted it down but then when I tried to start it up I got this error:
--SQL> startup
--ORA-48173: error checking directory existence during ADR initialization
--[C:\app\client\ivoespin\diag\rdbms\orcl]
--ORA-48187: specified directory does not exist
--OSD-00002: additional error information
--O/S-Error: (OS 5) Access is denied.
But I checked and the directory exists with an orcl folder and a i_1.mif file in it.
What am I missing?

SQL Server Agent Job called a Stored Procedure that used Linked Server did not work

I have a stored procedure that uses linked server:
The linked server was created pointing to the Source Database server and Security is "Be made using the login's current security context"
The credential was created using an AD service account
The proxy was created with a check on the "Operating system (CmdExec) "
The stored procedure used the linked server bame in the insert/select command. The stored procedure worked well when I executed it within SSMS.
However when I run the stored procedure from SQL Server Agent Job step, using SQLCMD, it did not work.
Here is the example of my stored procedure:
USE [MyDatabaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[TEST_LINKED_SERVER]
AS
BEGIN
INSERT INTO MyDatabaseName.dbo.MyTableName
SELECT *
FROM [linkedservername].SourceDatabaseName.dbo.SourceTableName
END
GO
After creating the stored procedure, I executed it from SSMS - stored procedure. I worked well.
MyTableName had data inserted from the SourceTableName.
I then created a SQL Server Agent job with two steps:
Step #1: Run a stored procedure, truncate data from MytableName
Step #2: Run the "TEST_LINKED_SERVER" stored procedure, update data to Mytablename, by insert data from the linked server/database/table on another server using the linked server.
Step #2 was setup as follows:
Type: Operating system (CmdExec)
Run as: ProxyName
Command: SQLCMD -Q "EXEC dbo.TEST_LINKED_SERVER"
The job completed successfully. However MytableName did not have any data. It is empty. Data was not inserted to MyTableName.
Would you have any idea? Do I need to update my SQLCMD? And how?
Your help is much appreciated.
I found the solution and it worked:
SQLCMD -E -S MyServerName -D MyDatabaseName -Q "EXEC dbo.TEST_LINKED_SERVER"

Why can't I execute msdb.dbo.send_dbmail from a stored procedure being executed in a job?

I have a job scheduled to run on my server. That job executes a stored procedure. Inside that stored procedure I am executing msdb.dbo.sp_send_dbmail. When I execute the stored procedure logged in as an admin it runs fine. When the job runs though, it fails with the following error:
Executed as user: AD\sql_server. Failed to initialize sqlcmd library with error number -2147467259. [SQLSTATE 42000](Error 22050). The step failed.
I have tried modifying the stored procedure and adding in WITH EXECUTE AS OWNER. When I do this the stored procedure fails with the following error:
Executed as user: AD\sql_server. The EXECUTE permission was denied on the object 'sp_send_dbmail', database 'msdb', schema 'dbo'. [SQLSTATE 42000](Error 229). The step failed.
What do I need to do to be able to execute a stored procedure in a job that executes msdb.dbo.sp_send_dbmail?
unfortunately WITH EXECUTE AS OWNER is not going to solve your problem.
You may have to add the user as a part of the built in database mail role with something like:
USE msdb;
EXEC sp_addrolemember 'DatabaseMailUserRole', 'AD\sql_server'
Check out this post.

'SQL1024N A database connection does not exist. SQLSTATE=08003' error while executing 'db2 -x' command through command stage in Datastage 9.1

I'm getting 'SQL1024N A database connection does not exist. SQLSTATE=08003' error, while executing 'db2 -x' command through execute command stage in Datastage 9.1(AIX Server). Can any one please help me out ?
To connect to DB2 - you need a catalog entry on your Linux server ( or wherever the Datastage in installed)
You may need to check with the datastage administrator.
Use the below command on the server to see all the cataloged db2 databases
db2 list db directory
You may need to source the dsenv before you run this.

How to run stored procedure if it's in a separate schema

I am using SQL Server 2008 R2, and I have created a schema Test and in that schema, I created a stored procedure.
I wanted to run it in the text mode by issuing this query:
EXEC SP_HELPTEXT SCHEMA.SPROC
But while running the above query I get this error:
Incorrect syntax near '.'.
Can someone please help me here to resolve this issue.
Try this
EXEC SP_HELPTEXT 'SCHEMA.SPROC'
sp_helptext to display the result when sp's or any other tsql binded scripts run without schema, for example:
sp_helptext <nameof sp>
but when you want to run it with schema name as initial then run it into single quotes
sp_helptext 'schma.<nameofsp>

Resources