Select SysID, TBName, TBAlias, TBCaption, TBType
  from PUB_SYS_TBInfo
 Where Sys_Code = 'DBG'
   and Gsdm = '888'
   and kjnd = '2012'
   and TBName <> 'DBG_ZCLYSJ'
   and TBName <> 'DBG_SRLYSJ'
   and (trim(TBName) in (select trim(Tbname)
                           from pub_sys_fldinfo
                          where Gsdm = '888'
                            and Kjnd = '2012'
                            and Sys_Code = 'DBG'
                            and Sys_Code = 'DBG'
                            and KeyFld = 'DZKDM') and
       (TBType = '0' or TBType = '1'))
   and (TBName in (select NAME from Sysobjects where xtype = 'U') or
       TBAlias in (select NAME from Sysobjects where xtype = 'U'))
 order by TBType, SysID
/*
服务器: 消息 195,级别 15,状态 10,行 8
'trim' 不是可以识别的 函数名。
服务器: 消息 195,级别 15,状态 1,行 8
'trim' 不是可以识别的 函数名。
服务器: 消息 156,级别 15,状态 1,行 16
在关键字 'or' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 17
第 17 行: ')' 附近有语法错误。
*/

解决方案 »

  1.   

    'trim' 不是可以识别的 函数名。你 select trim('abc') from dual 试试看,trim 函数是不是没有权限执行?
      

  2.   

    Select SysID, TBName, TBAlias, TBCaption, TBType
      from PUB_SYS_TBInfo
     Where Sys_Code = 'DBG'
       and Gsdm = '888'
       and kjnd = '2012'
       and TBName <> 'DBG_ZCLYSJ'
       and TBName <> 'DBG_SRLYSJ'
       and (rtrim(ltrim(TBName)) in (select rtrim(ltrim(Tbname))
                               from pub_sys_fldinfo
                              where Gsdm = '888'
                                and Kjnd = '2012'
                                and Sys_Code = 'DBG'
                                and Sys_Code = 'DBG'
                                and KeyFld = 'DZKDM') and
           (TBType = '0' or TBType = '1')))
       and (TBName in (select NAME from Sysobjects where xtype = 'U') or
           TBAlias in (select NAME from Sysobjects where xtype = 'U'))
     order by TBType, SysID
      

  3.   


    不行,还是一样的错,是SQL的语句。
      

  4.   

    -- 加个右圆括号试试:
    Select SysID, TBName, TBAlias, TBCaption, TBType
      from PUB_SYS_TBInfo
     Where Sys_Code = 'DBG'
       and Gsdm = '888'
       and kjnd = '2012'
       and TBName <> 'DBG_ZCLYSJ'
       and TBName <> 'DBG_SRLYSJ'
       and (trim(TBName)) in (select trim(Tbname)
                               from pub_sys_fldinfo
                              where Gsdm = '888'
                                and Kjnd = '2012'
                                and Sys_Code = 'DBG'
                                and Sys_Code = 'DBG'
                                and KeyFld = 'DZKDM') and
           (TBType = '0' or TBType = '1'))
       and (TBName in (select NAME from Sysobjects where xtype = 'U') or
           TBAlias in (select NAME from Sysobjects where xtype = 'U'))
     order by TBType, SysID
      

  5.   

    确认你的数据库版本。
    oracle早期版本里面没有trim函数,你可以按照2楼的方法变通一下。