Showing posts with label block. Show all posts
Showing posts with label block. Show all posts

Tuesday, March 20, 2012

PL-SQL LOOP equivilant in TRANSACT-SQL

Hi,

I need to convert this anonymous pl-sql block into transact-sql to run
in Microsoft SQL Server Query Analyser.

Does anyone know what the conversion syntax would be?

I know that to declare variables to use the @..
PRINT for printing the output.

No idea for the LOOP.

Any suggestions greatly appreciated.

Many thanks.

Thiko!
____________________________________________

SET SERVEROUTPUT ON

DECLARE
recordcount NUMBER;

BEGIN
DBMS_OUTPUT.ENABLE(5000000); -- Sets buffer size.
recordcount := 0;

LOOP
INSERT INTO RecoverTest VALUES (SYSDATE - (recordcount / 4));
COMMIT; -- frees up rollback segment;
recordcount := recordcount + 1;
DBMS_OUTPUT.PUT_LINE('INSERT: ' || recordcount || ' - 45000 ');
EXIT WHEN recordcount > 45000;
END LOOP;
END;
/Not certain about the Oracle date arithmetic but take a look at this post
which was a very similar requirement:
http://tinyurl.com/tlpi

--
David Portas
----
Please reply only to the newsgroup
--

Monday, February 20, 2012

Please help!! Urgent

Hi guys,

we have a database here and something happened which causes a database block. We tried to run the 'sp_who' 'active' command to see the spid which locked the database, and we found out that some transaction is blocking another transaction. The following is the sample data results from the sp_who 'active'

spid ecid status loginame hostname blk dbname cmd

52 0 sleeping HOSTING\SQLMonitor BLUE2 185 tempdb INSERT
53 0 sleeping sa 10.10.10.106 185 mfgq_live SELECT
56 0 sleeping sa 10.10.10.106 175 mfgq_live UPDATE
57 0 sleeping sa 10.10.10.143 185 mfgq_live SELECT

We killed all spid which casuse the blocking, but they are keep on coming.

Does anybody have any idea on what casuses this problem or a teporary solution for this? Please help.

Thx

you need to findout what these process is actually doing.. run

dbcc inputbuffer(185) to see the sql statement which these spid is executing.

madhu