R
R_Baggio
Unregistered / Unconfirmed
GUEST, unregistred user!
我想把下面的程序写成存储过程,应该怎样写:
function GetPY(InStr :String):String;//功能获取数据库中的汉字信息,
var //若不是汉字则输出是原形
Str,Str1 :String;
i,Count :Smallint;
begin
Str := InStr;
Count := 1;
for i := 1 to Length(Str) do
begin
if Count > Length(Str) then Break;
if Ord(Str[Count]) > 128 then
begin
Str1 := Copy(InStr,Count,2);
Inc(Count,2);
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('SELECT PY FROM PY WHERE HZ = '''+STR1+'''');
Query1.Open;
result := result +Query1.FieldByName('PY').AsString;
end else
begin
Str1 := Copy(InStr,Count,1);
Inc(Count);
result := result+ Str1;
end;
end;
end;
function GetPY(InStr :String):String;//功能获取数据库中的汉字信息,
var //若不是汉字则输出是原形
Str,Str1 :String;
i,Count :Smallint;
begin
Str := InStr;
Count := 1;
for i := 1 to Length(Str) do
begin
if Count > Length(Str) then Break;
if Ord(Str[Count]) > 128 then
begin
Str1 := Copy(InStr,Count,2);
Inc(Count,2);
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('SELECT PY FROM PY WHERE HZ = '''+STR1+'''');
Query1.Open;
result := result +Query1.FieldByName('PY').AsString;
end else
begin
Str1 := Copy(InStr,Count,1);
Inc(Count);
result := result+ Str1;
end;
end;
end;