| |

VerySource

 Forgot password?
 Register
Search
View: 3603|Reply: 30

How to write sql for document approval process

[Copy link]

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-8 10:00:01
| Show all posts |Read mode
There is a table used to store the business process, which is the definition of the approval process, as explained below
f_bmbm indicates the department that needs to be approved, f_xh indicates the sequence, and f_must indicates that the process must be reviewed by this department
create table tbnote_check_order
(
f_xh int Not Null,-
f_bmbm varchar (15) Not Null,-department code
f_must int Not Null, --must (0 no 1 yes)
Constraint tbnote_check_order_key Primary Key (f_xh)
)

In the specific business process, all approval information is stored in another field f_spyj.The format is stored in this way

| linebegin | --line prefix, which indicates the approval of a department
| lineend |-line suffix, which indicates that the approval of a department is over
bmbegin-the department prefix, which indicates the approval department
| bmend |-Department suffix, which indicates the approval department
ygbmbegin | --Employee prefix, which represents the employees of the approved department
ygbmend | --Employee suffix, which means the employee of the approval department

For example, the information stored in f_spyj is as follows:
| linebegin | 20070101 | bmbegin | 001 | bmend || ygbmbegin | yg01 | ygbmend | Reviewed by

The question now is as follows:
1.How to judge that a certain department's approval is already in
2.How to judge that all approvals have been completed
3.How to delete an approval message
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-1-9 08:27:02
| Show all posts
--1
select * from tbName where charindex ('| bmbegin | department ID | bmend |', f_spyj)> 0
Reply

Use magic Report

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-9 10:09:01
| Show all posts
4.How to not display these marks when displaying
| linebegin | --line prefix, which indicates the approval of a department
| lineend |-line suffix, which indicates that the approval of a department is over
bmbegin-the department prefix, which indicates the approval department
| bmend |-Department suffix, which indicates the approval department
ygbmbegin | --Employee prefix, which represents the employees of the approved department
ygbmend | --Employee suffix, which means the employee of the approval department
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-1-9 18:54:02
| Show all posts
Use the replace () function
Reply

Use magic Report

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-9 19:27:01
| Show all posts
Example
The following example replaces the string cde in abcdefghi with xxx.

SELECT REPLACE ('abcdefghicde', 'cde', 'xxx')
GO

Here is the result set:

------------
abxxxfghixxx
(1 row (s) affected)
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-1-9 19:36:01
| Show all posts
declare @str varchar (100)
set @ str = '| bmbegin | 001 | bmend |'
select replace (replace (@str, '| bmbegin |', ''), '| bmend |', '')

--result
001

(1 row (s) affected)
Reply

Use magic Report

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-9 19:54:01
| Show all posts
Thanks, 2 left
2.How to judge that all approvals have been completed
3.How to delete an approval message
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-1-9 20:45:02
| Show all posts
This table structure is not easy to do
Reply

Use magic Report

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-9 21:54:02
| Show all posts
The logo of a line is already there, just delete this line, is there a way?
Reply

Use magic Report

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-9 22:09:02
| Show all posts
If you find 001, you also find the lineend of 001, and then you can find linebegin. Is there a way?
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