Create procedure SUNGZXS @ SDATE datetime, @ EDATE datetime, @ TSDATE datetime, @ TEDATE datetime
As
The begin
If (select object_id (" # A ") is not null drop table # A
If (select object_id (" # B ")) is not null drop table # B
TRUNCATE TABLE SHLSBB
Select DEPTID, sum (XSJE XSJE), sum (XSBS) XSBS into # A from GZXS_HIS
Where JZRQ>=@ SDATE and JZRQ<=@ EDATE and DEPTID like '10060602%' group by DEPTID
Select DEPTID, sum (XSJE TQXS), sum (XSBS) TQBS into # B from GZXS_HIS
Where JZRQ>=@ TSDATE and JZRQ<=@ TEDATE and DEPTID like '10060602%' group by DEPTID
INSERT INTO SHLSBB (DEPTID, XSJE XSBS, TQXS, TQBS)
Select * FROM
(SELECT # a. d. EPTID XSJE, XSBS, TQXS, TQBS FROM # # A LEFT JOIN # B ON a. d. EPTID=# B.D EPTID
Union all
The SELECT # a. d. EPTID, XSJE XSBS, TQXS, TQBS FROM # # # JOIN A RIGHT B ON a. d. EPTID=# B.D EPTID) # A
End
PB is called as follows:
DECLARE P_1 PROCEDURE FOR SUNGZXS @ SDATE=: sd, @ EDATE=: Ed, @ TSDATE=: SDT, @ TEDATE=: edt. @ DEPTID=: gbid;
The execute P_1;
The FETCH P_1 INTO: sd, : Ed, SDT, : edt: gbid;
Commit the using the sqlca;
The close P_1;
The stored procedure in SQL running normally, after performing in PB no results, please tell, thank you
CodePudding user response:
You can refer to the following:https://www.cnblogs.com/powerbuilder/archive/2011/11/18/2254322.html
CodePudding user response:
What do you want the resultsCodePudding user response:
Your way through the following calls to see13. Call SQL Server storage process problems (through an ODBC connection is essentially database call a stored procedure and obtain the return or the output value)
1, create a new standard of the class, and the select standard class type, select the transaction, then opens a statement function window
2, in the above window option at the bottom of the Declare the instance variables page, in the variable type drop-down box to choose the Local External Functions provides
3, right-click in the blanks about aste - & gt; SQL - & gt; Remote stored procedure, back to the choice of the stored procedure window, select the function can generate
Such as: CREATE PROCEDURE sp_test (@ pinput varchar (10))
AS
The return of 1000
GO
When choosing sp_test generate the following function declaration
The function long sp_test (string pinput) RPCFUNC ALIAS FOR "dbo. Sp_test
"4, save your object is: uo_tran
5, double-click to open the application, choose additional properties - & gt; Variable types, modified with respect to the transaction in the SQLCA uo_tran can
6, and then in the program you can you like using the function call stored procedures, such as:
The integer li_return
Li_return=Sqlca. Sp_test (' 111 ')
Can ensure that both the ODBC and direct,
Reference:
https://bbs.csdn.net/topics/360004982
CodePudding user response:
For dynamic execution of SQL, give you a piece of code reference:Ls_sql="SET ANSI_NULLS ON; The SET ANSI_WarningS ON; The exec up_xfdj '" + ls_djids + "', '" + string (ll_dw) + "' "
The execute immediate: ls_sql using sqlca;
- note: up_xfdj is the name of the stored procedure, two parameters
CodePudding user response:
Make simple calls to try first, detailed test,