字符串解析在命令编号链中。 [英] String Parsing in Chain of command numbering.

查看:91
本文介绍了字符串解析在命令编号链中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个字段

DepartmentNumber 99个字符的文本

DepartmentDesc。 255个字符的文字。

一些数据样本:我有近20000条记录。

DepartmentNumber为空,没有数据。

DepartmentDesc充满了休闲数据。

Department1 / Center1 / Section1 / SubSection1 ...有时最多可以达到7个子级。

Department1 / Center1 / Section1 / SubSection2 ......有时它最多可以达到7个子级。

Department1 / Center1 / Section1 / SubSection3 ...有时最多可以达到7个子级。

Department1 / Center1 / Section2 / SubSection1 ...有时最多可以达到7个子级。

Department1 / Center1 / Section2 / SubSection2 ...有时最多可以达到7个子级。

Department1 / Center1 / Section2 / SubSection3 ...有时它最多可以达到7个子级。

Department1 / Center1 / Section2 / SubSection4 ...有时最多可以达到7个子级。

Department1 / Center1 / Section2 / SubSection5 ...有时它最多可以达到7个子级。

Department1 / Center2 / Section1 / SubSection1 ...有时它最多可以达到7个子级。

Department1 / Center2 / Section1 / SubSection2 ...有时最多可以达到7个子级别。

Department1 / Center2 / Section2 / SubSection1 ...有时最多可以达到7个子级别。

Department1 / Center2 / Section3 / SubSection1 ...有时最多可以达到7个子级别。

Department1 / Center2 / Section4 / SubSection1 ...有时它最多可以达到7个子级。

Department1 / Center2 / Section4 / SubSection2 ...有时最多可以达到7个子级别。



Department2 / Center1 / Section1 / SubSection1 ...有时它可以达到7个子级别。

Department2 / Center1 / Section1 / SubSection2 ...有时最多可以达到7个能级。

Department2 / Center1 / Section1 / SubSection3 ...有时最多可以达到7个子级。

Department2 / Center1 / Section2 / SubSection1 ...有时最多可以达到7个子级别。

Department2 / Center1 / Section2 / SubSection2 ...有时它最多可以达到7个子级。

Department2 / Center1 / Section2 / SubSection3 ...有时最多可以达到7个子级别。

Department2 / Center1 / Section2 / SubSection4 ...有时最多可以达到7个子级。

Department2 / Center1 / Section2 / SubSection5 ...有时最多可以达到7个子级别。

Department2 / Center2 / Section1 / SubSection1 ...有时它最多可以达到7个子级。

Department2 / Center2 / Section1 / SubSection2 ...有时最多可以达到7个子级别。

Department2 / Center2 / Section2 / SubSection1 ...有时最多可以达到7个子级。

Department2 / Center2 / Section3 / SubSection1 ...有时最多可以达到7个子级别。

Departme nt2 / Center2 / Section4 / SubSection1 ...有时它最多可以达到7个子级。

Department2 / Center2 / Section4 / SubSection2 ...有时最多可以达到7个子级别。



我的需求是:

我想给所有这些部门,中心,部门和小节提供数字。每个部分将采用3位数字。 Department = 000,Center = 000,Section = 000 ......等

这里的分隔符是数据之间的斜杠符号/。

具有相同部门的行将有部门的相同三位数代码,中心累计数字,001 002 003等。

同一部门的相同中心将具有相同的三位数代码和部分累计数字,001 002 003等。

同一中心和部门的相同部分将具有相同的三位数代码累计编号,分别为001 002 003等。等等所有子级别。

所以在一天结束时,我的部门号码将是这样的:











Department1 / Center1 / Section1 / SubSection1 ... 00100100100100000000000000 ... 000

Department1 / Center1 / Section1 / SubSection2 ... 00100100100200000000000000 ... 000

Department1 / Center1 / Section1 / SubSection3 ... 00100100100300000000000000 ... 000

Department1 / Center1 / Section2 / SubSection1 ... 001001002001000000000000000000 ... 000

Department1 / Center1 / Section2 / SubSection2 ... 00100100200200000000000000 ... 000

Department1 / Center1 / Section2 / SubSection3 ... 00100100200300000000000000 ... 000

Department1 / Center1 / Section2 / SubSection4 ... 00100100200400000000000000 ... 000

Department1 / Center1 / Section2 / SubSection5 ... 00100100200500000000000000 ... 000

Department1 / Center2 / Section1 / SubSection1 ... 00100200100100000000000000 ... 000

Department1 / Center2 / Section1 / SubSection2 ... 00100200100200000000000000 ... 000

Department1 / Center2 / Section2 / SubSection1 ... 00100200200100000000000000 ... 000

Department1 / Center2 / Section3 / SubSection1 ... 00100200300100000000000000 ... 000

Department1 / Center2 / Section4 / SubSection1 ... 00100200400100000000000000。 .. 000

Department1 / Center2 / Section4 / SubSection2 ... 00100200400200000000000000 ... 000

