• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getting message: oci_execute(): ORA-00942: table or view does not exist

#11
Smile 
hi all, 
still getting same error Huh , please help, i will be much grateful Smile 
regards

EDIT: have attached 4 files
1) database.php
2) controller/Depts.php
3) model/Dep_models.php
4) views/Dep_view.php

database.php have been modified for 'oracle' (referred to a solution while searching for)
as mentioned earlier: Database is Oracle 12c Release 2
unremark in apache/bin/php.ini following lines:

extension=pdo_oci
extension=oci8_12c  ; Use with Oracle Database 12c Instant Client

found somewhere and created new php file and it runs, showing data from table.column used in Select statement: ( i know its not CI but PHP ) 
PHP Code:
<?php
$c 
oci_connect('hr''hr''localhost/orclpdb');
$s oci_parse($c'select city from locations');
oci_execute($s);
while ((
$res oci_fetch_array($sOCI_ASSOC)) != false) {
 echo 
htmlentities($res['CITY']) . "<br>";
}
?>


Attached Files
.php   database.php (Size: 5.33 KB / Downloads: 42)
.php   Depts.php (Size: 1.74 KB / Downloads: 42)
.php   Dep_models.php (Size: 1.53 KB / Downloads: 39)
.php   Dep_view.php (Size: 1.92 KB / Downloads: 14)
Reply

#12
Did you setup the ./application/config/database.php ?

If so can you post here that file.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#13
I will look at the files and get back to you.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#14
Your database config is wrong, please read this article.

Codeigniter Oracle PDO-oci

You have all of your code above the CI database code but it is still using the default.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#15
(11-13-2018, 04:35 AM)InsiteFX Wrote: Your database config is wrong, please read this article.

Codeigniter Oracle PDO-oci

You have all of your code above the CI database code but it is still using the default.

thanks a bunch for your valuable time, I failed to understand, I followed a online tutorial and I don't know about the differences between oci8 and pdo-oci, this is what for I have uploaded files here. I want to use oracle recommended oci8 but if you seniors recommend I will use pdo-oci, I will check with it and give feedback. 

regards

EDIT: checked your link and I have tested with it "dsn" entry in database.php but it was not working, the dbdriver entry has oci8 or i misunderstood it?
Reply

#16
from my attached Dep_models.php, here I am using 'oracle' and the 'default' line is remarked:
PHP Code:
   public function __construct() //model construct function
 
   {
 
       $this->db=$this->load->database('oracle',true); // oracle db
 
       //$this->db=$this->load->database('default',true); // mysql db
 
   }

 
   public function getDept()
 
   {
 
       $query=$this->db->get('departments');
 
       //$query=$this->db->get('departments');
 
       return $query;
 
   
Reply

#17
@Ahmed Haroon,

I noticed that you had two 'save_queries' in the database.php file. Was that a typo?
Reply

#18
(11-13-2018, 11:14 AM)php_rocs Wrote: @Ahmed Haroon,

I noticed that you had two 'save_queries' in the database.php file.  Was that a typo?

thanks @php_rocs for your reply, i failed to get two 'save_queries' please guide me for this, I want to have to connect multiple databases, here first one is 'oracle' and second is 'mysql' ( i am not trying to teach you as you are far more experienced ), are these correct entries? if not how i can resolve the problem, all necessary files i have uploaded here. if needed i can upload here a zip file of complete project.

my current modified ( as @insiteFX referred to link for PDO-oci ) is now look like below  ( entry for mysql database is same in database.php file ):
PHP Code:
$active_group 'oracle';
$query_builder TRUE;

$db['oracle'] = array(
 
   'dsn'   => 'oci:dbname=(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orclpdb)
    )
  )'
,
 
   'hostname' => '',
 
   //'hostname' => 'localhost',
 
   'username' => 'hr'
 
   'password' => 'hr',
 
   'database' => '',
 
   'dbdriver' => 'oci8',
 
   'dbprefix' => '',
 
   'pconnect' => FALSE,
 
   'db_debug' => (ENVIRONMENT !== 'production'),
 
   'cache_on' => FALSE,
 
   'cachedir' => '',
 
   'char_set' => 'utf8',
 
   'dbcollat' => 'utf8_general_ci',
 
   'swap_pre' => '',
 
   'encrypt' => FALSE,
 
   'compress' => FALSE,
 
   'stricton' => FALSE,
 
   'failover' => array(),
 
   'save_queries' => TRUE
); 

