Re: Converting a client from Sybase to Oracle?

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1997/02/27
Message-ID: <3314f36d.4349374_at_nntp.mediasoft.net>#1/1


On 26 Feb 1997 19:11:18 GMT, alfred_at_hw.stratus.com (Alfred von Campe) wrote:

>
>How easy would it be to convert a program that uses the Sybase DBlib
>interface to use Oracle? I might be faced with the task to do this
>in the near future, and since I have never used Oracle (and from the
>little I have seen it looks completely different than Sybase), I have
>no idea how long it would take me to do this.
>
>Note that I am not concerned (at least not as far as this post goes)
>about converting the actual database (i.e., the tables) from Sybase
>to Oracle. My main concern is to convert the client. Here a small
>excerpt from one of our many (hundreds of) queries:
>
>dbfcmd(db1,"select distinct %s.spn, spn_body.body ",gbl_parts_table);
>dbfcmd(db1,"from %s, spn_body, bodyprop ",gbl_parts_table);
>dbfcmd(db1,"where %s.spn = spn_body.spn ",gbl_parts_table);
>dbcmd(db1,"and spn_body.body = bodyprop.body ");
>dbcmd(db1,"and bodyprop.property = 'SCANLINK' ");
>dbsqlexec(db1);
>dbresults(db1);
>dbbind(db1, 1, NTBSTRINGBIND, 0, spn);
>dbbind(db1, 2, NTBSTRINGBIND, 0, body_name);
>
>while (dbnextrow(db1) != NO_MORE_ROWS)
> {
> <snip>
> }

Using the precompiler it would look like:

static void process()
{
char sqlstmt[255];
char ename[40];  

    sprintf( sqlstmt, "select distinct %s.ename from %s", "emp", "emp" );     EXEC SQL PREPARE STMT FROM :sqlstmt;     EXEC SQL DECLARE CURS CURSOR FOR STMT;     EXEC SQL OPEN CURS;       for(;;)
    {

        EXEC SQL WHENEVER NOTFOUND DO break;
        EXEC SQL FETCH CURS INTO :ename;
        printf( "%s\n", ename );

    }
 EXEC SQL CLOSE CURS;
}

You could do it using OCI (Oracle Call Interface as well)....

>
>What would the above code look like if I were using an Oracle DB?
>If that is too much to ask, can someone post a similar code fragment
>but using an Oracle API?
>
>Thanks,
>Alfred
>
>P.S. I have cross-posted this to both Sybase and Oracle newsgroups.
>--
>+--------------------------------------------------------------+
>| Ma-Bell: H: 508.448.6214, W: 508.490.6306, fax: 508.460.2888 \
>| US Mail: Alfred von Campe, 402 Lowell Road, Groton, MA 01450 \
>| Internet: alfred_at_hw.stratus.com \

 +------------------------------------+-----------------------------+

>| Why is common sense so uncommon? | I'd rather be flying N4381Q |
>+------------------------------------+-----------------------------+

Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com                          

http://govt.us.oracle.com

  • Check out Oracle Governments web site! ----- Follow the link to "Tech Center" and then downloadable Utilities for some free software...

statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Thu Feb 27 1997 - 00:00:00 CET

Original text of this message