I'm trying to execute a simple .sql file that resets my database. It works fine when I run it in sqlplus with @, but returns ORA-00922: missing or invalid option, when I run it using php like that:
$query = file_get_contents($path);
$stid = oci_parse($con, $query);
$r = oci_execute($stid);
Here is the .sql file itself, it's quite simple and I simply can't find anything that is wrong with the commands:
ALTER SESSION SET NLS_LANGUAGE = AMERICAN;
ALTER SESSION SET NLS_TERRITORY = AMERICA;
DROP TABLE users;
DROP TABLE friends;
DROP TABLE replies;
DROP TABLE tweets;
DROP TABLE retweets;
DROP TABLE mentions;
DROP TABLE hashtags;
CREATE TABLE users (
id_str VARCHAR2(20) NOT NULL PRIMARY KEY,
name VARCHAR2(40) NOT NULL,
screen_name VARCHAR2(20) NOT NULL,
followers NUMBER(9) NOT NULL,
friends NUMBER(9) NOT NULL
);
CREATE TABLE friends (
id1_str VARCHAR2(20) NOT NULL,
id2_str VARCHAR2(20) NOT NULL,
CONSTRAINT friendship PRIMARY KEY (id1_str, id2_str)
);
CREATE TABLE replies (
id1_str VARCHAR2(20) NOT NULL,
id2_str VARCHAR2(20) NOT NULL,
CONSTRAINT reply PRIMARY KEY (id1_str, id2_str)
);
CREATE TABLE tweets (
id_str VARCHAR2(20) NOT NULL PRIMARY KEY,
user_id_str VARCHAR2(20) NOT NULL,
created DATE NOT NULL
);
CREATE TABLE retweets (
user_id_str VARCHAR2(20) NOT NULL,
tweet_id_str VARCHAR2(20) NOT NULL,
CONSTRAINT retweet PRIMARY KEY (user_id_str, tweet_id_str)
);
CREATE TABLE hashtags (
tweet_id_str VARCHAR2(20) NOT NULL,
text VARCHAR2(140) NOT NULL,
CONSTRAINT hashtag PRIMARY KEY (tweet_id_str, text)
);
CREATE TABLE mentions (
user_id_str VARCHAR2(20) NOT NULL,
tweet_id_str VARCHAR2(20) NOT NULL,
CONSTRAINT mention PRIMARY KEY (user_id_str, tweet_id_str)
);
COMMIT;
I know it's probably silly, but I've spent hours looking for the solution to no avail and would appreciate any tips (even a different method than loading this file).
commitat the end when running with php?begin / endbefore and after the script. Another try would be to run each statement in differentoci_executecall. Not sure if multiple statements is possible with oci and php.