Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community

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)

begin
   update statement ....
end

else

begin
  insert statement ....
end

Advantages are speed of execution, ease of use and re-useablility.

Hope this gives you some ideas, Tony.

View this thread on the forum...

  • third_party_content/community/commentary/forums_nonworks/8276e2842b93325b8525676d0072d1a5.txt
  • Last modified: 2023/12/28 07:40
  • by 127.0.0.1