Oracle/ja: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Oracle/ja
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## 低階層 Oracle サーバインタフェース | |
| 2 | + | ||
| 3 | + | The low level Oracle server interface exists of one unit, **oraoci**, which is a straight translation of the Oracle interface header files. | |
| 4 | + | ||
| 5 | + | There are 2 example programs: | |
| 6 | + | ||
| 7 | + | - **oraclew** contains some utility routines for the oracle interface, for easier management of result sets. Needs the classes unit from the FCL. | |
| 8 | + | - **test01** a simple test program to demonstrate the interface. | |
| 9 | + | ||
| 10 | + | ## Oracle へ直接接続 | |
| 11 | + | ||
| 12 | + | You can directly connect Lazarus and Oracle by using Oracle Data Access Components (ODAC). It is a library of components that provides native connectivity to Oracle from Lazarus (and Free Pascal) on Windows, Mac OS X, iOS, Android, Linux, and FreeBSD for both 32-bit and 64-bit platforms. The ODAC library is designed to help programmers develop faster and more native Oracle database applications. | |
| 13 | + | ||
| 14 | + | ## Oracle へのOOPアクセス | |
| 15 | + | ||
| 16 | + | Built over the low-level interface, the SQLDB framework supplied with FPC supports accessing Oracle (using TOracleConnection); see also [[Lazarus Database Overview|Lazarus_Database_Overview#Lazarus_and_Oracle]] | |
| 17 | + | ||
| 18 | + | Lazarus also has a component: [[TOracleConnection]] | |
| 19 | + | ||
| 20 | + | - Hostname: as with other sqldb connectors, use hostname or IP address. Leave empty if you use a TNSNAMES.ORA net service name in DatabaseName | |
| 21 | + | - Username/password: same as with other sqldb connectors | |
| 22 | + | - DatabaseName: | |
| 23 | + | - instance/SID of the Oracle server you want to connect to **or** | |
| 24 | + | - net service name in a TNSNAMES.ORA file | |
| 25 | + | ||
| 26 | + | > **Note:** Released FPC/Lazarus x64 versions on Windows do not include an Oracle connector. If you enable it and test successfully, please submit a patch with the changes so it can be included | |
| 27 | + | ||
| 28 | + | ## トラブルシューティング | |
| 29 | + | ||
| 30 | + | ### クライアントとサーバのキャラクタセット | |
| 31 | + | ||
| 32 | + | To get info about what character set/NLS settings are active, you can run the following program. | |
| 33 | + | ||
| 34 | + | Please don't forget to fill out correct server name, username, password and database name before compiling. | |
| 35 | + | ||
| 36 | + | ``` pascal | |
| 37 | + | program oracharset; | |
| 38 | + | ||
| 39 | + | { Shows client and server character set/NLS info} | |
| 40 | + | { PLEASE EDIT PASSWORDS ETC BELOW. } | |
| 41 | + | ||
| 42 | + | {$mode objfpc}{$H+} | |
| 43 | + | ||
| 44 | + | uses {$IFDEF UNIX} {$IFDEF UseCThreads} | |
| 45 | + | cthreads, {$ENDIF} {$ENDIF} | |
| 46 | + | Classes, | |
| 47 | + | SysUtils, | |
| 48 | + | sqldb, | |
| 49 | + | oracleconnection; | |
| 50 | + | ||
| 51 | + | var | |
| 52 | + | Col: integer; | |
| 53 | + | Conn: TOracleConnection; | |
| 54 | + | Tran: TSQLTransaction; | |
| 55 | + | Q: TSQLQuery; | |
| 56 | + | begin | |
| 57 | + | Conn := TOracleConnection.Create(nil); | |
| 58 | + | Tran := TSQLTransaction.Create(nil); | |
| 59 | + | Q := TSQLQuery.Create(nil); | |
| 60 | + | try | |
| 61 | + | // * EDIT IDENTIFYING INFO AS NEEDED* | |
| 62 | + | Conn.HostName := ''; | |
| 63 | + | Conn.UserName := 'system'; | |
| 64 | + | Conn.Password := ''; | |
| 65 | + | Conn.DatabaseName := 'XE'; | |
| 66 | + | // *END IDENTIFIYING INFO* | |
| 67 | + | Conn.Transaction := Tran; | |
| 68 | + | Q.DataBase := Conn; | |
| 69 | + | Conn.Open; | |
| 70 | + | Tran.Active := true; | |
| 71 | + | ||
| 72 | + | writeln('Server character set info:'); | |
| 73 | + | Q.SQL.Text := 'SELECT value$ FROM sys.props$ WHERE name like ''NLS_%'' '; | |
| 74 | + | Q.Open; | |
| 75 | + | Q.First; | |
| 76 | + | while not (Q.EOF) do | |
| 77 | + | begin | |
| 78 | + | writeln('*****************'); | |
| 79 | + | for Col := 0 to Q.Fields.Count - 1 do | |
| 80 | + | begin | |
| 81 | + | try | |
| 82 | + | writeln(Q.Fields[Col].DisplayLabel + ':'); | |
| 83 | + | writeln(Q.Fields[Col].AsString); | |
| 84 | + | except | |
| 85 | + | writeln('Error retrieving field ', Col); | |
| 86 | + | end; | |
| 87 | + | end; | |
| 88 | + | Q.Next; | |
| 89 | + | end; | |
| 90 | + | Q.Close; | |
| 91 | + | ||
| 92 | + | writeln(''); | |
| 93 | + | writeln('Client character set info:'); | |
| 94 | + | Q.SQL.Text := 'SELECT * FROM NLS_SESSION_PARAMETERS '; | |
| 95 | + | Q.Open; | |
| 96 | + | Q.First; | |
| 97 | + | while not (Q.EOF) do | |
| 98 | + | begin | |
| 99 | + | writeln('*****************'); | |
| 100 | + | for Col := 0 to Q.Fields.Count - 1 do | |
| 101 | + | begin | |
| 102 | + | try | |
| 103 | + | writeln(Q.Fields[Col].DisplayLabel + ':'); | |
| 104 | + | writeln(Q.Fields[Col].AsString); | |
| 105 | + | except | |
| 106 | + | writeln('Error retrieving field ', Col); | |
| 107 | + | end; | |
| 108 | + | end; | |
| 109 | + | Q.Next; | |
| 110 | + | end; | |
| 111 | + | Q.Close; | |
| 112 | + | // *END EXAMPLE BUG TESTING CODE* | |
| 113 | + | Conn.Close; | |
| 114 | + | finally | |
| 115 | + | Q.Free; | |
| 116 | + | Tran.Free; | |
| 117 | + | Conn.Free; | |
| 118 | + | end; | |
| 119 | + | writeln('Program complete. Press a key to continue.'); | |
| 120 | + | readln; | |
| 121 | + | end. | |
| 122 | + | ``` | |
| 123 | + | ||
| 124 | + | ### ORA-00911 : invalid character | |
| 125 | + | ||
| 126 | + | If you see this error message, you might want to try | |
| 127 | + | ||
| 128 | + | - removing a trailing semicolon - ; - if you have it in a SELECT statement | |
| 129 | + | - adding a trailing semicolon (e.g. in CALL or EXECUTE statements) | |
| 130 | + | ||
| 131 | + | See this thread which applies to .Net but may apply to SQLDB as well: [1](http://social.msdn.microsoft.com/Forums/en/adodotnetdataproviders/thread/58a27505-a3fb-4cb1-9063-3946b3f26acd) | |
| 132 | + | ||
| 133 | + | Go back to [[Packages List]] | |
| 134 | + | ||
| 135 | + | --- | |
| 136 | + | *From the Free Pascal wiki, page "Oracle/ja", as it stood on 2024-03-26 after a change by Ariben, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
