This question about Using an extension: Asked

Using SQLFORMAT inside FOREACH

Hi there!

I got a little problem with using SQLFORMAT and foreach. I got a Database containing a table i need to read out. The Dimension of the table is about 250fields with about 100.000 entrys. So i really really don't want wo write explicit statements for the 250 fields. Therefore i got a comma separated list with the fields and want so let them output automaticly via FOREACH. Just for example i wrote:

---++Query
%SQL{database="MyDatabase" "
 SELECT *
 FROM dbo.tabMzKopfdaten
WHERE dbo.tabMzKopfdaten.MusterzettelID = 50000}%;
"
 id="Muster_id"
 limit="1"
 format="SKIP OUTPUT HERE"
}%

---++SQLFORMAT Manual with 4 fields
%SQLFORMAT{"Muster_id" format="$MusterzettelID"}%%BR%
%SQLFORMAT{"Muster_id" format="$DokuArt"}%%BR%
%SQLFORMAT{"Muster_id" format="$DokuArtRef"}%%BR%
%SQLFORMAT{"Muster_id" format="$ErfDatum"}%%BR%

---++3 versions of SQLFORMAT inside FOREACH (with 4 fields)
%FOREACH{"Kopf_var" in="MusterzettelID,DokuArt,DokuArtRef,ErfDatum"}%
$percntSQLFORMAT{\"Muster_id\" format=\"$$Kopf_var\"}$percnt
%NEXT{"Kopf_var"}%

%FOREACH{"Kopf_var" in="MusterzettelID,DokuArt,DokuArtRef,ErfDatum"}%
$percntSQLFORMAT{\"Muster_id\" format=\"$dollar$Kopf_var\"}$percnt
%NEXT{"Kopf_var"}%

%FOREACH{"Kopf_var" in="MusterzettelID,DokuArt,DokuArtRef,ErfDatum"}%
%SQLFORMAT{"Muster_id" format="$$Kopf_var"}%
%NEXT{"Kopf_var"}%

The SQL query and the SQLFORMAT work just fine until SQLFORMAT is inside FOREACH: Generated output:

Query
SKIP OUTPUT HERE

SQLFORMAT Manual with 4 fields
50000
M
14
2008-02-25 00:00:00


3 versions of SQLFORMAT inside FOREACH (with 4 fields)
ERROR: unknown statement '"Muster_id" format="$MusterzettelID"' ERROR:
unknown statement '"Muster_id" format="$DokuArt"' ERROR: unknown statement
'"Muster_id" format="$DokuArtRef"' ERROR: unknown statement '"Muster_id"
format="$ErfDatum"'


ERROR: unknown statement '"Muster_id" format="$dollarMusterzettelID"' ERROR:
unknown statement '"Muster_id" format="$dollarDokuArt"' ERROR: unknown
statement '"Muster_id" format="$dollarDokuArtRef"' ERROR: unknown statement
'"Muster_id" format="$dollarErfDatum"'


$MusterzettelID? $DokuArt? $DokuArtRef? $ErfDatum?

What am i doing wrong? Why ist the statement unknown? Kind regards and have a nice weekend,

-- EnrikGuenter - 26 Nov 2010

QuestionForm edit

Subject Using an extension
Extension ForEachPlugin, SqlPlugin
Version Foswiki 1.1.2
Status Asked
Topic revision: r1 - 26 Nov 2010, EnrikGuenter
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy