Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Limitation in Format() function?
Limitation in Format() function? [message #13638] Fri, 18 January 2008 12:02 Go to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Hi
I am trying to send an SQL command to SQLite database and I an building it using the Format function. Target databse table has lots of fields.
IF I use more then ten % in the first argunt of the Format function and erro appears like this:

error: invalid conversion from `const char*' to `int'
error: initializing argument 1 of `Upp::String Upp::Format(int, const char*,Upp::Value, Upp::Value, Upp::Value,Upp::Value, Upp::Value, Upp::Value, Upp::Value, Upp::Value, Upp::Value, Upp::
Value)'

Example:

This works: strSQL=Format("( ...) %d,'%0.2d-%0.2d-%0.2d','%s',%d,'%s','%0.2d-%0.2d-%0.2d')",1,2008,1,1, "aaa",1,"aaa",2008,1,1);

This doesnt works: strSQL=Format("( ...) %d,'%0.2d-%0.2d-%0.2d','%s',%d,'%s','%0.2d-%0.2d-%0.2d',%d)",1,2008,1,1, "aaa",1,"aaa",2008,1,1,1);


Is that a limitation?

Alex

Re: Limitation in Format() function? [message #13640 is a reply to message #13638] Fri, 18 January 2008 15:28 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
alex100 wrote on Fri, 18 January 2008 06:02

Hi
I am trying to send an SQL command to SQLite database and I an building it using the Format function. Target databse table has lots of fields.
IF I use more then ten % in the first argunt of the Format function and erro appears like this:

error: invalid conversion from `const char*' to `int'
error: initializing argument 1 of `Upp::String Upp::Format(int, const char*,Upp::Value, Upp::Value, Upp::Value,Upp::Value, Upp::Value, Upp::Value, Upp::Value, Upp::Value, Upp::Value, Upp::
Value)'

Example:

This works: strSQL=Format("( ...) %d,'%0.2d-%0.2d-%0.2d','%s',%d,'%s','%0.2d-%0.2d-%0.2d')",1,2008,1,1, "aaa",1,"aaa",2008,1,1);

This doesnt works: strSQL=Format("( ...) %d,'%0.2d-%0.2d-%0.2d','%s',%d,'%s','%0.2d-%0.2d-%0.2d',%d)",1,2008,1,1, "aaa",1,"aaa",2008,1,1,1);


Is that a limitation?

Alex




Yes, currently, Format is limited to 10 parameters. Adding more is simple, but slightly increases the size of any linux binary using Format...

You can also use:

String Format(const char *s, const Vector<Value>& v);

- that has no limit at all.

Should I increase the limit?

Mirek
Re: Limitation in Format() function? [message #13645 is a reply to message #13640] Fri, 18 January 2008 20:58 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 698
Registered: December 2005
Location: Budapest, Hungary
Contributor
I think, it would be better (more readable and maintainable) to use SQL classes to crete SQL statements.

Some references:
http://www.ultimatepp.org/www$uppweb$overview$en-us.html (see "SQL programming" chapter)

http://www.ultimatepp.org/src$Sql$SqlExp$en-us.html (very useful reference by examples)
Re: Limitation in Format() function? [message #13664 is a reply to message #13638] Sat, 19 January 2008 17:13 Go to previous message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Ok,
Thanks to all of you!



Alex
Previous Topic: logs in release builds (801.r97, SVN rev 90)
Next Topic: DLI does not compile
Goto Forum:
  


Current Time: Sun May 05 06:27:08 CEST 2024

Total time taken to generate the page: 0.01853 seconds