Forum > Databases

[solved] SQL - IBX - "returning" - primary key

(1/6) > >>

Nicole:
So I am one step further (who read my last thread: The problem was due to a change from FireDac to IBX in the source row order)

The query below looks complex, but the question is not.
The query shall return the NEW primary key which is generated by a generator.
This has worked before in Firedac, so it shall be an easy change for those who know the trick in IBX.

so here is the query of which only the last line shall be important

--- Code: MySQL  [+][-]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 tbtrades (zukonto, STATUS_ ,POSITION_ ,FK_KONTRAKT,NAME_,COMM ,ERGEBNIS,ENTRY_PRICE,ENTRY_DATE,EXIT_DATE,ENTRY_TIME,EXIT_TIME,STOP,WORST,TARGET,BEST,PL,MARGIN) values  (:zuKonto,:STATUS_,:POSITION_ ,:FK_KONTRAKT,:NAME_,:COMM ,:ERGEBNIS,:ENTRY_PRICE,:ENTRY_DATE,:EXIT_DATE,:ENTRY_TIME,:EXIT_TIME,:STOP,:WORST,:TARGET,:BEST,:PL,:MARGIN) returning id_trade;'
The error message reads

--- Code: Text  [+][-]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";}};} ---Field not found : "id_trade"
The fields shall be returned and does not exist when I submit the query.
How to solve? I remember, that I tried for a long time to do it by Delphi / Firedac.
This putting above had worked there.

Can anybody give me the hint, how to return the newly generated primary key with IBX?
Thanks.

Zvoni:
Everything i could find it should still work.
Does it work in FlameRobin?

Nicole:

--- Code: Pascal  [+][-]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";}};} --- idEintrag:=IBQuery_TradeInDB.FieldByName('id_trade').AsInteger;
I took it with the line above and am not sure, how to test it.

id_trade shall be GENERATED by the db.
So it is not part of the query.
The only thing that I remember, that it was really hard to put this code. I tried a lot with this id_trade years ago.

Would be great, if anybody KNOWS it, how to put it.

korba812:
Try getting field directly from the insert query (I don't remember if it was from fields or from parameters):

--- Code: Pascal  [+][-]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";}};} ---idEintrag:=IBQuery_TradeInDB.QInsert.FieldByName('id_trade').AsInteger;or

--- Code: Pascal  [+][-]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";}};} ---idEintrag:=IBQuery_TradeInDB.QInsert.ParamByName('id_trade').AsInteger;

Nicole:
thanks, but it did not work neither.

It seems a question about IBX
catching this returning in "returning id_trade"

Navigation

[0] Message Index

[#] Next page

Go to full version