473,385 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with Oracle VARRAY and PHP

I have following code on my page....

$ora_tns =
"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP )(HOST=pirana)(PORT=1521))
)(CONNECT_DATA=(SID=pirana)(SERVER=DEDICATED)))";
$ora_username = "username";
$ora_password = "pwd";

$db = OCILogon($ora_username, $ora_password, $ora_tns);

$arr = OCINewCollection($db, 'LOCAL_ID_ARRAY');
$err = ocierror($db);
When I execute it on a simple page containing only this everything works
fine.....

However, when I put it on a larger page containing other stuff using other
oracle connections I get following error when trying to create collection:
"OCI-21522: attempted to use an invalid connection in OCI (object mode
only)"

What is the source of this error and how can I correct it....

LOCAL_ID_ARRAY is defined in Oracle as:
CREATE OR REPLACE TYPE local_id_array AS VARRAY(100) OF NUMBER(11);

Thank you in advance, Tomy.
Jul 17 '05 #1
6 3892
Forgot to mention:

Apache/1.3.29 (Win32) PHP/4.3.3
OCI8 Support enabled
Revision $Revision: 1.183.2.5 $

Tomy.
Jul 17 '05 #2
[ Followup-To: comp.lang.php ]

Tomislav Petrovic wrote:
$db = OCILogon($ora_username, $ora_password, $ora_tns);


I have never used OCI*, but it pays to do error checking no matter what
you use.

Try showing ocierror() after every OCI* function you use.
$db = OCILogon($ora_username, $ora_password, $ora_tns) or die(ocierror());
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
Pedro Graca wrote:
Try showing ocierror() after every OCI* function you use.
$db = OCILogon($ora_username, $ora_password, $ora_tns) or
die(ocierror());


Thanks for the comment, I do check this but have omitted it for
simplicity...
And unfortunately my problem is not in OCILogon but OCINewCollection...

Tomy.
Jul 17 '05 #4
Tomislav Petrovic wrote:
Thanks for the comment, I do check this but have omitted it for
simplicity...
Oh! ok, sorry
And unfortunately my problem is not in OCILogon but OCINewCollection...


I meant that ocierror() should be checked for all OCI functions.

Anyway, after googling for "attempted to use an invalid connection in
OCI (object mode only)" I got this page:

http://www.engin.umich.edu/caen/wls/...202/e19400.htm

which states

ORA-21522 attempted to use an invalid connection in OCI (object mode
only)

Cause: User attempted to use an invalid connection or a connection
that has been terminated in an OCI environment (object mode), or
user attempted to de-reference a REF obtained from a connection
which has been terminated.

Action: Ensure that the connection exists and is still valid.
Maybe the connection closed for some reason.
Can you do something like:

if (!connected()) {
reconnect();
}

before every OCINewCollection?
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #5
On Wed, 7 Jan 2004 13:08:35 +0100, "Tomislav Petrovic" <t.********@inet.hr>
wrote:
I have following code on my page....

$ora_tns =
"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TC P)(HOST=pirana)(PORT=1521))
)(CONNECT_DATA=(SID=pirana)(SERVER=DEDICATED))) ";
$ora_username = "username";
$ora_password = "pwd";

$db = OCILogon($ora_username, $ora_password, $ora_tns);

$arr = OCINewCollection($db, 'LOCAL_ID_ARRAY');
$err = ocierror($db);
When I execute it on a simple page containing only this everything works
fine.....

However, when I put it on a larger page containing other stuff using other
oracle connections I get following error when trying to create collection:
"OCI-21522: attempted to use an invalid connection in OCI (object mode
only)"

What is the source of this error and how can I correct it....

LOCAL_ID_ARRAY is defined in Oracle as:
CREATE OR REPLACE TYPE local_id_array AS VARRAY(100) OF NUMBER(11);

Which version of Oracle?

Can you reduce it to a simple testcase?

The error implies the connection's dropped; can you try a simple select after
the error to see if you get ORA-03114 not connected to Oracle?

If the connection has dropped, is there anything in the database alert log, or
a stack trace in your database's cdump directory if the Oracle process crashed?

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #6
Andy Hassall wrote:
Which version of Oracle? 9.2....
Can you reduce it to a simple testcase? No. That's my problem....
When I do everything I did on a simple page one after another, it
works like a charm...
But when I separate it into class methods and invoke them one after another
it does not :(
The error implies the connection's dropped; can you try a simple
select after the error to see if you get ORA-03114 not connected to
Oracle?

It is not dropped. Simple select or store procedure call after
works ok.

Tomy.
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: PedroSilva | last post by:
I need to know how to get a collection (varray), basically it's an array of chars with size of 9999 positions, from oracle so I can use it as an array with php. There's very little documentation...
1
by: KVN Chary | last post by:
I wrote a small package and it successfully compiled. When I test the package it was giving an error. Please look into the below code. Can anyone written Varrays as input and output variables in...
0
by: Anbazhagan | last post by:
Hi, I'm using Oracle 9i with Spatial to store geographical data. It has only hundreds of features with very minimal veritices. I use OO4O (Oracle InProc) as component to access the oracle server...
0
by: arvind | last post by:
Hello, We have been working on migrating oracle database to postgres for one of our client. We have a stored procedure in oracle which uses varray and I have to convert this stored procedure to...
3
by: sam.lumbroso | last post by:
I have the following object type created in Oracle (OCI8): create or replace type address as object ( address VARCHAR2(80), city VARCHAR2(80), state VARCHAR2(20), zip VARCHAR2(10) )
3
by: Tony Marston | last post by:
I am using PHP 4.4.4 with Oracle 10g Express Edition on Windows XP. I am trying to emulate in Oracle the SET datatype in MySQL and the ARRAY datatype in PostgreSQL I have the created a...
0
by: Aravindkumar | last post by:
Hi My name is Aravind. I would like to know how VARRAY and NESTED TABLES can be used in Oracle Stored Procedures / Packages. Please treat this as urgent Aravind
0
debasisdas
by: debasisdas | last post by:
RESTRICTIONS ON CURSOR VARIABLES ================================= Currently, cursor variables are subject to the following restrictions: Cannot declare cursor variables in a package spec. ...
2
by: NewToOracle | last post by:
Hi. Here is the code I tried for the use of the varray..I am trying to dump the values into the array using for loop.. But it's giving the error "error : Trying to access uninitialized object" ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.