如何获得触发器中的信息?

hlq 2002-03-06 11:05:12
触发器trigger1,其功能为先按某条件进行查找操作operator1,如果查找成功则对别外一个表的某些数据进行更新。

问题:如何获得operator1的查找结果,返回到pb程序中,再对这个结果进行处理。

运行环境:pb 7.0,sql server 7.0
...全文
72 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhanwei 2002-03-06
  • 打赏
  • 举报
回复
Using RAISERROR
RAISERROR is a more powerful statement than PRINT for returning messages back to applications. RAISERROR can return messages in either of these forms:

A user-defined error message that has been added to master.dbo.sysmessages using the sp_addmessage system stored procedure.
A message string specified in the RAISERROR statement.
RAISERROR also has these extensions to the capabilities of PRINT:

RAISERROR can assign a specific error number, severity, and state.
RAISERROR can request that the error be logged in the Microsoft® SQL Server™ error log and the Microsoft Windows NT® application log.
The message string can contain substitution variables and arguments, much like the C language printf function.
When RAISERROR is used with the msg_id of a user-defined message in sysmessages, msg_id is returned as the SQL Server error number, or native error code. When RAISERROR is used with a msg_str instead of a msg_id, the SQL Server error number and native error number returned is 50000.

When you use RAISERROR to return a user-defined error message, use a different state number in each RAISERROR that references that error. This can aid in diagnosing the errors when they are raised.

Use RAISERROR to help in troubleshooting Transact-SQL code, to check the values of data, or to return messages that contain variable text.

This example substitutes the values from the DB_ID and DB_NAME functions in a message sent back to the application:

DECLARE @DBID INT

SET @DBID = DB_ID()



DECLARE @DBNAME NVARCHAR(128)

SET @DBNAME = DB_NAME()



RAISERROR

('The current database ID is:%d, the database name is: %s.',

16, 1, @DBID, @DBNAME)



This example accomplishes the same process using a user-defined message:

sp_addmessage 50005, 16,

'The current database ID is:%d, the database name is: %s.'

GO

DECLARE @DBID INT

SET @DBID = DB_ID()



DECLARE @DBNAME NVARCHAR(128)

SET @DBNAME = DB_NAME()



RAISERROR (50005, 16, 1, @DBID, @DBNAME)

GO



This second RAISERROR example shows that substitution parameters can be specified in a user-defined error and filled with substitution arguments at the time the RAISERROR statement executes
hecf 2002-03-06
  • 打赏
  • 举报
回复

触发器在这儿不能用。因为触发器不能返回结果。使用过程试试。
hlq 2002-03-06
  • 打赏
  • 举报
回复
必须返加pb, 例如我想返回一个字符串,然后在pb下用一个窗口中的多行编辑器来显示,这样用户可以拷贝这个信息
zhanwei 2002-03-06
  • 打赏
  • 举报
回复
你所要的在触发器中都可实现,无需返回pb,监察结果,可用raiserror()
yling 2002-03-06
  • 打赏
  • 举报
回复
raiserror()
hlq 2002-03-06
  • 打赏
  • 举报
