SQL UPDATE Sample for RPG2SQL Integrator
From Support
5722WDS V5R1M0 010525 SEU SOURCE LISTING 02/06/04 15:05:51 PAGE 1
SOURCE FILE . . . . . . . RJSRPGSQL/SOURCE
MEMBER . . . . . . . . . SQTEST29R
SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
100 ********************************************************************* 10/09/02
200 * Program Name: SQTEST29R 02/06/04
300 * 03/02/03
400 * Purpose: 03/02/03
500 * This sample program simple opens the NameAddress table 03/02/03
600 * in the C:\Program Files\RPGSQLSV\IRPGSQL.MDB MS Access database, 03/02/03
700 * and update a record in the NameAddress table. 02/06/04
800 * 03/02/03
900 * Processing Steps: 03/02/03
1000 * 1) Connects to a RPG2SQL server using specified IP address. 03/03/03
1100 * 2) Opens a MS Access Database via ADO. 03/02/03
1200 * 2) Update Dollars in record based on ID key. 02/06/04
1300 * 5) Closes ADO connection. 10/09/02
1400 * 6) Closes RPG2SQL server connection. 03/03/03
1500 * 10/09/02
1600 * Note: This sample does no error checking. In your own code you 10/09/02
1700 * will need to check the return codes and last error by 10/09/02
1800 * using the last error return info returned by the 03/02/03
1900 * SQL_LastErrNum, SQL_LastErrMsg or SQL_LastFullErr message. 03/02/03
2000 * 03/02/03
2100 * DATE: 08/10/2002 03/02/03
2200 * AUTHOR: RICHARD J. SCHOEN. 03/02/03
2300 * MOD LEVEL: 0000 03/02/03
2400 * MOD DATE: XX/XX/XX 03/02/03
2500 * REASON: 03/02/03
2600 * 03/02/03
2700 ********************************************************************* 10/09/02
2800 *----------------------------------------------------------------------------- 03/02/03
2900 * RPG2SQL Integrator API Includes 03/02/03
3000 *----------------------------------------------------------------------------- 03/02/03
3100 /COPY SOURCE,RPGSQLH 10/09/02
3200 D quot S 1 INZ('''') 09/08/02
3300 10/09/02
3400 *----------------------------------------------------------------------------- 10/04/00
3500 * Main Program Processing 10/04/00
3600 *----------------------------------------------------------------------------- 10/04/00
3700 C *ENTRY PLIST 10/09/02
3800 C PARM IPADDR 100 10/09/02
3900 12/23/00
4000 *----------------------------------------------------------------------------- 10/03/00
4100 * ** Connect to RPG/SQL Server 03/02/03
4200 *----------------------------------------------------------------------------- 10/09/02
4300 C Eval SQL_Socket = SQL_Connect(%TRIM(IPADDR)) 10/09/02
4400 08/30/02
4500 C* ** Exit with Error Return - TCP Server Connect 08/30/02
4600 C If SQL_Socket = -999 08/30/02
4700 C Eval Rtn = -1 08/30/02
4800 C Eval *INLR = *On 08/30/02
4900 C Return 08/30/02
5000 C Endif 08/30/02
5100 08/30/02
5200 *----------------------------------------------------------------------------- 10/09/02
5300 * ** Open ADO SQL Database Connection 03/02/03
�
5722WDS V5R1M0 010525 SEU SOURCE LISTING 02/06/04 15:05:51 PAGE 2
SOURCE FILE . . . . . . . RJSRPGSQL/SOURCE
MEMBER . . . . . . . . . SQTEST29R
SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
5400 * ** for MS Access Database IRPGSQL.MDB 03/02/03
5500 *----------------------------------------------------------------------------- 10/09/02
5600 C Eval Rtn = SQL_DBOpenConn(SQL_Socket: 08/30/02
5700 C 'Driver={Microsoft Access Driver ' + 09/08/02
5800 C '(*.mdb)}; ' + 09/08/02
5900 C 'Dbq=c:\program files\' + 10/09/02
6000 C 'rpgsqlsv\irpgsql.mdb; ' + 10/09/02
6100 C 'Uid=admin;' + 09/08/02
6200 C 'Pwd=;') 09/08/02
6300 09/08/02
6400 *----------------------------------------------------------------------------- 10/09/02
6500 * ** Run Update SQL Query Update Record 02/06/04
6600 *----------------------------------------------------------------------------- 10/09/02
6700 C Eval Rtn = SQL_RunSQLExec(SQL_Socket: 09/08/02
6800 C 'UPDATE NameAddress ' + 02/06/04
6900 C 'SET Dollars = 999.99 ' + 02/06/04
7000 C 'WHERE ID = 3083') 02/06/04
7100 09/08/02
7200 *----------------------------------------------------------------------------- 10/09/02
7300 * ** Close ADO Database Connection. We're done. 03/02/03
7400 *----------------------------------------------------------------------------- 10/09/02
7500 C callp SQL_DBCloseConn(SQL_Socket) 08/30/02
7600 08/30/02
7700 *----------------------------------------------------------------------------- 10/09/02
7800 C* ** Disconnect from RPG2SQL server 03/02/03
7900 *----------------------------------------------------------------------------- 10/09/02
8000 C callp SQL_Disconnect(SQL_Socket) 08/30/02
8100 08/30/02
8200 C SETON LR 08/30/02
* * * * E N D O F S O U R C E * * * *
