Always do Commit or Rollback ... (I said or !!!)

Este forum é dedicado a códigos errados que se encontram por aí, ou seja, coisas que não se deve fazer de jeito nenhum! Não coloque neste forum dúvidas! (apenas situações bizarras do nosso dia a dia :-)
Post Reply
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

This code is medium "off-topic" as it is done in SQL * Server. But as Commit and Rollback is a universal medium, he deserves a prominent place as well:

Select all

DECLARE @ImportDate as DateTime 
 
SELECT @ImportDate = '2010-01-13 09:45:00'       
INSERT dbo.Customers ([Name], ListSegmentsID, ListDOMsCompanyNumbersID, 
      ListVerticalsID, ListAreasID, ListRegionsID,  
      UpdatedByUserID,DateUpdated,ListCountryTypesID, AffinityID) 
 
select distinct s$.CustomerName as CustomerName, 
      ls.id as segmentID, doms.ID as DomsID,  
      lv.ID as VerticalID, la.ID as AreaID, lr.ID as RegionID,   
      323 as ToolsTeamID, @ImportDate as UpdatedByDate, CT.ID as Country, s$.AffinityNumber 
from _ImportCustomers5 s$ 
left join ListSegments ls on ls.Segment = s$.Segment 
left join ListDOMsCompanyNumbers doms on doms.DOMsCompanyNumber = s$.DOMSCompanyNum 
left join ListVerticals lv on lv.Vertical = s$.Vertical 
left join ListAreas la on la.Area = s$.Area 
left join ListRegions lr on lr.Region = s$.Region 
left join ListCountryTypes as CT On CT.CountryType = s$.Country 
where NOT EXISTS (Select * from dbo.Customers c where c.name = s$.CustomerName) 
order by s$.CustomerName 
 
commit 
rollback 
 
update _ImportIssues5 
      set QuestCustomerID = c.ID 
      FROM _ImportIssues5 i$  
      INNER JOIN dbo.Customers c on c.Name = RTrim(i$.CustomerName) 
 
 
ROLLBACK 
COMMIT 
Yes, I was in production :-)
diegolenhardt
Moderador
Moderador
Posts: 1177
Joined: Thu, 15 Oct 2009 10:28 am
Location: Recife

This last update must be very important, uahuiahuaa
always from rollback
JOPA
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 58
Joined: Fri, 30 Oct 2009 9:52 am
Location: Salvador - BA
Contact:
Atenciosamente,

João Paulo A. C. do Bomfim

"Deu certo? Deixa! Funcionou? Não mexa!"

Curious ... :?

The table that is suffering update, in the case _ImportIssues5,
is being monitored by some trigger with an associated procedure?

take it away, maybe it's a silada..rs

interesting the post.
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests