Executing .sql file in oracle using php

Hello friends
I am converting the oracle form into web application.
My requirement is to execute a .sql file when i click on a button in the html form.
What i need to do is when the user click on the button then the sql+ window shoudl open up and a file located on the server should get executed.
Please note i have to do this in php. If any other alternative is there for this requirement then that also is welcomed.
Any help would be appreciated.
Thanks
Vinod

The thing is i am using
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
I am connecting to the DATABASE using
the below php code
=========================
<?php
if (!ini_get('display_errors')) {
ini_set('display_errors', 1);
PutEnv("ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/");
PutEnv("LD_LIBRARY_PATH=-Wl,-rpath,/usr/lib/oracle/xe/app/oracle/product/10.2.0/server//lib -L/usr/lib/oracle/xe/app/oracle/product/10.2.0/server//lib -lclntsh");
$dbstr ="(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XXX.XXX.XXX)(PORT = XXXX))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
if(!@($conn = oci_connect('SYSTEM','passwordString',$dbstr)))
     print_r(ocierror());
else
echo "connected succesfully";
exit;
?>
========================
I am able to connect the database and ececute query and fetch the results.
Now one file will be present in some directory on the server let say abc.sql
Now i need to execute that file and display the output to the user by means of php code.
So please provide me the detailed step on how to get this done.
Thanks

Similar Messages

  • Executing CVS files into Oracle using JDeveloper

    I am incredibly impressed with JDeveloper (11.1.1.4), and am working through a process walk through for our current development groups. We using CVS as our SCM, and I was able to easily connect and navigate the CVS directories.
    I can open the CVS file and view it, but I cannot seem to figure out how to execute/compile that file into a database. For example, when I'm working in development, I want to be able to open files from CVS, edit them, compile them, and then check them back in. Can someone please point out how this is accomplished? I'm sorry - this seems like an easy/silly question, but in all my searching, I'm unable to find the answer.
    Thank you for your time!
    T.j.
    Here is a screenshot of what I see, if that helps.
    Edited by: 910514 on Apr 5, 2012 6:53 AM

    ADF7 wrote:above toolbar from 7 of the last there sql icon. hit it to open the sql workesheet. or else press (alt+f10).Thank you for your quick response!
    This is my issue - I don't want to have to open a separate editor. Here is the process:
    1. Navigate the CVS repository for a file. Open that file for editing. (currently opens as read-only - I'm assuming this is a setting that I need to change)
    2. Make changes and compile into the database.
    3. When finished, commit those changes back into CVS. (this part I can see with the 'Pending Changes' tab)
    Does your response me that I have to copy the code into a SQL Worksheet, do my work, and then copy the changes back into the file?
    Thank you again!

  • How to execute .sql file using ODI

    Hi All,
    I need to execute .sql file using ODI.
    I tried @{path}{file} command in ODI procedure selecting oracle technology.but it is failing.
    Do any one have any other idea to execute .sql file.
    Thanks in advance

    Ohk...I think you can try creating batch file(.bat) if its Windows & call that from ODIOSCommand.
    The bat file should contain scripts which call .sql file using sqlplus  & there you can use @{path}{file} format.
    See if this helps.
    Regards,
    Santy

  • Execute sql files

    Hi,
    I'm trying to execute sql files located in
    unix environment using sqlplus from forms 6i
    in windows Me environment. I give the full
    directory like @/usr/users/oracle/toto.sql.
    But an error occures telling me that file
    cannot found (error SP2 0310).
    I hpe deeply that you can help me, please.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by dany:
    Hi,
    I'm trying to execute sql files located in
    unix environment using sqlplus from forms 6i
    in windows Me environment. I give the full
    directory like @/usr/users/oracle/toto.sql.
    But an error occures telling me that file
    cannot found (error SP2 0310).
    I hpe deeply that you can help me, please.<HR></BLOCKQUOTE>
    Be carreful of upper/lower-case. Unix is case sensitive !! Maybe @/usr/users/oracle/toto.SQL or @/usr/users/oracle/Toto.Sql or ...

  • How to execute sql file from servlet

    Hi,
    I am using JSP, Servlets and Oracle 8i in my application. I want to execute .sql file from java code. Is it possible to do that,
    as we execute .sql file from sql plus prompt.
    Suppose I have abc.sql file and I want to execute it from java code.
    If any body have the solution then pl. reply with sample code.
    Thanks,
    Rajesh

    If any body have the solution then pl. reply with
    sample code.No, no, dec - s/he doesn't want the actual solution, but the full code!
    /k1

  • How to execute .sql file

    hi,
    i want to execute .sql files in sql plus from a fixed location whether it may be network location or from system drive. so that i can use it from other computers when i will be working on different pc.
    so please tell me for network location solution and from drive. by default it fetch from BIN directory
    i am using oracle 10g.
    thanks

    Hi FRNzzz!! wrote:
    if the .sql files are placed on some network place then also i just need to put the path of that directory ? Sure. You can either set up a desktop shortcut for SQL*Plus using the remote folder as the "Start in" location, or (what I usually do) drag the script file into your SQL*Plus window.
    Edited by: William Robertson on Feb 26, 2011 2:21 PM

  • How to execute .sql file in Stored Procedure?

    Hi,
    I have an urgent requirement, where i have to execute .sql file form Stored Procedure.
    This .sql file will have set of update statement. I need to pass value to this update statement.
    Kindly please help me.
    Regards,
    Irfan

    This is required as part of Data Migration where  i have to do 100 of table's update. Each time update table will defer, so its better to have in separate script file (.sql). Can u paste some sample/syntax to exceute .sql file from stored procedure. I am new to this PL/SQL.
    How have you determined that it's "better" to have seperate scripts?  I assume you mean the table name will "differ" (and not "defer" - I assume that's just because English isn't your first language? no problem - I think I understand what you're asking).
    So what I think you're asking is that you have dynamic table names but each table needs to be updated in the same way?
    Question: Why do you have tables with different names that all need the same process doing to them?
    Assuming it's a valid requirement (and 99% of the time doing dynamic coding implies it's not).... you could use dynamic code, rather than 'scripts'...
    e.g.
    create procedure update_table(tbl_name varchar2) is
    begin
      execute immediate 'update '||tbl_name||' set lastupdate = null';
    end;
    As you haven't bothered to provide a database version, any example code/data or explanation of what you're actually doing, you're not going to get any detailed answer.  Please do take the time to read the FAQ and post appropriate details so people can help you.

  • Is it possible to run .sql files in oracle

    Hi
    I have a .sql file which contains the scripts of the tables .Is it possible for me to run the .sql file in oracle or will i have to run the scripts of each tables separately becoz there is about 240 table scripts in that single .sql file. In mysql by giving " \.filename.sql " the whole scripts in the .sql file will get executed .Is there any thing like this in oracle9i.Also i want to know how to make a dump file in oracle and to run that?
    Thanking you in advance

    Hi
    I did the way u said the whole script file is running but the execution of the script is not happening. The below is a part of script but the table creation is not happening at the end of each table script
    5946 drop table lms_class_permission;
    5947 CREATE TABLE lms_class_permission (
    5948 pk_permission_id NUMBER(11) NOT NULL ,
    5949 fk_class_Id NUMBER(11) default NULL,
    5950 fkSysGroupId NUMBER(11) default NULL,
    5951 perm NUMBER(11) default '0',
    5952 CONSTRAINT pk_permission_id_lms_class PRIMARY KEY (pk_permission_id),
    5953 CONSTRAINT uk_lms_class_permission UNIQUE (fk_class_Id,fkSysGroupId),
    5954 CONSTRAINT fk_lms_Class_Permission_1 FOREIGN KEY (fk_class_Id) REFERENCES lms_class (pk_class
    5955 CONSTRAINT fk_lms_Class_Permission_2 FOREIGN KEY (fkSysGroupId) REFERENCES t_system_groups (g
    5956 );
    5957 create index fk_class_Id_lms_class_perm on lms_class_permission (fk_class_Id);
    5958 create index fkSysGroupId on lms_class_permission (fkSysGroupId);
    5959 CREATE SEQUENCE lms_class_permission_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NO
    5960 CREATE OR REPLACE TRIGGER TR_lms_class_permission_BI
    5961 BEFORE INSERT
    5962 ON lms_class_permission
    5963 REFERENCING NEW AS NEW OLD AS OLD
    5964 FOR EACH ROW
    5965 BEGIN
    5966 SELECT lms_class_permission_SEQ.NEXTVAL INTO :NEW.pk_permission_id FROM dual;
    5967 END ;
    5968 drop table lms_contact_us ;
    5969 CREATE TABLE lms_contact_us (
    5970 pkautoid NUMBER(10) not null ,
    5971 user_name VARCHAR2(255) default '0',
    5972 email VARCHAR2(255) default '0',
    5973 subject VARCHAR2(1000),
    5974 message VARCHAR2(1000),
    5975 loginId VARCHAR2(255) default NULL,
    5976 status NUMBER(11) default NULL,
    5977 classId NUMBER(11) default NULL,
    5978 CONSTRAINT pkautoid_lms_contact_us PRIMARY KEY (pkautoid)
    5979 );
    5980 CREATE SEQUENCE lms_contact_us_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NOCYCLE NO
    5981 CREATE OR REPLACE TRIGGER TR_lms_contact_us_BI
    5982 BEFORE INSERT
    5983 ON lms_contact_us
    5984 REFERENCING NEW AS NEW OLD AS OLD
    5985 FOR EACH ROW
    5986 BEGIN
    5987 SELECT lms_contact_us_SEQ.NEXTVAL INTO :NEW.pkautoid FROM dual;
    5988 END ;
    5989 drop table borland_feedback ;
    5990 CREATE TABLE borland_feedback (
    5991 pkautoid NUMBER(10) not null ,
    5992 FeedTitle VARCHAR2(1000),
    5993 FeedBody VARCHAR2(1000),
    5994 EnteredBy NUMBER(11) default '0',
    5995 FeedStatus NUMBER(11) default '0',
    5996 FeedEnteredDate TIMESTAMP,
    5997 CONSTRAINT pkautoid_borland_feedback PRIMARY KEY (pkautoid)
    5998 );
    5999 CREATE SEQUENCE borland_feedback_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NOCYCLE
    6000 CREATE OR REPLACE TRIGGER TR_borland_feedback_BI
    6001 BEFORE INSERT
    6002 ON borland_feedback
    6003 REFERENCING NEW AS NEW OLD AS OLD
    6004 FOR EACH ROW
    6005 BEGIN
    6006 SELECT borland_feedback_SEQ.NEXTVAL INTO :NEW.pkautoid FROM dual;
    6007 END ;
    Thanking you advance
    dinny

  • How to execute SQL statement with oracle jdev

    Please I'm a beginner in oracle jdeveloper. I want to know how to use and execute sql statememt within oracle Jdeveloper 10 g release 3 to manipulate objects in oracle database. I want for e.g. to Enable/disable trigger using sql statement "ALTER TRIGGER trigername DISABLE" explicitly. Please tell me how to proceed.
    i am sure you can help me
    Sincerly yours.

    Hi,
    Using following tutorial http://www.oracle.com/technology/obe/ADF_tutorial_1013/10131/index.htm
    you will found how to connect from Jdev to a database (chapter 1 or 2 ?). Then you just have to go under Tool>SQL*Plus or Tools>SQL Worksheet depending on what you need.
    Luck,
    Tif

  • Can i import .sql file into oracle apex?

    i'm new to oracle apex....
    Can i import .sql file into oracle apex?
    i've to import a table into apex...
    what script i have to write into the .sql file....
    pls help...
    Edited by: 794244 on Jan 31, 2011 9:31 PM

    Hi Mahesh
    Navigate to the APEX documentation page - all the documents are listed there ;) (including direct links to the step-by-step "how-to's" - great stuff)
    http://www.oracle.com/technetwork/developer-tools/apex/documentation/index.html
    Enjoy the wonderful world of APEX!
    Mike

  • Importing and executing a .sql file into  Oracle 10g

    Hi
    I am looking to import and execute a .sql file(create scripts created of a databse designed in MS SQL Server 2005). The file was imported into Oracle APEX 3.10 but we are unable to execute the script. Please suggest alternatives as to how we can import these files.
    Thanks in advance.

    You likely need to migrate the database (objects and data). This is not so easy and you should have a look to migration tools: http://www.oracle.com/technology/oramag/oracle/07-sep/o57sql.html.

  • Execute .sql file using JDBC

    I have a .sql file which contains a SELECT query and spools the ouput into a .txt file.
    The problem is, I have some formatting queries like SET LINESIZE 500 etc.
    How do I execute the .SQL file

    vignesh_shrinivasan wrote:
    I have a .sql file which contains a SELECT query and spools the ouput into a .txt file.
    The problem is, I have some formatting queries like SET LINESIZE 500 etc.
    How do I execute the .SQL fileYou have a file which has SQLPLUS script.
    Nothing you do will make SQLPLUS command statements work via JDBC.
    There are only two options.
    1. Create a PL/SQL which does the same thing.
    2. Use SQLPLUS and do not use jdbc.

  • How to execute SQL queris in BPEL using JDeveloper?????..Please suggest

    Hi,
    I am very new to JDeveloper. Curently i am tryin to execute an SQL query from the BPEL process, there is an query in the source field and the output of the query is to be mapped to a variable field in the target xsd file. the query is fairly simple, like
    SELECT emp
    FROM emp_table
    WHERE emp_id=123
    The target field, namely "employee", is an element from the xsd file. I tried using Java embedding activity to connect to the db and execute the query through a piece of Java code, but couldn't find a way to assign the output of the query to the associated target field. however lately i also discovered the Database Adapter services which helps me to create a database connection, but still i am not sure as of how to handle and map the output of the query to the variable field. Is there any other way to execute database queries in Jdeveloper using BPEL process????????? Please suggest.
    Can somebody please help me in resolving the issue either through Java Embed activity or Database Adapter services??
    Thanks in advance
    Prabha

    http://download.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/adptr_db.htm
    maybe this one is helpful for you.
    best is to use the db adapter for this.
    if you just execute it you will see the format of the output in your audittrial (so some kind of list of employees). In bpel when you doubleclick the invoke-activity you will see the outputvariable.
    With use of xpath you coud loop over this 'list' (collection/array/etc) of employees and do with it whatever you want.
    Too see how you need to loop over the array you could check this :
    http://clemensblog.blogspot.com/2006/03/bpel-looping-over-arrays-collections.html

  • Executing SQL FILE to generate CSV

    I have xxxxx.sql file, I need to execute it against Oracle10g(10.2.0.1.0) databse and should get the output as CSV file.
    What is the best way doing it using Oracle proceduer/ function, etc... and I can call it using Java class

    If you cannot create it in SQL/Plus beforehand, you can still read it (e.g. using FileInputStream) with Java and use executeQuery() with PreparedStatement.
    You can find some open source library (e.g. opencsv) to read the ResultSet with CSVWriter(java.io.Writer writer, char separator, char quotechar), and then output to a file with writeAll(java.sql.ResultSet rs, boolean includeColumnNames).
    regards,
    a.t.

  • Executing *.sql files from jdbc

    Hi, does anyone know how can I execute an sql file using jdbc?
    Please make me know, tnx.
    Regards

    Check this out.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:14961192831279021580::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:952229840241,

Maybe you are looking for

  • Previewing images in forms 11g from the server

    Hi All, i need your help in this issue please i've just migrated my application from forms 6i to forms 11g there is a function in my application that i used that previewed images that exists on a network drive that are used in an image gallary now i

  • HP Officejet Pro X576dw MFP (CN598A) Total memory question

    Hello, We bought a HP Officejet Pro X576dw MFP (CN598A), and we noticed something weird on the printer's web settings page. The specification on the hp website states that this printer comes with: - Memory, standard 768 MB (Not expandable) - Memory,

  • Unable to connect to report server - on Win 8.1 and SQL Server 2014

    unable to connect to report server on  Win 8.1 and SQL Server 2014 version Microsoft SQL Server 2014 - 12.0.2000.8 (Intel X86)     Feb 20 2014 19:20:46     Copyright (c) Microsoft Corporation     Express Edition on Windows NT 6.3 <X64> (Build 9600: )

  • How can I get the username of the person currently logged in?

    I have built a custom authentication scheme and I am building a form page and I would like to show the username of the person who is currently logged in? How can I do this......

  • Condition Pricing Date

    Hi, I have a PO made on 17/02/2011. but when I check its pricing details it shows CondPricingDate - 25/11/2011. How is this possible?