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.

NewBie: DoAutoIncrementNumber

5 posts in Trigger Last posting was on 2005-08-24 13:34:03.0Z
Saras Setiawan Posted on 2005-08-06 08:25:04.0Z
From: "Saras Setiawan" <saras-setiawanAT@centrinDOT.netDOT.id>
Newsgroups: advantage.trigger
Subject: NewBie: DoAutoIncrementNumber
Date: Sat, 6 Aug 2005 15:25:04 +0700
Lines: 10
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 222.124.41.226
Message-ID: <42f4756c@solutions.advantagedatabase.com>
X-Trace: 6 Aug 2005 02:31:40 -0700, 222.124.41.226
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!222.124.41.226
Xref: solutions.advantagedatabase.com Advantage.Trigger:171
Article PK: 1136237

Hi,

I have a custom AutoIncrementNumber, eg. VD.0500001, VD.0500002, ..., etc.

How should I write this trigger ?

Regards
Saras Setiawan


Joachim Duerr (ADS Support) Posted on 2005-08-22 09:57:14.0Z
From: "Joachim Duerr (ADS Support)" <jojo.duerr@gmx.de>
Subject: Re: NewBie: DoAutoIncrementNumber
Newsgroups: Advantage.Trigger
References: <42f4756c@solutions.advantagedatabase.com>
Organization: Extended Systems GmbH
User-Agent: XanaNews/1.17.4.1
X-Face: ,QMv7[luB)BpWAQ~:"kw6n%0ieY63.:g2K3n~8ky0;||5Xle*Xq+=~<Fy:0CVC2nx@8~vZ
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 195.2.185.25
Message-ID: <4309936a@solutions.advantagedatabase.com>
Date: 22 Aug 2005 02:57:14 -0700
X-Trace: 22 Aug 2005 02:57:14 -0700, 195.2.185.25
Lines: 13
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!195.2.185.25
Xref: solutions.advantagedatabase.com Advantage.Trigger:172
Article PK: 1136238


Saras Setiawan wrote in <42f4756c@solutions.advantagedatabase.com> :

> I have a custom AutoIncrementNumber, eg. VD.0500001, VD.0500002, ...,
> etc.
>
> How should I write this trigger ?

I'd keep an 'id-table' containing the prefix and the last used number.

--
Joachim Duerr
EMEA Lead ADS Support, Extended Systems GmbH, Germany
advantage[AT]extendsys.de


Saras Setiawan Posted on 2005-08-24 01:16:50.0Z
From: "Saras Setiawan" <saras-setiawanAT@centrinDOT.netDOT.id>
Newsgroups: Advantage.Trigger
References: <42f4756c@solutions.advantagedatabase.com> <4309936a@solutions.advantagedatabase.com>
Subject: Re: NewBie: DoAutoIncrementNumber
Date: Wed, 24 Aug 2005 08:16:50 +0700
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 222.124.57.34
Message-ID: <430bcc29@solutions.advantagedatabase.com>
X-Trace: 23 Aug 2005 19:23:53 -0700, 222.124.57.34
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!222.124.57.34
Xref: solutions.advantagedatabase.com Advantage.Trigger:173
Article PK: 1136240

I have no difficult with client-side programming.
But...
How should I write this code in server-side, especially with trigger ?
Could you explain step by step ?


Regards
Saras Setiawan
Epsylon Citra Informatika, pt


"Joachim Duerr (ADS Support)" <jojo.duerr@gmx.de> wrote in message
news:4309936a@solutions.advantagedatabase.com...
: Saras Setiawan wrote in <42f4756c@solutions.advantagedatabase.com> :
:
: > I have a custom AutoIncrementNumber, eg. VD.0500001, VD.0500002, ...,
: > etc.
: >
: > How should I write this trigger ?
:
: I'd keep an 'id-table' containing the prefix and the last used number.
:
: --
: Joachim Duerr
: EMEA Lead ADS Support, Extended Systems GmbH, Germany
: advantage[AT]extendsys.de


Joachim Duerr (ADS Support) Posted on 2005-08-24 08:22:53.0Z
From: "Joachim Duerr (ADS Support)" <jojo.duerr@gmx.de>
Subject: Re: NewBie: DoAutoIncrementNumber
Newsgroups: Advantage.Trigger
References: <42f4756c@solutions.advantagedatabase.com> <4309936a@solutions.advantagedatabase.com> <430bcc29@solutions.advantagedatabase.com>
Organization: Extended Systems GmbH
User-Agent: XanaNews/1.17.4.1
X-Face: ,QMv7[luB)BpWAQ~:"kw6n%0ieY63.:g2K3n~8ky0;||5Xle*Xq+=~<Fy:0CVC2nx@8~vZ
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 195.2.185.25
Message-ID: <430c204d@solutions.advantagedatabase.com>
Date: 24 Aug 2005 01:22:53 -0700
X-Trace: 24 Aug 2005 01:22:53 -0700, 195.2.185.25
Lines: 40
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!195.2.185.25
Xref: solutions.advantagedatabase.com Advantage.Trigger:174
Article PK: 1136239


Saras Setiawan wrote in <430bcc29@solutions.advantagedatabase.com> :

> I have no difficult with client-side programming.
> But...
> How should I write this code in server-side, especially with trigger ?
> Could you explain step by step ?

1) Create a table containing all the tables in the database

create table idtable(id autoinc, tbname cichar(200), prefix cichar(3),
lastval integer);
insert into idtable(tbname,prefix,lastval) values ('mytable1','VD.',0);
insert into idtable(tbname,prefix,lastval) values ('mytable2','VD.',0);
insert into idtable(tbname,prefix,lastval) values ('mytable3','VD.',0);

2) Create a DLL/COM/.NET/so Trigger (see tutorials in the help file),
using the dev environment of your choice:

- get the table name
- locate the record with the table name in idtable
- edit that record (will lock it for others)
- read out lastval+1 and write that value back
- read out prefix
- post idtable
- create the id string for your table, using
prefix+string_with_leading_zeros(lastval)
- replace the id field in the source table with that string

3) Apply this trigger to the tables (call this for each table!):
create trigger trig_ins_mytable1
on mytable1
instead of insert
function idtrigger
in library mysuperspecialtrigs.dll;

That's it.
--
Joachim Duerr
EMEA Lead ADS Support, Extended Systems GmbH, Germany
advantage[AT]extendsys.de


Saras Setiawan Posted on 2005-08-24 13:34:03.0Z
From: "Saras Setiawan" <saras-setiawanAT@centrinDOT.netDOT.id>
Newsgroups: Advantage.Trigger
References: <42f4756c@solutions.advantagedatabase.com> <4309936a@solutions.advantagedatabase.com> <430bcc29@solutions.advantagedatabase.com> <430c204d@solutions.advantagedatabase.com>
Subject: Re: NewBie: DoAutoIncrementNumber
Date: Wed, 24 Aug 2005 20:34:03 +0700
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 222.124.57.212
Message-ID: <430c78c9@solutions.advantagedatabase.com>
X-Trace: 24 Aug 2005 07:40:25 -0700, 222.124.57.212
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!222.124.57.212
Xref: solutions.advantagedatabase.com Advantage.Trigger:175
Article PK: 1136241

I'll try.

Thanks and Best Regards.

Saras Setiawan
Epsylon Citra Informatika, pt


"Joachim Duerr (ADS Support)" <jojo.duerr@gmx.de> wrote in message
news:430c204d@solutions.advantagedatabase.com...
: Saras Setiawan wrote in <430bcc29@solutions.advantagedatabase.com> :
:
: > I have no difficult with client-side programming.
: > But...
: > How should I write this code in server-side, especially with trigger ?
: > Could you explain step by step ?
:
: 1) Create a table containing all the tables in the database
:
: create table idtable(id autoinc, tbname cichar(200), prefix cichar(3),
: lastval integer);
: insert into idtable(tbname,prefix,lastval) values ('mytable1','VD.',0);
: insert into idtable(tbname,prefix,lastval) values ('mytable2','VD.',0);
: insert into idtable(tbname,prefix,lastval) values ('mytable3','VD.',0);
:
: 2) Create a DLL/COM/.NET/so Trigger (see tutorials in the help file),
: using the dev environment of your choice:
:
: - get the table name
: - locate the record with the table name in idtable
: - edit that record (will lock it for others)
: - read out lastval+1 and write that value back
: - read out prefix
: - post idtable
: - create the id string for your table, using
: prefix+string_with_leading_zeros(lastval)
: - replace the id field in the source table with that string
:
: 3) Apply this trigger to the tables (call this for each table!):
: create trigger trig_ins_mytable1
: on mytable1
: instead of insert
: function idtrigger
: in library mysuperspecialtrigs.dll;
:
: That's it.
: --
: Joachim Duerr
: EMEA Lead ADS Support, Extended Systems GmbH, Germany
: advantage[AT]extendsys.de