Execute EXP command in SQL or PL/SQL window
Hi,
Sorry
Regards
Sanjit
Edited by: userSanjit on Jun 2, 2009 2:47 PM
You cannot use exp or imp commands from PL/SQL.
Why don't you use [DATA Pump|http://www.oracle-base.com/articles/10g/OracleDataPump10g.php]? If you are using 10g then you can easily incorporated that in your environment.
Regards.
Satyaki De.
Similar Messages
-
ERRORs executing CWM commands in SQL Plus
Hi,
I tried to execute following command in SQL Plus:
execute cwm_olap_dimension.set_plural_name('olapdata', 'OLAP_APARAT_DIM', 'OLAP_APARAT_DIM');
And in response I got following result:
BEGIN cwm_olap_dimension.set_plural_name('olapdata', 'OLAP_APARAT_DIM', 'OLAP_APARAT_DIM'); END;
ERROR at line 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "OLAPSYS.CWM$UTIL", line 535
ORA-06512: at "OLAPSYS.CWM$OLAP$DIMENSION", line 17
ORA-06512: at line 1
Can anyone explane me what am i doing wrong ?
I would really appreciate any help!
Thankscheck SQL*Plus user's guide
e.g column REMARK format a30
set linesize 2243
etc etc etc -
Executing OS command from sql procedure
i want to execute an OS command from the procedure, can i do this way? looks like it is not executing the command move....
declare
begin
dbms_output.put_line(' moving...');
host;
move c:\file1\test.txt C:\moved
exit;
/True. But that job is going to run in a separate session, some time after the current transaction commits (depending on the number of jobs queued up to run). So if you need to pass information back from the job, or you want the procedure to handle exceptions thrown by the job, or you want to tie job related failures back to a particular application level event, or you want the rest of your procedure to wait for the operating system command to finish, using the DBMS_SCHEDULER for this sort of thing is going to require a fair amount of additional coordination/ monitoring/ infrastructure code. It's certainly not a Herculean task to write that additional code, and it's reasonable in some situations, but the Java stored procedure approach strikes me as substantially easier to deal with in most cases.
Justin -
Is there any way to execute an arbitrary os command (e.g., grep, etc.) and pipe its output into a SQL statement?
e.g., UPDATE table SET column = `grep ....`;Thanks, Chris.
We have a bit of a catch-22 here, since we're creating a sequence based on the contents of a table, and we want both the table and the sequence to be replicated via Cache Connect. We load the table, do a select and use the output of the select to create the sequence. The create sequence fails if the cache group exists, but if the cache group doesn't exist, then the table doesn't get replicated. There is no alter sequence command...
Yes, we could load the table, do the select, save the result, truncate the table, create the cache group with the sequence, and then re-load the table, but that seems like a bit more trouble than its worth. Was hoping we could do something with the raw files before they were loaded directly from the ddl. Oh, well.... -
Execute Unix command from Java program running on windows
Hello,
I need to write a java program that fetches file count in a particular unix machine directory. But java program will be running on windows machine.
The program should execute unix list command and fetch the output of that command.
Can anyone help me on this?
Thanks.Hi there,
I had a similiar problem, though years ago. It was to have a java program execute any other. Lately, I've had to have a java program running on a unix machine execute a shell script. Entirely two different scenarios. I'm not sure what you will need for your app, but look into this:
Java Native Interface for executing C/C++ code.
C/C++ Code for launching the program you need to run.
java.lang.Runtime(?).exec(....)
With a combination of that stuff, you can make a launcher for any os that has Java running on it, and with Runtime, you can exec() pretty near any sort of unix shell or app command you'd like.
Good luck.
Tim -
HI,
I am getting below error while deploying BAM activity ...Pls help me resolve this issue.
Microsoft.BizTalk.Bam.Management.BamManagerException: The BAM deployment failed. ---> Microsoft.BizTalk.Bam.Management.BamManagerException: Encountered error while executing command on SQL Server
"ServerName". ---> System.Data.SqlClient.SqlException: An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or
[] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed.
Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias
to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An
object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column
name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing
or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For
SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements,
verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column
has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For
other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name.An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements,
look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock,
Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean
sendToPipe, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteBatches(String cmdText) at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteNonQuery(String
cmdText, CommandType cmdType, Boolean inTransaction, Transaction transaction) --- End of inner exception stack trace --- at Microsoft.BizTalk.Bam.Management.SqlHelper.ExecuteNonQuery(String cmdText, CommandType cmdType, Boolean inTransaction,
Transaction transaction) at Microsoft.BizTalk.Bam.Management.ViewModule.Create(XmlDocument defXmlDoc) at Microsoft.BizTalk.Bam.Management.WorkerModule.DispatchOperation(OperationType operation, XmlDocument defXmlDoc) at
Microsoft.BizTalk.Bam.Management.BamManager.ProcessOneBamArtifactType(BamArtifactType bamArtifact, OperationType operation) at Microsoft.BizTalk.Bam.Management.BamManager.ManageInfrastructure(OperationType operation) at Microsoft.BizTalk.Bam.Management.BamManager.Deploy()
--- End of inner exception stack trace --- at Microsoft.BizTalk.Bam.Management.BamManager.Deploy() at Microsoft.BizTalk.Bam.Management.BamManagementUtility.BamManagementUtility.HandleDeployAll() at Microsoft.BizTalk.Bam.Management.BamManagementUtility.BamManagementUtility.DispatchCommand()
at Microsoft.BizTalk.Bam.Management.BamManagementUtility.BamManagementUtility.Run() at Microsoft.BizTalk.Bam.Management.BamManagementUtility.BamManagementUtility.Main(String[] args)Your View Name, OLAP Cube Name and certain other restrictions listed @http://msdn.microsoft.com/en-us/library/aa561577.aspx
Please review your BAM Definitons.
Regards. -
AddVMOption command in SQL developer configuration files
Greetings developers,
I'm a newbie in database and Java world trying to understand what the Oracle sql developer configuration files do by executing AddVMOption commands. I'm guessing this command is something to do with Jdeveloper. Please enlighten me what the command does.
Regards,
ValerieValerie,
Nothing to do with JDeveloper at all.
SQL Developer (and JDeveloper incidentally) are created using Java - the AddVMOption's that you are referring to are arguments passed to the Java Virtual Machine that is used to run SQL Developer. For example, you can use AddVMOption to give more memory to SQL Developer.
Hope this clarifies,
John -
Dear Guru's,
I have Script of my all the procedure.
After all procedure gets execute, As a output it create .csv files.
This .csv files i manually copy past on one of my directory.
For avoiding this manual copy past i want to use xcopy command from sql itself.
Please guide me how do i do this.
Regards,
Chanchal wankhade.CHACHA wrote:
I have Script of my all the procedure.
After all procedure gets execute, As a output it create .csv files.
This .csv files i manually copy past on one of my directory.
For avoiding this manual copy past i want to use xcopy command from sql itself.
Please guide me how do i do this.Do not like the sound of the architecture you are using for this. Scripts? Scripts for Oracle should be limited to installing s/w.
Writing any kind of Oracle application using scripts, is questionable ito design, robustness, flexibility, security and so on.
Wanting to use console commands from a SQL cursor? That sounds even more broken and wrong. If you want to do o/s calls, it should be done carefully and securely from PL/SQL code.
And PL/SQL code should be inside the database - not outside in some script.
As for copying files. Realise that SQL and PL/SQL code executes on the server inside an Oracle server process. This does not have access to your client's file system and directories. -
Using Powershell to execute DBCC CheckDB from SQL Agent.
So, I have a weird situation that I think is tied tot he resource group and powershell, but I am having trouble determining if it is that or not. I run DBCC CheckDB using a resource pool and a secondary account. The account has permissions to do the work
and if I log onto the server and run the procedure locally it runs fine in the resource pool configuration. However, when I kick it from the SQL Agent job using the powershell step, it only does checkDB on the first 3 system databases and then stops once it
hits a user database. I am not seeing any errors or messages, it just stops. I ran profiler and I see it do the work, get to the first user database, issues this statement from DBCC, then just stops, and the job ends.
SELECT @BlobEater = CheckIndex (ROWSET_COLUMN_FACT_BLOB)
FROM { IRowset 0xD0936A7902000000 }
GROUP BY ROWSET_COLUMN_FACT_KEY
>> WITH ORDER BY
ROWSET_COLUMN_FACT_KEY,
ROWSET_COLUMN_SLOT_ID,
ROWSET_COLUMN_COMBINED_ID,
ROWSET_COLUMN_FACT_BLOB
OPTION (ORDER GROUP)
I am not doing anything special in my code that would limit which databases to process. As I said earlier, executing the call to the procedure from a query window runs as expected and processes all of the databases.
Here is the Agent Code calling powershell:
[string] $DayOfWeek = ""
$DayOfWeek = (get-date).DayOfWeek.ToString()
$DayOfWeek
if ($DayOfWeek -eq 'Sunday')
invoke-sqlcmd -database sysadm -serverinstance HQIOSQLDEV01\DEV01 "exec ConsistencyCheck.upConsistencyCheck NULL, 'N', 'Y', 'N', 'N', 'N'"
else
invoke-sqlcmd -database sysadm -serverinstance HQIOSQLDEV01\DEV01 "exec ConsistencyCheck.upConsistencyCheck NULL, 'Y', 'N', 'N', 'N', 'N'"
John M. CouchThere are 3 additional databases. The last known good is today as I am able to execute the procedure via query window just fine. It is only when executed from a SQL Agent job as above that it stops after only doing the System Databases. The largest database
is 130GB in size, with the largest table being 62 GB.
-- Create Procedures
raiserror('Creating Procedure ''%s''', 0, 1, '[ConsistencyCheck].[upConsistencyCheck]')
go
/*==============================================================================
Procedure: upConsistencyCheck
Schema: ConsistencyCheck
Database: SysAdm
Owner: dbo
Application: dbo
Inputs: Catalogue : nvarchar(128) : NULL = All Databases
Physical Only : nchar(1) : Y/N, NULL = N
Data Purity : nchar(1) : Y/N, NULL = N
No Index : nchar(1) : Y/N, NULL = N
Extended Logical Checks : nchar(1) : Y/N, NULL = N
Table Lock : nchar(1) : Y/N, NULL = N
Outputs: (0 = Success, !=0 = failure)
Result Set: N/A
Usage: declare @ii_Rc int
,@invc_Catalogue nvarchar(128)
,@inc_PhysicalOnly nchar(1)
,@inc_DataPurity nchar(1)
,@inc_NoIndex nchar(1)
,@inc_ExtendedLogicalChecks nchar(1)
,@inc_TabLock nchar(1)
select @invc_Catalogue = NULL
,@inc_PhysicalOnly = 'Y'
,@inc_DataPurity = 'N'
,@inc_NoIndex = 'N'
,@inc_ExtendedLogicalChecks = 'N'
,@inc_TabLock = 'N'
exec @ii_Rc = ConsistencyCheck.upConsistencyCheck @invc_Catalogue
, @inc_PhysicalOnly
, @inc_DataPurity
, @inc_NoIndex
, @inc_ExtendedLogicalChecks
, @inc_TabLock
print 'Return Code: ' + convert(varchar, @ii_Rc)
Description: This Procedure is used to run DBCC CheckDB on 1 or all Databases
on the existing instance.
Version: 1.00.00
Compatability: SQL Server 2008 (100)
Created By: John M. Couch
Created On: 04-26-2012
================================================================================
Notes
1. Some logic was taken directly from Ola Hallengren's Maintenance Script.
http://ola.hallengren.com
================================================================================
History: (Format)
When Who Version Code Tag What
04-26-2012 John Couch 1.00.00 (None) Initial Revision
==============================================================================*/
alter procedure ConsistencyCheck.upConsistencyCheck (@invc_Catalogue nvarchar(128)
,@inc_PhysicalOnly nchar(1)
,@inc_DataPurity nchar(1)
,@inc_NoIndex nchar(1)
,@inc_ExtendedLogicalChecks nchar(1)
,@inc_TabLock nchar(1)) as
/*==============================================================================
Variable Declarations & Temporary Tables
==============================================================================*/
declare @li_Rc int = 0
,@lnvc_ExecutedBy nvarchar(128) = user_name()
,@ldt_ExecutedOn datetime = getdate()
,@lnvc_Catalogue nvarchar(128) = @invc_Catalogue
,@lnc_PhysicalOnly nchar(1) = coalesce(@inc_PhysicalOnly, 'N')
,@lnc_DataPurity nchar(1) = coalesce(@inc_DataPurity, 'N')
,@lnc_NoIndex nchar(1) = coalesce(@inc_NoIndex, 'N')
,@lnc_ExtendedLogicalChecks nchar(1) = coalesce(@inc_ExtendedLogicalChecks, 'N')
,@lnc_TabLock nchar(1) = coalesce(@inc_TabLock, 'N')
,@lnvc_Instance nvarchar(128) = cast(serverproperty('ServerName') as nvarchar)
,@lnvc_Version nvarchar(40) = cast(serverproperty('ProductVersion') as nvarchar)
,@lnvc_Edition nvarchar(40) = cast(serverproperty('Edition') as nvarchar)
,@li_Compatibility int
,@ldt_CreateDate datetime
,@lnvc_UserAccess nvarchar(35)
,@lnvc_StateDescription nvarchar(35)
,@lnvc_PageVerifyOption nvarchar(35)
,@lti_IsReadOnly tinyint
,@lti_IsInStandBy tinyint
,@lnvc_Recipients nvarchar(2000) = '[email protected]'
,@lnvc_Subject nvarchar(128)
,@lnvc_ErrorMessage nvarchar(4000)
,@lnvc_SQL nvarchar(max)
,@lnvc_ManualSQL nvarchar(max)
,@lnvc_Query nvarchar(2048)
,@li_ConsistencyCheckID int
,@ldt_ExecutionStart datetime
,@ldt_ExecutionFinish datetime
declare @ltbl_Catalogue table (Catalogue sysname
,CompatibilityLevel int
,CreateDate datetime
,UserAccess nvarchar(35) -- MULTI_USER, SINGLE_USER, RESTRICTED_USER
,StateDescription nvarchar(35) -- ONLINE, RESTORING, RECOVERING, RECOVERY_PENDING, SUSPECT, EMERGENCY, OFFLINE
,PageVerifyOption nvarchar(35) -- NONE, TORN_PAGE_DETECTION, CHECKSUM
,IsReadOnly tinyint
,IsInStandBy tinyint
,IsAutoShrink tinyint
,IsAutoClose tinyint
,Flag bit default 0)
create table #ltbl_Output (Error int,
Level int,
State int,
MessageText nvarchar(max),
RepairLevel nvarchar(30),
Status int,
DBID smallint,
ObjectID int,
IndexID smallint,
PartitionID bigint,
AllocunitID bigint,
[File] int,
Page int,
Slot int,
RefFile int,
RefPage int,
RefSlot int,
Allocation int)
/*==============================================================================
Initialize Environment
==============================================================================*/
set nocount on
set quoted_identifier on
/*==============================================================================
Parameter Validation
==============================================================================*/
-- Configure Alert Mail Subject Line
set @lnvc_Subject = 'Check consistency parameter validation error occurred on ' + cast(@@servername as nvarchar)
if @lnc_PhysicalOnly not in ('Y','N')
begin
set @lnvc_ErrorMessage = N'The value for parameter @inc_PhysicalOnly is not supported.' + char(13) + char(10) + ' '
set @li_Rc = -1
end
if @lnc_DataPurity not in ('Y','N') and @li_Rc = 0
begin
set @lnvc_ErrorMessage = N'The value for parameter @inc_DataPurity is not supported.' + char(13) + char(10) + ' '
set @li_Rc = -1
end
if @lnc_NoIndex not in ('Y','N') and @li_Rc = 0
begin
set @lnvc_ErrorMessage = N'The value for parameter @inc_NoIndex is not supported.' + char(13) + char(10) + ' '
set @li_Rc = -1
end
if @lnc_ExtendedLogicalChecks not in ('Y','N') and @li_Rc = 0
begin
set @lnvc_ErrorMessage = N'The value for parameter @inc_ExtendedLogicalChecks is not supported.' + char(13) + char(10) + ' '
set @li_Rc = -1
end
if @lnc_TabLock not in ('Y','N') and @li_Rc = 0
begin
set @lnvc_ErrorMessage = N'The value for parameter @inc_TabLock is not supported.' + char(13) + char(10) + ' '
set @li_Rc = -1
end
if @lnc_ExtendedLogicalChecks = 'Y' and @lnc_PhysicalOnly = 'Y' and @li_Rc = 0
begin
set @lnvc_ErrorMessage = N'Extended Logical Checks and Physical Only cannot be used together.' + char(13) + char(10) + ' '
set @li_Rc = -1
end
if @lnc_DataPurity = 'Y' and @lnc_PhysicalOnly = 'Y' and @li_Rc = 0
begin
set @lnvc_ErrorMessage = N'Physical Only and Data Purity cannot be used together.' + char(13) + char(10) + ' '
set @li_Rc = -1
end
if @li_Rc != 0
goto errlog
/*==============================================================================
Code Section
==============================================================================*/
select @lnvc_SQL = N'select d.name, d.compatibility_level, d.create_date, d.user_access_desc, d.state_desc,
d.page_verify_option_desc, cast(d.is_in_standby as tinyint), cast(d.is_read_only as tinyint),
cast(databasepropertyex(quotename(d.name), ''IsAutoShrink'') as tinyint),
cast(databasepropertyex(quotename(d.name), ''IsAutoClose'') as tinyint),
0
from master.sys.databases d
where d.name = ' + case when isnull(@lnvc_Catalogue, '') = '' then ' d.name'
else '''' + @lnvc_Catalogue + ''''
end + '
and d.name != ''tempdb'''
insert into @ltbl_Catalogue (Catalogue, CompatibilityLevel, CreateDate, UserAccess,
StateDescription, PageVerifyOption, IsReadOnly, IsInStandBy,
IsAutoShrink, IsAutoClose, Flag)
exec sp_executesql @lnvc_SQL
while (select top 1 1
from @ltbl_Catalogue c
where c.Flag = 0) = 1
begin
select top 1 @lnvc_Catalogue = c.Catalogue
,@li_Compatibility = c.CompatibilityLevel
,@ldt_CreateDate = c.CreateDate
,@lnvc_UserAccess = c.UserAccess
,@lnvc_StateDescription = c.StateDescription
,@lnvc_PageVerifyOption = c.PageVerifyOption
,@lti_IsReadOnly = c.IsReadOnly
,@lti_IsInStandBy = c.IsInStandBy
from @ltbl_Catalogue c
where c.Flag = 0
select top 1 @lnvc_Catalogue
,@li_Compatibility
,@ldt_CreateDate
,@lnvc_UserAccess
,@lnvc_StateDescription
,@lnvc_PageVerifyOption
,@lti_IsReadOnly
,@lti_IsInStandBy
if @lnvc_StateDescription = 'ONLINE' and @lnvc_UserAccess != 'SINGLE_USER'
begin
-- Build Execution String
select @lnvc_SQL = N'dbcc checkdb (' + quotename(@lnvc_Catalogue) + ')' + case when @lnc_NoIndex = 'Y' then ', noindex'
else ''
end + ' with tableresults, no_infomsgs, all_errormsgs '
+ case when @lnc_PhysicalOnly = 'Y' then ', physical_only'
else ''
end
+ case when @lnc_DataPurity = 'Y' then ', data_purity'
else ''
end
-- Option not supported with Compatibility < 100 (SQL Server 2005 and below)
+ case when @lnc_ExtendedLogicalChecks = 'Y' then
case when @li_Compatibility = 100 then ', extended_logical_checks'
else ''
end
else ''
end
+ case when @lnc_TabLock = 'Y' then ', tablock'
else ''
end
-- Prepare Processing Environment
truncate table #ltbl_Output
set @ldt_ExecutionFinish = null
set @ldt_ExecutionStart = null
-- Capture Start Time.
set @ldt_ExecutionStart = getdate()
-- Execute the Command.
insert into #ltbl_Output(Error, Level, State, MessageText, RepairLevel, Status,
DBID, ObjectID, IndexID, PartitionID, AllocunitID,
[File], Page, Slot, RefFile, RefPage, RefSlot, Allocation)
exec sp_executesql @lnvc_SQL
-- Capture Completion Time.
set @ldt_ExecutionFinish = getdate()
-- Add Header Record to Confirm Execution.
insert into SysAdm.ConsistencyCheck.ExecutionLog(Instance, [Version], Edition, Catalogue, PhysicalOnly,
NoIndex, ExtendedLogicalChecks, DataPurity, [TabLock],
Command, ExecutionStart, ExecutionFinish,
CreatedOn, CreatedBy)
values(@lnvc_Instance, @lnvc_Version, @lnvc_Edition, @lnvc_Catalogue, @lnc_PhysicalOnly,
@lnc_NoIndex, @lnc_ExtendedLogicalChecks, @lnc_DataPurity, @lnc_TabLock,
@lnvc_SQL, @ldt_ExecutionStart, @ldt_ExecutionFinish,
@ldt_ExecutedOn, @lnvc_ExecutedBy)
-- Capture Header Record ID
select @li_ConsistencyCheckID = @@IDENTITY
-- Were there errors?
if (select top 1 1
from #ltbl_Output t) = 1
begin
select @li_ConsistencyCheckID, t.Error, t.Level, t.State, t.MessageText, t.RepairLevel,
t.Status, t.ObjectID, t.IndexID, t.PartitionID, t.AllocunitID, t.[File], t.Page,
t.Slot, t.RefFile, t.RefPage, t.RefSlot, t.Allocation, @ldt_ExecutedOn, @lnvc_ExecutedBy
from #ltbl_Output t
-- Log Failure Entries
insert into SysAdm.ConsistencyCheck.ErrorLog (ExecutionLogID, Error, Severity, [State]
,ErrorMessage, RepairLevel, [Status], ObjectID
,IndexID, PartitionID, AllocationUnitID, FileID
,Page, Slot, RefFileID, RefPage, RefSlot, Allocation
,CreatedOn, CreatedBy)
select @li_ConsistencyCheckID, t.Error, t.Level, t.State, t.MessageText, t.RepairLevel,
t.Status, t.ObjectID, t.IndexID, t.PartitionID, t.AllocunitID, t.[File], t.Page,
t.Slot, t.RefFile, t.RefPage, t.RefSlot, t.Allocation, @ldt_ExecutedOn, @lnvc_ExecutedBy
from #ltbl_Output t
-- Configure Alert Mail Subject Line
set @lnvc_Subject = 'Consistency Check failure for Database ' + quotename(@lnvc_Catalogue) + ' on Instance ' + quotename(@lnvc_Instance) + ' !'
set @lnvc_ErrorMessage = 'To view more details, logon to the Instance and execute the query: ' +
+ char(13) + char(10) + char(13) + char(10) +
'select * from sysadm.consistencycheck.ErrorLog where ExecutionLogID = ' + cast(@li_ConsistencyCheckID as varchar) + ''
+ char(13) + char(10) + char(13) + char(10) +
'Consistency Check Output: ' +
+ char(13) + char(10)
select @lnvc_SQL = N'set nocount on;select ltrim(rtrim(ErrorMessage)) as Message
from SysAdm.ConsistencyCheck.ErrorLog r
where r.ExecutionLogID = ''' + cast(@li_ConsistencyCheckID as nvarchar(128)) + ''''
exec msdb.dbo.sp_send_dbmail @profile_name = 'SQL Mailbox',
@recipients = @lnvc_Recipients,
@subject = @lnvc_Subject,
@body = @lnvc_ErrorMessage,
@query = @lnvc_SQL,
@execute_query_database = @lnvc_Catalogue,
@query_result_header = 1,
@query_result_width = 32767,
@query_no_truncate = 1,
@body_format = 'TEXT',
@importance = 'High'
end
end
else
begin
-- If we get here, then the database was not processed due to it having a status other than ONLINE, being in SINGLE_USER mode or
-- having a compatability level < 100
set @lnvc_Subject = 'Unable to perform consistency checks for Database ' + quotename(@lnvc_Catalogue) + ' on ' + quotename(@lnvc_Instance) + '!'
set @lnvc_ErrorMessage = 'One of the following conditions was not met. ' + CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) +
'* Database must be ONLINE. It''s current state is: ' + @lnvc_StateDescription + CHAR(13) + CHAR(10) +
'* Database access level cannot be set to SINGLE_USER. It''s current access level is: ' + @lnvc_UserAccess
exec msdb.dbo.sp_send_dbmail @profile_name = 'SQL Mailbox',
@recipients = @lnvc_Recipients,
@subject = @lnvc_Subject,
@body = @lnvc_ErrorMessage,
@body_format = 'TEXT',
@importance = 'High'
end
update t
set Flag = 1
from @ltbl_Catalogue t
where t.Catalogue = @lnvc_Catalogue
end
/*==============================================================================
Cleanup Temp Tables
==============================================================================*/
cleanup:
if object_id('tempdb..#ltbl_Output') is not null
drop table #ltbl_Output
/*==============================================================================
Exit Procedure
==============================================================================*/
quit:
return @li_Rc
/*==============================================================================
Error Processing
==============================================================================*/
errlog:
-- Raise Error, and write to Application Event Log
raiserror (@lnvc_ErrorMessage, 16, 1) with log, nowait
-- Send Email Notification of Error
exec msdb.dbo.sp_send_dbmail @profile_name = 'Mailbox',
@recipients = @lnvc_Recipients,
@subject = @lnvc_Subject,
@body = @lnvc_ErrorMessage,
@importance = 'High'
goto cleanup
go
John M. Couch -
Executing SSIS packages through SQL Server Jobs.
Hi,
I have an SSIS package which generates xml and text files and ftps it to an ftp site. When i run the package from BIDS it works successfully but when i run it from a job it fails. My SSIS package connects to DB server A and though i'm creating a job on DB
server A but my folder structure and the package resides in server B from where i'm connecting to DB server A through Management Studio. I'm using File system in SQL server Agent Job to call the package. When i execute the job i get following error:
Executed as user: I\A. ...er Execute Package Utility Version 9.00.3042.00 for 64-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 5:08:05 PM Error: 2011-06-21 17:08:05.11
Description: Unable to load the package as XML because of package does not have a valid XML format. A specific XML parser error will be posted. End Error Error: 2011-06-21 17:08:05.11 Description:
Failed to open package file "E:\P\H\R\Tools\R\R\R.dtsx" due to error 0x80070003 "The system cannot find the path specified.". This happens when loading a package and the file cannot be opened or loaded correctly into the XML document. This can be the
result of either providing an incorrect file name was specified when calling LoadPackage or the XML file was specified and has . The step failed.
Could you please tell me where am i going wrong?
Thanks,
Deepti
DeeptiHi Christa Kurschat,
I'm running the job under proxy account. And that account has sysadmin permissions.
I used following script to create proxy account and run my package under that account:
I. Create job executor account
Highlight Security->New Login, say to make login as devlogin, type your password, default database can be your target database.
Server roles: check �sysadmin�
User mapping: your target database
Msdb database: you make sure to include
SQLAgentUserRole, SQLAgentReaderRole, SQLAgentOperatorRole
Then click OK
II. Create SQL proxy account and associate proxy account with job executor account
Here is the code and run it the query window.
Use master
CREATE CREDENTIAL [MyCredential] WITH IDENTITY = 'yourdomain\myWindowAccount', secret = 'WindowLoginPassword'
Use msdb
Sp_add_proxy @proxy_name='MyProxy', @credential_name='MyCredential'
Sp_grant_login_to_proxy @login_name=' devlogin', @proxy_name='MyProxy'
Sp_grant_proxy_to_subsystem @proxy_name='MyProxy', @subsystem_name='SSIS'
III. Create SSIS package
In MS SQL Server Business Intelligence Development Studio, you use job executor account devlogin to create the SSIS package (DTS) and make sure you can execute this package
in SQL Server Business Intelligence Development Studio. Compile/build this package.
IV. Create the job, schedule the job and run the job
In SQL Server Management Studio, highlight SQL Server Agent -> Start. Highlight Job ->New Job�, name it , myJob.
Under Steps, New Step, name it, Step1,
Type: SQL Server Integration Service Package
Run as: myProxy
Package source: File System
Browse to select your package file xxx.dtsx
Click Ok
Schedule your job and enable it
I followed these steps.
Thanks,
Deepti
Deepti -
What is the Copy Command in SQL ?
COPY Command is used to COPY database table from one Schema to another Schema.
-
My coldfusion service crashes intermitantly and when I check
the application logs the error that I see for the time frame is the
one below. Does anyone know where I might begain to solve this?
Thanks!
Error Executing Database
Query.coldfusion.sql.DatabaseConnectionException: Timed out trying
to establish connection The specific sequence of files included or
processed is: E:\wwwroot\lifeworks\default.cfmI'm no expert, but thought I would try to be helpful.
I was getting this same error on a regular basis.
The short term fix was to restart the ODBC server service.
The long term fix was twofold:
1. I recreated the ODBC connection in ColdFusion
Administrator to use the system connection (I was using the SA and
PW for login).
2. I created a second user ODBC connection as well as the
system one under ODBC in Windows Server 2003.
I haven't had the problem since.
I also read a pretty good set of "stuff" to try from the help
area:
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_17277
Hope this helps. -
Using the equivalent of a BREAK ON command in SQL Developer SQL window
Folks.
In SQL*PLUS "BREAK ON Col1 ON Col2;", I can generate a report similar to the following:
Col1Value1 Col2Value1 Col3Value1
Col3Value2
Col3Value3
Col2Value2 Col3Value1
Col3Value2
Col3Value3
Col1Value2 Col2Value1 Col3Value1
Col3Value2
Col3Value3
Col2Value2 Col3Value1
Col3Value2
Col3Value3
etc.
I want to be able to do the same thing in my SQL Developer SQL window so that I can export the results to a spreadsheet file.
Does anyone know if this is possible?
I've tried using the SQL*PLUS BREAK command in my SQL Developer window but it appears to be ignored. My resultset looks something like
Col1Value1 Col2Value1 Col3Value1
Col1Value1 Col2Value1 Col3Value2
Col1Value1 Col2Value1 Col3Value3
Col1Value1 Col2Value2 Col3Value1
Col1Value1 Col2Value2 Col3Value2
Col1Value1 Col2Value2 Col3Value3
Col1Value2 Col2Value1 Col3Value1
Col1Value2 Col2Value1 Col3Value2
Col1Value2 Col2Value1 Col3Value3
Col1Value2 Col2Value2 Col3Value1
Col1Value2 Col2Value2 Col3Value2
Col1Value2 Col2Value2 Col3Value3
.OK thanks.
I did get around this by using SQL*PLUS to generate an output file with a separation character between the columns and spooling the SQL*PLUS output to a text file.
I then open the text file with Excel and specify the same character as a column separator. Seems to load properly into Excel. -
Execute a function in SQL Worksheet
How can I execute a function in SQL Worksheet.
The function takes in two parameters of type varchar2 and returns a boolean.
the syntax is:
set serveroutput on
VARIABLE x BOOLEAN;
EXECUTE :x := check_number('78','A');
PRINT x ;
my error is:
SP2-0552: Bind variable "X" not declared.
I have also tried:
set serveroutput on
select check_number('78','A')
from dual;
my error is:
ERROR at line 1:
ORA-06552: PL/SQL: Statement ignored
ORA-06553: PLS-382: expression is of wrong type
thanks.You could even cut out the variable:
SQL> CREATE OR REPLACE FUNCTION is_true
2 ( p1 VARCHAR2
3 , p2 VARCHAR2 )
4 RETURN BOOLEAN
5 AS
6 BEGIN
7 RETURN p1 = p2;
8 END is_true;
9 /
Function created.
SQL> exec dbms_output.put_line(sys.diutil.bool_to_int(IS_TRUE('x','y')))
0
PL/SQL procedure successfully completed.
SQL> exec dbms_output.put_line(sys.diutil.bool_to_int(IS_TRUE('x','x')))
1
PL/SQL procedure successfully completed. -
Executing a bunch of .SQL scripts in a folder ???
hi ,
I have 60+ sql scripts in a folder X..Is there any way to execute these scripts in one go..??
I am searching for a shortcut to execute these scripts using SQL PLUS Scripting (any possible way) ..
Can anyone give some light to solve my issue??
Regards,
johnjpy wrote:
hi ,
I have 60+ sql scripts in a folder X..Is there any way to execute these scripts in one go..??
I am searching for a shortcut to execute these scripts using SQL PLUS Scripting (any possible way) ..
Can anyone give some light to solve my issue??
Regards,
johnls -1 *sql > combined.sql
edit combined.sql and add "@" as first character of every lines
sqlplus scott/tiger @combined.sql
Maybe you are looking for
-
i need to know how can i fix my phone, after it gave me the black screen with the connect to itunes logo!!!!!!!! I NEED THE PHONE, and i can't have another one now, it is night!!!!!
-
Hi All, I'm trying to configure BR*Tools studio on Windows system. When i start the server i get the following reply Oracle Application Server Containers for J2EE 10g (9.0.4.1.0) Initialized. When i try to open the webpage with the following url, i g
-
Want to move RH Server 8 to 64 bit Windows 2008 Server R2
Can someone please confirm what version of Windows 2008 Server that RoboHelp Server 8 will run on? The Server Admin group says that they have to replace the server on which RH Server 8 is currently running an end-of-line operating system (Windows 200
-
Hi! i have a problem. I'm trying to access and old keychain password in a secure notes. It's not a keychain I use now, I think it's from a couple of years ago. I can access the keychain but not the passwords. When I click on the secure note I want to
-
How do I correct eyeglasses glare?
What is the best way to deal with eyeglasses glare?