velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claude Brisson" <>
Subject Re: Velocity + Database
Date Sat, 23 Aug 2003 07:02:48 GMT
(sorry for the delay...)

Aaron wrote :
> I didn't notice that you could embed SQL using velosurf.  So I could just do
> a #parse(filewithsql.sql) to include it?  That would allow my DBAs to work
> with the SQL, the designers to work with the pages, and my Java programmers
> to keep cutting code regardless the structure of the DB?

You can't embed sql with #parse, and it's an implementation choice ! :-)
This would tie the template containing the #parse directive with the sql file.
Instead, you gather sql code in the velosurf.xml file. And DBAs, designers and
java programmers can work on separate sections.

> IMHO it would help your cause a little if you had some _very_ simple
> examples of using Velosurf to:
> a) pull a single value out of the database and display it (a Hello World if
> you will so we can get a super quick notion of your syntax)

Assuming you have a table named 'message' which contains (id=1, text='Hello World'),

the Hello World display app would be :


Or, to be more explicit :

#set( $hello = $db.messages.fetch(1) )

> b) pull multiple rows of a single column out and loop through them simply
> displaying them on the screen in sequential order

#foreach($message in $db.messages)

> c) show a single insert

Assuming that $values is an empty map and that the 'id' column is autoincremental :

#set( $values.text = 'How do you do ?' )
#set( $success = $db.messages.insert($values) )

#if ($success)
    New row inserted : id = $db.messages.lastInsertID
    Error : $db.error

Hope that'll help.
I'll put those examples in the doc.

> Ok, ok, I admit it ... I'm a cry baby ... I want to be spoon-fed the info!

And I admit that Velosurf documentation still needs some enhancements... Would you or anyone
else want to help ?


View raw message