oracle10g

oci_connect() works only from command line

我怕爱的太早我们不能终老 提交于 2019-12-30 18:51:07
问题 OK, so I have this terrible problem with oci, apache, php and suse. First off, versions: PHP 5.3.15 (cli) Apache/2.2.22 (Linux/SUSE) OCI8 1.4.9 SUSE 12.2 32 bit Oracle client 10.2.0.4 Problem I have really simple php file: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); oci_connect('user', 'passwd', 'host/sid'); ?> When I run it from command line it executes fine: machine:~ # php oci.php machine:~ # But when i run it in browser, it gives me: Warning: oci_connect() [function.oci

Oracle SQL: select from table with nested table

若如初见. 提交于 2019-12-30 08:35:09
问题 I wonder how can i make select statement from table which have a typed column ? Type of this column is defined as: create or replace TYPE "MYCOL" as table of MYTYPE; create or replace TYPE "MYTYPE" as OBJECT ( myid Number, myname Varchar2); UPD1 Table is defined as CREATE TABLE "T_TABLE" ( "ID" NUMBER NOT NULL ENABLE, "NAME" "MYCOL" ) If i select this column with select * from T_TABLE i will get this not informative result: 1, MYSCHEMA.MYCOL([MYSCHEMA.MYTYPE],[MYSCHEMA.MYTYPE]) I want just to

How to override >2499 character error in Oracle DB?

时间秒杀一切 提交于 2019-12-30 06:42:27
问题 I have a Oracle query which I'm executing through shell script and in that my query is getting exceeded the maximum length of 2499. I'm getting error SP2-0027: INPUT IS TOO LONG(> 2499 CHARACTERS) - LINE IGNORED 回答1: Here are some options for working around SQL*Plus line length limitations: Upgrade to 12.2(?) client. On 12.2 the client allows up to 4999 characters. Which is infuriating in a way - if Oracle finally admits that 2499 is not enough, why did they only increase the limit to 4999?

How to find top three highest salary in emp table in oracle?

眉间皱痕 提交于 2019-12-30 01:30:12
问题 How to find top three highest salary in emp table in oracle? 回答1: SELECT *FROM ( SELECT *FROM emp ORDER BY Salary desc ) WHERE rownum <= 3 ORDER BY Salary ; 回答2: You can try. SELECT * FROM ( SELECT EMPLOYEE, LAST_NAME, SALARY, RANK() OVER (ORDER BY SALARY DESC) EMPRANK FROM emp ) WHERE emprank <= 3; This will give correct output even if there are two employees with same maximun salary 回答3: Something like the following should do it. SELECT Name, Salary FROM ( SELECT Name, Salary FROM emp ORDER

Can I create Foreign Keys across Databases?

爱⌒轻易说出口 提交于 2019-12-29 07:38:08
问题 We have 2 databases - DB1 & DB2. Can I create a table in DB1 that has a relation with one of the tables in DB2? In other words, can I have a Foreign Key in my table from another database? I connect to these databases with different users. Any ideas? Right now, I receive the error: ORA-00942:Table or view does not exist 回答1: No, Oracle does not allow you to create a foreign key constraint that references a table via a database link. You would have to use triggers to enforce the integrity. 回答2:

DISTINCT results in ORA-01791: not a SELECTed expression

我是研究僧i 提交于 2019-12-28 16:30:24
问题 select DISTINCT a.FNAME||' '||a.LNAME from AUTHOR a, books B, BOOKAUTHOR ba, customers C, orders where C.firstname='BECCA' and C.lastname='NELSON' and a.AUTHORID=ba.AUTHORID and b.ISBN=bA.ISBN order by a.LNAME gives ORA-01791: not a SELECTed expression but works without DISTINCT. How to make it work? 回答1: Just add LNAME as a column on its own in the select clause: SELECT full_name FROM ( select DISTINCT a.FNAME||' '||a.LNAME AS full_name, a.LNAME from AUTHOR a, books B, BOOKAUTHOR ba,

How do I use CREATE OR REPLACE?

ⅰ亾dé卋堺 提交于 2019-12-28 08:06:08
问题 Am I correct in understanding that CREATE OR REPLACE basically means "if the object exists, drop it, then create it either way?" If so, what am I doing wrong? This works: CREATE TABLE foo (id NUMBER, title VARCHAR2(4000) DEFAULT 'Default Title') And this doesn't (ORA-00922: missing or invalid option): CREATE OR REPLACE TABLE foo (id NUMBER, title VARCHAR2(4000) DEFAULT 'Default Title') Am I doing something stupid? I don't seem to be able to find much documentation about this syntax. 回答1: This

How to kill a running SELECT statement

纵饮孤独 提交于 2019-12-27 16:59:18
问题 How can I stop a running SELECT statement by killing the session? The command is continuously giving me output based on the SELECT statement, I want to stop it in between. 回答1: As you keep getting pages of results I'm assuming you started the session in SQL*Plus. If so, the easy thing to do is to bash ctrl + break many, many times until it stops. The more complicated and the more generic way(s) I detail below in order of increasing ferocity / evil. The first one will probably work for you but

null vs empty string in Oracle [duplicate]

谁说我不能喝 提交于 2019-12-27 12:16:45
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Why does Oracle 9i treat an empty string as NULL? I have a table in Oracle 10g named TEMP_TABLE with only two columns - id and description just for the sake of demonstration. The column id is a sequence generated primary key of type NUMBER(35, 0) not null and the column DESCRIPTION is a type of VARCHAR2(4000) not null . The basic table structure in this case would look something like the following. +------------

handle special characters in PL/SQL procedures.?

岁酱吖の 提交于 2019-12-25 18:28:05
问题 I'm using oracle 10g plsql procedures for inserting and listing, but if we have any special characters like ' (single quote ) and & etc. query fails. How to handle special characters in plsql? before: lquery := 'select count(id) into lCount From dual where name = '||iName||' and Id= '||iId after: select into lCount From dual where Id= iId and name = iName; after changing the query its working fine. Problem is if we keep variable like name value inside single quotes some times query wont