Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

HELP

2 posts in General Discussion (Chinese) Last posting was on 2010-02-22 07:43:24.0Z
568509225 Posted on 2010-02-05 04:41:45.0Z
From: "568509225" <568509225@qq.com>
Newsgroups: sybase.public.chinese.powerbuilder.general
Subject: HELP
Lines: 126
Organization: qq
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3598
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b6ba189@forums-1-dub>
Date: 4 Feb 2010 20:41:45 -0800
X-Trace: forums-1-dub 1265344905 10.22.241.152 (4 Feb 2010 20:41:45 -0800)
X-Original-Trace: 4 Feb 2010 20:41:45 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.chinese.powerbuilder.general:503
Article PK: 104527

ÈçÏÂÊÇÎҵĴ洢¹ý³Ì£¬Ð´ÔÚ SQL ÖУ¬Ö´ÐоùÎÞÎÊÌ⣬ÔÚ²éѯÆ÷ÖУ¬ËùÓеĿÉÄÜ·µ»ØÖµ¶¼¿ÉÒԵõ½¡£¼û´úÂ룺
CREATE PROCEDURE Up_AuditTransRequiredTask
@aRequireTaskNo Varchar(50),
@aOperator Varchar(50)
AS
Declare @ld_SysDateTime Datetime
Declare @Error1 Int
Declare @RowCount1 Int
Declare @Error2 Int
Declare @RowCount2 Int
Declare @Error3 Int
Declare @RowCount3 Int

Declare @ll_Result Int

Declare @IsEdiRequired Int
Declare @IsBulkRequired Int

SET @ld_SysDateTime = GetDate()

/*IF (@aRequireTaskNo IS NULL) OR Len(LTrim(RTrim(@aRequireTaskNo))) < 1
BEGIN
SET @ll_Result = -1
RETURN @ll_Result
END*/
SELECT @ll_Result = Count(*) FROM TransRequiredTaskItems WHERE RequireTaskNo
= @aRequireTaskNo
IF @ll_Result < 1
BEGIN
SET @ll_Result = -2
RETURN @ll_Result
END
SELECT @ll_Result = AuditStates FROM TransRequiredTask WHERE RequireTaskNo =
@aRequireTaskNo
IF @ll_Result = 1
BEGIN
SET @ll_Result = -3
RETURN @ll_Result
END

SELECT @IsEdiRequired = Sum(IsEdiRequired) FROM TransOrderItems WHERE
GOrderNo IN (SELECT GOrderNo FROM TransRequiredTaskItems WHERE RequireTaskNo
= @aRequireTaskNo)
SELECT @IsBulkRequired = Sum(IsBulkRequired) FROM TransOrderItems WHERE
GOrderNo IN (SELECT GOrderNo FROM TransRequiredTaskItems WHERE RequireTaskNo
= @aRequireTaskNo)
IF @IsEdiRequired >= 1 SET @IsEdiRequired = 1
IF @IsBulkRequired >= 1 SET @IsBulkRequired = 1

BEGIN TRAN

INSERT INTO
TransControlCenter(TransControlNo,RequireTaskNo,IsEdiRequired,IsBulkRequired,Weight,VehicleType,
HouseBill,CYCloseDTime,SealNo,ShippingOrder,ContainerNo,Containers,
AuditStates,Inputer,InputerDateTime,TAuditStates)
SELECT
RequireTaskNo,RequireTaskNo,@IsEdiRequired,@IsBulkRequired,Weight,VehicleType,
(SELECT TOP 1 HouseBill FROM TransOrder WHERE GOrderNo IN (SELECT GOrderNo
FROM TransRequiredTaskItems WHERE RequireTaskNo = @aRequireTaskNo)),
(SELECT TOP 1 CYCloseDTime FROM TransOrder WHERE GOrderNo IN (SELECT
GOrderNo FROM TransRequiredTaskItems WHERE RequireTaskNo =
@aRequireTaskNo)),
(SELECT TOP 1 SealNo FROM TransOrder WHERE GOrderNo IN (SELECT GOrderNo
FROM TransRequiredTaskItems WHERE RequireTaskNo = @aRequireTaskNo)),
(SELECT TOP 1 ShippingOrder FROM TransOrder WHERE GOrderNo IN (SELECT
GOrderNo FROM TransRequiredTaskItems WHERE RequireTaskNo =
@aRequireTaskNo)),
(SELECT TOP 1 ContainerNo FROM TransOrder WHERE GOrderNo IN (SELECT
GOrderNo FROM TransRequiredTaskItems WHERE RequireTaskNo =
@aRequireTaskNo)),
(SELECT TOP 1 Containers FROM TransOrder WHERE GOrderNo IN (SELECT GOrderNo
FROM TransRequiredTaskItems WHERE RequireTaskNo = @aRequireTaskNo)),
0,@aOperator,Getdate(),0
FROM TransRequiredTask
WHERE RequireTaskNo = @aRequireTaskNo