I have two fields
DepartmentNumber text of 99 characters
DepartmentDesc. Text of 255 characters.
Sample of some data: I have almost over than 20000 records.
DepartmentNumber is empty, have no data.
DepartmentDesc is full of data like the fallow.
Department1/Center1/Section1/SubSection1 … sometimes it can reach up to 7 sublevels.
Department1/Center1/Section1/SubSection2 … sometimes it can reach up to 7 sublevels.
Department1/Center1/Section1/SubSection3 … sometimes it can reach up to 7 sublevels.
Department1/Center1/Section2/SubSection1 … sometimes it can reach up to 7 sublevels.
Department1/Center1/Section2/SubSection2 … sometimes it can reach up to 7 sublevels.
Department1/Center1/Section2/SubSection3 … sometimes it can reach up to 7 sublevels.
Department1/Center1/Section2/SubSection4 … sometimes it can reach up to 7 sublevels.
Department1/Center1/Section2/SubSection5 … sometimes it can reach up to 7 sublevels.
Department1/Center2/Section1/SubSection1 … sometimes it can reach up to 7 sublevels.
Department1/Center2/Section1/SubSection2 … sometimes it can reach up to 7 sublevels.
Department1/Center2/Section2/SubSection1 … sometimes it can reach up to 7 sublevels.
Department1/Center2/Section3/SubSection1 … sometimes it can reach up to 7 sublevels.
Department1/Center2/Section4/SubSection1 … sometimes it can reach up to 7 sublevels.
Department1/Center2/Section4/SubSection2 … sometimes it can reach up to 7 sublevels.

Department2/Center1/Section1/SubSection1 … sometimes it can reach up to 7 sublevels.
Department2/Center1/Section1/SubSection2 … sometimes it can reach up to 7 sublevels.
Department2/Center1/Section1/SubSection3 … sometimes it can reach up to 7 sublevels.
Department2/Center1/Section2/SubSection1 … sometimes it can reach up to 7 sublevels.
Department2/Center1/Section2/SubSection2 … sometimes it can reach up to 7 sublevels.
Department2/Center1/Section2/SubSection3 … sometimes it can reach up to 7 sublevels.
Department2/Center1/Section2/SubSection4 … sometimes it can reach up to 7 sublevels.
Department2/Center1/Section2/SubSection5 … sometimes it can reach up to 7 sublevels.
Department2/Center2/Section1/SubSection1 … sometimes it can reach up to 7 sublevels.
Department2/Center2/Section1/SubSection2 … sometimes it can reach up to 7 sublevels.
Department2/Center2/Section2/SubSection1 … sometimes it can reach up to 7 sublevels.
Department2/Center2/Section3/SubSection1 … sometimes it can reach up to 7 sublevels.
Department2/Center2/Section4/SubSection1 … sometimes it can reach up to 7 sublevels.
Department2/Center2/Section4/SubSection2 … sometimes it can reach up to 7 sublevels.

My needs are:
I want to give numbers to all of these departments, Centers, Sections and subsections. Each part will take 3 digits . Department = 000, Center = 000, Section =000 … etc.
My delimiter here is the slash sign "/" between data.
Rows with the same department will have the same three digits code for department, and accumulated number for center, 001 002 003 etc.
Same Centers with the same department will have the same three digits code and accumulated number for sections, 001 002 003 etc.
Same sections at the same center and department will have the same three digits code accumulated number for subsections, 001 002 003 etc.. And so on with all sublevels.
So at the end of the day my DepartmentNumber will be like this:





Department1/Center1/Section1/SubSection1 … 00100100100100000000000000... 000
Department1/Center1/Section1/SubSection2 … 00100100100200000000000000... 000
Department1/Center1/Section1/SubSection3 … 00100100100300000000000000... 000
Department1/Center1/Section2/SubSection1 … 00100100200100000000000000... 000
Department1/Center1/Section2/SubSection2 … 00100100200200000000000000... 000
Department1/Center1/Section2/SubSection3 … 00100100200300000000000000... 000
Department1/Center1/Section2/SubSection4 … 00100100200400000000000000... 000
Department1/Center1/Section2/SubSection5 … 00100100200500000000000000... 000
Department1/Center2/Section1/SubSection1 … 00100200100100000000000000... 000
Department1/Center2/Section1/SubSection2 … 00100200100200000000000000... 000
Department1/Center2/Section2/SubSection1 … 00100200200100000000000000... 000
Department1/Center2/Section3/SubSection1 … 00100200300100000000000000... 000
Department1/Center2/Section4/SubSection1 … 00100200400100000000000000... 000
Department1/Center2/Section4/SubSection2 … 00100200400200000000000000... 000

推荐答案

令人困惑的需要你有一个解决方案希望你应用你的逻辑...



应用一个C#代码为你声明不同的变量部门,中心,部分和小节。



执行字符串的for循环,使用Split方法从DepartmentDesc检索SQL列:

String.Split方法

并从该拆分字符串中获取值并输入您的变量。



使用for循环再次应用更新查询到您的DepartmentNumber列,从您声明的变量中获取值。希望你明白了。
The confusing Need of yours have a solution hope you apply your logic...

Apply a C# code declaring different variables for your Departments, Centers, Sections and Subsections.

Perform a for loop of your string that u retrieve from DepartmentDesc your SQL Column using Split method :
String.Split Method
and getting values from that split string and feeding to your variables.

Apply update query again using for loop to your DepartmentNumber column getting values from your declared variables. Hope you got it.


这篇关于字符串解析在命令编号链中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