SQL: using the newly inserted index as a value for insertion

Peter Haworth pete at lcsql.com
Sun Nov 24 01:26:03 EST 2013


You want the word key to be replaced by the value of the primary key from
the row from the INSERT statement?

If so,  that's how the trigger can help.  You can refer to any column from
the INSERT using the syntax "new.colname" where colname is the name of any
column in master table.

Still not 100% sure I understand but maybe that helps.

Pete
lcSQL Software
On Nov 23, 2013 8:54 PM, "Dr. Hawkins" <dochawk at gmail.com> wrote:

> Perhaps a simpler way to explain what I'm after:
>
> Suppose I need to retrieve that the value of joe's"stuff" is "fluffy".
>
> Suppose further that when I toss this in, the primary key that gets
> assigned will be "5"
>
> So I want to be able to retrieve the command to put this into the :memory:
> db:
>
>    INSERT INTO memTable (key, child, stuff) VALUES(5,'Joe', 'fluffy');
>
> but I don't know that 5 will be assigned when I put this into the table.
> So my thinking is
>
>   INSERT INTO masterTable (child,scratch) VALUES('Joe','abc123');
>   UPDATE masterTable SET cmd='INSERT INTO memTable (key, child, stuff)
> VALUES(' || key ||' ,''Joe'', ''fluffy'');' WHERE scratch='abc123';
>
> The actual commands are more complicated; there are about 45 fields that
> get set.  There is also no guarantee that the child (Joe) is unique (in
> fact, frequently it will not be).
>
> What I'm seeing is that "key" is indeed recognized as a column name--but it
> states that there is no such column available.
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list