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


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

hi all,

I am very new to Codeigniter, I am creating a Form to get Oracle's default HR schema table departments data but it showing error:

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

the same things working for MySQL database, with just change 2 lines in model, my model file is as below:

Quote:<?php
//public $db;

class dep_models extends CI_Model{

function __construct()//model construct function
{
    parent::__construct();
    $this->oracle_db=$this->load->database('oracle',true); // oracle db
    //$this->db=$this->load->database('default',true); // mysql db
}

function getDept(){
   //return $this->oracle_db->get('departments')->result();
   $result=$this->oracle_db->get('departments'); // oracle db
   //$result=$this->db->get('departments'); // mysql db
   return $result;
}
}
?>

when un-comment lines with "mysql db" and simply refresh page, it works fine but for "oracle db" it is showing error but it seems connected successfully. 
please help as i am working on Oracle database.

regards


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

This is wrong CodeIgniter CI_Model has no constructor so you cannot use 
PHP Code:
parent::__construct(); 

This is how it should be, see how the class name is ucfirst uppercase it also needs to be saved that way.
PHP Code:
class Dep_models extends CI_Model
{
 
   private $oracle_db;

 
   public function __construct() //model construct function
 
   {
 
       $this->oracle_db $this->load->database('oracle',true); // oracle db
 
   }

 
   public function getDept()
 
   {
 
       $query $this->oracle_db->get('departments')
 
                     ->result();

 
       return $query;
 
   }


Of course you would need to add error checking on all of your database code.
Use Google to search for what you need.


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

@ahmed Haroon,

What does your config file look like?

Your hostname should be something along this line...

'hostname' => '123.345.456.21:1521/SSID',


RE: getting message: oci_execute(): ORA-00942: table or view does not exist - dave friend - 11-08-2018

(11-08-2018, 10:05 AM)InsiteFX Wrote: This is wrong CodeIgniter CI_Model has no constructor so you cannot use 
PHP Code:
parent::__construct(); 

I admit I'm being pedantic here, but CI_Model does have a constructor. It is empty, but it's there. So you're right in the sense that making the call is pointless.


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

(11-08-2018, 10:05 AM)InsiteFX Wrote: This is wrong CodeIgniter CI_Model has no constructor so you cannot use 
PHP Code:
parent::__construct(); 

This is how it should be, see how the class name is ucfirst uppercase it also needs to be saved that way.
PHP Code:
class Dep_models extends CI_Model
{
 
   private $oracle_db;

 
   public function __construct() //model construct function
 
   {
 
       $this->oracle_db $this->load->database('oracle',true); // oracle db
 
   }

 
   public function getDept()
 
   {
 
       $query $this->oracle_db->get('departments')
 
                     ->result();

 
       return $query;
 
   }


Of course you would need to add error checking on all of your database code.
Use Google to search for what you need.

thanks very much for reply and guidance. still getting same error, i am posting here code of files as below:

in Controller folder, file name Depts.php
PHP Code:
<?php
class Depts extends CI_Controller{
 
 function __construct(){
 
   parent::__construct();
 
   $this->load->model('dep_models');
 
 }
 
 function index(){
 
   $data['departments'] = $this->dep_models->getDept();
 
   $this->load->view('dep_view',$data);
 
 }
}
?>

in Model folder, Dep_Models.php
PHP Code:
<?php
class Dep_models extends CI_Model
{
 
   private $oracle_db;

 
   public function __construct() //model construct function
 
   {
 
       $this->oracle_db $this->load->database('oracle',true); // oracle db
 
   }

 
   public function getDept()
 
   {
 
       $query $this->oracle_db->get('departments')->result();

 
       return $query;
 
   }

?>

in config folder, file database.php
PHP Code:
$active_group 'oracle';
$query_builder TRUE;

$db['oracle'] = array(
 
   'dsn'   => '',
 
   'hostname' => '127.0.0.1:1521/orclpdb',
 
   //'hostname' => 'localhost',
 
   'username' => 'hr'
 
   'password' => 'hr',
 
   'database' => 'orclpdb',
 
   '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,
 
   'save_queries' => TRUE,
); 

Error:
Quote:A PHP Error was encountered
Severity: Warning

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

Filename: oci8/oci8_driver.php

Line Number: 286

Backtrace:

File: C:\wamp64\www\myproject\application\models\dep_models.php
Line: 13
Function: get

File: C:\wamp64\www\myproject\application\controllers\Depts.php
Line: 8
Function: getDept

File: C:\wamp64\www\myproject\index.php
Line: 315
Function: require_once

------------------------------------------------------------------------------------------------------

A Database Error Occurred
Error Number: 942

ORA-00942: table or view does not exist

SELECT * FROM "departments"

Filename: C:/wamp64/www/myproject/system/database/DB_driver.php

Line Number: 691

if anything else, i can share because all are just Test / Practice files.
regards


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

(11-08-2018, 10:12 AM)php_rocs Wrote: @ahmed Haroon,

What does your config file look like?

Your hostname should be something along this line...

'hostname' => '123.345.456.21:1521/SSID',

thanks for your reply, I have posted above my database.php entry for Oracle database.
regards


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

Did you save your model with the first character upper case?

Dep_models.php


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

(11-09-2018, 04:45 AM)InsiteFX Wrote: Did you save your model with the first character upper case?

Dep_models.php

thank you Smile

No, I didn't...


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

@ahmed Haroon,

Are you still getting an error message? Is it working for you now?


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

thanks @php_rocs, i already have mentioned in my reply to @InsiteFX that getting same error (also posted program codes and complete errors), now I can test anything on coming Monday if I someone guide me.
I have following environment ( on VM )
Win 8.1, Oracle Database 12c Release 2, WAMP current version.

also edited file php.ini in Apache to have oci_12c.

regards