OI - SQL (OpenInsight Specific)
At 10 MAY 1999 04:54:07PM ARACELY CAZARES wrote:
I need to pass information from a table in OI to SQL. I already use QryMethod() to executes "INSERT" and "UPDATE" and it works, but I also need to know if a code exist in the table in SQL before to execute the INSERT. I want to execute "SELECT * FROM TABLE_SQL WHERE CODE=99999'" if the record exist i want to know it. I tried to use QryGetProperty(), but I don't know how it works. Could yot please help me!!
Aracely Cazares
At 10 MAY 1999 09:48PM Bob Carten, WinWin Solutions, Inc wrote:
Aracely,
Try something like this…
/* Check to see if the record already exists on SQL Server */
Target_Keyname =MyId"
TargetTable=MyTable"
RowExists ='
script =SELECT 1 "
Script := " FROM ": TargetTable
Script := " WHERE ": Target_Keyname : "= : "'" : key : "'" : ";"
flag=QryMethod( hQry, QRY_EXECUTE$, Script, NULL$, NULL$, NULL$, NULL$
)
Result=QryMethod( hQry, QRY_GETROW$)
RowExists=( Result=1 )
flag=QryMethod( hQry, QRY_CANCEL$ )
Hope this helps
Bob[email protected]
At 12 MAY 1999 04:21AM Tony Marler @ Prosolve wrote:
We tend to use stored procedures for all write to SQL Server (or any client/server backend). In this way you can just pass a stored procedure name and arguments containing the columns to be written including key. The stored procedure runs something like
if exists (select count(*) from table where key=@argkey)
beginupdate statement ....endelse
begininsert statement ....endAdvantages are speed of execution, ease of use and re-useablility.
Hope this gives you some ideas, Tony.