数据库原理与技术简明教程(第二版)课后习题参考答案 下载本文

if @tableName='Book' select * from book where book_id=@id else if @tableName='reader'select * from reader where reader_id=@id

else print '不适用本函数' end 测试:

exec search1 'book','A32DT00002' exec search1 'borrow','A32DT00002' (8) create

proc

search2(@tableName

varchar(20)=NULL) as begin

if @tableName='Book' begin

if(@id IS null)

select top 1 * from Book ELSE

varchar(20),@id

SELECT * FROM BOOK WHERE book_ID=@ID end

else if @tableName='reader' begin

if(@id IS null)

select top 1 * from reader ELSE

SELECT * FROM READER WHERE Reader_ID=@ID end

else print '不适用本函数' end 测试:

exec search2 'book','A32DT00002' exec search2 'borrow','A32DT00002' exec search2 'book'