[ic] DB query using scratch variable
Stefan Hornburg (Racke)
racke at linuxia.de
Thu Mar 2 17:41:27 UTC 2023
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 at interchangecommerce.org
> https://www.interchangecommerce.org/mailman/listinfo/interchange-users
>
--
Automation expert - Ansible and friends
Linux administrator & Debian maintainer
Perl Dancer & conference hopper
More information about the interchange-users
mailing list