BBC BASIC for Windows
« Oracle Database Connection »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:15pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Oracle Database Connection  (Read 1163 times)
michael42
New Member
Image


member is offline

Avatar




PM


Posts: 1
xx Oracle Database Connection
« Thread started on: Dec 21st, 2011, 12:46pm »

Hello,

I am using the latest version of BBC BASIC for Windows. How can I connect to an Oracle database (10g/11g)?

If there are any code snippets that would be ideal.

EDIT: I did find and download the ODBC32.bbc but this only shows the initial CALL statement. A few standard SQL examples could go a long way. A SELECT to return a cursor\recordset and a standard DML statement (INSERT\UPDATE\DELETE).


Thanks,

Michael
« Last Edit: Dec 21st, 2011, 2:30pm by michael42 » User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Oracle Database Connection
« Reply #1 on: Dec 21st, 2011, 2:32pm »

on Dec 21st, 2011, 12:46pm, michael42 wrote:
I am using the latest version of BBC BASIC for Windows. How can I connect to an Oracle database (10g/11g)?

One way would be to use the Microsoft ODBC driver (ODBC32.DLL) which you probably already have on your PC:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms713590.aspx

The ODBC API reference is here:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms714562.aspx

If you can find, say, some Visual BASIC code which does what you want it will probably be quite straightforward to translate it to BBC BASIC.

Richard.
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: Oracle Database Connection
« Reply #2 on: Dec 21st, 2011, 2:57pm »

Here's a code snippet (untested) to get you started:

Code:
      SYS "LoadLibrary", "ODBC32.DLL" TO odbc%
      SYS "GetProcAddress", odbc%, "SQLAllocEnv" TO `SQLAllocEnv`
      SYS "GetProcAddress", odbc%, "SQLAllocConnect" TO `SQLAllocConnect`
      SYS "GetProcAddress", odbc%, "SQLDriverConnect" TO `SQLDriverConnect`
      
      SYS `SQLAllocEnv`, ^glEnv%
      IF glEnv% = 0 ERROR 100, "Unable to initialize ODBC API drivers"
      
      SYS `SQLAllocConnect`, glEnv%, ^glDbc%
      IF glDbc% = 0 ERROR 100, "Unable to allocate memory for connection handle"
      
      Connect$ = "DSN=" + DSN$ + ";UID=" + LoginID$ + ";PWD=" + Password$ + \
      \          ";APP=" + AppCode$ + ";DATABASE=" + Database$
      
      Result$ = STRING$(1024, CHR$0)
      
      SYS `SQLDriverConnect`, glDbc%, @hwnd%, Connect$, LEN(Connect$), \
      \                       Result$, LEN(Result$), ^size%, 0 TO res%
      IF res% ERROR 100, "Unable to connect to database"
      
      Result$ = LEFT$(Result$, size%) 

Richard.
« Last Edit: Dec 21st, 2011, 2:58pm by admin » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls