For example, the stored procedure starts from a node N and finds the parent node at the top. This frequently used process can be undertaken by the stored procedure and shared by repeated use on the webpage.
Null: indicates that the node is a top-level node.
Fjdid (parent node number)
Node N is not empty. It indicates the parent node number of the node.
Dwmc (unit name)
Create proc search_dwmc @ dwikidold int, @ dwmcresult varchar (100) Output
As
Declare @ stop int
Declare @ result varchar (80)
Declare @ dwmc varchar (80)
Declare @ dwid int
Set nocount on
Set @ stop = 1
Set @ dwmc = ""
Select @ dwmc = dwmc, @ dwid = convert (INT, fjdid) from jtdw where id = @ dwidold
Set @ result = rtrim (@ dwmc)
If @ dwid = 0
Set @ stop = 0
While (@ stop = 1) and (@ dwid <> 0)
Begin
Set @ dwidold = @ dwid
Select @ dwmc = dwmc, @ dwid = convert (INT, fjdid) from jtdw where id = @ dwidold
If @ rowcount = 0
Set @ dwmc = ""
Else
Set @ result = @ dwmc + @ result
If (@ dwid = 0) or (@ rowcount = 0)
Set @ stop = 0
Else
Continue
End
Set @ dwmcresult = rtrim (@ result)
Use exec pro-name [pram1 pram2....]
(Www.gz u521.com), original address: http://www.gzu521.com/campus/article/program/200803/165794.htm