免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: winjjd
打印 上一主题 下一主题

pb 要跟sybase 连接时,出现以下问题。。 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2004-09-21 20:13 |只看该作者

pb 要跟sybase 连接时,出现以下问题。。

见鬼,附件咋了?扩展名 *** 是不被允许的      是pbsyc.sql自己去找吧

论坛徽章:
0
12 [报告]
发表于 2004-09-22 08:48 |只看该作者

pb 要跟sybase 连接时,出现以下问题。。

你要将以下存储过程导入你新建的数据库
create procedure sp_pb60table              
@table_name   varchar(32) = null,              
@table_owner  varchar(32) = null,              
@table_qualifier varchar(32) = null,              
@table_type   varchar(100) = null              
as              
declare @type1  varchar(3)            
        
if @table_type is null              
   begin              
    /* Select all ODBC supported data types  */              
     select @type1 = 'SUV'              
   end              
else              
   begin      
     /*  TableType is case sensitive if CS server */              
     select @type1 = null              
     /*  Add System Tables  */              
     if (charindex("'SYSTEM TABLE'", @table_type) != 0)              
        select @type1 = @type1 + 'S'              
    /*  Add User Tables  */              
   if (charindex ("'TABLE'", @table_type) != 0)              
         select @type1 = @type1 + 'U'              
    /*  Add Views  */            
     if (charindex ("'VIEW'", @table_type) != 0)            
         select @type1 = @type1 + 'V'              
   end        
              
if @table_name is null              
   begin              
     /*  If table name not supplied, match all  */              
     select @table_name = '%'              
   end              
/*else         
   begin                 
  if (@table_owner is null) and (charindex('%', @table_name) = 0)              
       begin              
         /*  If owner not specified and table is specified  */              
         if exists (select * from sysobjects where uid = user_id() and            
                    name = @table_name and (type = 'U' or type = 'V' or type = 'S'))              
           begin              
           /*  Override supplied owner w/owner of table */              
             select @table_owner = user_name()              
        end              
       end           
   end              
            
   /*  If no owner supplied, force wildcard */              
if @table_owner is null               
*/            
       select @table_owner = 'dbo'              
              
/*   select o.name, o.id, o.type, o.uid, user_name(o.uid) */            
   select o.name, o.id, o.type, user_id(user), user              
   from sysobjects o              
where o.name like @table_name              
   and user_name(o.uid) like @table_owner              
   and charindex(substring(o.type,1,1),@type1) != 0  
***********************************************
***********************************************
create proc sp_pb60column            
   @id int            
as           
    declare @text varchar(255)           
    select @text = null           
   select c.colid, c.status, c.type, c.length, c.name, c.usertype,            
          c.prec,  c.scale, @text   
   from dbo.syscolumns c  where c.id = @id and c.cdefault = 0           
   union select           
           c.colid, c.status, c.type, c.length, c.name, c.usertype,            
             c.prec, c.scale, m.text           
             from dbo.syscolumns c, dbo.syscomments m where c.id = @id            
and c.cdefault = m.id  and m.colid = 1           
   order by c.colid
**************************************************
**************************************************
导入这两个存储过程就可以连接但是,你还必须导入(sp_pb60index,sp_pb60foreignkey,sp_pb60primarykey)
这些和索引、主键、外键等。
我以Pb6.5为例子

论坛徽章:
0
13 [报告]
发表于 2004-09-22 08:49 |只看该作者

pb 要跟sybase 连接时,出现以下问题。。

