Forum > Databases

Firebird 'if' problem

(1/4) > >>

ronhud:
'IF NOT EXISTS (SELECT EQSYMBOL FROM EQUITLST WHERE EQSYMBOL = :eqsymbol) INSERT INTO EQUITLST (eqsymbol,eqname) VALUES  (:eqsymbol,:eqname)'

This statement  is failing on IF     - error 104

Using Lazarus with Firebird and sqldb
Should I be able to use INSERT and IF in the same statement?

ronhud:
The statement actually reads as follows:-

'IF NOT EXISTS (SELECT EQSYMBOL FROM EQUITLST WHERE EQSYMBOL = :eqsymbol) THEN INSERT INTO EQUITLST (eqsymbol,eqname) VALUES  (:eqsymbol,:eqname)'

mistyped earlier.

Groffy:
if statement is only possible in PSQL language. You can use the update or insert syntax :

update or insert into EQUITLST(eqsymbol,eqname) VALUES  (:eqsymbol,:eqname) matching(EQSYMBOL)

and see if it works for your needs


Best regards

Zoran:


--- Code: SQL  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---INSERT INTO equitlst (eqsymbol, eqname)VALUES (:eqsymbol,:eqname)WHERE NOT EXISTS (SELECT 1 FROM equitlst WHERE eqsymbol = :eqsymbol) 

ronhud:
Zoran tried that and failed with error 104 but said line 1 col 54 WHERE.   However col 54 in the statement is the m in eqsymbol in VALUES

Navigation

[0] Message Index

[#] Next page

Go to full version