0

我在 shell 存档中有这个命令:

sh -c $POSTGRESbin'psql -U '$POSTGRESuser' -h localhost -d '$POSTGRESdb' -c "select preview from '$fildCatalog' where preview <>'nodata' and id_registro in (select distinct(id_record) from e3_article_items where id_catalog=2101 and id_article in (select id_article from document_articles where id_document in(select distinct(id_document) from p3_logical_pages where id_logical_page in (select id_logical_page from p3_flatplan_pages where id_edition=1536 and id_logical_page is not null order by cast(pagenumber as numeric)))));"' > $queryFolder$highFile"_"$previewFile;

但在 <>'nodata' 中出现错误,我不知道如何解决它。错误是:

ERROR:  column "nodata" does not exist
LINE 1: select preview from XT_FIJOS where preview <>nodata and id_r...

有谁能够帮我 ?

谢谢 !!^

4

2 回答 2

0

这是正确的方法:

sh -c $POSTGRESbin'psql -U '$POSTGRESuser' -h localhost -d '$POSTGRESdb' -c "select preview from '$fildCatalog' where preview <>'\'nodata\'' and id_registro in (select distinct(id_record) from e3_article_items where id_catalog=2101 and id_article in (select id_article from document_articles where id_document in(select distinct(id_document) from p3_logical_pages where id_logical_page in (select id_logical_page from p3_flatplan_pages where id_edition=1536 and id_logical_page is not null order by cast(pagenumber as numeric)))));"' > $queryFolder$previewFile"_"$fildCatalog;

谢谢你的帮助 !!

于 2012-10-25T17:14:49.860 回答
0

问题是您正在使用'...'引用 shell 命令的部分内容,因此您不能在命令的这些部分中使用它们。因此,您的 SQL 查询包含nodata而不是'nodata',因此它认为nodata应该是列名。

要解决此问题,您可以在需要"..."的地方使用而不是:'...'

sh -c "${POSTGRESbin}psql -U $POSTGRESuser -h localhost -d $POSTGRESdb -c \"select preview from '$fildCatalog' where preview <> 'nodata' and id_registro in (select distinct(id_record) from e3_article_items where id_catalog=2101 and id_article in (select id_article from document_articles where id_document in(select distinct(id_document) from p3_logical_pages where id_logical_page in (select id_logical_page from p3_flatplan_pages where id_edition=1536 and id_logical_page is not null order by cast(pagenumber as numeric)))));\"" > "$queryFolder${highFile}_$previewFile";

(请注意,可以通过 using"..."包含文字,这使其更加灵活。)"\"

于 2012-10-25T17:01:08.823 回答