原本的语句是这样的
PROCEDURE GETLISTGEOMETRYWKT(OBJECTIDS IN VARCHAR2, PCURSOR OUT PNCURSOR) as OBJIDS varchar2(300); BEGIN OBJIDS:=','||OBJECTIDS||','; OPEN PCURSOR FOR SELECT T.ID as OBJECTID,T.SHAPE.GET_WKT() as COORD FROM T_PLACE T WHERE instr(OBJIDS,','||TO_CHAR(ID)||',')>0; END GETLISTGEOMETRYWKT;
传入的参数是逗号隔开的ID字符串
现在由于表名会变动,所以要改成动态的sql语句,
现在想问instr中那一串怎么动态拼接
看了半天,也没看懂,MSSQL到ORACLE还是有不小的差距。
如果在MSSQL里,可以这样:
declare @sql nvarchar(max);
declare @tableName nvarchar(100);
set @sql = 'OPEN PCURSOR FOR
SELECT T.ID as OBJECTID,T.SHAPE.GET_WKT() as COORD
FROM ' + @tableName + ' T
WHERE instr(@OBJIDS,'',''||TO_CHAR(ID)||'','')>0';
sp_execute @sql, @OBJIDS=OBJIDS
(没用Sql验证,单词拼写可能有错误,语法也可能有错误)