473,567 Members | 2,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

table trigger just hangs

I have a UDF that cleans a field of control characters and I use it
like this
select
dbo.udf_CleanAl phaNum(Address1 ) as Address1
from Leads

It works great. I use it to clean several fields from a vendors SQL
server. The downside is I have to first load the data into my database
so I can use my function to clean the data THEN proceed to load it
into the destination table. I thought I could create a trigger on the
final table that calls this function via a trigger.

This is my test CREATE TRIGGER

USE [Strayer_Staging]
GO
/****** Object: Trigger [dbo].[Clean_Q_Lead_De mographics] Script
Date: 04/16/2008 15:32:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFI ER ON
GO
CREATE TRIGGER [dbo].[Clean_Q_Lead_De mographics]
ON [Strayer_Staging].[dbo].[Q_Lead_Demograp hics]
for update, insert
AS
update Strayer_Staging .dbo.Q_Lead_Dem ographics
set address1 = dbo.udf_CleanAl phaNum(inserted .Address1)
from INSERTED ;

when I try to update a record with

update q_lead_demograp hics
set address1 = '2 chestnut street'
where leadid = 1075789

it looks like it updates all records becuase it take 4 minutes and I
get this message:
(1055538 row(s) affected)

(1 row(s) affected)

it works, but on all rows, not just the updated row.

Is there a @@ variable that is the primary key so I should use a
WHERE, or am going about this all wrong?
TIA
Jun 27 '08 #1
4 2754
On Apr 16, 3:32*pm, rcamarda <robert.a.cama. ..@gmail.comwro te:
I have a UDF that cleans a field of control characters and I use it
like this
select
* dbo.udf_CleanAl phaNum(Address1 ) as Address1
from *Leads

It works great. I use it to clean several fields from a vendors SQL
server. The downside is I have to first load the data into my database
so I can use my function to clean the data THEN proceed to load it
into the destination table. I thought I could create a trigger on the
final table that calls this function via a trigger.

This is my test CREATE TRIGGER

USE [Strayer_Staging]
GO
/****** Object: *Trigger [dbo].[Clean_Q_Lead_De mographics] * *Script
Date: 04/16/2008 15:32:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFI ER ON
GO

CREATE TRIGGER [dbo].[Clean_Q_Lead_De mographics]
* *ON *[Strayer_Staging].[dbo].[Q_Lead_Demograp hics]
* for update, insert
AS
* update Strayer_Staging .dbo.Q_Lead_Dem ographics
* set address1 = dbo.udf_CleanAl phaNum(inserted .Address1)
from INSERTED * ;

when I try to update a record with

update q_lead_demograp hics
set address1 = '2 chestnut street'
where leadid = 1075789

it looks like it updates all records becuase it take 4 minutes and I
get this message:
(1055538 row(s) affected)

(1 row(s) affected)

it works, but on all rows, not just the updated row.

Is there a @@ variable that is the primary key so I should use *a
WHERE, or am going about this all wrong?
TIA
This seems to work better the result shows I updated 2 records. Is it
becuase an update is really a delete and an update?

ALTER TRIGGER [dbo].[Clean_Q_Lead_De mographics]
ON [Strayer_Staging].[dbo].[Q_Lead_Demograp hics]
for update, insert
AS
update Strayer_Staging .dbo.Q_Lead_Dem ographics
set
address1 = dbo.udf_CleanAl phaNum(inserted .Address1),
address2 = dbo.udf_CleanAl phaNum(inserted .Address2),
address3 = dbo.udf_CleanAl phaNum(inserted .Address3),
bad_email = dbo.ValidateEma ilAddress(lower (replace(insert ed.email,'
',''))),
City = dbo.udf_CleanAl phaNum(inserted .City)
from inserted
where q_lead_demograp hics.leadid = inserted.leadid
Jun 27 '08 #2
I got the trigger to work, but what added to my confusion was the bulk
load.
I was using the API method of bulk loading as provided in Cognos' Data
Manager ETL tool. I discovered that the trigger would work when I used
a normal relational delivery, but not the API bulk load.
Jun 27 '08 #3
rcamarda wrote:
I got the trigger to work, but what added to my confusion was the bulk
load.
I was using the API method of bulk loading as provided in Cognos' Data
Manager ETL tool. I discovered that the trigger would work when I used
a normal relational delivery, but not the API bulk load.
http://msdn2.microsoft.com/en-us/library/ms171769.aspx indicates that
bulk loads ignore triggers unless called with FireTriggers = TRUE. Does
Data Manager have an option to activate that flag?
Jun 27 '08 #4
Turns out it doesnt.
I've submitted an enhancement request to Cognos about that aspect of
API loads and triggers.

Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
18709
by: Michael Spiegel | last post by:
Hi, I have a stored procedure that needs to know the name of the table from which it is called. If you are familiar with a "this" pointer in Java or C++, that's very similar to what I need. I know I can use db_name() to retrieve the database name, but how do retrieve the table name? Thanks, --Michael
36
4623
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am proposing a single column table with a field name called vehicle_type and this will contain the vehicle type. Sot it will be
3
7273
by: takilroy | last post by:
Hi, Does anyone know of a simple way to do this? I want to create an insert trigger for a table and if the record already exists based on some criteria, I want to update the table with the values that are passed in via the insert trigger without having to use all the 'set' statements for each field (so if we add fields in the future I...
33
4746
by: coosa | last post by:
I have a table: ---------------------------------------------------- CREATE TABLE CATEGORY ( CATEGORY_ID INTEGER IDENTITY(1,1) NOT NULL, CATEGORY_NAME VARCHAR(40) NOT NULL, PARENT_CATEGORY_ID INTEGER, CATEGORY_ICON IMAGE, DEPTH INTEGER,
7
3371
by: yoyo | last post by:
Is there anyway to delay a trigger from firing for a few seconds? I have an after insert trigger on table1, which selects information from table2 and table3. Obviously it cannot fire unless the required rows in table2 and 3 are filled out first. I can't just put the trigger on table2 or 3, because the order of insert there is different,...
6
3612
by: Jchick | last post by:
Im a newbie with a sql table in a MSDE database that contains fields of CustName, BrokerName, Type, Status. I am trying to write a trigger that does this: 1. When a new record in a table is added, I would like the selected fields to be copied to another table (call it Master). 2. If that Master table already contains a record where the...
7
6965
by: Serge Rielau | last post by:
Hi all, Following Ian's passionate postings on problems with ALTOBJ and the alter table wizard in the control center I'll try to explain how to use ALTOBJ with this thread. I'm not going to get into the GUI because it is hard to describe in text. First of all what is the purpose of ALTOBJ()? This procedure was created mostly for ISVs who...
2
4254
by: tolcis | last post by:
I have a trigger that should be execute on each row insert and only if appcode = 'I' and datasent = 0. It should execute a DTS package. The DTS package by itself runs about 6 seconds. Trigger was created successfuly. When I try to insert a row my db hangs. I can see that SPID on my db is hang by SPID from master db. It doesn't complete...
0
1817
by: Bo Holmberg | last post by:
Hi I am attemtpting to do a couple of inserts into an AS400page using a iSeries ODBC driver (CWBODBC.DLL 10.00.10.00). This works fine except on the last insert which is done on a table which has a trigger (after insert). The trigger seems to lock the session and as I dont receive a response after the insert the application hangs and the lock...
0
7905
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7651
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6272
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5488
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3648
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3630
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1205
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.