Skip to main content

[Migrated content. Thread originally posted on 07 May 2012]

I'm only able to connect to my Oracle database via:

-Going control panel -> administrative tools -> ODBC data source manager; creating a DSN for Oracle XE

-Putting he following in the program: exec sql CONNECT WITH PROMPT end-exec

-Once the program's running, a prompt appears; I select the aforementioned DSN.

-Then a prompt corresponding to that DSN appears; I type service name, user name, password.


Are there simpler ways for this? Something akin to a connection string? My main hope is to be able to skip the prompt for DSN and its creation, and maybe the prompt asking for password. I.e. ideally as soon as the program's running it connects right away with no need for user input.

[Migrated content. Thread originally posted on 07 May 2012]

I'm only able to connect to my Oracle database via:

-Going control panel -> administrative tools -> ODBC data source manager; creating a DSN for Oracle XE

-Putting he following in the program: exec sql CONNECT WITH PROMPT end-exec

-Once the program's running, a prompt appears; I select the aforementioned DSN.

-Then a prompt corresponding to that DSN appears; I type service name, user name, password.


Are there simpler ways for this? Something akin to a connection string? My main hope is to be able to skip the prompt for DSN and its creation, and maybe the prompt asking for password. I.e. ideally as soon as the program's running it connects right away with no need for user input.

Well, I found something that solves most of it:

EXEC SQL
    CONNECT TO 'nameOfTheDsn' USER 'username.password'
END-EXEC


Of course, the DSN still needs to have been created manually beforehand; no ways around that?

[Migrated content. Thread originally posted on 07 May 2012]

I'm only able to connect to my Oracle database via:

-Going control panel -> administrative tools -> ODBC data source manager; creating a DSN for Oracle XE

-Putting he following in the program: exec sql CONNECT WITH PROMPT end-exec

-Once the program's running, a prompt appears; I select the aforementioned DSN.

-Then a prompt corresponding to that DSN appears; I type service name, user name, password.


Are there simpler ways for this? Something akin to a connection string? My main hope is to be able to skip the prompt for DSN and its creation, and maybe the prompt asking for password. I.e. ideally as soon as the program's running it connects right away with no need for user input.

You can use Format 6 of the Connect Statement to specify an input_connection string


Format 6
>>----EXEC SQL---CONNECT USING input_connection---------->

>-----.-------------.---.---------------------.---------->
        --AS db_name-     --WITH-.----.-PROMPT-
                                  -NO-

>-----.------------------------------.------END-EXEC----><
        --RETURNING output_connection-



Example in Net Express documentation for Excel:


01  connectString               PIC X(72) value
                   'DRIVER={Microsoft Excel Driver (*.xls)};'
                   &'DBQ=c:\\demo\\demo.xls;'
                   &'DRIVERID=22'
                   .

procedure division.

     EXEC SQL
         CONNECT USING :connectString
     END-EXEC


The example above connects to an Excel spreadsheet without setting up a data source


Several examples for Oracle connect strings can be found here.

Including the following for Oracle XE:

Driver=(Oracle in XEClient);dbq=111.21.31.99:1521/XE;Uid=myUsername;Pwd=myPassword;