|
You are very well correct, its a trigger which will generate LEVEL AND
HIERARCHY of given data, and I want to do the same thing in DB2 for AS/400.
The trigger is from Sql Server, its:
CREATE TRIGGER trg_employees_i_calchierarchy ON Employees FOR INSERT
AS
DECLARE @numrows AS int
SET @numrows = @@rowcount
IF @numrows > 1
BEGIN
RAISERROR('Only single row inserts are supported!', 16, 1)
ROLLBACK TRAN
END
ELSE
IF @numrows = 1
BEGIN
UPDATE E
SET lvl =
CASE
WHEN E.mgrid IS NULL THEN 0
ELSE M.lvl + 1
END
FROM Employees AS E JOIN inserted AS I
ON I.empid = E.empid
LEFT OUTER JOIN Employees AS M
ON E.mgrid = M.empid
END
Best Regards,
Luqman
"Walden H. Leverich" <WaldenL@xxxxxxxxxxxxxxx> wrote
in message
news:D351C107947DD042B6C5DF1A02179E3924E280@xxxxxxxxxxxxxxxxxxxxxxxxxx
> >Can anyone translate this Sql Server Query into DB2 Sql for AS/400 ?
>
> Probably. <G> Have you tried? What's the error you're getting?
>
> First, this is from a trigger, so you'll need to understand AS/400
> triggers to implement similar functionality. Second, the DB2 syntax
> you're looking for is more like "set lvl = (select m.lvl + 1 from ...)"
>
> That should help. Let us know if you have specific problems.
>
> -Walden
>
> ------------
> Walden H Leverich III
> Tech Software
> (516) 627-3800 x11
> WaldenL@xxxxxxxxxxxxxxx
> http://www.TechSoftInc.com
> Quiquid latine dictum sit altum viditur.
> (Whatever is said in Latin seems profound.)
>
> --
> This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
> list
> To post a message email:
> MIDRANGE-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/midrange-l
> or email: MIDRANGE-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/midrange-l.
>
>
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.