| |

VerySource

 Forgot password?
 Register
Search
View: 2297|Reply: 16

Cursor building will not be done, wait online, thank you ~

[Copy link]

4

Threads

27

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

Post time: 2020-3-22 10:00:02
| Show all posts |Read mode
Table 1: Student Situation Information Form XS
Student ID Name Professional Name Gender Birth Time Total Credits Remarks
Primary key
Table III: Students and curriculum XS_KC
Table 2: Course schedule KC
Course number Course name Start semester Hours Credits
Primary key


Student No. Course No. Grade Credits
Primary key primary key

Create cursor
 Create a cursor MYCURSOR, the query result set is the total credits of all students, and define the variable @score to read the current result into the @score variable, and use the WHILE statement to loop, if you find:. Divide one by one: delete the record (in the WHERE clause, use the CURRENT OF cursor name to indicate the record pointed to by the current cursor pointer.) If the record is between 30 and 40, add 20 points. After the operation is completed, Close the cursor and delete.
Note: CURRENT OF keyword does not appear in the cursor definition when READ-ONLY or FAST FORWARD.
Reply

Use magic Report

4

Threads

27

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-4-19 17:30:01
| Show all posts
Please use SQL statement, thank you
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-4-20 03:15:01
| Show all posts
Ha ha. . .
I did a lot of similar topics today

Upstairs is right, if you want to learn, you have to do it yourself
If you just want to find an answer, the ideas in it are not clear to you, or you have changed to a professional ~
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-4-20 11:30:01
| Show all posts
Don't understand the place, see SQL online help
declare cursor section

The subject may not be understood by the owner himself ~ Ha ha

If you find :. Points divided by 1: Records are deleted (in the WHERE clause, the name of the CURRENT OF cursor is used to indicate the record pointed to by the current cursor pointer.) If the records are between 30 and 40, then add 20 points, after the operation Close the cursor and delete.

What did you miss in the first half?
Reply

Use magic Report

4

Threads

27

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-4-20 16:30:01
| Show all posts
Create the cursor MYCURSOR, query the result set for the total credits of all students, and define the variable @score to read the current result into the @score variable, use the WHILE statement to loop, and delete the records below 20 points (in the WHERE clause) The name of the cursor CURRENT OF cursor indicates that it is the record pointed to by the current cursor pointer.) If the record is between 30 and 40, it will increase by 20 points. After the operation is completed, the cursor is closed and deleted.
Note: When the CURRENT OF keyword is used, READ-ONLY or FAST FORWARD does not appear in the cursor definition.
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-4-20 17:30:01
| Show all posts
Ha ha, if we help you, the ingredients for help are big. Just look at the help of curosr, it's not difficult.
declare cursor
open
fetch
close
deallocate
Reply

Use magic Report

0

Threads

10

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-5-22 21:00:01
| Show all posts
Just look at the cursor in the SQL help,
The core is to read data line by line,
Read the specific column or columns of data read into the variable,
Reprocess

Between 30 and 40
Also select top 10 * from table where id not in (select top 30 id from table order by id)
order by id
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-5-24 12:30:01
| Show all posts
For records between 30 and 40, add 20 points

Between 30 and 40, should it refer to points?
Reply

Use magic Report

4

Threads

27

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-6-6 03:15:01
| Show all posts
Yes, I don’t know how to compare each data
Depressed, stupid is
Reply

Use magic Report

4

Threads

27

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 China

 Author| Post time: 2020-6-26 13:00:01
| Show all posts
The core is to read data line by line,
Read the specific column or columns of data read into the variable,
Reprocess

This is not going to be depressed
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