<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><category>pcsoft.us.windev</category><copyright>Copyright 2026, PC SOFT</copyright><lastBuildDate>26 Apr 2018 07:06:32 Z</lastBuildDate><pubDate>8 Nov 2016 17:21:07 Z</pubDate><description>I try to retrieve the id of the record(s) inserted with a query to no avail. The closest I've got is, from http://forum.pcsoft.fr/es-ES/pcsoft.us.windev/30754-windev-insert-query-get-last-inserted/read.awp, HRetrieveItem but first it will only get me the last record, regardless of who inserted it (if someone else added other records then this will not be good) but regardless, it does not work anyways as I am inserting the records using a transaction.&#13;
&#13;
My DB is MS SQL 2012 using OLEDB and the simplest code that does not work is like this:&#13;
&#13;
// I defined a very simple query named QRY_InsertCompany like INSERT INTO COMPANIES (NAME) VALUES ({paramName})&#13;
[code:wl]&#13;
FUNCTION PRIVATE AddCompany(cCompany): int&#13;
&#13;
QRY_InsertCompany.ParamName = cCompany&#13;
IF HExecuteQuery(QRY_InsertCompany, hWithTransaction) THEN&#13;
	sLastRecord is string = HRetrieveItem (Companies, 1)&#13;
	RESULT sLastRecord&#13;
END&#13;
RESULT 0&#13;
[/code]&#13;
&#13;
Ignoring the fact that the return value would be wrong as is a string instead of int, it will return the last record of the table but it is not the one inserted probably because of the transaction which I cannot close for I need to use this ID on other inserts, so it does not help me at all. Even if it worked, there is no guarantee that is MY record and even if all that is satisfied it will work for one record, but what if I do something like&#13;
&#13;
INSERT INTO COMPANIES (NAME) SELECT NEW_NAME FROM NEWCOMPANIES&#13;
&#13;
Or something like that, how would I retrieve all the inserted pks?&#13;
&#13;
(In other languages I would use the OUTPUT clause of SQL Server Insert command but I was not able to make it work with WinDev 21 and found little help &#13;
&#13;
TIA</description><ttl>30</ttl><generator>WEBDEV</generator><language>en_US</language><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records/read.awp</link><title>Retrieving ID of records</title><managingEditor>moderateur@pcsoft.fr (El moderador)</managingEditor><webMaster>webmaster@pcsoft.fr (El webmaster)</webMaster><item><author>jamblard.altaiire</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-65310/read.awp</comments><pubDate>26 Apr 2018 07:06:32 Z</pubDate><description>Hello, &#13;
&#13;
I got the w23 42u version but still have the problem of duplicate rows during insert statement with output clause.&#13;
&#13;…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-65310/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-65310/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records/read.awp">Retrieving ID of records</source><title>Re: Retrieving ID of records</title></item><item><author>amarrete</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60344/read.awp</comments><pubDate>14 Nov 2016 18:48:56 Z</pubDate><description>Hi Fabrice,&#13;
&#13;
I see that my answer is lost...&#13;
&#13;
Not my good month...</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60344/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60344/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records/read.awp">Retrieving ID of records</source><title>Re: Retrieving ID of records</title></item><item><author>amarrete</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60343/read.awp</comments><pubDate>14 Nov 2016 18:25:34 Z</pubDate><description>Thanks for the answer Fabrice, but I still cannot get this going, very frustrating as this should be very easy. I am sure I am n…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60343/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60343/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records/read.awp">Retrieving ID of records</source><title>Re: Retrieving ID of records</title></item><item><author>fromweb</author><category>pcsoft.us.windev</category><comments>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60276/read.awp</comments><pubDate>8 Nov 2016 19:17:52 Z</pubDate><description>Hello Hugo,&#13;
&#13;
to do that, if it's supported by your target DB, you need to use the SQL &#13;
syntax sending back the created ID.&#13;
O…</description><guid isPermaLink="true">https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60276/read.awp</guid><link>https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records-60276/read.awp</link><source url="https://forum.pcsoft.fr/es-ES/pcsoft.us.windev/60274-retrieving-records/read.awp">Retrieving ID of records</source><title>Re: Retrieving ID of records</title></item></channel></rss>
