Monday, March 26, 2012
Problem In Connecting Oracle9i SP with CR11.0
I made an Stored Proc. in oracle 9i, in which i inserted data in a temporary table. The SP got compiled successfully. But when i tried to add that SP in the CR 11.0, through DSN, i got an error msg.
Database Connector Error: 'HY000:[Oracle][ODBC][Ora]ORA-01456: may not perform insert/delete/update operation inside a READ ONLY transaction
ORA-06512: at "SCOTT.TEST_INSERTDATA1", line 6
ORA-06512: at line 1
If data is not inserted in stored proc, then no error comes while connecting Crystal report to stored proc of oracle.
This problem is specifically for those stored procs, where data is inserted in some table inside stored proc and that is used in CR.
Code of Oracle Stored Proc is as follows.
----------------
create or replace procedure Test_InsertData1(curmain in out CommonCursor_Pkg.abc,arg1 varchar2,arg2 varchar2)
as
lcsqry varchar2(500);
begin
lcsqry:='delete from reptable1';
execute immediate(lcsqry);
for i in 1..10 loop
lcsqry:='insert into reptable1(sfld1,nfld1) values(''aa'','||i||')';
execute immediate(lcsqry);
end loop;
commit;
lcsqry:='select sfld1,nfld1 from reptable1';
open curmain for (lcsqry);
end;
/
--------------------
-- Here CommonCursor_Pkg.abc denotes a ref cursor type named 'abc' declared inside CommonCursor_Pkg package. Code for this is :
create package CommonCursor_Pkg
as
type abc is ref cursor;
end;
/
-------------------
-- 'reptable1' is a global temporary table.
--CR 11.0 is connected to oracle in following manner.
Goto
Database Expert-> create new connection ->ODBC(RDO)
Then selecting the Oracle DSN from the list.
Or
Goto
Database Expert-> Create new Connection-> OLE DB(ADO)
please see how to fix this problem.
Thanks and regards
Vineet kumarThe procedure should have select statement at the end. As you are using using dynamic sql, scope is over if you run that proceudre. Try using global temporary tablesql
Wednesday, March 21, 2012
Problem getting execution status of a SQL Agent Job
I’m having trouble retrieving the execution status of a job – perhaps someone can help me.
I have a stored proc (on SQL 2005) that dynamically creates and executes a SQL Agent Job. The stored proc first has to check whether the job exists. If it already exists and is not active then I simply reuse the existing job. However if the job exists but is currently executing then I need to create a new job because there can be multiple instances of the program that the job runs. My problem is how to check whether the job is currently executing. I tried using sp_help_job as shown below but the rowcount seems to return 1 even when there are no jobs executing!
Exec msdb.dbo.sp_help_job
@.job_aspect = 'JOB',
@.execution_status = 0,
@.job_name = @.JobName
If @.@.rowcount > 0 Begin
…
End
I then tried this code…
If (select count(*) from msdb.dbo.sysjobs j
left outer join msdb.dbo.sysjobhistory h on j.job_id = h.job_id where name = @.JobName and
h.step_id = 1 and
run_status = 4) > 0
Begin
…
End
… but it doesn’t seem to pick up records even when the job is currently executing.
How can I, in T-SQL, get the execution status of the job?
exec master.dbo.xp_sqlagent_enum_jobs 1, {insert job owner here}
This procedure outputs a 'Running' field that will return a 1 if it the job is running, or otherwise a 0. This is not complete code for you, but should get you pointed in the right direction. I am going to build a temp table with this XP and filter on the job ID to return the status.
|||sp_help_jobactivity is the sp that should give status of jobs in SQL2005. See BOL for more info on this SP.sqlTuesday, March 20, 2012
Problem executing a stored proc, please help
I have stored proc that processes about 60,000 rows using a cursor. When I
call the SP from Query Analyzer, I get the following error message after
processing about 12,000 records :
Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (InvalidParam()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
ODBC: Msg 0, Level 16, State 1
Communication link failure
Connection Broken
12614 records
What can i do to make this SP run sucessfully ? I even tried using a table
variable instead of a cursor, but got the same result. Please suggest .
THE output from SP_CONFIG on database server is
Option
config_value
------
affinity mask 0
allow updates 0
awe enabled 0
c2 audit mode 0
cost threshold for parallelism 5
Cross DB Ownership Chaining 0
cursor threshold -1
default full-text language 1033
default language 0
fill factor (%) 0
index create memory (KB) 0
lightweight pooling 0
locks 0
max degree of parallelism 0
max server memory (MB) 2147483647
max text repl size (B) 65536
max worker threads 255
media retention 0
min memory per query (KB) 1024
min server memory (MB) 0
nested triggers 1
network packet size (B) 4096
open objects 0
priority boost 0
query governor cost limit 0
query wait (s) -1
recovery interval (min) 0
remote access 1
remote login timeout (s) 20
remote proc trans 0
remote query timeout (s) 0
scan for startup procs 0
set working set size 0
show advanced options 1
two digit year cutoff 2049
user connections 0
user options 0
Hi
It would help if you posted DDL and example data such as
http://www.aspfaq.com/etiquettXXe.asp?id=5006 and
example data as insert statements
http://vyaskn.tripod.com/code.XXhtm#inserts
Connection broken implies a network failure/disconnection, possibly a
timeout but you do not indicate how long this process takes.
Check your SQL server version and service pack level, you may also want to
check MDAC version and consistancy along with the SQL Server log and event
log to see if there is any more information that may help.
Other posts on this http://tinyurl.com/4ebus may be helpful.
John
"rajeshlh" <rajeshlh@.discussions.microsoft.com> wrote in message
news:F1F399D6-BB17-4FC9-BF10-4F7D3A31F7B1@.microsoft.com...
> Hi All,
> I have stored proc that processes about 60,000 rows using a cursor. When I
> call the SP from Query Analyzer, I get the following error message after
> processing about 12,000 records :
>
> Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead
> (InvalidParam()).
> Server: Msg 11, Level 16, State 1, Line 0
> General network error. Check your network documentation.
> ODBC: Msg 0, Level 16, State 1
> Communication link failure
>
> Connection Broken
>
>
> 12614 records
>
> What can i do to make this SP run sucessfully ? I even tried using a table
> variable instead of a cursor, but got the same result. Please suggest .
>
> THE output from SP_CONFIG on database server is
> Option
> config_value
> ------
> affinity mask 0
> allow updates 0
> awe enabled 0
> c2 audit mode 0
> cost threshold for parallelism 5
> Cross DB Ownership Chaining 0
> cursor threshold -1
> default full-text language 1033
> default language 0
> fill factor (%) 0
> index create memory (KB) 0
> lightweight pooling 0
> locks 0
> max degree of parallelism 0
> max server memory (MB) 2147483647
> max text repl size (B) 65536
> max worker threads 255
> media retention 0
> min memory per query (KB) 1024
> min server memory (MB) 0
> nested triggers 1
> network packet size (B) 4096
> open objects 0
> priority boost 0
> query governor cost limit 0
> query wait (s) -1
> recovery interval (min) 0
> remote access 1
> remote login timeout (s) 20
> remote proc trans 0
> remote query timeout (s) 0
> scan for startup procs 0
> set working set size 0
> show advanced options 1
> two digit year cutoff 2049
> user connections 0
> user options 0
>
>
>
Problem executing a stored proc, please help
I have stored proc that processes about 60,000 rows using a cursor. When I
call the SP from Query Analyzer, I get the following error message after
processing about 12,000 records :
Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (InvalidParam()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
ODBC: Msg 0, Level 16, State 1
Communication link failure
Connection Broken
12614 records
What can i do to make this SP run sucessfully ? I even tried using a table
variable instead of a cursor, but got the same result. Please suggest .
THE output from SP_CONFIG on database server is
Option
config_value
------
affinity mask 0
allow updates 0
awe enabled 0
c2 audit mode 0
cost threshold for parallelism 5
Cross DB Ownership Chaining 0
cursor threshold -1
default full-text language 1033
default language 0
fill factor (%) 0
index create memory (KB) 0
lightweight pooling 0
locks 0
max degree of parallelism 0
max server memory (MB) 2147483647
max text repl size (B) 65536
max worker threads 255
media retention 0
min memory per query (KB) 1024
min server memory (MB) 0
nested triggers 1
network packet size (B) 4096
open objects 0
priority boost 0
query governor cost limit 0
query wait (s) -1
recovery interval (min) 0
remote access 1
remote login timeout (s) 20
remote proc trans 0
remote query timeout (s) 0
scan for startup procs 0
set working set size 0
show advanced options 1
two digit year cutoff 2049
user connections 0
user options 0Hi
It would help if you posted DDL and example data such as
http://www.aspfaq.com/etiquette.asp?id=5006 and
example data as insert statements
http://vyaskn.tripod.com/code.htm#inserts
Connection broken implies a network failure/disconnection, possibly a
timeout but you do not indicate how long this process takes.
Check your SQL server version and service pack level, you may also want to
check MDAC version and consistancy along with the SQL Server log and event
log to see if there is any more information that may help.
Other posts on this http://tinyurl.com/4ebus may be helpful.
John
"rajeshlh" <rajeshlh@.discussions.microsoft.com> wrote in message
news:F1F399D6-BB17-4FC9-BF10-4F7D3A31F7B1@.microsoft.com...
> Hi All,
> I have stored proc that processes about 60,000 rows using a cursor. When I
> call the SP from Query Analyzer, I get the following error message after
> processing about 12,000 records :
>
> Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead
> (InvalidParam()).
> Server: Msg 11, Level 16, State 1, Line 0
> General network error. Check your network documentation.
> ODBC: Msg 0, Level 16, State 1
> Communication link failure
>
> Connection Broken
>
>
> 12614 records
>
> What can i do to make this SP run sucessfully ? I even tried using a table
> variable instead of a cursor, but got the same result. Please suggest .
>
> THE output from SP_CONFIG on database server is
> Option
> config_value
> ------
> affinity mask 0
> allow updates 0
> awe enabled 0
> c2 audit mode 0
> cost threshold for parallelism 5
> Cross DB Ownership Chaining 0
> cursor threshold -1
> default full-text language 1033
> default language 0
> fill factor (%) 0
> index create memory (KB) 0
> lightweight pooling 0
> locks 0
> max degree of parallelism 0
> max server memory (MB) 2147483647
> max text repl size (B) 65536
> max worker threads 255
> media retention 0
> min memory per query (KB) 1024
> min server memory (MB) 0
> nested triggers 1
> network packet size (B) 4096
> open objects 0
> priority boost 0
> query governor cost limit 0
> query wait (s) -1
> recovery interval (min) 0
> remote access 1
> remote login timeout (s) 20
> remote proc trans 0
> remote query timeout (s) 0
> scan for startup procs 0
> set working set size 0
> show advanced options 1
> two digit year cutoff 2049
> user connections 0
> user options 0
>
>
>
Problem executing a stored proc, please help
I have stored proc that processes about 60,000 rows using a cursor. When I
call the SP from Query Analyzer, I get the following error message after
processing about 12,000 records :
Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (InvalidP
aram()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
ODBC: Msg 0, Level 16, State 1
Communication link failure
Connection Broken
12614 records
What can i do to make this SP run sucessfully ? I even tried using a table
variable instead of a cursor, but got the same result. Please suggest .
THE output from SP_CONFIG on database server is
Option
config_value
----
---
affinity mask 0
allow updates 0
awe enabled 0
c2 audit mode 0
cost threshold for parallelism 5
Cross DB Ownership Chaining 0
cursor threshold -1
default full-text language 1033
default language 0
fill factor (%) 0
index create memory (KB) 0
lightweight pooling 0
locks 0
max degree of parallelism 0
max server memory (MB) 2147483647
max text repl size (B) 65536
max worker threads 255
media retention 0
min memory per query (KB) 1024
min server memory (MB) 0
nested triggers 1
network packet size (B) 4096
open objects 0
priority boost 0
query governor cost limit 0
query wait (s) -1
recovery interval (min) 0
remote access 1
remote login timeout (s) 20
remote proc trans 0
remote query timeout (s) 0
scan for startup procs 0
set working set size 0
show advanced options 1
two digit year cutoff 2049
user connections 0
user options 0Hi
It would help if you posted DDL and example data such as
http://www.aspfaq.com/etiquett__e.asp?id=5006 and
example data as insert statements
http://vyaskn.tripod.com/code.__htm#inserts
Connection broken implies a network failure/disconnection, possibly a
timeout but you do not indicate how long this process takes.
Check your SQL server version and service pack level, you may also want to
check MDAC version and consistancy along with the SQL Server log and event
log to see if there is any more information that may help.
Other posts on this http://tinyurl.com/4ebus may be helpful.
John
"rajeshlh" <rajeshlh@.discussions.microsoft.com> wrote in message
news:F1F399D6-BB17-4FC9-BF10-4F7D3A31F7B1@.microsoft.com...
> Hi All,
> I have stored proc that processes about 60,000 rows using a cursor. When I
> call the SP from Query Analyzer, I get the following error message after
> processing about 12,000 records :
>
> Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead
> (InvalidParam()).
> Server: Msg 11, Level 16, State 1, Line 0
> General network error. Check your network documentation.
> ODBC: Msg 0, Level 16, State 1
> Communication link failure
>
> Connection Broken
>
>
> 12614 records
>
> What can i do to make this SP run sucessfully ? I even tried using a table
> variable instead of a cursor, but got the same result. Please suggest .
>
> THE output from SP_CONFIG on database server is
> Option
> config_value
> ----
---
> affinity mask 0
> allow updates 0
> awe enabled 0
> c2 audit mode 0
> cost threshold for parallelism 5
> Cross DB Ownership Chaining 0
> cursor threshold -1
> default full-text language 1033
> default language 0
> fill factor (%) 0
> index create memory (KB) 0
> lightweight pooling 0
> locks 0
> max degree of parallelism 0
> max server memory (MB) 2147483647
> max text repl size (B) 65536
> max worker threads 255
> media retention 0
> min memory per query (KB) 1024
> min server memory (MB) 0
> nested triggers 1
> network packet size (B) 4096
> open objects 0
> priority boost 0
> query governor cost limit 0
> query wait (s) -1
> recovery interval (min) 0
> remote access 1
> remote login timeout (s) 20
> remote proc trans 0
> remote query timeout (s) 0
> scan for startup procs 0
> set working set size 0
> show advanced options 1
> two digit year cutoff 2049
> user connections 0
> user options 0
>
>
>
Problem executing a stored proc
Hi All,
I have stored proc that processes about 60,000 rows using a cursor. When I call the SP from Query Analyzer, I get the following error message after processing about 12,000 records :
Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionRead (InvalidParam()).
Server: Msg 11, Level 16, State 1, Line 0
General network error. Check your network documentation.
ODBC: Msg 0, Level 16, State 1
Communication link failure
Connection Broken
12614 records
What can i do to make this SP run sucessfully ? I even tried using a table variable instead of a cursor, but got the same result.
THE output from SP_CONFIG is
Option config_value
---------------------------------------
affinity mask | 0 |
allow updates | 0 |
awe enabled | 0 |
c2 audit mode | 0 |
cost threshold for parallelism | 5 |
Cross DB Ownership Chaining | 0 |
cursor threshold | -1 |
default full-text language | 1033 |
default language | 0 |
fill factor (%) | 0 |
index create memory (KB) | 0 |
lightweight pooling | 0 |
locks | 0 |
max degree of parallelism | 0 |
max server memory (MB) | 2147483647 |
max text repl size (B) | 65536 |
max worker threads | 255 |
media retention | 0 |
min memory per query (KB) | 1024 |
min server memory (MB) | 0 |
nested triggers | 1 |
network packet size (B) | 4096 |
open objects | 0 |
priority boost | 0 |
query governor cost limit | 0 |
query wait (s) | -1 |
recovery interval (min) | 0 |
remote access | 1 |
remote login timeout (s) | 20 |
remote proc trans | 0 |
remote query timeout (s) | 0 |
scan for startup procs | 0 |
set working set size | 0 |
show advanced options | 1 |
two digit year cutoff | 2049 |
user connections | 0 |
user options | 0 |
Saturday, February 25, 2012
Problem correctly setting a local_variable
Hi,
I've been trying to write a stored proc to no avail. I'm trying to set a local variable and every time I try to execute the stored proc I get the following error:
Running [dbo].[StoredProcedure2].
Conversion failed when converting the nvarchar value 'TEST2' to data type int.
No rows affected.
(0 row(s) returned)
@.RETURN_VALUE =
Finished running [dbo].[StoredProcedure2].
Here's the code (which I skimmed down to try and pinpoint where the issue was).
Initially, I was trying to assign a numeric string value stored as nvarchar(10) and anytime the value would be over '2147999999' (in that area) it would bomb... Now even this simple code won't work and I can't understand why. If anyone would be kind enough to enlighten me ;-)
ALTER PROCEDURE dbo.StoredProcedure2
AS
DECLARE @.ME NVARCHAR(10);
SET @.ME = 'TEST2';
RETURN @.ME
u must use Print/Select instead of Return.
fromBOL
RETURN
Exits unconditionally from a query or procedure. RETURN is immediate and complete and can be used at any point to exit from a procedure, batch, or statement block. Statements following RETURN are not executed.
Syntax
RETURN [ integer_expression ]
alter PROCEDURE dbo.StoredProcedure2
AS
DECLARE @.ME NVARCHAR(10);
SET @.ME = 'TEST2';
select @.me
Madhu
|||The value following the RETURN keyword MUST be an integer value.
Strings are not allowable RETURN values.
Instead use:
Code Snippet
ALTER PROCEDURE dbo.StoredProcedure2
AS
DECLARE @.ME NVARCHAR(10);
SET @.ME = 'TEST2';
SELECT @.Me
GO |||It always better to use OUTPUT parameter, or Select statement to get the single row & column data from the SP. Return only supports integer.
NOTE:
PRINT – you can’t get the result on the UI. It will get suppressed.