Re: Insert/Select question in 4gl
Posted in 1998
Mickey Mestel wrote:
>
> hi,
>
> i'm at a customers where in a 4gl program they are doing something like
> this:
>
> insert into table1 col1,..., name, ...coln
> values (select ..., first_name + last_name, ...from table2)
The syntax above looks a bit strange...
> so all they want to do is to concatenate the first and last name from
> table2, and put it into the name column of table1. this works fine in
> dbaccess, but doesn't in 4gl. we get a runtime error, which i just
> realized i don't have written down, but can get later if need be.
>
> this seems like it should be simple, but i haven't been able to figure
> it out in the few minutes i had to put into it.
>
> any ideas?
>
> mickm
> --
>
It's late and therefore I don't want to check it in my 4GL environment.
But try it in this way:
insert into table1 ( col1, ..., name, coln ) select c1, ...,first_name || last_name, cn from table2 where ... ;
The column-list must be enclosed in braces, the select-list
must not.
If your 4GL compiler will not accept the syntax like dbaccess,
simply prepare and execute the statement.
In this way you will pass by the 4GL syntax parser.
Bye
Stefan Weideneder