but it is showing error as below  (only first lines from both errors):

A PHP Error was encountered
Message: oci_connect(): ORA-01017: invalid username/password; logon denied

A Database Error Occurred
Unable to connect to your database server using the provided settings.

I can connect with same credentials through SQL Plus (above dsn entry is copy pasted from tnsnames.ora file)

please help.
regards

EDIT: Sorry for inconvenience, I checked again database.php and found what "two save_queries" mean, I have removed 2nd entry but still getting same error as mentioned above.
Reply

#19
@Ahmed Haroon,

How is Oracle configured with PHP? What does your PHP.ini file say for oracle?
Reply

#20
(11-14-2018, 09:46 AM)php_rocs Wrote: @Ahmed Haroon,

How is Oracle configured with PHP?  What does your PHP.ini file say for oracle?

i have modified php.ini file ( in C:\wamp64\bin\apache\apache2.4.35\bin ), line un-remarked for
extension=oci8_12c

is there anything else to do in this file, i don't know about. i have tried various entries found on web but didn't worked yet. the following entries i have to mention with Error messages: ( now i removed entry in database.php for mysql and keep for oracle only as default and here i am posting partial entries to avoid long list )
PHP Code:
//Message: oci_connect(): ORA-01017: invalid username/password; logon denied


 
   $db['default'] = array(
 
   'dsn'   => 'oci:dbname=(DESCRIPTION =
                (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
                (CONNECT_DATA =
                  (SERVER = DEDICATED)
                  (SERVICE_NAME = orclpdb)
                )
              )'
,
 
   'port'  => 1521,
 
   'hostname' => '',
 
   'username' => 'hr',
 
   'password' => 'hr',
 
   'database' => '',
 
   'dbdriver' => 'oci8',
 
   'dbprefix' => '',
 
   'pconnect' => FALSE,
);

//and this

$db['default'] = array(
 
   'dsn'   => 'oci:dbname=localhost/orclpdb',
 
   'port'  => 1521,
 
   'hostname' => '',
 
   'username' => 'hr',
 
   'password' => 'hr',
 
   'database' => '',
 
   'dbdriver' => 'oci8',
 
   'dbprefix' => '',
 
   'pconnect' => FALSE,


//Message: oci_execute(): ORA-00942: table or view does not exist


 
   $db['default'] = array(
 
   'dsn'   => '',
 
   'port'  => 1521,
 
   'hostname' => 'localhost',
 
   'username' => 'hr',
 
   'password' => 'hr',
 
   'database' => 'orclpdb',
 
   'dbdriver' => 'oci8',
 
   'dbprefix' => '',
 
   'pconnect' => FALSE,

//and this

$db['default'] = array(
 
   'dsn'   => 'oci:dbname=localhost/orclpdb',
 
   'port'  => 1521,
 
   'hostname' => 'localhost',
 
   'username' => 'hr',
 
   'password' => 'hr',
 
   'database' => 'orclpdb',
 
   'dbdriver' => 'oci8',
 
   'dbprefix' => '',
 
   'pconnect' => FALSE,

//and this

$dbhost "127.0.0.1"//host 
$dbport"1521"//port default is 1521 
$dbname "orclpdb"//name of database 
$dbuser "hr"//db user with all priviliges
$dbpassword "hr"// password of user
$dbConnString "(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = "$dbhost .")(PORT = "$dbport ."))
)(CONNECT_DATA =(SERVICE_NAME = "
$dbname .")))"// connection string for this we must create TNS entry for Oracle 
$db['default']['hostname'] = $dbConnString;
$db['default']['username'] = $dbuser;
$db['default']['password'] = $dbpassword;
$db['default']['database'] = "";
$db['default']['dbdriver'] = "oci8";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci"
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.