Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

C trigger problem

7 posts in Trigger Last posting was on 2008-07-17 17:33:51.0Z
Roberto Parisi Posted on 2008-07-15 16:34:02.0Z
From: "Roberto Parisi" <roberto@isw.it>
Newsgroups: Advantage.Trigger
Subject: C trigger problem
Date: Tue, 15 Jul 2008 18:34:02 +0200
Lines: 55
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 151.38.8.195
Message-ID: <487cd073@solutions.advantagedatabase.com>
X-Trace: 15 Jul 2008 10:29:39 -0700, 151.38.8.195
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!151.38.8.195
Xref: solutions.advantagedatabase.com Advantage.Trigger:395
Article PK: 1136456

I wrote the trigger below as after update trigger. It show me the
VATDescription field from the current record. It works on the first record i
update (from ARC) but it doesn't execute for the second record I try to
update.

Where is my mistake??

Regards,
Roberto Parisi

#include "windows.h"
#include "ace.h"

#define ACECHECK(ulRet) if (ulRet != AE_SUCCESS) AdsShowError("Error");

UNSIGNED32 __declspec(dllexport) ADSTrigger (
UNSIGNED32 ulConnectionID,
ADSHANDLE hConnection,
UNSIGNED8 *pucTriggerName,
UNSIGNED8 *pucTableName,
UNSIGNED32 ulEventType,
UNSIGNED32 ulTriggerType,
UNSIGNED32 ulRecNo);

BOOL APIENTRY DllMain(HINSTANCE h, DWORD d, LPVOID p)
{
return TRUE;
}


UNSIGNED32 ADSTrigger (
UNSIGNED32 ulConnectionID,
ADSHANDLE hConnection,
UNSIGNED8 *pucTriggerName,
UNSIGNED8 *pucTableName,
UNSIGNED32 ulEventType,
UNSIGNED32 ulTriggerType,
UNSIGNED32 ulRecNo)
{
ADSHANDLE hTable;
UNSIGNED8 text[1024];
UNSIGNED32 textlen = 1024;

ACECHECK(AdsOpenTable(hConnection, pucTableName, NULL, ADS_DEFAULT,
ADS_DEFAULT, ADS_PROPRIETARY_LOCKING, NULL, ADS_SHARED, &hTable));
ACECHECK(AdsGotoRecord(hTable, ulRecNo));

ACECHECK(AdsGetString(hTable, "VATDescription", text, &textlen, ADS_NONE));
MessageBox(0, text, 0, 0);

ACECHECK(AdsCloseTable(hTable));
return AE_SUCCESS;
}


Jeremy Mullin Posted on 2008-07-15 16:55:09.0Z
Date: Tue, 15 Jul 2008 16:55:09 +0000 (UTC)
Message-ID: <1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com>
From: Jeremy Mullin <no@email.com>
Subject: Re: C trigger problem
Newsgroups: Advantage.Trigger
References: <487cd073@solutions.advantagedatabase.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1; format=flowed
X-Newsreader: JetBrains Omea Reader 1098.1
NNTP-Posting-Host: 10.24.38.114
X-Trace: 15 Jul 2008 10:49:08 -0700, 10.24.38.114
Lines: 15
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!10.24.38.114
Xref: solutions.advantagedatabase.com Advantage.Trigger:396
Article PK: 1136457

An unrelated issue:

It is much more efficient to open the __new table and read the value, as
opposed to opening the base table and positioning and reading. The virtual
table __new has a single record in it that corresponds to the new record
that was just modified.

If you are using local server this is an OK way to test. Don't show message
boxes in remote server, however. They will usually be blocked and cause the
worker thread to hang.

J.D. Mullin
Advantage R&D


