Mailing List Archive

DB query using scratch variable
I have a scratch variable set for which

sku_prefix = |[scratch sku_prefix]| (using the pipe delimiters to
help me see extra white space) displays:

sku_prefix = | BS |

I'm not sure why the white space exists and can't seem to get rid of it.


This:
data1= |[data interpolate=1 table=cat col=source foreign=sku_prefix key=BS]|

displays as expected
data1= |CPS|

but
data2= |[data interpolate=1 table=cat col=source foreign=sku_prefix
key=[scratch sku_prefix]]

displays
data2= |]|


I get similar issues if I try the query in a perl block. The below works
but I fails when I try to replace BS with [scratch sku_prefix] or with
$Scratch->{sku_prefix};

[tmp mysource]
[perl tables="cat"]
($Db{cat}->query("SELECT distinct `source` FROM cat WHERE
sku_prefix = 'BS'"))[0][0][0];
[/perl]
[/tmp]
HEY [scratch mysource]
_______________________________________________
interchange-users mailing list
interchange-users@interchangecommerce.org
https://www.interchangecommerce.org/mailman/listinfo/interchange-users
Re: DB query using scratch variable [ In reply to ]
On 02/03/2023 17:14, DB via interchange-users wrote:
> I have a scratch variable set for which
>
> sku_prefix = |[scratch sku_prefix]|     (using the pipe delimiters to help me see extra white space) displays:
>
> sku_prefix = | BS |
>
> I'm not sure why the white space exists and can't seem to get rid of it.
>
>
> This:
> data1= |[data interpolate=1 table=cat col=source foreign=sku_prefix key=BS]|
>
> displays as expected
> data1= |CPS|
>
> but
> data2= |[data interpolate=1 table=cat col=source foreign=sku_prefix key=[scratch sku_prefix]]

Hello Dave,

you need to quote the nested expression:

data2= |[data interpolate=1 table=cat col=source foreign=sku_prefix key='[scratch sku_prefix]']|

Regards
Racke

>
> displays
> data2= |]|
>
>
> I get similar issues if I try the query in a perl block. The below works but I fails when I try to replace BS with [scratch sku_prefix] or with $Scratch->{sku_prefix};
>
>        [tmp mysource]
>          [perl tables="cat"]
>            ($Db{cat}->query("SELECT distinct `source` FROM cat WHERE sku_prefix = 'BS'"))[0][0][0];
>          [/perl]
>        [/tmp]
> HEY [scratch mysource]
> _______________________________________________
> interchange-users mailing list
> interchange-users@interchangecommerce.org
> https://www.interchangecommerce.org/mailman/listinfo/interchange-users
>

--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper


_______________________________________________
interchange-users mailing list
interchange-users@interchangecommerce.org
https://www.interchangecommerce.org/mailman/listinfo/interchange-users