Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Declined Here documents redirection

Jun
29
0
I recently tried (unsuccessfully) to create a "here document" with
redirection (ala perl) as per example below:

[example]
odbc %irisdb %sql1 | tee con | ^
for %li in (@con:) echo <<-ETX1 >> clip:
INSERT INTO branch (asset, brnch, customer, external, internal,
xtended)
VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li],

%@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null],

%@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null],
%@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
ETX1
[/example] -- excuse the line wrapping

Of course TIMTOWTDI and I achieved something similar, but the method
depicted above would have been prettier.

I would like to suggest this method of redirection for consideration as
an enhancement to the "here document" feature. I hope others might find
this enhancement pretty useful too.

John

--
Regards
John McMahon
[email protected]
 
You can do something similar to that already.

(for %li in (@con) do echo %li) << ETX1
INSERT INTO branch (asset, brnch, customer, external, internal, xtended)
VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li],
%@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null],
%@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null],
%@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
ETX1

Or equivilently in TC12:

(do li in @con (echo %li)) << ETX1
...
ETX1

Looking at your code, I see that you expected the input to come from stdin
and to use the entire here-document as the target of the ECHO. So my
example doesn't really apply...

-Scott

jmcm <> wrote on 08/30/2010 10:23:22 PM:


> I recently tried (unsuccessfully) to create a "here document" with
> redirection (ala perl) as per example below:
>
> [example]
> odbc %irisdb %sql1 | tee con | ^
> for %li in (@con:) echo <<-ETX1 >> clip:
> INSERT INTO branch (asset, brnch, customer, external, internal,
> xtended)
> VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li],
>
> %@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null],
>
> %@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null],
> %@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
> ETX1
> [/example] -- excuse the line wrapping
>
> Of course TIMTOWTDI and I achieved something similar, but the method
> depicted above would have been prettier.
>
> I would like to suggest this method of redirection for consideration as
> an enhancement to the "here document" feature. I hope others might find
> this enhancement pretty useful too.
>
> John
>
> --
> Regards
> John McMahon
> [email protected]
>
>
>
>
>
>
>
>
 
This does work however:

odbc %irisdb %sql1 | tee con | for %li in (@con) do (
echo INSERT INTO branch (asset, brnch, customer, external, internal,
xtended) ^
VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li], ^
%@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null], ^
%@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null], ^
%@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
) >> clip:

-Scott

samintz <> wrote on 08/31/2010 11:46:03 AM:


> You can do something similar to that already.
>
> (for %li in (@con) do echo %li) << ETX1
> INSERT INTO branch (asset, brnch, customer, external, internal, xtended)
> VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li],
> %@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null],
> %@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null],
> %@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
> ETX1
>
> Or equivilently in TC12:
>
> (do li in @con (echo %li)) << ETX1
> ...
> ETX1
>
> Looking at your code, I see that you expected the input to come from
stdin

> and to use the entire here-document as the target of the ECHO. So my
> example doesn't really apply...
>
> -Scott
>
> jmcm <> wrote on 08/30/2010 10:23:22 PM:
>
>
>
> ---Quote---
> > I recently tried (unsuccessfully) to create a "here document" with
> > redirection (ala perl) as per example below:
> >
> > [example]
> > odbc %irisdb %sql1 | tee con | ^
> > for %li in (@con:) echo <<-ETX1 >> clip:
> > INSERT INTO branch (asset, brnch, customer, external, internal,
> > xtended)
> > VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li],
> >
> > %@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null],
> >
> > %@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null],
> > %@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
> > ETX1
> > [/example] -- excuse the line wrapping
> >
> > Of course TIMTOWTDI and I achieved something similar, but the method
> > depicted above would have been prettier.
> >
> > I would like to suggest this method of redirection for consideration
as

> > an enhancement to the "here document" feature. I hope others might
find

> > this enhancement pretty useful too.
> >
> > John
> >
> > --
> > Regards
> > John McMahon
> > [email protected]
> >
> >
> >
> >
> >
> >
> >
> >
> ---End Quote---
>
>
>
 
Thanks for responding Scott. That last example was exactly how I did it.
I was not looking for a solution, I was proposing an enhancement to
"here documents" in the TCC environment to do something that I thought
could be done in another environment (but can't verify right now)
because I thought it would be neat.

TIMTOWTDI (There Is More Than One Way To Do It).

John

On 1/09/2010 4:45 AM, samintz wrote:

> This does work however:
>
> odbc %irisdb %sql1 | tee con | for %li in (@con) do (
> echo INSERT INTO branch (asset, brnch, customer, external, internal,
> xtended) ^
> VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li], ^
> %@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null], ^
> %@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null], ^
> %@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
> ) >> clip:
>
> -Scott
>
> samintz <> wrote on 08/31/2010 11:46:03 AM:
>
>
>
> ---Quote---
>> You can do something similar to that already.
>>
>> (for %li in (@con) do echo %li) << ETX1
>> INSERT INTO branch (asset, brnch, customer, external, internal, xtended)
>> VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li],
>> %@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null],
>> %@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null],
>> %@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
>> ETX1
>>
>> Or equivilently in TC12:
>>
>> (do li in @con (echo %li)) << ETX1
>> ...
>> ETX1
>>
>> Looking at your code, I see that you expected the input to come from
> ---End Quote---
> stdin
>
>
> ---Quote---
>> and to use the entire here-document as the target of the ECHO. So my
>> example doesn't really apply...
>>
>> -Scott
>>
>> jmcm <> wrote on 08/30/2010 10:23:22 PM:
>>
>>
>>
>> ---Quote---
>>> I recently tried (unsuccessfully) to create a "here document" with
>>> redirection (ala perl) as per example below:
>>>
>>> [example]
>>> odbc %irisdb %sql1 | tee con | ^
>>> for %li in (@con:) echo <<-ETX1 >> clip:
>>> INSERT INTO branch (asset, brnch, customer, external, internal,
>>> xtended)
>>> VALUES (%@field[0,%li], %@field[1,%li], %@field[2,%li],
>>>
>>> %@if[%@isalnum[%@field[3,%li]],%@field[3,%li],null],
>>>
>>> %@if[%@isalnum[%@field[4,%li]],%@field[4,%li],null],
>>> %@if[%@isalnum[%@field[5,%li]],%@field[5,%li],null]);
>>> ETX1
>>> [/example] -- excuse the line wrapping
>>>
>>> Of course TIMTOWTDI and I achieved something similar, but the method
>>> depicted above would have been prettier.
>>>
>>> I would like to suggest this method of redirection for consideration
> ---End Quote---
> as
>
>
> ---Quote---
>>> an enhancement to the "here document" feature. I hope others might
> ---End Quote---
> find
>
>
> ---Quote---
>>> this enhancement pretty useful too.
>>>
>>> John
>>>
>>> --
>>> Regards
>>> John McMahon
>>> [email protected]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> ---End Quote---
>>
>>
>>
> ---End Quote---
>
>
>
>

--
Regards
John McMahon
[email protected]
 
Back
Top