标题: pb 要跟sybase 连接时,出现以下问题。。 [打印本页] 作者: winjjd 时间: 2004-09-16 16:29 标题: pb 要跟sybase 连接时,出现以下问题。。 client library login: 里面我是这样配置的
server Name: spsvr
Logon ID : sa
password: 空
Application Name : 空
Host Name: 空
连接好,打开数据库表时出现问题,,不知道是什么意思?
stored procedure 'sp_pb60table' not found. specify owner.objectname or use sp_help to check whether the object exists(sp_help may produce lots of output).
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为例子作者: 献给爱丽丝 时间: 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作者: nettang 时间: 2004-09-25 10:44 标题: pb 要跟sybase 连接时,出现以下问题。。 是把这些建在master里面还是建在在用的数据库里面?(好象应该是在在用的数据库里面吧?)