Re: Can it be done in SQL
Posted in 1996
In article <tdenbow-0907961153010001@tdenbow.mathworks.com>, tdenbow@mathworks.com (Toby Denbow) says:
>
>I want to insert some rows into a detail table. The question is how can
>I, in SQL, create line numbers for the rows being inserted without
>hardcoding them?
>I could probalby do it with a stored procedure but would prefer using SQL.
>
>For example I want the_line_number to be incremented for each row os that
>line_no is a valid line_no.
>
>EXAMPLE:
>insert into line_no, col1, col2
>select the_line_number, table.col1, table.col2 from table where col2 = "a">
>
>Please reply via email if you can.
>
>Thanks,
>Toby Denbow
>tdenbow@mathworks.com
>
>== Toby Denbow ========================= tdenbow@mathworks.com ==
> The MathWorks, Inc. info@mathworks.com
> 24 Prime Park Way http://www.mathworks.com
> Natick, MA 01760-1500 ftp.mathworks.com
>==== Tel: 508-647-7243 ==========================================
Toby
I've seen a few answers one of which won't work because it selects and inserts
into the same table.
A serial would cure the problem but here the line numbers will be chosen for
you. Is this OK ?
Otherwise are you able to use 4GL where you can produce a string for execution
Let me know
Terry