Roberto Parisi Posted on 2008-07-15 17:06:11.0Z
From: "Roberto Parisi" <roberto@isw.it>
Newsgroups: Advantage.Trigger
References: <487cd073@solutions.advantagedatabase.com> <1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com>
Subject: Re: C trigger problem
Date: Tue, 15 Jul 2008 19:06:11 +0200
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 151.38.8.195
Message-ID: <487cd7fc@solutions.advantagedatabase.com>
X-Trace: 15 Jul 2008 11:01:48 -0700, 151.38.8.195
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!151.38.8.195
Xref: solutions.advantagedatabase.com Advantage.Trigger:397
Article PK: 1136459

Thx Jeremy.

Ok... the trigger goal is to update the record... the messagebox is for
testing purposes.

Yes, it run on ALS... I can't understand why it run only on the first record
I update and not on every update.

Thx in advance,
Roberto Parisi

"Jeremy Mullin" <no@email.com> ha scritto nel messaggio
news:1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com...

> An unrelated issue:
>
> It is much more efficient to open the __new table and read the value, as
> opposed to opening the base table and positioning and reading. The virtual
> table __new has a single record in it that corresponds to the new record
> that was just modified.
>
> If you are using local server this is an OK way to test. Don't show
> message boxes in remote server, however. They will usually be blocked and
> cause the worker thread to hang.
>
> J.D. Mullin
> Advantage R&D
>
>


Roberto Parisi Posted on 2008-07-16 09:51:53.0Z
From: "Roberto Parisi" <roberto@isw.it>
Newsgroups: Advantage.Trigger
References: <487cd073@solutions.advantagedatabase.com> <1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com> <487cd7fc@solutions.advantagedatabase.com>
Subject: Re: C trigger problem
Date: Wed, 16 Jul 2008 11:51:53 +0200
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 151.38.8.195
Message-ID: <487dc3b1@solutions.advantagedatabase.com>
X-Trace: 16 Jul 2008 03:47:29 -0700, 151.38.8.195
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!151.38.8.195
Xref: solutions.advantagedatabase.com Advantage.Trigger:398
Article PK: 1136458

Ok... my mistake... I miss WINAPI in ADSTrigger declaration.

Now it works... but unfortunately it is more slow than the equivalent sql
script trigger.

...waiting for more performance in updating the record with the username who
made the changes... :)

Regards,
Roberto Parisi

"Roberto Parisi" <roberto@isw.it> ha scritto nel messaggio
news:487cd7fc@solutions.advantagedatabase.com...

>
> Thx Jeremy.
>
> Ok... the trigger goal is to update the record... the messagebox is for
> testing purposes.
>
> Yes, it run on ALS... I can't understand why it run only on the first
> record I update and not on every update.
>
> Thx in advance,
> Roberto Parisi
>
> "Jeremy Mullin" <no@email.com> ha scritto nel messaggio
> news:1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com...
>> An unrelated issue:
>>
>> It is much more efficient to open the __new table and read the value, as
>> opposed to opening the base table and positioning and reading. The
>> virtual table __new has a single record in it that corresponds to the new
>> record that was just modified.
>>
>> If you are using local server this is an OK way to test. Don't show
>> message boxes in remote server, however. They will usually be blocked and
>> cause the worker thread to hang.
>>
>> J.D. Mullin
>> Advantage R&D
>>
>>
>
>


Edgar Sherman Posted on 2008-07-16 17:40:33.0Z
Date: Wed, 16 Jul 2008 11:40:33 -0600
From: Edgar Sherman <no@email.com>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Newsgroups: Advantage.Trigger
Subject: Re: C trigger problem
References: <487cd073@solutions.advantagedatabase.com> <1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com> <487cd7fc@solutions.advantagedatabase.com> <487dc3b1@solutions.advantagedatabase.com>
In-Reply-To: <487dc3b1@solutions.advantagedatabase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 10.24.34.164
Message-ID: <487e311a@solutions.advantagedatabase.com>
X-Trace: 16 Jul 2008 11:34:18 -0700, 10.24.34.164
Lines: 51
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!10.24.34.164
Xref: solutions.advantagedatabase.com Advantage.Trigger:399
Article PK: 1136460

Yes, DLL triggers will be slower then script triggers.

