This question about Documentation: Asked

can you provide examples for formating

hi!

I am using your great sqlPlugin, but I can't get behind the Syntax for Format, Header, footer...

For example, when retrieving a single row and column from a database, how to avoid the column title in the Output? I just want to use the Information given in the data field without the heading.

Maybe you can provide one or two short examples on how to use Format, Header, footer?

-- RalfWigand - 21 Jul 2014

The formatting syntax is the same as in other Foswiki macros. The only trick is to know that the row values are in $variables named after the table column names.

By trial and error I came up with this:
%SQL{database="myDatabase" query="SELECT field1,field2 FROM myTable WHERE myParameter like ?"  params="foo%" header="" format="| $field1 | $field2 |$n"}%

If you want to customize the header:
%SQL{database="myDatabase" query="SELECT field1,field2 FROM myTable WHERE myParameter like ?"  params="foo%" header="| Column 1 | Column 2 |$n" format="| $field1 | $field2 |$n"}%

-- RafaelVarela - 13 Jul 2017

I want to get the value from a single cell and display it as text. If I yse the following code I get an error:

 %SQL{database="myDatabase" query="Select [Column Name] From myTable WHERE CONVERT(NVARCHAR(MAX), [Column 2]) = 'Cell Value' AND CONVERT(NVARCHAR(MAX), [Column 3]) = 'Cell Value 2'" params="foo%" header="" format="$[Column Name]"}% 

 ERROR: DBD::ODBC::st execute failed: called with 1 bind variables when 0 are needed 

However, if I remove the foo% in params then I just get "$[Column Name]" and not the call value of that column. What do i need to do to fix this?

QuestionForm edit

Subject Documentation
Extension SqlPlugin
Version Foswiki 1.1.9
Status Asked
Related Topics
Topic revision: r3 - 31 Jan 2024, JeremyChristophel
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