I haven't worked myself with this part of the code, but I can show you how
we did it.

Sergio - which database driver are you using and what is the expression to
> read in multiple rows
>

FreeTDS

This is how we performed a query:

*clientes*
| rows lista |
rows := (self executeSQL: 'SELECT * from GVA14 order by NOM_COM') rows.
lista := Dictionary new.
rows do: [ :row | lista at: (row valueNamed: 'COD_CLIENT') put: (Cliente
fromRow: row)   ].
^ lista

*executeSQL: aSQLStatement*

self ensureDBConnection.
self dbType = 'MYSQL'
ifTrue: [ ^ (self conn prepare: aSQLStatement) execute: #() ].
self dbType = 'ODBC'
ifTrue: [ ^ (self conn query: aSQLStatement) execute asTable ]
ifFalse: [ ^ self conn execute: aSQLStatement ]

But the driver had several quirks, so we had to do this on
ensureDBConnection

*ensureDBConnection*

[self dbType isNil ifTrue: [
self conn isConnected
ifFalse: [ self conn connect ].
self conn isOpen
ifFalse: [
[ self conn open ] on: DBXError do: [ self error: 'Error de conexion con la
base de datos.' ].
self conn execute: 'SET ANSI_NULLS ON'.
self conn execute: 'SET ANSI_WARNINGS ON' ].
^* (self conn execute: 'select 1') rows first rawValues first = '1']*
ifFalse: [^self ensureDBConnectionFor: self dbType]] on: Error do: [self
error: 'Error de conexion con la base de datos']

Reply via email to