create procedure sp_pb60index              
@objname varchar(92)                    /* the table to check for indexes */              
as              
declare @objid int                      /* the object id of the table */              
declare @indid int /* the index id of an index */              
declare @key1 varchar(30)               /* first key  */              
declare @key2 varchar(30)               /* second key  */              
declare @key3 varchar(30)               /* third key  */              
declare @key4 varchar(30)   /* fourth key  */            
declare @key5 varchar(30)               /* ...  */              
declare @key6 varchar(30)              
declare @key7 varchar(30)              
declare @key8 varchar(30)              
declare @key9 varchar(30)          /* ...  */        
declare @key10 varchar(30)              
declare @key11 varchar(30)            
declare @key12 varchar(30)              
declare @key13 varchar(30)               /* ...  */              
declare @key14 varchar(30)   
declare @key15 varchar(30)           
declare @key16 varchar(30)              
              
declare @unique smallint      /* index is unique */              
declare @clustered  smallint         /* index is clustered */              
declare @isolevel   int /* ptrack 325579  isolation level */            
/*              
**  Check to see the the table exists and initialize @objid.              
*/              
select @objid = object_id(@objname)              
              
/*              
**  Table doesn't exist so return.              
*/      
if @objid is null         
begin              
       return              
end            
              
/*              
**  See if the object has any indexes.              
**  Since there may be more than one entry in sysindexes for the object,              
**  this select will set @indid to the index id of the first index.              
*/            
select @indid = min(indid)              
       from sysindexes              
             where id = @objid              
                    and indid >; 0              
      and indid < 255              
           
/*              
**  If no indexes, return.            
*/              
if @indid is null              
begin              
       return              
end   
              
/*  ptrack 325579  override isolation level 0 default */              
select @isolevel = @@isolation               
if @isolevel = 0              
begin      
   set transaction isolation level 1            
end              
              
/*              
**  Now check out each index, figure out it's type and keys and      
**  save the info in a temporary table that we'll print out at the end.              
*/              
create table #spindtab              
(              
       index_name    varchar(30),              
       index_num   int,              
      index_key1  varchar(30) null,              
       index_key2      varchar(30) null,              
       index_key3      varchar(30) null,              
       index_key4      varchar(30) null,              
       index_key5      varchar(30) null,              
       index_key6      varchar(30) null,              
      index_key7      varchar(30) null,              
       index_key8      varchar(30) null,         
       index_key9  varchar(30) null,              
     index_key10     varchar(30) null,              
    index_key11  varchar(30) null,              
       index_key12     varchar(30) null,              
       index_key13     varchar(30) null,              
   index_key14     varchar(30) null,            
       index_key15     varchar(30) null,              
       index_key16  varchar(30) null,              
    index_unique    smallint,              
     index_clustered smallint,              
   index_status    smallint,            
      index_status2   int              
)              
            
while @indid != null              
begin           
              
       /*              
       **  First we'll figure out what the keys are.              
       */              
       declare @i int              
   declare @thiskey varchar(30)   
       declare @lastindid int              
              
      select @i = 1              
              
       set nocount on              
              
    while @i <= 16              
       begin              
             select @thiskey = index_col(@objname, @indid, @i)            
              
             if @thiskey = null              
             begin              
                    goto keysdone              
       end        
              
     if @i = 1              
             begin              
     select @key1 = index_col(@objname, @indid, @i)              
   end              
       else              
             if @i = 2              
         begin      
      select @key2 = index_col(@objname, @indid, @i)              
             end     
             else            
             if @i = 3              
     begin              
       select @key3 = index_col(@objname, @indid, @i)              
    end         
        else              
  if @i = 4              
             begin              
         select @key4 = index_col(@objname, @indid, @i)              
      end              
       else              
             if @i = 5              
   begin              
                select @key5 = index_col(@objname, @indid, @i)              
end              
             else              
             if @i = 6        
   begin            
    select @key6 = index_col(@objname, @indid, @i)      
             end              
             else              
   if @i = 7              
      begin              
       select @key7 = index_col(@objname, @indid, @i)              
             end              
     else      
             if @i = 8            
             begin              
            select @key8 = index_col(@objname, @indid, @i)      
             end        
             else              
             if @i = 9         
             begin              
select @key9 = index_col(@objname, @indid, @i)              
      end      
             else              
             if @i = 10     
   begin              
