CodeIgniter Forums
getting message: oci_execute(): ORA-00942: table or view does not exist - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: getting message: oci_execute(): ORA-00942: table or view does not exist (/showthread.php?tid=72115)

Pages: 1 2 3


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - Ahmed Haroon - 11-12-2018

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>";
}
?>



RE: getting message: oci_execute(): ORA-00942: table or view does not exist - InsiteFX - 11-13-2018

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

If so can you post here that file.


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - InsiteFX - 11-13-2018

I will look at the files and get back to you.


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - InsiteFX - 11-13-2018

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.


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - Ahmed Haroon - 11-13-2018

(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?


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - Ahmed Haroon - 11-13-2018

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;
 
   



RE: getting message: oci_execute(): ORA-00942: table or view does not exist - php_rocs - 11-13-2018

@ahmed Haroon,

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


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - Ahmed Haroon - 11-13-2018

(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.


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - php_rocs - 11-14-2018

@ahmed Haroon,

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


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - Ahmed Haroon - 11-14-2018

(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"