Osk*_*kar 10 stored-procedures sybase-ase
如果在proc中某处出现文本字符串,如何在Sybase数据库中找到存储过程?我想看看db中的任何其他proc是否与我正在查看的那个有相似的逻辑,我想我有一个非常独特的搜索字符串(字面值)
编辑:
我正在使用Sybase版本11.2
Ada*_*amH 15
关于Graeme答案的两个变体(所以这也不适用于11.2):
这也列出了sproc的名称,但如果文本多次出现,则会为每个sproc返回多行:
select object_name(id),* from syscomments
where texttype = 0 and text like '%whatever%'
Run Code Online (Sandbox Code Playgroud)
这只列出了一次:
select distinct object_name(id) from syscomments
where texttype = 0 and text like '%whatever%'
Run Code Online (Sandbox Code Playgroud)
在SQL Anywhere和Sybase IQ中:
select * from SYS.SYSPROCEDURE where proc_defn like '%whatever%'
Run Code Online (Sandbox Code Playgroud)
我对ASE并不熟悉,但根据文档(可从sybooks.sybase.com获得),它类似于:
select * from syscomments where texttype = 0 and text like '%whatever%'
Run Code Online (Sandbox Code Playgroud)
小智 6
select * from sysobjects where
id in ( select distinct (id) from syscomments where text like '%SearchTerm%')
and xtype = 'P'
Run Code Online (Sandbox Code Playgroud)
请记住,syscomments中的text列是varchar(255),因此一个大的过程可以包含syscomments中的许多行,因此,如果在syscomments中将过程名分割为2个文本行,则上述选择将找不到过程名称.
我建议以下选择,它将处理上述情况:
declare @text varchar(100)
select @text = "%whatever%"
select distinct o.name object
from sysobjects o,
syscomments c
where o.id=c.id
and o.type='P'
and (c.text like @text
or exists(
select 1 from syscomments c2
where c.id=c2.id
and c.colid+1=c2.colid
and right(c.text,100)+ substring(c2.text, 1, 100) like @text
)
)
order by 1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
51637 次 |
| 最近记录: |