Ok, so we are getting back the fact that the insert occurred.

Usually this is done with a connection query. In SQL Server it's: SELECT 
@@identity

One way you can do it is to immediately SELECT max(id) FROM table - assuming 
that the key you want is auto incrementing. Doing this in a transaction would 
ensure you get the record you just inserted.

Another way is to select the id of the record you just inserted using the 
values as keys:

INSERT INTO table (col1, col2, col3) VALUES (123, 456, 789)

Then

SELECT id FROM table WHERE col1 = 123 AND col2 = 456 AND col3 = 789

Of course you just need to use enough columns to ensure you get the same record 
back, so if there's something unique, like a timestamp, or email address, etc. 
then you can just rely on those columns.

One of the nice things about rewriting v8 is the ability to [finally] solve 
issues like this. The v8 solution works like this:

You make an query with a "get identity" flag set (this is automatic for the 
insert action). Internally, we then do what we need to get the identity of the 
newly inserted record. Note that this can fail for certain reasons. After the 
insert, there's a new tag @IDENTITY that resolves to the newly generated key. 
No need to run an additional query or setup a transaction. TS takes care of it 
for you. I should also note that this relies on support from the DBMS and JDBC 
driver.

Robert


-----Original Message-----
From: Wayne Irvine [mailto:[email protected]]
Sent: Friday, July 20, 2018 9:17 AM
To: [email protected]
Subject: Re: TeraScript-Talk: Insert action results

<@NUMAFFECTED> returns 1
> On 21 Jul 2018, at 1:52 am, Robert Shubert <[email protected]> wrote:
>
> It may now. Check @NUMAFFECTED afterwards.
>
> This is something we're looking at supporting better in v8 with an explicit 
> flag to obtain the identity after insert. JDBC supports a mechanism for doing 
> so, but we need to explicitly invoke it.
>
> Robert
>
> -----Original Message-----
> From: Wayne Irvine [mailto:[email protected]]
> Sent: Thursday, July 19, 2018 7:56 PM
> To: [email protected]
> Subject: Re: TeraScript-Talk: Insert action results
>
> Scratch that. Seems I asked the same question 5 years ago. The answer in the 
> case of FMS as a JDBC datasource is no.
>
>> On 20 Jul 2018, at 12:48 pm, Wayne Irvine <[email protected]> wrote:
>>
>> The Search action returns @@resultset. Does the Insert action return any 
>> results (a row ID for example) and if so how do we access it?
>>
>> Wayne
>>
>> Byteserve Pty Ltd
>> w: http://www.byteserve.com.au/
>> e: [email protected]
>> p: +61 02 9960 6099
>> m: 0409 960 609
>> f: +61 02 9960 6088
>>
>>
>>
>>
>> ----------------------------------------
>>
>> To unsubscribe from this list, please send an email to 
>> [email protected] with "unsubscribe terascript-talk" in the body.
>>
>
> Byteserve Pty Ltd
> w: http://www.byteserve.com.au/
> e: [email protected]
> p: +61 02 9960 6099
> m: 0409 960 609
> f: +61 02 9960 6088
>
>
>
>
> ----------------------------------------
>
> To unsubscribe from this list, please send an email to 
> [email protected] with "unsubscribe terascript-talk" in the body.
>
>
>
>
> ----------------------------------------
>
> To unsubscribe from this list, please send an email to 
> [email protected] with "unsubscribe terascript-talk" in the body.
>

Byteserve Pty Ltd
w: http://www.byteserve.com.au/
e: [email protected]
p: +61 02 9960 6099
m: 0409 960 609
f: +61 02 9960 6088




----------------------------------------

To unsubscribe from this list, please send an email to [email protected] 
with "unsubscribe terascript-talk" in the body.




----------------------------------------

To unsubscribe from this list, please send an email to [email protected] 
with "unsubscribe terascript-talk" in the body.

Reply via email to