Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Bonjour a tous,
je voudrais savoir s'il était possible de lister les tables utilisées dans une procédure stockée ? Ou si il existe un utilitaire capable de le faire.
Merci
Hors ligne
Pour Oracle, tu as Toad qui te permet de faire ça très facilement:
Database => Schema Browser => Procedure => onglet "Deps(Uses)"
Hors ligne
Je suis sur ASE isql avec une base Sybase.
Hors ligne
Je ne connais pas ASE, mais je sais que CAST marche dessus.
Par contre, c'est pas donné.... Et puis, c'est quand même de la grosse artillerie
Hors ligne
Bonjour,
Sous ASE, il suffit de se connecter avec Sybase Central pour accéder au code source de la procédure stockée.
En listant le code source, tu devrais déterminer les tables utilisées dans la procédure stockée.
Hors ligne
Bonjour, ca ne répond pas réellement à ton souci mais tu peux utiliser la commande
'sp_depends ' , qui va te donner les dépendances pour chacun de tes objets
Hors ligne
Voici un code qui prend en paramètre le nom du procédure et retourne les tables réferencées.
Pour ceux qui reconnaitrons , c'est effectivement sp_depends un peu nettoyée.
Si ça peu aider.
If Exists(Select name From sysobjects Where name='procedure_linked_tables' And (type= 'P') And uid = User_id()) Drop Procedure procedure_linked_tables go Create Proc procedure_linked_tables ( @objname varchar(92) ) As Begin declare @found_some bit /* flag for table dependencies found */ , @msg varchar(1024) , @sptlang int /* current sessions language */ , @length int , @colid int /* column id from syscolumns */ , @objid int if @@trancount = 0 begin set chained off end set transaction isolation level 1 set nocount on /* ** Make sure the @objname is local to the current database. */ if @objname like "%.%.%" and substring(@objname, 1, charindex(".", @objname) - 1) != db_name() begin /* ** 17460, "Object must be in the current database." */ raiserror 17460 return (1) end /* ** See if @objname exists. */ if not exists (select id from sysobjects where id = object_id(@objname) and type = 'P') -- uniquement les procédures begin /* ** 17461, "Object does not exist in this database." */ raiserror 17461 return (1) end /* ** Initialize @found_some to indicate that we haven't seen any dependencies. */ select @found_some = 0 /* ** Print out the particulars about the local dependencies. */ if exists (select * from sysdepends where id = object_id(@objname) ) begin /* ** 17462, "Things the object references in the current database." */ exec sp_getmessage 17462, @msg output print @msg select @sptlang = @@langid if @@langid != 0 begin if not exists ( select * from master.dbo.sysmessages where error between 17010 and 17014 and langid = @@langid) select @sptlang = 0 else if not exists ( select * from master.dbo.sysmessages where error between 17100 and 17109 and langid = @@langid) select @sptlang = 0 end begin select @length = max(datalength(s.name + "." + o.name)) from sysobjects o, sysdepends d, sysusers s where o.id = d.depid and d.id = object_id(@objname) and o.uid = s.uid and o.type = 'U' --DrHouse if (@length > 40) select object = s.name + "." + o.name, type = convert(char(16), m0.description), updated = convert(char(10), m1.description), selected = convert(char(10), m2.description) from sysobjects o, master.dbo.spt_values v, sysdepends d, master.dbo.spt_values u, master.dbo.spt_values w, sysusers s, master.dbo.sysmessages m0, master.dbo.sysmessages m1, master.dbo.sysmessages m2 where o.id = d.depid and o.sysstat & 15 = v.number and v.type = 'O' and v.msgnum = m0.error and isnull(m0.langid, 0) = @sptlang and u.type = 'B' and u.number = d.resultobj and u.msgnum = m1.error and isnull(m1.langid, 0) = @sptlang and w.type = 'B' and w.number = d.readobj and w.msgnum = m2.error and isnull(m2.langid, 0) = @sptlang and d.id = object_id(@objname) and o.uid = s.uid and o.type = 'U' --Dr House else select object = convert(char(40), (s.name + "." + o.name)), type = convert(char(16), m0.description), updated = convert(char(10), m1.description), selected = convert(char(10), m2.description) from sysobjects o, master.dbo.spt_values v, sysdepends d, master.dbo.spt_values u, master.dbo.spt_values w, sysusers s, master.dbo.sysmessages m0, master.dbo.sysmessages m1, master.dbo.sysmessages m2 where o.id = d.depid and o.sysstat & 15 = v.number and v.type = 'O' and v.msgnum = m0.error and isnull(m0.langid, 0) = @sptlang and u.type = 'B' and u.number = d.resultobj and u.msgnum = m1.error and isnull(m1.langid, 0) = @sptlang and w.type = 'B' and w.number = d.readobj and w.msgnum = m2.error and isnull(m2.langid, 0) = @sptlang and d.id = object_id(@objname) and o.uid = s.uid and o.type = 'U' -- DrHouse end select @found_some = 1 end /* ** Did we find anything in sysdepends? */ if (@found_some = 0) begin /* ** 17464, "Object doesn't reference any object and no objects reference it." */ exec sp_getmessage 17464, @msg output print @msg end End
Hors ligne
Bonjour,
Merci.
Doctor Z.
Hors ligne
bel effort Dr.Z, mais en l'occurrence c'est la balise code=mssql
Hors ligne
erasorz a écrit:
bel effort Dr.Z, mais en l'occurrence c'est la balise code=mssql
Hors ligne