SELECT @Error1 = @@ERROR,@RowCount1 = @@RowCount

UPDATE TransOrderItems SET IsCompleted = 1
FROM TransOrderItems TOI,TransRequiredTaskItems TRTI
WHERE TRTI.TransNo = TOI.TransNo AND TRTI.GOrderNo = TOI.GOrderNo AND
TRTI.RequireTaskNo = @aRequireTaskNo

SELECT @Error2 = @@ERROR,@RowCount2 = @@RowCount

UPDATE TransRequiredTask SET AuditStates = 1,Auditor =
@aOperator,AuditDateTime = @ld_SysDateTime WHERE RequireTaskNo =
@aRequireTaskNo

SELECT @Error3 = @@ERROR,@RowCount3 = @@RowCount

IF @Error1 = 0 AND @Error2 = 0 AND @Error3 = 0 AND @RowCount1 = 1 AND
@RowCount2 >= 1 AND @RowCount3 = 1
BEGIN
COMMIT TRAN
SET @ll_Result = 1
RETURN @ll_Result
END
ELSE
BEGIN
ROLLBACK TRAN
SET @ll_Result = -1
RETURN @ll_Result
END


ÈçÏ´úÂëÊÇÎÒµÄ×é¼þÖдúÂ룺

DECLARE Up_AuditTrans PROCEDURE FOR Up_AuditTransRequiredTask
:as_formno,:as_operator;
Execute Up_AuditTrans;
DO
Fetch Up_AuditTrans Into :ll_Result;
el.log("Fetch result: " + String(ll_Result))

LOOP WHILE SQLCA.SqlCode = 0

Close Up_AuditTrans;


µÃµ½µÄ ll_Result ÓÀÔ¶¶¼ÊÇ 0 £¬·µ»ØÖµÖж¼Ã»ÓÐ 0


Çë´ó¼Ò°ïæ¡£Ôõô²ÅÄܵõ½¹ý³ÌÖÐÕýÈ·µÄ·µ»ØÖµ £¿


hgong Posted on 2010-02-22 07:43:24.0Z
Sender: dff.4b82357a.1804289383@sybase.com
From: hgong
Newsgroups: sybase.public.chinese.powerbuilder.general
Subject: Re: HELP
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4b82359c.e01.1681692777@sybase.com>
References: <4b6ba189@forums-1-dub>
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 21 Feb 2010 23:43:24 -0800
X-Trace: forums-1-dub 1266824604 10.22.241.41 (21 Feb 2010 23:43:24 -0800)
X-Original-Trace: 21 Feb 2010 23:43:24 -0800, 10.22.241.41
Lines: 150
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.chinese.powerbuilder.general:505
Article PK: 104528

>
ÈçÏÂÊÇÎҵĴ洢¹ý³Ì£¬Ð´ÔÚ
SQL

