Showing posts with label endless. Show all posts
Showing posts with label endless. Show all posts

Thursday, March 29, 2012

Endless subqueries

I have a table with two columns: OID and Cumulative (witch is the same type as OID)

Each OID can have one or more Cumulatives.

Example of data:

OID Cumulative

167 292

167 294

167 296

168 292

169 302

169 304

The cumulation of each OID don't stop at one cumulation, but can be endless (theoretical).

Example: 167->292->590

So the table would have on more row:

OID Cumulative

295 505

I would like to represent this strucuture in a tree view and I'm looking for a query that could give me a table with this structure:

OID Cumul1 Cumul2 Cuml3 Cuml4 .... Cumuln

in the way I can read the row and have as many child nodes as I have values in the columns. The number of columns depends on the row with most cumulations.

How can I do the query?

Is there a better way as my table with n columns?

Thanks for suggestions

Your sample data is confusing..Can you fix it. Let us know the sample output from the input (sample data) you provided.

Endless running package using a proxy

I have a package which runs fine, when I execute it with my account (e.g. double-click on the .dtsx file and run it).

Now I would like to establish a job, which starts the package. I created first a credential for my Account (which is a domain administrator account also for the box, where SQL Server is running on), then I defined a proxy to this credential.

In the job definition I changed the Run as... to this Proxy (it is a SSIS Proxy) and then I started the job.

Th job does NOT abend, it runs forever! So I have to stop it manually.

In the log I can see as last entry : "operation complete". It stops at a "Execute process task" where I call the bcp utility.

Does anyone has an idea, why a package can run forever?!?!

Regards

Norbert

Sorry, it is not the package running forever (it logged "operation complete) but the job does not stop.

In addition I would like to add another information. I tested the package also as CmdExec Call (dtexec ....) but the result is still the same.

Regards

Norbert Bender

Endless looping job!

i have created a job that i have scheduled to run every 10 min everything is configured well since i have tested preety everything their is to be tested and found that it was my last step wich as a fetch in it so i imagine that this fetch is making it loop over and over again. the job goes trought all the steps and starts back at the first step and keep going like that till i disable it here is my fetch statement and if you have any clue any help would be widely apreciated.

PS: i suspected it to be that fetch statement causing the havoc ;)

DECLARE
@.TransactionNb varchar(10),
@.EqId varchar(10)

DECLARE TransactionNb_cursor CURSOR
FOR
SELECT TransactionNb, EqId
FROM DetCom
WHERE UpdCode = 'C'

OPEN TransactionNb_cursor

FETCH NEXT FROM TransactionNb_cursor
INTO @.TransactionNb, @.EqId

WHILE @.@.FETCH_STATUS <> -1
BEGIN
-- Vrifier s'il existe une transaction avec le UpdCode = 'C' dans EntCom
IF (SELECT UpdCode
FROM EntCom
WHERE TransactionNb = @.TransactionNb and EqId = @.EqId) = 'C'
BEGIN
CONTINUE
END
ELSE
BEGIN
RAISERROR (50006, 10, 0, @.TransactionNb, @.EqId)
END

FETCH NEXT FROM TransactionNb_cursor
INTO @.TransactionNb, @.EqId
END

CLOSE TransactionNb_cursor
DEALLOCATE TransactionNb_cursorChange the loop terminator to WHILE @.@.FETCH_STATUS = 0
not <> -1

Endless loop while sync.

I am trying to replicate a database but it seems to go into endless
loop showing:
Processing article: 'Table1'
Processing article: 'Table2'
Processing article: 'Table3'
Processing article: 'Table1'
Processing article: 'Table2'
..
..
..
I stopped it after quite a lot of loop cycles, but it looks like it is
still running in background. In enterprise manager the last action is
"Synchronization in progress" and status is "Running". I already
restarted the sql-server service and also the computer - didn't help.
The replication is done using an external program and not with job.
Thanks
This can be normal. You should let this process finish. It is somewhat
transactional, ie it will pick up where it left off.
Hilary Cotter
Looking for a SQL Server replication book?
Now available for purchase at:
http://www.nwsu.com/0974973602.html
"or dromi" <or_dromi@.walla.co.il> wrote in message
news:539934ef.0411240754.37ab924a@.posting.google.c om...
>I am trying to replicate a database but it seems to go into endless
> loop showing:
> Processing article: 'Table1'
> Processing article: 'Table2'
> Processing article: 'Table3'
> Processing article: 'Table1'
> Processing article: 'Table2'
> .
> .
> .
> I stopped it after quite a lot of loop cycles, but it looks like it is
> still running in background. In enterprise manager the last action is
> "Synchronization in progress" and status is "Running". I already
> restarted the sql-server service and also the computer - didn't help.
> The replication is done using an external program and not with job.
>
> Thanks
sql

Endless loop

