同一查询中的多个操作 [英] multiple operation in same query

查看:127
本文介绍了同一查询中的多个操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个RECID,regionID,areaID,UserID,AppNo,NextAppNo(接受null)



和数据如下



(NextApp仅在第一行)

1,102,Ar-1,xyz,1,1

2,102,Ar-1, ,erer,2

3,102,Ar-1,tyty,3

4,102,Ar-1,tyty,4



1)

现在我要添加另一条记录

我正在做的是

首先获得APPID的最大数量areaID = Ar-1和regionID = 102

然后检查如果我们从查询得到的最大appNo是0然后添加nextappNo否则不是

然后插入db现在是它可以在一个查询中完成





2)



现在我要删除第一条记录,我现在正在做的是首先选择数据,其中areaID = Ar-1和regionID = 102



现在循环我检查是否Recid与我们要删除的id相同。

从那里开始我更新了列ap证明者以及我们要删除的记录是否为approverNO = 1,然后还将下一个审批者更新为下一个记录之一。

然后从表中删除记录。



如果有什么不清楚我的英语不好,请回复。

i have a RECID,regionID, areaID ,UserID ,AppNo, NextAppNo(Accepts null)

and data is as follow

(NextApp is in the first row only)
1,102,Ar-1,xyz,1,1
2,102,Ar-1,,erer,2
3,102,Ar-1,tyty,3
4,102,Ar-1,tyty,4

1)
now i want to add another record
what i am doing is
first getting the max number of APPID where areaID = Ar-1 and regionID =102
and then check that if max appNo we got from query is 0 then add nextappNo otherwise not
and then inserting into db now is it possible to do it in one query


2)

now i want to delete the first record what i am doing now is first selecting data where areaID = Ar-1 and regionID =102

and now in loop i check if Recid is the same id we want to delete.
and from there onward i update the the column approver and also if the record which we are going to delete has approverNO = 1 then also update the next approver to one of the next record.
then delete the record from table.

Reply if anything is unclear which i am expexting from my bad english.

推荐答案

您无法在一个查询中执行此操作。您可以在一个存储过程中执行此操作,该过程可以包含任意数量的操作。
You can't do that in one query. You CAN do it in one stored procedure, which can have as many operations in it as you like.


这篇关于同一查询中的多个操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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