| |

VerySource

 Forgot password?
 Register
Search
Author: caoyuezj

How to write sql for document approval process

[Copy link]

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-9 22:36:02
| Show all posts
2.How to judge that all approvals have been completed
Regarding this, first take out all the departments in '| bmbegin | department | bmend |' in f_spyj to form a total string, and in tbnote_check_order, form all the departments into one line. That means it's all there, how to do it?
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-1-10 00:18:01
| Show all posts
There may be multiple | linebegin |, | lineend | in one line?
Reply

Use magic Report

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-10 02:18:02
| Show all posts
One line here refers to the approval information of a department. There is no limit on the number of characters, that is, the approval information of a department is enclosed by linebegin and lineend, and it should be understood as a pair of ().
Reply

Use magic Report

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-10 12:00:01
| Show all posts
One line is the meaning of a pair of brackets, not a single line of text.A pair of brackets may be one line or multiple lines, and there may be multiple pairs of brackets in a line.
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-10 17:27:02
| Show all posts
Learn
Reply

Use magic Report

1

Threads

15

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-1-16 15:45:02
| Show all posts
create table tbnote_check_order
(
f_djlxbm varchar (3) Not Null, --document type encoding
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_djlxbm, f_xh)
)
That is, different documents have different approval business processes. I just requested a business process for a document. Is it so difficult to write?
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-1-16 17:00:01
| Show all posts
Table structure has a problem
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-16 18:45:01
| Show all posts
/ *
Design idea: first get the number of all departments that must be reviewed in tbnote_check_order, then decode the approval information, and judge whether the department must be reviewed when it encounters department characters.
        If the conditions are met, it means that one of all the review processes has been met, and at the end of the cycle, it can be known whether the number of required review departments included in the approval information is equal to tbnote_check_order
        Number specified in
Parameter Description:
 @vDjlxbm
  Indicates the type of document to be reviewed
 @vSpInfo
  Incoming approval information string
Return parameters:
 @iIsOver
  0 means no
  1 means all passed
  2 means no approval process
* /
create procedure p_SpIsOver (@vDjlxbm varchar (3), @vSpInfo varchar (8000), @iIsOver int output)
as
begin
     declare @s as varchar (8000)
     declare @i as int
     declare @j as int
     declare @len as int
     declare @bm as varchar (30)
     select @ i = count (f_bmbm) from tbnote_check_order where f_djlxbm = @ vDjlxbm and f_must = 1
     if @i> 0
     begin
       set @ len = len (@vSpInfo)
       if @ len = 0
       begin
         set @ iIsOver = 0
         return
       end
       else
       begin
         while @len> 1
         begin
            if substring (right (@ vSpInfo, @ len), 1, len ('| bmbegin |')) = '| bmbegin |'
            begin
              set @ bm = substring (@ vSpInfo, len (@vSpInfo)-@ len + len ('| bmbegin |') + 1, charindex ('| bmend |', right (@ vSpInfo, @ len))-len (' | bmbegin | ')-1)
              select @ j = count (f_bmbm) from tbnote_check_order where f_djlxbm = @ vDjlxbm and f_must = 1 and f_bmbm = @ bm
              if @ j = 1 set @ i = @ i-1
            end
            set @ len = @ len-1
         end
         if @ i = 0 set @ iIsOver = 1
         else set @ iIsOver = 0
       end
     end
     else
     begin
       set @ iIsOver = 2
       return
     end
end
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-17 09:00:01
| Show all posts
--test environment

create table tbnote_check_order
(
f_djlxbm varchar (3) Not Null, --document type encoding
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_djlxbm, f_xh)
)

insert into tbnote_check_order
select 'abc', 1, '001', 1 union all
select 'abc', 2, '002', 0 union all
select 'abc', 3, '004', 1

declare @c int
exec p_SpIsOver 'abc', '| linebegin | haha2007-1-1 | bmbegin | 001 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjklsd | lineend |', @ c out
select @c

--result
0

declare @c int
exec p_SpIsOver 'abc', '| linebegin | haha2007-1-1 | bmbegin | 001 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjklsd | lineend |
| linebegin | haha2007-2-1 | bmbegin | 004 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjkfddfdfssfdlsd | lineend |
', @ c out
select @c
--result
1

declare @c int
exec p_SpIsOver 'abc', '| linebegin | haha2007-1-1 | bmbegin | 001 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjklsd | lineend |
| linebegin | haha2007-2-1 | bmbegin | 002 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjkfddfdfssfdlsd | lineend |
', @ c out
select @c
--result
0

declare @c int
exec p_SpIsOver 'abc', '| linebegin | haha2007-1-1 | bmbegin | 001 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjklsd | lineend |
| linebegin | haha2007-2-1 | bmbegin | 002 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjkfddfdfssfdlsd | lineend |
| linebegin | haha2007-2-1 | bmbegin | 004 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjkfddfdfssfdlsd | lineend |
', @ c out
select @c
--result
1
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Turkey

Post time: 2020-1-17 12:09:01
| Show all posts
declare @c int
exec p_SpIsOver 'aaa', '| linebegin | haha2007-1-1 | bmbegin | 001 | bmend | hehe123 | ygbmbegin | 001 | ygbmend | sdjklsd | lineend |', @ c out
select @c
--result
2
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