有个道程序在PB9通过,但是11.5没通过

ilearn 2012-06-17 08:59:19
这道程序是让PB执行sqlupdate.dat内的SQL语句的,以-----*****作为分隔符,但是发现PB11.5里读取的是乱码,PB9读取正常,为什么?

下面是在bytes_read = FileRead(li_filenum, b) 那里读出SQL语句的

/加储存过程
string ls_sp_change_prod_mb,ls_sql_sp_change_prod_mb
//select name into :ls_sp_change_prod_mb from sysobjects where name='sp_change_prod_mb';
//if ls_sp_change_prod_mb='' then
//\\

ULong ls_fh
String ls_path_name
Integer li_filenum, loops, i
Long flen, bytes_read, new_pos
Blob b, tot_b

SetPointer(hourglass!)
ls_path_name = 'sqlupdate.dat'
flen = FileLength(ls_path_name)
li_filenum = FileOpen(ls_path_name, streammode!, Read!, lockread!)

If li_filenum = 1 Then


// flen=33000

If flen > 32765 Then

If Mod(flen, 32765) = 0 Then

loops = flen/32765

Else

loops = (flen/32765) + 1

End If

Else

loops = 1

End If

new_pos = 1

For i = 1 To loops

bytes_read = FileRead(li_filenum, b)

tot_b = tot_b + b

Next


FileClose(li_filenum)


String ls_sql
ls_sql = String(tot_b)


FileRead(ls_fh,ls_sql)
FileClose(ls_fh)

String l_all
String l_p1,l_p2,l_all2
Long s_p1,s_p2,row
String l_n,l_d,l_t
l_all = ls_sql
l_p1 = '-----*****'
l_p2 = '-----#####'

lab1:
s_p1 = Pos(l_all,l_p1)
s_p2 = Pos(l_all,l_p2)


If s_p1 >= 0 And s_p2 > 0 Then

l_n = Mid(l_all,s_p1, s_p2 - s_p1 + 10 )

l_all = mid(l_all, s_p2 + 10 , Len(l_all) - (s_p2 + 10) + 1 )

ls_sql_sp_change_prod_mb=l_n
execute immediate:ls_sql_sp_change_prod_mb using sqlca;
commit using sqlca;

Goto lab1


End If

//\\

else
messagebox('提醒','本文件夹下找不到sqlupdate.dat文件,请复制此文件到软件所在文件夹下!')
return
end if
...全文
124 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
A啦Dbit 2012-06-19
  • 打赏
  • 举报
回复
解决了就好!!!
ilearn 2012-06-19
  • 打赏
  • 举报
回复
7楼:TEXTMODE!不行
你们都错了!!后来我用行模式就正常了,超晕!!!
A啦Dbit 2012-06-18
  • 打赏
  • 举报
回复
fileopen时有个字符集参数,加一下就好了
A啦Dbit 2012-06-18
  • 打赏
  • 举报
回复
TextMode!试试
乐不 2012-06-18
  • 打赏
  • 举报
回复
mid(),left(),right(),len()等字符串函数都要调整的,类似mid变成midW(),你自己找下pb11的帮助文档,
ilearn 2012-06-18
  • 打赏
  • 举报
回复
按你的说法改成 li_filenum = FileOpen(ls_path_name, streammode!, Read!, lockread!,Append!, EncodingUTF8! )
但是 li_filenum的数返回值是 负数,就是错了如果字符集改为EncodingANSI! 又乱码
ilearn 2012-06-17
  • 打赏
  • 举报
回复
sqlupdate.dat 的内容

-----*****
create procedure deletedupdicateclient
as
if object_id('tempdb..#tempclient') is not null drop table #tempclient

CREATE TABLE #tempclient (
[cli_no] [char] (8) NULL ,
[cli_name] [char] (50) NOT NULL ,
[cli_ass] [char] (20) NULL ,
[cli_add] [char] (50) NULL ,
[cli_tel] [char] (25) NULL ,
[cli_bank] [char] (40) NULL ,
[cli_count] [char] (20) NULL ,
[cli_inv] [char] (16) NULL ,
[cli_zip] [char] (6) NULL ,
[cli_per] [numeric](6, 2) NULL ,
[cli_memo] [char] (50) NULL ,
[client_type_no] [char] (2) NOT NULL ,
[dis_no] [char] (3) NULL ,
[rebate_enable] [bit] NOT NULL ,
[sex] [char] (2) NULL ,
[xl] [char] (10) NULL ,
[jf] [int] NULL ,
[nl] [int] NULL ,
[sum_jf] [int] NULL ,
[pr_jf] [int] NULL
) ON [PRIMARY]

declare @myclino char(8)
declare @sql_11 varchar(2000)

declare cli_cur cursor for select distinct cli_no from client
open cli_cur
fetch next from cli_cur into @myclino
while (@@fetch_status=0)
begin
set @sql_11='insert #tempclient select top 1 * from client where cli_no=''' + @myclino +''''
execute (@sql_11)
fetch next from cli_cur into @myclino
end
close cli_cur
deallocate cli_cur
delete from client
insert client select * from #tempclient

-----#####
-----*****

if exists (select cli_no from client group by cli_no having count(cli_no) > 1)
exec deletedupdicateclient

-----#####
-----*****
if not exists (select * from sysobjects where id = object_id(N'[dbo].[upload_log]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
CREATE TABLE [dbo].[upload_log] (
[id] [numeric](18, 0) IDENTITY (1, 1) NOT NULL primary key,
[upload_time] [datetime] NULL ,
[memo] [char] (50) NULL ,
[auto_flage] [bit] NULL ,
[succ_upload] [bit] NULL
) ON [PRIMARY]
-----#####
-----*****

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[V_inv3]') and OBJECTPROPERTY(id,N'IsView') = 1)
drop view V_inv3

-----#####
-----*****

CREATE VIEW dbo.v_inv3
AS
SELECT a.list_no, a.prod_no, a.batch_no, a.inv_num, a.sell_price, b.cli_no AS md_no,
e.cli_no, e.cli_name, e.cli_add, e.cli_tel,e.inv_Date
FROM dbo.company b CROSS JOIN
dbo.inv_sub a LEFT OUTER JOIN
(SELECT inv_main.list_no AS list_no, inv_main.cli_no, client.cli_name,
client.cli_add, client.cli_tel, inv_main.inv_date
FROM inv_main LEFT JOIN
client ON inv_main.cli_no = client.cli_no) e ON a.list_no = e.list_no
-----#####
xufxuf 2012-06-17
  • 打赏
  • 举报
回复
PB9到PB10以上有很大变化的,PB内部字符集从ANSI变成了UNICODE.很多涉及字符串的代码都需要重写.
xufxuf 2012-06-17
  • 打赏
  • 举报
回复
PB 11 下应该有filereadex()函数了吧?用那个就不用关心读取一次32K字节上限的问题了.

1,072

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