Interesante, habra que documentar y empezar a probar.
On Wed, Mar 1, 2006, ""Alexandro Colorado"" <[EMAIL PROTECTED]> dijo:
> Dada la discusion sobre informacion sobre macr0s lanzare algun0s snippets
> utiles para empezar a d0cumentar 000Basic.
>
> Aqui estan un snippets creados por Andrew Pitonyak, pueden probarlos para
> empezar a programar:
>
> Crear una base de datos HSQLDB vacia:
>
> REM Use "Option Compatible", or you can not use a default argument.
> Sub CreateBinaryDB(Optional dbURL$ = "", Optional bVerbose = False)
> Dim oDBContext 'DatabaseContext service.
> Dim oDB 'Database data source.
>
> REM No URL Specified, get one.
> If dbURL = "" Then dbURL = ChooseAFile(OOoBaseFilters(), False)
>
> REM Still No URL Specified, exit.
> If dbURL = "" Then Exit Sub
>
> If FileExists(dbURL) Then
> If bVerbose Then Print "The file already exists."
> Else
> If bVerbose Then Print "Creating " & dbURL
> oDBContext = createUnoService( "com.sun.star.sdb.DatabaseContext" )
> oDB = oDBContext.createInstance()
> oDB.URL = "sdbc:embedded:hsqldb"
> oDB.DatabaseDocument.storeAsURL(dbURL, Array())
> End If
> End Sub
>
> Crear una tabla con ID, Nombre y Datos:
>
> REM Create the database specified by dbURL. If it
> REM does not exist, then it is created.
> REM If bForceNew is True, then an existing table is deleted first.
> REM If bVerbose is True, progress messages are printed.
>
> Sub CreateBinaryTables(dbURL As String, _
> Optional bForceNew = False, _
> Optional bVerbose = False)
> Dim sTableName$ 'The name of the table to creat.
> Dim oTable 'A table in the database.
> Dim oTables 'Tables in the document
> Dim oTableDescriptor 'Defines a table and how it looks.
> Dim oCols 'The columns for a table.
> Dim oCol 'A single column descriptor.
> Dim oCon 'Database connection.
> Dim oBaseContext 'Database context service.
> Dim oDB 'Database data source.
>
> REM If the database does not exist, then create it.
> If NOT FileExists(dbURL) Then
> CreateBinaryDB(dbURL, bVerbose)
> End If
>
> REM Use the DatabaseContext to get a reference to the database.
> oBaseContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
> oDB = oBaseContext.getByName(dbURL)
> oCon = oDB.getConnection("", "")
>
> oTables = oCon.getTables()
>
> sTableName$ = "BINDATA"
> If oTables.hasByName(sTableName$) Then
> If bForceNew Then
> If bVerbose Then Print "Deleting table " & sTableName
> oTables.dropByName(sTableName)
> oDB.DatabaseDocument.store()
> 'oCon.close()
> 'Exit Sub
> Else
> If bVerbose Then Print "Table " & sTableName & " already exists!"
> oCon.cose()
> Exit Sub
> End If
> End If
>
> REM For now, this should always be True
> If NOT oTables.hasByName(sTableName$) Then
> oTableDescriptor = oTables.createDataDescriptor()
> oTableDescriptor.Name = sTableName$
>
> oCols = oTableDescriptor.getColumns()
> oCol = oCols.createDataDescriptor()
> oCol.Name = "ID"
> oCol.Type = com.sun.star.sdbc.DataType.INTEGER
> oCol.IsNullable = com.sun.star.sdbc.ColumnValue.NO_NULLS
> oCol.IsAutoIncrement = True
> oCol.Precision = 10
> oCol.Description = "Primary Key"
> oCols.appendByDescriptor(oCol)
>
> oCol.Name = "NAME"
> oCol.Type = com.sun.star.sdbc.DataType.VARCHAR
> oCol.Description = "Filename"
> oCol.Precision = 255
> oCol.IsAutoIncrement = False
> oCols.appendByDescriptor(oCol)
>
> oCol.Name = "DATA"
> oCol.Type = com.sun.star.sdbc.DataType.LONGVARBINARY
> oCol.Precision = 2147483647
> oCol.IsNullable = com.sun.star.sdbc.ColumnValue.NULLABLE
> oCol.Description = "Binary Data"
> oCols.appendByDescriptor(oCol)
>
> oTables.appendByDescriptor(oTableDescriptor)
> End If
>
> REM Do not dispose the database context or you will NOT be able to
> REM get it back without restarting OpenOffice.org.
> REM Store the associated document to persist the changes to disk.
> oDB.DatabaseDocument.store()
> oCon.close()
> If bVerbose Then Print "Table " & sTableName & " created!"
> End Sub
>
>
> --
> Alexandro Colorado
> CoLeader of OpenOffice.org ES
> http://es.openoffice.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Eduardo Moreno
TOKONHU de México
044 55 5182 4398
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]