Brian C. wrote:
On Fri, Jun 01, 2007 at 03:45:58AM +0900, Peter B. wrote:
end
as above, but it’s interrogating the same database.
First, I simply connected to the database using the SQLPlus initial GUI.
Can you connect using the sqlplus command line? I didn’t even know that
sqlplus came in a GUI variant. (Are you sure it’s SQLPlus, and not
something
like Toad?)
Your later post says that you connect to “grpprod”. In that case, try
the
pure oci8 script I posted before, using “grpprod” as the database name.
And
try your DBI script with
DBI.connect("DBI:OCI8:grpprod","user","passw")
Can you show your entire /etc/tnsnames.ora ?
Brian.
Here’s my tnsnames.ora file, Brian.
tnsnames.ora Network Configuration File:
E:\live\oracle\product\10.2.0\client_1\network\admin\tnsnames.ora
Generated by Oracle configuration tools.
GRPPROD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = graphicsdb-prod.bna.com)(PORT =
1521))
)
(CONNECT_DATA =
(SERVICE_NAME = GRPPROD.bna.com)
)
)
I put in what you suggested above and, it does seem to be actually
talking to the database, and, it’s respecting my script’s error
presentations.
require ‘oci8’
require ‘dbi’
begin
# connect to the Oracle server
#dbh =
OCI8.new(‘oracleuser’,‘oracle2user’,‘//graphicsdb-prod.bna.com/grpprod.bna.com"’)
#dbh =
DBI.connect(“DBI:OCI8:ORCL:graphicsdb-prod.bna.com/grpprod.bna.com”,
“orcauser”, “orca2user”)
dbh = DBI.connect(“DBI:OCI8:grpprod”,“orcauser”,“orca2user”)
# get server version string and display it
row = dbh.select_one("SELECT VERSION()")
puts "Server version: " + row[0]
rescue DBI::DatabaseError => e
puts “An error occurred”
puts “Error code: #{e.err}”
puts “Error message: #{e.errstr}”
ensure
# disconnect from server
dbh.disconnect if dbh
end
With the above, I get:
An error occurred
Error code: 923
Error message: ORA-00923: FROM keyword not found where expected
Program exited with code 0
which is exactly what the script said to do, to report the exact errors,
number and all.