select @key10 = index_col(@objname, @indid, @i)              
           end              
             else              
     if @i = 11              
      begin              
            select @key11 = index_col(@objname, @indid, @i)              
end              
      else              
             if @i = 12              
            begin              
                select @key12 = index_col(@objname, @indid, @i)              
    end         
             else              
  if @i = 13              
             begin              
   select @key13 = index_col(@objname, @indid, @i)              
     end              
        else              
             if @i = 14              
   begin      
                select @key14 = index_col(@objname, @indid, @i)              
end              
else              
        if @i = 15              
           begin              
              select @key15 = index_col(@objname, @indid, @i)              
             end              
             else              
   if @i = 16              
             begin              
         select @key16 = index_col(@objname, @indid, @i)         
             end              
              
             /*              
             ** Increment @i so it will check for the next key.              
             */              
select @i = @i + 1              
            
       end        
            
              
       /*         
       **  When we get here we now have all the keys.              
       */              
keysdone:              
             set nocount off              
         
       /*              
       **  Figure out if it's a clustered or nonclustered index.              
       */              
    if @indid = 1              
         select @clustered = 1         
      
       if @indid >; 1              
         select @clustered = 0              
              
/*              
**  Now we'll check out the status bits for this index              
    */              
              
     /*              
       **  See if the index is unique (0x02).              
       */              
       if exists (select *        
from master.dbo.spt_values v, sysindexes i              
                    where i.status & v.number = v.number              
     and v.type = 'I'              
       and v.number = 2              
          and i.id = @objid              
     and i.indid = @indid)              
      select @unique = 1         
       else              
        select @unique = 0              
              
       /*         
       **  Now we have all the needed info for the index so we'll add              
     **  the goods to the temporary table.      
       */              
   insert into #spindtab              
         select name, @i - 1, @key1, @key2, @key3, @key4,              
  @key5, @key6, @key7, @key8, @key9,              
                   @key10, @key11, @key12, @key13, @key14,              
            @key15, @key16, @unique, @clustered, status, status2              
               from sysindexes              
                        where id = @objid              
                               and indid = @indid         
       /*              
   **  Now move @indid to the next index.            
       */              
       select @lastindid = @indid              
      select @indid = null              
      select @indid = min(indid)   
            from sysindexes              
              where id = @objid              
                and indid >; @lastindid              
                          and indid < 255         
end              
              
/*              
**  Now print out the contents of the temporary index table.            
*/              
select index_name, index_num, index_key1, index_key2,              
      index_key3, index_key4, index_key5, index_key6,              
      index_key7, index_key8, index_key9, index_key10,              
index_key11, index_key12, index_key13, index_key14,            
   index_key15, index_key16, index_unique, index_clustered,               
      index_status, index_status2              
       from #spindtab              
              
drop table #spindtab         
/*   ptrack 325579  reset isolation 0 after we're done with procedure */              
if @isolevel = 0            
begin               
   set transaction isolation level 0              
end              
****************************************************************************************************
create proc sp_pb60primarykey              
@objname varchar(92)              
as              
declare @objid   int           /* the object id of the table */              
declare @keyname varchar(30)   /* name of primary key        */              
declare @indid   int  /* the index id of the index  */              
declare @keycnt  smallint      /* number of columns in pk    */              
              
select  @objid = object_id(@objname)              
if @objid is null              
begin               
return 1            
end      
           
select @keyname = name,               
   @indid   = indid,              
  @keycnt  = keycnt              
from dbo.sysindexes               
  where id = object_id(@objname) and              
        indid >; 0 and           /* make sure it is an index  */         
        (status2 & 2) = 2 and      /* make sure declaritive constraint */              