回复
高手快来呀
实验3 触发器及其应用 一、实验目的   1、掌握基本RS、JK、D和T触发器的逻辑功能 2、掌握集成触发器的逻辑功能及使用方法 3、熟悉触发器之间相互转换的方法 二、实验原理   触发器具有两个稳定状态,用以表示逻辑状态"1"和"0",在一定的外界信号作用下 ,可以从一个稳定状态翻转到另一个稳定状态,它是一个具有记忆功能的二进制信息存 贮器件,是构成各种时序电路的最基本逻辑单元。 1、基本RS触发器 图5-8-1为由两个与非门交叉耦合构成的基本RS触发器,它是无时钟控制低电平直 接触发的触发器。基本RS触发器具有置"0"、置"1"和"保持"三种功能。通常称为置 "1"端,因为=0(=1)时触发器被置"1";为置"0"端,因为=0 (=1)时触发器被置"0",当==1时状态保持;==0时, 触发器状态不定,应避免此种情况发生,表5-8-1为基本RS触发器的功能表。 基本RS触发器。也可以用两个"或非门"组成,此时为高电平触发有效。 表5-8-1 "输 入 "输 出 " "[pic"[pic"Qn+1"[pic" "] "] " "]n+1" "0 "1 "1 "0 " "1 "0 "0 "1 " "1 "1 "Qn "[pic" " " " "]n " "0 "0 "φ "φ " 图 5—8—1 基本RS触发器 2、JK触发器 在输入信号为双端的情况下,JK触发器是功能完善、使用灵活和通用性较强的一种触发 器。本实验采用74LS112双JK触发器,是下降边沿触发的边沿触发器。引脚功能及逻辑符 号如图5-8-2所示。 JK触发器的状态方程为       Qn+1 =Jn+Qn J和K是数据输入端,是触发器状态更新的依据,若J、K有两个或两个以上输入端时,组 成"与"的关系。Q与 为两个互补输出端。通常把 Q=0、=1的状态定为触发器"0"状态;而把Q=1,=0定为"1"状态。 图5-8-2 74LS112双JK触发器引脚排列及逻辑符号 下降沿触发JK触发器的功能如表5-8-2 表5-8-2 "输 入 "输 出 " "[pic"[pic"CP "J "K "Qn+1"[pic" "]D "]D " " " " "]n+1" "0 "1 "× "× "× "1 "0 " "1 "0 "× "× "× "0 "1 " "0 "0 "× "× "× "φ "φ " "1 "1 " "0 "0 "Qn "[pic" " " " " " " "]n " "1 "1 " "1 "0 "1 "0 " "1 "1 " "0 "1 "0 "1 " "1 "1 " "1 "1 "[pic"Qn " " " " " " "]n " " "1 "1 " "× "× "Qn "[pic" " " " " " " "]n " 注:×— 任意态  — 高到低电平跳变 — 低到高电平跳变 Qn(n )— 现态 Qn+1(n+1 )— 次态 φ— 不定态 JK触发器常被用作缓冲存储器,移位寄存器和计数器。 3、D触发器 在输入信号为单端的情况下,D触发器用起来最为方便,其状态方程为 Qn+1=Dn,其输出状态的更新发生在CP脉冲的上升沿,故又称为上升沿触发的边沿触发 器,触发器的状态只取决于时钟到来前D端的状态,D触发器的应用很广,可用作数字信 号的寄存,移位寄存,分频和波形发生等。有很多种型号可供各种用途的需要而选用。 如双D 74LS74、四D 74LS175、六D 74LS174等。 图5-8-3 为双D 74LS74的引脚排列及逻辑符号。功能如表5-8-3。 图5-8-3 74LS74引脚排列及逻辑符号   表5-8-3     表5-8-4 "输 入 "输 出 " "[pic"[pic"CP "D "Qn+1"n" "]D "]D " " " "+1 " "0 "1 "× "× "1 "0 " "1 "0 "× "× "0 "1 " "0 "0 "× "× "φ "φ " "1 "1 " "1 "1 "0 " "1 "1 " "0 "0 "1 " "1 "1 " "× "Qn "n" "输 入 "输出 " "[pic"[pi"CP "T "Qn+1" "]D "c]D" " " " "0 "1 "× "× "1 " "1 "0 "× "× "0 " "1 "1 " "0 "Qn " "1 "1 " "1 "" " " " " "n " 4、触发器之间的相互转换 在集成触发器的产品,每一种触发器都有自己固定的逻辑功能。但可以利用转换的 方法获得具有其它功能的触发器。例如将JK触发器的J、k两端连在一起,并认它为T端, 就得到所需的T触发器。如图5-8-4(a)所示,其状态方程为: Qn+1 =Tn +Qn         (a) T触发器 (b) T'触

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