*** edited by: master4eva ***
Please enclose your code in
</ code> tags (without the space between the "</" and "code"). This will make your code easier to read online; therefore, encouraging a response to be faster. It is to your own benefit for your question to be answered in future.

I have already done the editing to include the <code></ code> tags.
*********

I have a trigger that fires this stored procedure during an update event. But i think i am getting an endless loop. Any idea? Thanks in advance...
<code>
ALTER PROCEDURE TrigRetReqRecIDP1
@.REID int

AS

Declare @.RRID int
Declare @.intREID varchar(20)
Declare @.intIMID varchar(20)
Declare @.RetValint
Declare cr cursor
for
select RRID from RequestRecords where REID=@.REID and RRStatus = 'PE'
open cr

fetch next from cr
into
@.RRID

while @.@.fetch_status = 0
Begin
select @.intIMID = (select IMID from ImplementationGroup where ImGrpName = 'Help Desk')
insert into ImplementationTasks
(
IMID,
ITStatus,
ITStatusDate
)
VALUES
(
@.intIMID,
'2',
GetDate()
)
SET @.RetVal = @.@.IDENTITY
Update RequestRecords
set ITID = @.RETVal, RRStatus = 'IA'
where REID = @.REID and RRID = @.RRID

end

close cr
deallocate cr

GO

and what is the code for the trigger ?|||CREATE TRIGGER trUpdateRequestNewP1
on dbo.Requests
For Update
AS
DECLARE @.REIDint

SELECT @.REID = (SELECT REID from inserted where REStatus ='AC' and REType = 'N')

-- EXEC TrigAssignImpTaskNewP1 @.REID
EXEC TrigRetReqRecIDP1 @.REID|||i dont see any update stmt for records within the proc TrigRetReqRecIDP1...do you have any updates in TrigAssignImpTaskNewP1 ?

hth|||Here's the new version but it is only updating the first record @.RRID...

What I am trying to do is...

I have multiple RRID from RequestRecords where REID = @.REID.
I want to assign each RRID a task from the implementationtasks table...
SO if there are 10 RRID's then ten tasks should be created in the implementationtable. Each @.retval returned from the implementationTasks table will be assigned and updated to each RRID in requestrecords table...

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

ALTER PROCEDURE TrigRetReqRecIDP1
@.REID int

AS

Declare @.RRID int
Declare @.intREID varchar(20)
Declare @.intIMID varchar(20)
Declare @.RetValint
Declare crReqRec cursor for
select RRID from RequestRecords where REID = @.REID and RRSTatus = 'PE'
open crReqRec
fetch next from crReqRec
into
@.RRID

while @.@.fetch_status = 0
Begin

set @.intIMID = (select IMID from ImplementationGroup where ImGrpName = 'Help Desk')
insert into ImplementationTasks
(
IMID,
ITStatus,
ITStatusDate
)
VALUES
(
@.intIMID,
'2',
GetDate()
)
SET @.RetVal = @.@.IDENTITY

Update RequestRecords
set ITID = @.RETVal, RRStatus = 'IA'
where REID = @.REID and RRID = @.RRID

FETCH NEXT FROM crReqRec
end

close crReqRec
deallocate crReqRec

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

|||This one works perfectly but do you have any suggestion to improve it?... Thanks

SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO

ALTER PROCEDURE TrigRetReqRecIDP1
@.REID int

AS

Declare @.RRID int
Declare @.intREID varchar(20)
Declare @.intIMID varchar(20)
Declare @.RetValint
Declare crReqRec cursor for
select RRID from RequestRecords where REID = @.REID and RRSTatus = 'PE'
open crReqRec
fetch next from crReqRec
into
@.RRID

while @.@.fetch_status = 0
Begin

set @.intIMID = (select IMID from ImplementationGroup where ImGrpName = 'Help Desk')
insert into ImplementationTasks
(
IMID,
ITStatus,
ITStatusDate
)
VALUES
(
@.intIMID,
'2',
GetDate()
)
SET @.RetVal = @.@.IDENTITY

Update RequestRecords
set ITID = @.RETVal, RRStatus = 'IA'
where REID = @.REID and RRID = @.RRID

FETCH NEXT FROM crReqRec
into
@.RRID
end

close crReqRec
deallocate crReqRec

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

|||this part of your code :

set @.intIMID = (select IMID from ImplementationGroup where ImGrpName = 'Help Desk')
insert into ImplementationTasks
(IMID,ITStatus,ITStatusDate)
VALUES
(@.intIMID,'2',GetDate())
SET @.RetVal = @.@.IDENTITY

does not have to be in the cursor since it is not dependent on the cursor values..the insert stmt will run for each record in the cursor...unless that is what you want...
you can move this part outside the cursor..so it will run only once...also i'd suggest using SCOPE_IDENTITY() instead of @.@.IDENTITY.

hth