>
ÖУ¬Ö´ÐоùÎÞÎÊÌ⣬ÔÚ²éѯÆ÷ÖУ¬ËùÓеĿÉÄÜ·µ»ØÖµ¶¼¿ÉÒԵõ½¡£
> ¼û´úÂ룺 CREATE PROCEDURE
Up_AuditTransRequiredTask
> @aRequireTaskNo Varchar(50),
> @aOperator Varchar(50)
> AS
> Declare @ld_SysDateTime Datetime
> Declare @Error1 Int
> Declare @RowCount1 Int
> Declare @Error2 Int
> Declare @RowCount2 Int
> Declare @Error3 Int
> Declare @RowCount3 Int
>
> Declare @ll_Result Int
>
> Declare @IsEdiRequired Int
> Declare @IsBulkRequired Int
>
> SET @ld_SysDateTime = GetDate()
>
> /*IF (@aRequireTaskNo IS NULL) OR
> Len(LTrim(RTrim(@aRequireTaskNo))) < 1
> BEGIN
> SET @ll_Result = -1
> RETURN @ll_Result
> END*/
> SELECT @ll_Result = Count(*) FROM TransRequiredTaskItems
> WHERE RequireTaskNo = @aRequireTaskNo
> IF @ll_Result < 1
> BEGIN
> SET @ll_Result = -2
> RETURN @ll_Result
> END
> SELECT @ll_Result = AuditStates FROM TransRequiredTask
> WHERE RequireTaskNo = @aRequireTaskNo
> IF @ll_Result = 1
> BEGIN
> SET @ll_Result = -3
> RETURN @ll_Result
> END
>
> SELECT @IsEdiRequired = Sum(IsEdiRequired) FROM
> TransOrderItems WHERE GOrderNo IN (SELECT GOrderNo FROM
> TransRequiredTaskItems WHERE RequireTaskNo =
> @aRequireTaskNo) SELECT @IsBulkRequired =
> Sum(IsBulkRequired) FROM TransOrderItems WHERE GOrderNo
> IN (SELECT GOrderNo FROM TransRequiredTaskItems WHERE
> RequireTaskNo = @aRequireTaskNo)
> IF @IsEdiRequired >= 1 SET @IsEdiRequired = 1
> IF @IsBulkRequired >= 1 SET @IsBulkRequired = 1
>
> BEGIN TRAN
>
> INSERT INTO
> TransControlCenter(TransControlNo,RequireTaskNo
> ,IsEdiRequired,IsBulkRequired,Weight,VehicleType,
> HouseBill,CYCloseDTime,SealNo,ShippingOrder
> ,ContainerNo,Containers,
> AuditStates,Inputer,InputerDateTime,TAuditStates)
> SELECT
> RequireTaskNo,RequireTaskNo,@IsEdiRequired,@IsBulkRequired
> ,Weight,VehicleType,
> (SELECT TOP 1 HouseBill FROM TransOrder WHERE GOrderNo IN
> (SELECT GOrderNo FROM TransRequiredTaskItems WHERE
> RequireTaskNo = @aRequireTaskNo)),
> (SELECT TOP 1 CYCloseDTime FROM TransOrder WHERE GOrderNo
> IN (SELECT GOrderNo FROM TransRequiredTaskItems WHERE
> RequireTaskNo = @aRequireTaskNo)),
> (SELECT TOP 1 SealNo FROM TransOrder WHERE GOrderNo IN
> (SELECT GOrderNo FROM TransRequiredTaskItems WHERE
> RequireTaskNo = @aRequireTaskNo)),
> (SELECT TOP 1 ShippingOrder FROM TransOrder WHERE
> GOrderNo IN (SELECT GOrderNo FROM TransRequiredTaskItems
> WHERE RequireTaskNo = @aRequireTaskNo)),
> (SELECT TOP 1 ContainerNo FROM TransOrder WHERE GOrderNo
> IN (SELECT GOrderNo FROM TransRequiredTaskItems WHERE
> RequireTaskNo = @aRequireTaskNo)),
> (SELECT TOP 1 Containers FROM TransOrder WHERE GOrderNo
> IN (SELECT GOrderNo FROM TransRequiredTaskItems WHERE
> RequireTaskNo = @aRequireTaskNo)),
> 0,@aOperator,Getdate(),0
> FROM TransRequiredTask
> WHERE RequireTaskNo = @aRequireTaskNo
>
> SELECT @Error1 = @@ERROR,@RowCount1 = @@RowCount
>
> UPDATE TransOrderItems SET IsCompleted = 1
> FROM TransOrderItems TOI,TransRequiredTaskItems TRTI
> WHERE TRTI.TransNo = TOI.TransNo AND TRTI.GOrderNo =
> TOI.GOrderNo AND TRTI.RequireTaskNo = @aRequireTaskNo
>
> SELECT @Error2 = @@ERROR,@RowCount2 = @@RowCount
>
> UPDATE TransRequiredTask SET AuditStates = 1,Auditor =
> @aOperator,AuditDateTime = @ld_SysDateTime WHERE
> RequireTaskNo = @aRequireTaskNo
>
> SELECT @Error3 = @@ERROR,@RowCount3 = @@RowCount
>
> IF @Error1 = 0 AND @Error2 = 0 AND @Error3 = 0 AND
> @RowCount1 = 1 AND @RowCount2 >= 1 AND @RowCount3 =
1
> BEGIN
> COMMIT TRAN
> SET @ll_Result = 1
> RETURN @ll_Result
> END
> ELSE
> BEGIN
> ROLLBACK TRAN
> SET @ll_Result = -1
> RETURN @ll_Result
> END
>
>
>
ÈçÏ´úÂëÊÇÎÒµÄ×é¼þÖдúÂ룺
>
> DECLARE Up_AuditTrans PROCEDURE FOR
> Up_AuditTransRequiredTask :as_formno,:as_operator;
> Execute Up_AuditTrans;
> DO
> Fetch Up_AuditTrans Into :ll_Result;
> el.log("Fetch result: " + String(ll_Result))
>
> LOOP WHILE SQLCA.SqlCode = 0
>
> Close Up_AuditTrans;
>
>
> µÃµ½µÄ ll_Result ÓÀÔ¶¶¼ÊÇ 0
£¬·µ»ØÖµÖж¼Ã»ÓÐ 0
>
>
>

Çë´ó¼Ò°ïæ¡£Ôõô²ÅÄܵõ½¹ý³ÌÖÐÕýÈ·µÄ·µ»ØÖµ
£¿
>
>

You can try using Transaction objects to call stored
procedures.
and you can get detail steps from powerbuilder help (search
"Using Transaction objects to call stored procedures" in
<<Compiled HTML Help File>> ).