What are you trying to do that you can't in a script trigger?

Edgar

Roberto Parisi wrote:
> Ok... my mistake... I miss WINAPI in ADSTrigger declaration.
>
> Now it works... but unfortunately it is more slow than the equivalent sql
> script trigger.
>
> ...waiting for more performance in updating the record with the username who
> made the changes... :)
>
> Regards,
> Roberto Parisi
>
> "Roberto Parisi" <roberto@isw.it> ha scritto nel messaggio
> news:487cd7fc@solutions.advantagedatabase.com...
>> Thx Jeremy.
>>
>> Ok... the trigger goal is to update the record... the messagebox is for
>> testing purposes.
>>
>> Yes, it run on ALS... I can't understand why it run only on the first
>> record I update and not on every update.
>>
>> Thx in advance,
>> Roberto Parisi
>>
>> "Jeremy Mullin" <no@email.com> ha scritto nel messaggio
>> news:1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com...
>>> An unrelated issue:
>>>
>>> It is much more efficient to open the __new table and read the value, as
>>> opposed to opening the base table and positioning and reading. The
>>> virtual table __new has a single record in it that corresponds to the new
>>> record that was just modified.
>>>
>>> If you are using local server this is an OK way to test. Don't show
>>> message boxes in remote server, however. They will usually be blocked and
>>> cause the worker thread to hang.
>>>
>>> J.D. Mullin
>>> Advantage R&D
>>>
>>>
>>
>
>


Roberto Parisi Posted on 2008-07-17 06:49:17.0Z
From: "Roberto Parisi" <roberto@isw.it>
Newsgroups: Advantage.Trigger
References: <487cd073@solutions.advantagedatabase.com> <1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com> <487cd7fc@solutions.advantagedatabase.com> <487dc3b1@solutions.advantagedatabase.com> <487e311a@solutions.advantagedatabase.com>
Subject: Re: C trigger problem
Date: Thu, 17 Jul 2008 08:49:17 +0200
Lines: 64
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 151.38.8.195
Message-ID: <487eea66@solutions.advantagedatabase.com>
X-Trace: 17 Jul 2008 00:44:54 -0700, 151.38.8.195
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!151.38.8.195
Xref: solutions.advantagedatabase.com Advantage.Trigger:400
Article PK: 1136461

I need a way to update the field "UpdateUser" with the Username who changed
the record.

I can do this with script triggers but it is very slow on massive updates.

Like the rowtime field it will be usefull to have a field with the username
who process in less time then a sql script.

Regards,
Roberto Parisi

"Edgar Sherman" <no@email.com> ha scritto nel messaggio
news:487e311a@solutions.advantagedatabase.com...

> Yes, DLL triggers will be slower then script triggers.
>
> What are you trying to do that you can't in a script trigger?
>
> Edgar
>
> Roberto Parisi wrote:
>> Ok... my mistake... I miss WINAPI in ADSTrigger declaration.
>>
>> Now it works... but unfortunately it is more slow than the equivalent sql
>> script trigger.
>>
>> ...waiting for more performance in updating the record with the username
>> who made the changes... :)
>>
>> Regards,
>> Roberto Parisi
>>
>> "Roberto Parisi" <roberto@isw.it> ha scritto nel messaggio
>> news:487cd7fc@solutions.advantagedatabase.com...
>>> Thx Jeremy.
>>>
>>> Ok... the trigger goal is to update the record... the messagebox is for
>>> testing purposes.
>>>
>>> Yes, it run on ALS... I can't understand why it run only on the first
>>> record I update and not on every update.
>>>
>>> Thx in advance,
>>> Roberto Parisi
>>>
>>> "Jeremy Mullin" <no@email.com> ha scritto nel messaggio
>>> news:1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com...
>>>> An unrelated issue:
>>>>
>>>> It is much more efficient to open the __new table and read the value,
>>>> as opposed to opening the base table and positioning and reading. The
>>>> virtual table __new has a single record in it that corresponds to the
>>>> new record that was just modified.
>>>>
>>>> If you are using local server this is an OK way to test. Don't show
>>>> message boxes in remote server, however. They will usually be blocked
>>>> and cause the worker thread to hang.
>>>>
>>>> J.D. Mullin
>>>> Advantage R&D
>>>>
>>>>
>>>
>>


