indexing description: "Oracle specification"; date: "$Date$" revision: "$Revision$" class ORACLE inherit DATABASE redefine normal_parse, parse, update_map_table_error, bind_parameter, convert_string_type end STRING_HANDLER feature database_handle_name: STRING is "ORACLE" feature -- For DATABASE_STATUS is_error_updated: BOOLEAN -- Has an Oracle function been called since last update which may have -- updated error code, error message or warning message? found: BOOLEAN -- Is there any record matching the last -- selection condition used ? clear_error is -- Reset database error status. do ora_clear_error end feature -- For DATABASE_CHANGE descriptor_is_available: BOOLEAN is do Result := ora_available_descriptor = 1 end feature -- For DATABASE_FORMAT date_to_str (object: DATE_TIME): STRING is -- String representation in SQL of `object' do create Result.make (1) Result.append ("to_date ('") Result.append (object.formatted_out ("[0]mm/[0]dd/yyyy [0]hh:mi:ss")) Result.append ("','MM/DD/YYYY HH24:MI:SS')") end string_format (object: STRING): STRING is -- String representation in SQL of `object'. -- WARNING: use "IS NULL" if object is empty instead of -- "= NULL" which does not work. do if object /= Void and then not object.is_empty then Result := object.twin Result.replace_substring_all ("'", "''") if Result.count > Max_char_size then Result := break (Result) end Result.precede ('%'') Result.extend ('%'') else Result := "NULL" end end True_representation: STRING is "'T'" False_representation: STRING is "'F'" feature -- For DATABASE_SELECTION, DATABASE_CHANGE normal_parse: BOOLEAN is do if is_proc then Result := False is_proc := False else Result := True end end parse (descriptor: INTEGER; uht: HASH_TABLE [ANY, STRING]; uhandle: HANDLE; sql: STRING): BOOLEAN is do if uhandle.execution_type.immediate_execution then Result := True else init_order (descriptor, sql) bind_args_value (descriptor, uht, sql) Result := True end end bind_parameter (value: ARRAY [ANY]; parameters: ARRAY [ANY]; descriptor: INTEGER; sql: STRING) is local i: INTEGER tmp_c2, tmp_c, c_temp: C_STRING do create c_temp.make (sql) from i:=1 until value.count Result loop ar.put (l_area.read_integer_8 (i - 1).to_character, i) i := i + 1 end end put_data (no_descriptor: INTEGER; index: INTEGER; ar: STRING; max_len:INTEGER): INTEGER is local l_area: MANAGED_POINTER i: INTEGER do create l_area.make (max_len) Result := ora_put_data (no_descriptor, index, l_area.item) check Result <= max_len end ar.set_count (Result) from i := 1 until i > Result loop ar.put (l_area.read_integer_8 (i - 1).to_character, i) i := i + 1 end end conv_type (indicator: INTEGER; index: INTEGER): INTEGER is do Result := ora_conv_type (index) end get_count (no_descriptor: INTEGER): INTEGER is do Result := ora_get_count (no_descriptor) end get_data_len (no_descriptor: INTEGER; ind: INTEGER): INTEGER is do Result := ora_get_data_len (ind, no_descriptor) end get_col_len (no_descriptor: INTEGER; ind: INTEGER): INTEGER is do Result := ora_get_col_len (no_descriptor, ind) end get_col_type (no_descriptor: INTEGER; ind: INTEGER): INTEGER is do Result := ora_get_col_type (no_descriptor,ind) end get_integer_data (no_descriptor: INTEGER; ind: INTEGER): INTEGER is do Result := ora_get_integer_data (no_descriptor, ind) end get_float_data (no_descriptor: INTEGER; ind: INTEGER): DOUBLE is do Result := ora_get_float_data (no_descriptor, ind) end get_real_data (no_descriptor: INTEGER; ind: INTEGER): REAL is do Result := ora_get_real_data (no_descriptor, ind) end get_boolean_data (no_descriptor: INTEGER; ind: INTEGER): BOOLEAN is do Result := ora_get_boolean_data (no_descriptor, ind) end is_null_data (no_descriptor: INTEGER; ind: INTEGER): BOOLEAN is -- is last retrieved data null? do Result := ora_is_null_data (no_descriptor, ind) end get_date_data (no_descriptor: INTEGER; ind: INTEGER): INTEGER is do Result := ora_get_date_data (no_descriptor, ind) end get_hour (no_descriptor: INTEGER; ind: INTEGER): INTEGER is local tmp_strg: STRING do create tmp_strg.make (0) tmp_strg.from_c (ora_get_hour) Result := tmp_strg.to_integer end get_sec (no_descriptor: INTEGER; ind: INTEGER): INTEGER is local tmp_strg: STRING do create tmp_strg.make (0) tmp_strg.from_c (ora_get_sec) Result := tmp_strg.to_integer end get_min (no_descriptor: INTEGER; ind: INTEGER): INTEGER is local tmp_strg: STRING do create tmp_strg.make (0) tmp_strg.from_c (ora_get_min) Result := tmp_strg.to_integer end get_year (no_descriptor: INTEGER; ind: INTEGER): INTEGER is local tmp_strg: STRING do create tmp_strg.make (0) tmp_strg.from_c (ora_get_year) Result := tmp_strg.to_integer end get_day (no_descriptor: INTEGER; ind: INTEGER): INTEGER is local tmp_strg: STRING do create tmp_strg.make (0) tmp_strg.from_c (ora_get_day) Result := tmp_strg.to_integer end get_month (no_descriptor: INTEGER; ind: INTEGER): INTEGER is local tmp_strg: STRING do create tmp_strg.make (0) tmp_strg.from_c (ora_get_month) Result := tmp_strg.to_integer end c_string_type: INTEGER is do Result := ora_c_string_type end c_character_type: INTEGER is do Result := ora_c_character_type end c_integer_type: INTEGER is do Result := ora_c_integer_type end c_float_type: INTEGER is do Result := ora_c_float_type end c_real_type: INTEGER is do Result := ora_c_real_type end c_boolean_type: INTEGER is do Result := ora_c_boolean_type end c_date_type: INTEGER is do Result := ora_c_date_type end database_make (i: INTEGER) is do ora_database_make (i) end connect (user_name, user_passwd, data_source, application, hostname, roleId, rolePassWd, groupId: STRING) is local c_temp1, c_temp2: C_STRING do create c_temp1.make (user_name) create c_temp2.make (user_passwd) ora_connect (c_temp1.item, c_temp2.item) is_error_updated := False end disconnect is do ora_disconnect is_error_updated := False found := False end commit is do ora_commit is_error_updated := False end rollback is do ora_rollback is_error_updated := False end trancount: INTEGER is do Result := ora_trancount end begin is do end feature {NONE} -- External features repository_name: STRING is_proc: BOOLEAN ora_get_error_message: POINTER is external "C | %"oracle.h%"" end ora_get_error_code: INTEGER is external "C | %"oracle.h%"" end ora_get_warn_message: POINTER is external "C | %"oracle.h%"" end ora_new_descriptor: INTEGER is external "C | %"oracle.h%"" end ora_init_order (command: POINTER; no_descriptor: INTEGER) is external "C | %"oracle.h%"" end ora_start_order (no_descriptor: INTEGER) is external "C | %"oracle.h%"" end ora_next_row (no_descriptor: INTEGER): INTEGER is external "C | %"oracle.h%"" end ora_terminate_order (no_descriptor: INTEGER) is external "C | %"oracle.h%"" end ora_exec_immediate (no_descriptor: INTEGER; command: POINTER) is external "C (EIF_INTEGER, text *) | %"oracle.h%"" end ora_put_select_name (no_descriptor: INTEGER; index: INTEGER; ar: POINTER): INTEGER is external "C | %"oracle.h%"" end ora_put_data (no_descriptor: INTEGER; index: INTEGER; ar: POINTER): INTEGER is external "C | %"oracle.h%"" end ora_conv_type (index: INTEGER): INTEGER is external "C | %"oracle.h%"" end ora_get_count (no_descriptor: INTEGER): INTEGER is external "C | %"oracle.h%"" end ora_get_data_len (ind: INTEGER; no_descriptor: INTEGER): INTEGER is external "C | %"oracle.h%"" end ora_get_col_len (no_descriptor: INTEGER; ind: INTEGER): INTEGER is external "C | %"oracle.h%"" end ora_get_col_type (no_descriptor: INTEGER; ind: INTEGER): INTEGER is external "C | %"oracle.h%"" end ora_get_integer_data (no_descriptor:INTEGER; ind: INTEGER): INTEGER is external "C | %"oracle.h%"" end ora_get_float_data (no_descriptor:INTEGER; ind: INTEGER): DOUBLE is external "C | %"oracle.h%"" end ora_get_real_data (no_descriptor:INTEGER; ind: INTEGER): REAL is external "C | %"oracle.h%"" end ora_get_boolean_data (no_descriptor:INTEGER; ind: INTEGER): BOOLEAN is external "C | %"oracle.h%"" end ora_is_null_data (no_descriptor:INTEGER; ind: INTEGER): BOOLEAN is external "C | %"oracle.h%"" end ora_get_date_data (desc: INTEGER; index: INTEGER): INTEGER is external "C | %"oracle.h%"" end ora_get_hour: POINTER is external "C | %"oracle.h%"" end ora_get_sec: POINTER is external "C | %"oracle.h%"" end ora_get_min: POINTER is external "C | %"oracle.h%"" end ora_get_year: POINTER is external "C | %"oracle.h%"" end ora_get_day: POINTER is external "C | %"oracle.h%"" end ora_get_month: POINTER is external "C | %"oracle.h%"" end ora_database_make (i: INTEGER) is external "C | %"oracle.h%"" alias "c_ora_make" end ora_disconnect is external "C | %"oracle.h%"" end ora_commit is external "C | %"oracle.h%"" end ora_rollback is external "C | %"oracle.h%"" end ora_trancount: INTEGER is external "C | %"oracle.h%"" end ora_connect (user_name, user_passwd: POINTER) is external "C (text *, text*) | %"oracle.h%"" end ora_available_descriptor: INTEGER is external "C | %"oracle.h%"" end ora_set_parameter (descriptor: INTEGER; sql: POINTER; ph: POINTER; value: POINTER) is external "C (EIF_INTEGER, text *, text *, char *) | %"oracle.h%"" end ora_string_type: INTEGER is external "C [macro %"oracle.h%"]" alias "VARCHAR2_TYPE" end ora_number_type: INTEGER is external "C [macro %"oracle.h%"]" alias "NUMBER_TYPE" end ora_date_type: INTEGER is external "C [macro %"oracle.h%"]" alias "DATE_TYPE" end ora_c_string_type: INTEGER is external "C | %"oracle.h%"" end ora_c_character_type: INTEGER is external "C | %"oracle.h%"" end ora_c_integer_type: INTEGER is external "C | %"oracle.h%"" end ora_c_float_type: INTEGER is external "C | %"oracle.h%"" end ora_c_real_type: INTEGER is external "C | %"oracle.h%"" end ora_c_boolean_type: INTEGER is external "C | %"oracle.h%"" end ora_c_date_type: INTEGER is external "C | %"oracle.h%"" end ora_clear_error is external "C | %"oracle.h%"" end break (s: STRING): STRING is -- Broken long string using -- Oracle's concatenation character. require s_not_void: s /= Void local i: INTEGER do create Result.make (s.count + ( (s.count // Max_char_size) * Concat_string.count)) from i := 1 until i > s.count loop Result.append (s.substring (i, s.count.min (i + Max_char_size - 1))) i := i + Max_char_size if not (i > s.count) then Result.append (Concat_string) end end end Concat_string: STRING is "'||'" end -- class ORACLE --|---------------------------------------------------------------- --| EiffelStore: library of reusable components for ISE Eiffel. --| Copyright (C) 1986-2001 Interactive Software Engineering Inc. --| All rights reserved. Duplication and distribution prohibited. --| May be used only with ISE Eiffel, under terms of user license. --| Contact ISE for any other use. --| --| Interactive Software Engineering Inc. --| ISE Building --| 360 Storke Road, Goleta, CA 93117 USA --| Telephone 805-685-1006, Fax 805-685-6869 --| Electronic mail --| Customer support: http://support.eiffel.com> --| For latest info see award-winning pages: http://www.eiffel.com --|----------------------------------------------------------------