Tags:
create new tag
view all tags

Question

Can the DatabasePlugin be used with SpreadSheetPlugin ? I run the query

%DATABASE_SQL{description="staff" sql="select StaffName from staffdetails where staffid='3'" format="$StaffName" separator="$nop"}%

and get the output Chengs.

But when I want to compare it using the $EXACT command in SpreadSheetPlugin using the command:

%CALC{"$EXACT(%DATABASE_SQL{description="staff" sql="select StaffName from staffdetails where staffid='3'" format="$StaffName" separator="$nop"}%,Chengs)"}%

I get the error $EXACT(No such DB staff,Abc) at /usr/lib/perl5/5.8/CGI/Carp.pm line 314. at /usr/lib/perl5 etc...

looks like the Database command can not be used inside the Spreadsheet command.

How do I achieve this ?

Environment

TWiki version: unspecified
TWiki plugins: DefaultPlugin, DatabasePlugin, SpreadSheetPlugin
Server OS: WindowsXP
Web server: Apache 1.3.39
Perl version: 5.008008 (cygwin)
Client OS: Windows XP
Web Browser: IE 6
Categories: Plugins

-- ChengappaCB - 10 Dec 2008

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

Continuing the experiment, I changed the Plugin order and put Database Plugin first (followed by Spreadsheet Plugin). Now I don't get the error but the output is

%CALC{"$EXACT(Chengs

Now it looks as if it is executing the Database Plugin part but not the Spreadsheet Plugin part. What am I missing ?

-- ChengappaCB - 10 Dec 2008

Ah, yes, the plugin order should do it.

The CALC expects all parameters to be on one and the same line. That is, your CALC breaks if your DB query introduces newlines. Try a query that does not contain newlines.

-- PeterThoeny - 10 Dec 2008

As I have given the parameter separator="$nop", the DB query does not introduce new lines. For example, the command

%DATABASE_SQL{description="staff" sql="select !StaffName from staffdetails where staffid='3'" format="$StaffName" separator="$nop"}% Test for newline

gives the output:

Chengs Test for newline

without a newline between 'Chengs' and 'Test for newline' (verified from the source page of the html page). Any suggestions ? (I am wondering if the use of $NOP() in CALC will help but not sure how to go about it.

-- ChengappaCB - 11 Dec 2008

What is the exact DATABASE_SQL - in CALC statement you use?

What is the HTML output?

Another approach worth a try: You could stuff an escaped CALC inside the format of DATABASE_SQL. Example: format="$percntCALC{$dollarEXACT($StaffName, Chengs)}$percnt"

-- PeterThoeny - 11 Dec 2008

Oh! This seems to be working. I wasn't aware that 'format' can be used this way. Now my

%DATABASE_SQL{description="staff" sql="select StaffName from staffdetails where StaffId='3'" format="$percntCALC{$dollarEXACT($StaffName,Chengs)}$percnt" separator="$nop"}% 

gives an output "1" which is what I wanted. Thank you very much !

-- ChengappaCB - 11 Dec 2008

Glad it worked out! With this solution you do not need the special plugn execution order because the CALC is escaped and executes later.

-- PeterThoeny - 11 Dec 2008

Change status to:
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2008-12-11 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.