Edgar Sherman Posted on 2008-07-17 17:33:51.0Z
Date: Thu, 17 Jul 2008 11:33:51 -0600
From: Edgar Sherman <no@email.com>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Newsgroups: Advantage.Trigger
Subject: Re: C trigger problem
References: <487cd073@solutions.advantagedatabase.com> <1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com> <487cd7fc@solutions.advantagedatabase.com> <487dc3b1@solutions.advantagedatabase.com> <487e311a@solutions.advantagedatabase.com> <487eea66@solutions.advantagedatabase.com>
In-Reply-To: <487eea66@solutions.advantagedatabase.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 10.24.34.164
Message-ID: <487f8106@solutions.advantagedatabase.com>
X-Trace: 17 Jul 2008 11:27:34 -0700, 10.24.34.164
Lines: 82
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!10.24.34.164
Xref: solutions.advantagedatabase.com Advantage.Trigger:401
Article PK: 1136462

Are you running 8.1? There was an improvement to the speed of script
triggers in 8.1.

Also, what was your script? were you using an instead of or after
trigger? I believe it should be pretty efficient to use an instead of
trigger with something like the following. Probably in large bulk
updates you may see a performance hit, but with normal OLTP it should
not be noticeable:

UPDATE customers SET
name = ( SELECT name FROM __new ),
.
.
.
updatedby = user()
WHERE id = ( SELECT id FROM __new )

Edgar

Roberto Parisi wrote:
> I need a way to update the field "UpdateUser" with the Username who changed
> the record.
>
> I can do this with script triggers but it is very slow on massive updates.
>
> Like the rowtime field it will be usefull to have a field with the username
> who process in less time then a sql script.
>
> Regards,
> Roberto Parisi
>
> "Edgar Sherman" <no@email.com> ha scritto nel messaggio
> news:487e311a@solutions.advantagedatabase.com...
>> Yes, DLL triggers will be slower then script triggers.
>>
>> What are you trying to do that you can't in a script trigger?
>>
>> Edgar
>>
>> Roberto Parisi wrote:
>>> Ok... my mistake... I miss WINAPI in ADSTrigger declaration.
>>>
>>> Now it works... but unfortunately it is more slow than the equivalent sql
>>> script trigger.
>>>
>>> ...waiting for more performance in updating the record with the username
>>> who made the changes... :)
>>>
>>> Regards,
>>> Roberto Parisi
>>>
>>> "Roberto Parisi" <roberto@isw.it> ha scritto nel messaggio
>>> news:487cd7fc@solutions.advantagedatabase.com...
>>>> Thx Jeremy.
>>>>
>>>> Ok... the trigger goal is to update the record... the messagebox is for
>>>> testing purposes.
>>>>
>>>> Yes, it run on ALS... I can't understand why it run only on the first
>>>> record I update and not on every update.
>>>>
>>>> Thx in advance,
>>>> Roberto Parisi
>>>>
>>>> "Jeremy Mullin" <no@email.com> ha scritto nel messaggio
>>>> news:1b468bc835ee08cab480621592ef@devzone.advantagedatabase.com...
>>>>> An unrelated issue:
>>>>>
>>>>> It is much more efficient to open the __new table and read the value,
>>>>> as opposed to opening the base table and positioning and reading. The
>>>>> virtual table __new has a single record in it that corresponds to the
>>>>> new record that was just modified.
>>>>>
>>>>> If you are using local server this is an OK way to test. Don't show
>>>>> message boxes in remote server, however. They will usually be blocked
>>>>> and cause the worker thread to hang.
>>>>>
>>>>> J.D. Mullin
>>>>> Advantage R&D
>>>>>
>>>>>
>