(status & 204 = 2048    /* make sure it is primary key      */              
              
if @keycnt is null        
begin     
   return 1   
end         
/*  keycnt contains #clustered key columns but it contains #keys + 1  */              
/* for non-clustered indexes. */               
if @indid >; 1              
begin              
   select @keycnt = @keycnt - 1              
end           
if @keycnt = 0              
begin               
  return 1              
end              
      
select @keyname, @keycnt,               
  index_col(@objname, @indid, 1),           
  index_col(@objname, @indid, 2),              
  index_col(@objname, @indid, 3),               
  index_col(@objname, @indid, 4),               
  index_col(@objname, @indid, 5),               
  index_col(@objname, @indid, 6),               
  index_col(@objname, @indid, 7),               
index_col(@objname, @indid, ,      
  index_col(@objname, @indid, 9),            
  index_col(@objname, @indid, 10),               
  index_col(@objname, @indid, 11),               
  index_col(@objname, @indid, 12),               
  index_col(@objname, @indid, 13),               
  index_col(@objname, @indid, 14),               
  index_col(@objname, @indid, 15),               
  index_col(@objname, @indid, 16)                 
  *************************************************
*************************************************
create proc sp_pb60foreignkey              
@objname varchar(92)              
as              
declare @objid    int           /* the object id of the fk table       */              
declare @keyname  varchar(30)   /* name of foreign key                 */   
declare @constid int    /* the constraint id in sysconstraints */              
declare @keycnt   smallint      /* number of columns in pk    */              
declare @stat     int              
declare @isolevel   int          /* ptrack 325579  isolation level */         
           
select  @objid = object_id(@objname)              
if (@objid is null)              
begin               
   return (1)              
end              
select  @stat = sysstat2              
   from  dbo.sysobjects              
   where id = @objid  and           
     (sysstat2 & 2) = 2              
if (@stat is null)            
begin               
   return (1)            
end               
              
/* Now I know this table has one or more foreign keys.  */              
/*  ptrack 325579  override isolation level 0 default */            
select @isolevel = @@isolation               
if @isolevel = 0              
begin               
   set transaction isolation level 1            
end              
              
select  o1.name, r.keycnt, o2.name, user_name(o2.uid),               
       r.fokey1,  r.fokey2,  r.fokey3,  r.fokey4,  r.fokey5,  r.fokey6,              
   r.fokey7,  r.fokey8,  r.fokey9,  r.fokey10, r.fokey11, r.fokey12,              
        r.fokey13, r.fokey14, r.fokey15, r.fokey16            
  from  dbo.sysconstraints c, dbo.sysobjects o1,      
        dbo.sysreferences r,  dbo.sysobjects o2              
  where c.tableid  =  @objid    and         
        c.status   =  64         and              
        c.constrid =  o1.id      and              
        o1.type    = 'RI'       and            
        c.constrid =  r.constrid and              
     r.reftabid = o2.id               
         
if @isolevel = 0              
begin         
   set transaction isolation level 0              
end

论坛徽章:
0
14 [报告]
发表于 2004-09-25 10:44 |只看该作者

pb 要跟sybase 连接时,出现以下问题。。

是把这些建在master里面还是建在在用的数据库里面?(好象应该是在在用的数据库里面吧?)

还问一下:好象那两张临时表不能建呢?报语法错误!

论坛徽章:
0
15 [报告]
发表于 2004-09-27 09:21 |只看该作者

pb 要跟sybase 连接时,出现以下问题。。

对,在新建的数据库里面。
报什么语法错误?

论坛徽章:
0
16 [报告]
发表于 2004-09-28 22:08 |只看该作者

pb 要跟sybase 连接时,出现以下问题。。

这也就是PB盘里的PBSYC。SQL  PBSYCB。SQL执行一下就行了要不用PB连接连接数据库时不成功。

论坛徽章:
0
17 [报告]
发表于 2004-09-30 15:31 |只看该作者

pb 要跟sybase 连接时,出现以下问题。。

对,这几个SQL在光盘的 “pb7.0setup\Server”这个目录中PBSYC*.SQL
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP