Page 1 of 1

Oracle connection issue / question

Posted: 04.02.2021, 14:54
by Nebulus
Hi,

I wanted to test the Zeos Component with Lazarus as well as with Delphi on our Oracle Database, but not sure how this is supposed to work, I get an error

Compiled and installed the components, no error.

I dropped a ZConnection on the form and entered these properties:

Database : prod1
HostName : db.orsrv.intra (also tried with IP address)
Port : 1521
Password : xxx
User : xxx
Protocol : oracle

When I click to enable 'Connected' it takes about 15 seconds wait and it says : SQL Error : OCI_ERROR: ORA-12154: TNS ^:could not resolve the connect identifier specified
The TNS string I use in the ODBC config, and that works fine from other programs is : db.orsrv.intra:1521/prod1

is it the wrong way to do or did I forget something ? Is Zeos accessing Oracle natively or through a library / dll ?

Thanks in advance for any good hint :-)

Re: Oracle connection issue / question

Posted: 06.02.2021, 10:40
by marsupilami
Hello Nebulus,

I very rarely use Oracle, so my advice might be of limited help. I seem to remember that the database property of the TZConnection is linked to entries of the tnsnames.ora. So maybe you have to somehow specify your connection settings in tnsnames.ora and then use that in the database name?

Best regards,

Jan

Re: Oracle connection issue / question

Posted: 06.02.2021, 12:23
by miab3
@Nebulus,

through a library / dll

I am using:
Database: Server Name
LibraryLocation: C:\instantclient\oci.dll

Michal

Re: Oracle connection issue / question

Posted: 06.02.2021, 13:31
by aehimself
Jan is right.

oci.dll requires a TNSNames.ora file and an entry for the connection, because... Oracle.
Also, an environment variable must be created on the PC named TNS_ADMIN, pointing to the folder where your TNSNames.ora file is located. E.g.: C:\Oracle\TNSNames.ora -> SET TNS_ADMIN=C:\Oracle

Then, set up Zeos like this:
Database: connection entry name in TNSNames.ora
User / Pass: credentials
Host name can be empty, not used for Oracle. Target is stored in TNSNames.ora
Catalog: the schema name to use. Important for metadata, if multiple schemas exists with same tables / procedures / etc.

An average TNSNames.ora entry will look like this:

IDENTIFIER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = SOMETHING)
)
)

Re: Oracle connection issue / question

Posted: 06.02.2021, 18:44
by Nebulus
Thanks for all the support, I thik i messed around mith my env. variables :shock: , probable reason why it didn't work, discovered I had a similar issue when accessing Orable db through Excel VBA.

I'll play around with it next week

Thanks again for the precious hints :-)