分享:sp_get_object 实例下查找指定对象名

本文介绍了一个用于查询SQL Server中特定类型对象的存储过程。该过程可根据输入参数搜索指定数据库或所有数据库中的对象,并返回对象名称、类型及所在数据库等信息。
 
use master
go
IF OBJECT_ID('sp_get_object', 'P') IS NOT NULL   
    DROP PROCEDURE sp_get_object    
go     
CREATE PROCEDURE sp_get_object  
    ( @objectname NVARCHAR(128) = '' ,  
      @typeInput varchar(8) = 'U',
	  @is_current_db CHAR(1) = 'N'  --是否当前数据库  
    )  
AS   
--  作者:陈恩辉-弘恩     
    SET NOCOUNT ON ;    
    IF @is_current_db = 'Y'     
        SELECT  DB_NAME() AS db_name ,  
                type ,  
                name  
        FROM    sys.objects  
        WHERE   name LIKE @objectname + '%' and type like @typeInput +'%'
    ELSE   
        BEGIN     
            SELECT TOP 0  
                    DB_NAME() AS db_name ,  
                    type ,  
                    name  
            INTO    #sp_get_object  
            FROM    sys.objects    
            DECLARE @sql NVARCHAR(MAX) ,@sql_exec NVARCHAR(1000) ,@new_line CHAR(2)   
            SELECT  @sql = '' ,@new_line = CHAR(13) + CHAR(10),  
             @sql_exec =  @new_line+ 'USE [@dbname] ' +@new_line    
                        +'INSERT INTO #sp_get_object ( db_name,type ,name ) ' +@new_line      
                        +'SELECT DB_NAME() AS db_name, type ,name ' + @new_line  
                        +'FROM    sys.objects ' +@new_line  
						+' where type like ''' +  @typeInput +'%'''
                        +' and   name like '''     
            SELECT  @sql = @sql + REPLACE( @sql_exec + @objectname + '%'' ', '@dbname',name)  
            FROM    sys.databases     
            PRINT @sql    
            EXEC sp_executesql @sql     
            SELECT  db_name ,  
                    type ,  
                    name  ,
					case when type = 'U' then 'select top 10 * from '+db_name+'..['+name+']' else '' end  as _sql
            FROM    #sp_get_object    
            DROP TABLE #sp_get_object         
        END    
GO    
EXEC sp_MS_marksystemobject 'sp_get_object'    
GO  

