PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Error while update mssql Database via ODBC  (Read 1549 times)

thomas@pruco.at

  • Member
  • **
  • Posts: 15
    • View Profile
Error while update mssql Database via ODBC
« on: July 06, 2022, 11:12:54 AM »
Hello fellow colleagues!

I have the following problem. I'm testing around with SQL and have the following code:

0100 ! ^100
0110 LET DATABASE$="[ODB]lansweeper;"
0120 LET OPT$="USER=lansweeperuser;PSWD=***********"
0130 LET DB1=HFN
0140 OPEN (DB1,OPT=OPT$)DATABASE$
0150 GOSUB READ_IT
1000 READ_IT:! ^1000
1010 LET ASSETID=34393
1015 LET SEL_STRG$="select assetname from tblassets where ASSETID="+STR(ASSETID)
1016 READ (DB1,KEY=SEL_STRG$)
1017 LET SEL_STRG$="update tblassetcustom set custom1='400_neu' where ASSETID="+STR(ASSETID)
1020 ! READ RECORD (DB1,KEY=SEL_STRG$)SATZ$
1025 READ (DB1,KEY=SEL_STRG$)
1030 READ (DB1)A$,B$,C$
9900 ENDE:! 9900
9910 ESCAPE

Unfortunately I get an error message during the command to update.

->run
1025 READ (DB1,KEY=SEL_STRG$)
Error #15: Operating system command failed
Last IO to [ODB]lansweeper;, channel 63
Current program is C:\PVX\SQLTEST1, line 1025
HY010: [Microsoft][ODBC Driver Manager] Fehler in der Funktionsreihenfolge
1>


However, the value was still correctly written to the SQL database...


What am I doing wrong?

Maybe you can help me?

Many thanks!
Thomas

Devon Austen

  • Administrator
  • Diamond Member
  • *****
  • Posts: 386
  • Don’t Panic
    • View Profile
    • PVX Plus Technologies
Re: Error while update mssql Database via ODBC
« Reply #1 on: July 06, 2022, 12:37:06 PM »
From the doc: https://manual.pvxplus.com/?PxPlus%20User%20Guide/Data%20Integration/Introduction%20to%20SQL/Using%20SQL%20Directly%20Within%20PxPlus.htm

I think you need to add a ! to the beginning of your SQL statements i.e. KEY="!"+SEL_STRG$
Principal Software Engineer for PVX Plus Technologies LTD.

thomas@pruco.at

  • Member
  • **
  • Posts: 15
    • View Profile
Re: Error while update mssql Database via ODBC
« Reply #2 on: July 07, 2022, 12:51:34 AM »
Hi Devon!

Many thanks, that's it...

Bet Regards, Thomas