| |

VerySource

 Forgot password?
 Register
Search
View: 710|Reply: 6

Regarding SQL triggers, please help me see where there is a mistake, as soon as it runs

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 United States

Post time: 2020-3-12 15:30:01
| Show all posts |Read mode
CREATE trigger tr_fkpz on payment document
for insert
as
declare @CusName VARCHAR (100),
        @Mname varchar (100),
        @GradeName varchar (100),
        @Jweight decimal,
        @ID char (15),
        @NUM int,
        @count int
select @ count = count (*) from ls
set @ NUM = 1
while @NUM <@ count + 1
begin
select @ ID = ID from ls where NUM = @ NUM
uPDATE App_Ponderation SET YS = 1 where IDcode = @ ID
end
SET @ NUM = @ NUM + 1
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 Unknown

Post time: 2020-6-6 18:45:02
| Show all posts
CREATE trigger tr_fkpz on payment voucher
for insert
as
declare @CusName VARCHAR(100),
        @Mname varchar(100),
        @GradeName varchar(100),
        @Jweight decimal,
        @ID char(15),
        @NUM int,
        @count int
select @count=count(*) from ls
set @NUM=1
while @NUM<@count+1
begin
select @ID=ID from ls where NUM=@NUM
uPDATE App_Ponderation SET YS=1 where IDcode=@ID
SET @NUM=@NUM+1
end
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-6 22:00:01
| Show all posts
What did you change upstairs
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-6-6 22:30:01
| Show all posts
Put SET @NUM=@NUM+1 outside of while, and enter an infinite loop as soon as it runs
Reply

Use magic Report

0

Threads

28

Posts

25.00

Credits

Newbie

Rank: 1

Credits
25.00

 Korea, Republic of

Post time: 2020-6-7 10:45:01
| Show all posts
Try it with
CREATE trigger tr_fkpz on payment voucher
for insert
as
declare @CusName VARCHAR(100),
        @Mname varchar(100),
        @GradeName varchar(100),
        @Jweight decimal,
        @ID char(15),
        @NUM int,
        @count int
select @count=count(*) from ls
set @NUM=1
while @NUM<@count+1
begin
select @ID=ID from ls where NUM=@NUM
uPDATE App_Ponderation SET YS=1 where IDcode=@ID
SET @NUM=@NUM+1

end
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-6-7 19:00:01
| Show all posts
No, i'm dizzy
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-6-7 22:00:02
| Show all posts
Yes you dizzy
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list