Server Help

ASSS Questions - Connecting Oracle to an AS3 server

Animate Dreams - Sun Dec 24, 2006 4:22 pm
Post subject: Connecting Oracle to an AS3 server
Some of you may know Sass, one of the many owners of Omega Fire. Anyway, by profession he works with databases, mainly Oracle, and what drew him to AS3 in the first place was the ability to connect to databases. We spent a bit of time trying to figure out how to re-code the existing mysql.c to see how easy it would be to connect to Oracle instead, but we were both confused. He doesn't know enough about AS3 and C, I guess, and I don't know enough about any of it to figure it out. Anyway, long story short, we'd like to connect to an Oracle database and we don't know how.

The only real leads we've gotten are sqlda.h and sqlcpr.h. We found a couple programs that connected using only those includes(apart from normal ones like stdio.h). But we're still having problems. Take this for example:

Code: Show/Hide
/* --------------------------------------------------------------------------
logon to ORACLE, and open the cursors. The program exits if any errors occur.
-------------------------------------------------------------------------- */

  strcpy((char *)uid.arr,"SCOTT");
  uid.len = (short) strlen((char *)uid.arr);
  strcpy((char *)pwd.arr,"TIGER");
  pwd.len = (short) strlen((char *)pwd.arr);

  EXEC SQL WHENEVER SQLERROR GOTO errexit;
  EXEC SQL CONNECT :uid IDENTIFIED BY :pwd;


This seems to be the important part, the connection. Things like pwd and uid were pre-defined. This part makes sense to Sass, but it's not enough... like, where's host? Does it assume localhost? And port? I couldn't even find the port for the mysql.c module, for that matter. Anyone wanna help me there?

Anyway, if any of you happen to have any experience in this and can clue us in on how to connect, that would be great. As for the rest of the module, I'm hoping we can manage to copy over existing functions from the mysql.c module to a new connection module, maybe even close enough that other modules that used the database wouldn't have to be re-coded. I guess we'll have to see about that later.

Also, if I sound really confused in this post, it's because I am. Any help would definitely be appreciated.
Smong - Mon Dec 25, 2006 7:29 am
Post subject:
That exec stuff doesn't look like C, is it some kind of macro? And if it's meant to be a query string then you will need some special API function to pass in uid/pwd since they are some kind of special struct (infact it looks like maybe they are C++ classes).

Something like:
oracle_query("EXEC SQL CONNECT %s IDENTIFIED BY %s", uid, pwd);
CypherJF - Mon Dec 25, 2006 2:00 pm
Post subject:
I took a look at the Oracle site most of their examples I believe were in C++ even though they refer to having C API calls. Good luck! icon_smile.gif
Animate Dreams - Mon Dec 25, 2006 8:29 pm
Post subject:
Actually, Smong, I just figured out what that stuff is. It has to do with Pro*C, a "pre-compiler" I keep seeing on Oracle sites. Apparently it does this

"An Oracle Precompiler is a programming tool that enables the user to embed SQL statements in a high-level source program. As Figure 1-1 shows, the precompiler accepts the source program as input, translates the embedded SQL statements into standard Oracle runtime library calls, and generates a modified source program that you can compile, link, and execute in the usual way."

Which is cool. That was the main thing I wasn't understanding... I kept reading code, and I kept seeing all these SQL statements, and I have no idea how SQL is normally embedded in programs, so I thought it was natural... but nothing I was doing was working. Now I know I need to get a Pro*C pre-compiler. Wherever that is.

Now my problem is just being a Linux noob, it takes me forever to figure out where things are installed. I'm pretty sure Pro*C is already installed, and it would logically follow that I can call it with a command. I'll look into this later. It's Christmas.

Once I get connectivity figured out, I'll probably have to ask a few questions about the mysql module. Like, where is the port defined? Does the module assume the default mysql port? If so, where does it do it? In the code I mean. What line?
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group