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.

How to make the value of a field dependant on autoinc field through trigger?

2 posts in Trigger Last posting was on 2004-08-27 08:22:32.0Z
NageswarRao,G. Posted on 2004-08-27 06:11:44.0Z
Reply-To: "NageswarRao,G." <gnr@hyderabadwater.gov.in>
From: "NageswarRao,G." <gnr@hyderabadwater.gov.in>
Newsgroups: advantage.trigger
Subject: How to make the value of a field dependant on autoinc field through trigger?
Date: Fri, 27 Aug 2004 11:41:44 +0530
Lines: 9
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 202.63.103.130
Message-ID: <412ed07b@solutions.advantagedatabase.com>
X-Trace: 27 Aug 2004 00:11:07 -0700, 202.63.103.130
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!202.63.103.130
Xref: solutions.advantagedatabase.com Advantage.Trigger:122
Article PK: 1136191

I want to post automatically a value derived from its autoinc field in
another field. How can I do it with triggers? any help please?

For example, ID is autoinc field. I want SECONDFLD to be automatically =
STRZERO(ID,10). Can I do this through Triggers?

NageswaraRao


Joachim Duerr (ADS Support) Posted on 2004-08-27 08:22:32.0Z
From: "Joachim Duerr (ADS Support)" <jojo.duerr@gmx.de>
Subject: Re: How to make the value of a field dependant on autoinc field through trigger?
Newsgroups: Advantage.Trigger
References: <412ed07b@solutions.advantagedatabase.com>
Organization: Extended Systems GmbH
User-Agent: XanaNews/1.16.3.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: <412ee138@solutions.advantagedatabase.com>
Date: 27 Aug 2004 01:22:32 -0700
X-Trace: 27 Aug 2004 01:22:32 -0700, 195.2.185.25
Lines: 21
Path: solutions.advantagedatabase.com!solutions.advantagedatabase.com!195.2.185.25
Xref: solutions.advantagedatabase.com Advantage.Trigger:123
Article PK: 1136189


NageswarRao,G. wrote in <412ed07b@solutions.advantagedatabase.com> :

> I want to post automatically a value derived from its autoinc field in
> another field. How can I do it with triggers? any help please?
>
> For example, ID is autoinc field. I want SECONDFLD to be
> automatically = STRZERO(ID,10). Can I do this through Triggers?

Create trigger trig_ins_mytable
on mytable
instead of insert
begin
update __new set secondfld=(Select repeat('0',10-length(cast(id as
SQL_CHAR))+cast(id as SQL_CHAR) from __new);
insert into mytable select * from __new;
end;

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