oracle 儲存過程模糊查詢

2021-06-08 10:40:54 字數 1057 閱讀 4316

t-sql的寫法:

useadventureworks;

gocreate

procedure

findemployee 

@emplname

varchar(20

)asselect

@emplname

=rtrim

(@emplname) +

'%';

select

c.firstname, c.lastname, a.city

from

person.contact c 

join

person.address a 

onc.contactid 

=a.addressid

where

c.lastname 

like

@emplname;go

exec

findemployee 

@emplname='

barb';

pl/sql的寫法:

create

orreplace

procedure

query_by_key

(p_key1 

invarchar2

,p_key2 

invarchar2

,p_cursor out jn_table.jn_ctable)*

asstr_sql  

varchar2

(500):=

'select * from tablea'||

'where   pname like :v_key1  and pname like :v_key2 ';

begin

open

p_cursor 

forstr_sql using  '%

'||p_key1||'

%', '

%'||p_key2||'

%';end

query_by_key;  

**:

模糊查詢(儲存過程)

set ansi nulls on set quoted identifier on goalter procedure dbo searchvague description varchar 1000 descriptionlength int,pagenumber tinyint,product...

儲存過程實現模糊查詢分頁

if exists select 1 from sysobjects where name getnewscount and type p drop proc getnewscount gocreate procedure getnewscount title nvarchar asselect c...

儲存過程實現模糊查詢問題

環境sql server 2008 查詢器 create proc lyf a hto nvarchar 50 null asselect ordponumer from orderline like n hto go執行 exec lyf a 洛陽 查詢字段結果很多?的資訊 我用查詢語句測試 se...