Consolidate compiler generated dependencies of target cpp_node [ 50%] Building CXX object CMakeFiles/cpp_node.dir/src/cpp_node.cpp.o /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp: In function ‘int main(int, char**)’: /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:6:47: error: expected ‘,’ or ‘;’ before ‘{’ token 6 | auto node = std::make_shared<rclcpp::Node>{"cpp_node"}; | ^ In file included from /opt/ros/humble/include/rclcpp/rclcpp/client.hpp:40, from /opt/ros/humble/include/rclcpp/rclcpp/callback_group.hpp:24, from /opt/ros/humble/include/rclcpp/rclcpp/any_executable.hpp:20, from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategy.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategies.hpp:18, from /opt/ros/humble/include/rclcpp/rclcpp/executor_options.hpp:20, from /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:37, from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:1: /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:7:23: error: request for member ‘get_logger’ in ‘* node’, which is of non-class type ‘std::shared_ptr<rclcpp::Node>()’ 7 | RCLCPP_INFO(node->get_logger(),"你好C++节点!"); | ^~~~~~~~~~ /opt/ros/humble/include/rclcpp/rclcpp/logging.hpp:517:40: note: in definition of macro ‘RCLCPP_INFO’ 517 | ::std::is_convertible_v<decltype(logger), ::rclcpp::Logger>, \ | ^~~~~~ /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:7:23: error: request for member ‘get_logger’ in ‘* node’, which is of non-class type ‘std::shared_ptr<rclcpp::Node>()’ 7 | RCLCPP_INFO(node->get_logger(),"你好C++节点!"); | ^~~~~~~~~~ /opt/ros/humble/include/rclcpp/rclcpp/logging.hpp:517:40: note: in definition of macro ‘RCLCPP_INFO’ 517 | ::std::is_convertible_v<decltype(logger), ::rclcpp::Logger>, \ | ^~~~~~ /opt/ros/humble/include/rclcpp/rclcpp/logging.hpp:517:14: error: template argument 1 is invalid 517 | ::std::is_convertible_v<decltype(logger), ::rclcpp::Logger>, \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:7:5: note: in expansion of macro ‘RCLCPP_INFO’ 7 | RCLCPP_INFO(node->get_logger(),"你好C++节点!"); | ^~~~~~~~~~~ In file included from /opt/ros/humble/include/rclcpp/rclcpp/logging.hpp:24, from /opt/ros/humble/include/rclcpp/rclcpp/client.hpp:40, from /opt/ros/humble/include/rclcpp/rclcpp/callback_group.hpp:24, from /opt/ros/humble/include/rclcpp/rclcpp/any_executable.hpp:20, from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategy.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategies.hpp:18, from /opt/ros/humble/include/rclcpp/rclcpp/executor_options.hpp:20, from /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:37, from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:1: /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:7:23: error: request for member ‘get_logger’ in ‘* node’, which is of non-class type ‘std::shared_ptr<rclcpp::Node>()’ 7 | RCLCPP_INFO(node->get_logger(),"你好C++节点!"); | ^~~~~~~~~~ /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:7:5: note: in expansion of macro ‘RCLCPP_INFO’ 7 | RCLCPP_INFO(node->get_logger(),"你好C++节点!"); | ^~~~~~~~~~~ /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:7:23: error: request for member ‘get_logger’ in ‘* node’, which is of non-class type ‘std::shared_ptr<rclcpp::Node>()’ 7 | RCLCPP_INFO(node->get_logger(),"你好C++节点!"); | ^~~~~~~~~~ /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:7:5: note: in expansion of macro ‘RCLCPP_INFO’ 7 | RCLCPP_INFO(node->get_logger(),"你好C++节点!"); | ^~~~~~~~~~~ /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:8:17: error: no matching function for call to ‘spin(std::shared_ptr<rclcpp::Node> (*&)())’ 8 | rclcpp::spin(node); | ~~~~~~~~~~~~^~~~~~ In file included from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:1: /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:45:1: note: candidate: ‘void rclcpp::spin(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr)’ 45 | spin(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr); | ^~~~ /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:45:60: note: no known conversion for argument 1 from ‘std::shared_ptr<rclcpp::Node> (*)()’ to ‘rclcpp::node_interfaces::NodeBaseInterface::SharedPtr’ {aka ‘std::shared_ptr<rclcpp::node_interfaces::NodeBaseInterface>’} 45 | spin(rclcpp::node_interfaces::NodeBaseInterface::SharedPtr node_ptr); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:49:1: note: candidate: ‘void rclcpp::spin(rclcpp::Node::SharedPtr)’ 49 | spin(rclcpp::Node::SharedPtr node_ptr); | ^~~~ /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:49:30: note: no known conversion for argument 1 from ‘std::shared_ptr<rclcpp::Node> (*)()’ to ‘rclcpp::Node::SharedPtr’ {aka ‘std::shared_ptr<rclcpp::Node>’} 49 | spin(rclcpp::Node::SharedPtr node_ptr); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/c++allocator.h:33, from /usr/include/c++/11/bits/allocator.h:46, from /usr/include/c++/11/memory:64, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:153, from /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:1: /usr/include/c++/11/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = rclcpp::Node; _Args = {}; _Tp = rclcpp::Node]’: /usr/include/c++/11/bits/alloc_traits.h:516:17: required from ‘static void std::allocator_traits<std::allocator<_Tp1> >::construct(std::allocator_traits<std::allocator<_Tp1> >::allocator_type&, _Up*, _Args&& ...) [with _Up = rclcpp::Node; _Args = {}; _Tp = rclcpp::Node; std::allocator_traits<std::allocator<_Tp1> >::allocator_type = std::allocator<rclcpp::Node>]’ /usr/include/c++/11/bits/shared_ptr_base.h:519:39: required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {}; _Tp = rclcpp::Node; _Alloc = std::allocator<rclcpp::Node>; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/11/bits/shared_ptr_base.h:650:16: required from ‘std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = rclcpp::Node; _Alloc = std::allocator<rclcpp::Node>; _Args = {}; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/11/bits/shared_ptr_base.h:1342:14: required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<rclcpp::Node>; _Args = {}; _Tp = rclcpp::Node; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic]’ /usr/include/c++/11/bits/shared_ptr.h:409:59: required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<rclcpp::Node>; _Args = {}; _Tp = rclcpp::Node]’ /usr/include/c++/11/bits/shared_ptr.h:862:14: required from ‘std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = rclcpp::Node; _Alloc = std::allocator<rclcpp::Node>; _Args = {}]’ /usr/include/c++/11/bits/shared_ptr.h:878:39: required from ‘std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = rclcpp::Node; _Args = {}]’ /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:6:22: required from here /usr/include/c++/11/ext/new_allocator.h:162:11: error: no matching function for call to ‘rclcpp::Node::Node()’ 162 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /opt/ros/humble/include/rclcpp/rclcpp/executors/single_threaded_executor.hpp:28, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:22, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /home/cyt/chapt2/demo_cpp_pkg/src/cpp_node.cpp:1: /opt/ros/humble/include/rclcpp/rclcpp/node.hpp:1294:3: note: candidate: ‘rclcpp::Node::Node(const rclcpp::Node&, const string&)’ 1294 | Node( | ^~~~ /opt/ros/humble/include/rclcpp/rclcpp/node.hpp:1294:3: note: candidate expects 2 arguments, 0 provided /opt/ros/humble/include/rclcpp/rclcpp/node.hpp:101:12: note: candidate: ‘rclcpp::Node::Node(const string&, const string&, const rclcpp::NodeOptions&)’ 101 | explicit Node( | ^~~~ /opt/ros/humble/include/rclcpp/rclcpp/node.hpp:101:12: note: candidate expects 3 arguments, 0 provided /opt/ros/humble/include/rclcpp/rclcpp/node.hpp:89:12: note: candidate: ‘rclcpp::Node::Node(const string&, const rclcpp::NodeOptions&)’ 89 | explicit Node( | ^~~~ /opt/ros/humble/include/rclcpp/rclcpp/node.hpp:89:12: note: candidate expects 2 arguments, 0 provided make[2]: *** [CMakeFiles/cpp_node.dir/build.make:76:CMakeFiles/cpp_node.dir/src/cpp_node.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:137:CMakeFiles/cpp_node.dir/all] 错误 2 make: *** [Makefile:146:all] 错误 2
最新发布
09-28
status_t CameraProviderManager::openHidlSession(const std::string &id, const sp<device::V3_2::ICameraDeviceCallback>& callback, /*out*/ sp<device::V3_2::ICameraDeviceSession> *session) { std::lock_guard<std::mutex> lock(mInterfaceMutex); auto deviceInfo = findDeviceInfoLocked(id); if (deviceInfo == nullptr) return NAME_NOT_FOUND; auto *hidlDeviceInfo3 = static_cast<HidlProviderInfo::HidlDeviceInfo3*>(deviceInfo); sp<ProviderInfo> parentProvider = deviceInfo->mParentProvider.promote(); if (parentProvider == nullptr) { return DEAD_OBJECT; } const sp<provider::V2_4::ICameraProvider> provider = static_cast<HidlProviderInfo *>(parentProvider.get())->startProviderInterface(); if (provider == nullptr) { return DEAD_OBJECT; } std::shared_ptr<HalCameraProvider> halCameraProvider = std::make_shared<HidlHalCameraProvider>(provider, provider->descriptor); saveRef(DeviceMode::CAMERA, id, halCameraProvider); Status status; hardware::Return<void> ret; auto interface = hidlDeviceInfo3->startDeviceInterface(); if (interface == nullptr) { return DEAD_OBJECT; } ret = interface->open(callback, [&status, &session] (Status s, const sp<device::V3_2::ICameraDeviceSession>& cameraSession) { status = s; if (status == Status::OK) { *session = cameraSession; } }); if (!ret.isOk()) { removeRef(DeviceMode::CAMERA, id); ALOGE("%s: Transaction error opening a session for camera device %s: %s", __FUNCTION__, id.c_str(), ret.description().c_str()); return DEAD_OBJECT; } return HidlProviderInfo::mapToStatusT(status); }
07-24
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值