Home > database >  PB to read the content of the third database table
PB to read the content of the third database table

Time:10-06

Everybody is good, I think excuse me, I in PB code defines two transaction variable SQLCA2 SQLCA3 (note: the background is SQL2000), then use SQLCA2 connecting to a database, using SQLCA3 connect to the database 2 (note that the default SQCA connected to another database), and then make a list of SQLCA2 content with data window display, I want to show the data window to choose a line, then put in the selected row a deposit into a variable ypbh, then I open SQLCA3 database, I want to use ypbh this variable is associated with one of the tables with SQLCA3, then read out a note ypbh storage with the contents of a table of SQLCA3 is connected)
Here is my code: (note, the database connection is no problem, table KCZL is a table in the database with SQLCA3 open) please help me have a look at, starting from the SQL query the wrong there? Would be all right in front of the SELECT
String ls_ypbh
Int number
Int r
If dw_1. GetRow () & gt;=1 then
R=dw_1. GetRow ()
Sle_2. Text=string (dw_1. Object. The DATA [r, 3])
Sle_3. Text=string (dw_1. Object. The DATA [r, 5])
Ddlb_2. Text=string (dw_1. Object. The DATA [r, 4])
//sle_5. Text=string (dw_1. Object. The DATA [r, 8])
//sle_15. Text=string (dw_1. Object. The data [r, 9])
Ls_ypbh=string (string (dw_1. Object. The DATA [r, 1)))

SELECT SUM (" KCZL ". "kcsl_mz")
Into: number
FROM "KCZL
"GROUP BY "KCZL". "ypbh
"HAVING "KCZL". "ypbh"=: ls_ypbh
The ORDER BY "KCZL". "ypbh" using SQLCA3;
Sle_4. Text=string (number)

End the if
If keydown (keytab! Then
Tab_1. Tabpage_1. Sle_4. Setfocus ()
end if

CodePudding user response:

SELECT SUM (kcsl_mz)
Into: number
The FROM KCZL
Where ypbh=: ls_ypbh
Using SQLCA3;

CodePudding user response:

1/f, the wrong answer, don't come out

CodePudding user response:

SELECT SUM (" KCZL ". "kcsl_mz") into: number
FROM "KCZL
"WHERE "KCZL". "ypbh"=: ls_ypbh
GROUP BY "KCZL". "ypbh
"ORDER BY "KCZL". "ypbh" ASC using SQLCA3;

If not, then you have a breakpoint debugged, see ls_ypbh value didn't get to,

CodePudding user response:

I tested, ls_ypbh value no problem

CodePudding user response:

I thought for a moment, is not to add a loop statement? If and how to judge whether or not to the end of the table?

CodePudding user response:


KCZL there? Assess the
Select count (*) into: (I) the from KCZL
Where ypbh=: ls_ypbh using sqlca3;
Look at how much I was! 0 is not number

Grouping sum? Your group is ls_ypbh, it group, what's the use of the sorting!

If i> 0 then
The select sun (kcsl_mz) into: number
The from KCZL
Where the using sqlca3;
The else

Return
End the if
It's ok






CodePudding user response:

The grammar of the 1/f, no problem, the estimate is the issue of data.
  • Related