How to execute pl/sql block from a file

hi all,
can anybody tell me how to execute a pl/sql block from a file.it wont contain any procedures.it is of the form
--begin
--declare
--end;
Thanx

Here is the file
File is stored in C Drive (Windows Environment)
declare
x number;
begin
select 1 into x from dual;
dbms_output.put_line(x);
end;
SQL> @c:\t.sql;
1
PL/SQL procedure successfully completed.Are you facing any issues?
Regards,
Bhushan

Similar Messages

  • How to execute a  .sql file from a batch file

    Hi all
    I've to take backup of a database weekly twice on every wednesday & Friday @ 5pm IST. I've written a hot backup script, which works every well.
    now i want to automate the script. ie i want this script to run on wednesday & friday @ 5pm without any human interfearance ie with out actually any1 executing this script.
    i created a batch file prod.bak with the following lines
    @echo off
    set oracle_sid=testdb
    set oracle_home=d:\oracle\ora92
    sqlplus /nolog
    connect sys as sysdba/oracletest@testdb
    this batch file when eexecuted connects me to sql prompt.
    Now i want to execute my backup script bkp.sql automatically when it is connected to sql prompt.
    (i tried with these lines in the above batch file...
    call bkp.sql---it just opens the bkp.sql file in notepad & displays the script
    start bkp.sql---same as call
    connect / as sysdba/pwd@[email protected] --- does not work simply remains a the sql prompt.
    At 17:00 /Every:w,f "d:\bkp.sql"---does not work simply remains at the sql promt.)
    Can any1 let me know what should i write in the batch file that will execute the bkp.sql file automatically after it gets connected to sql prompt. M using oracle 9i.
    I'll manage he time through windows utility of scheduling task.. Let me know how to execute the .sql file from a batch file.
    Thanks
    Tripti

    Try
    sqlplus "sys/oracletest as sysdba" @bpk.sql
    Working locally, and having set the ORACLE_SID, you don't need to specify the SqlNet alias (@testdb).
    Remember to put an exit at the end of the bpk.sql script.

  • How execute pl/sql command from Oracle ADF Business Components

    can't find examples for how execute pl/sql command from Oracle ADF Business Components and how call pl/sql package procedure from ADF Business Components.
    insert,update,delete rows in view object instance cache is good but if i must do some complex operations while insert,update,delete rows..it's more better for me to call
    pl/sql procedure from oracle db.Am i wrong ????

    Roman,
    this should be similar to how it worked in JDeveloper 9.0.3. hava a look at <JDev903 Home>\BC4J\samples\StoredProc for a code example.
    Frank

  • How to execute an SQL query present in a string inside an ABAP program?

    hello,
    How to execute an SQL query present in a string inside an ABAP program

    Raut,
    You can execute Native SQl statements.
    Ex: To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
    EXEC SQL [PERFORMING <form>].
      <Native SQL statement>
    ENDEXEC.
    There is no period after Native SQL statements. Furthermore, using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax. You need to know whether table and field names are case-sensitive in your chosen database.
    In Native SQL statements, the data is transported between the database table and the ABAP program using host variables. These are declared in the ABAP program, and preceded in the Native SQL statement by a colon (:). You can use elementary structures as host variables. Exceptionally, structures in an INTO clause are treated as though all of their fields were listed individually.
    If the selection in a Native SQL SELECT statement is a table, you can pass it to ABAP line by line using the PERFORMING addition. The program calls a subroutine <form> for each line read. You can process the data further within the subroutine.
    As in Open SQL, after the ENDEXEC statement, SY-DBCNT contains the number of lines processed. In nearly all cases, SY-SUBRC contains the value 0 after the ENDEXEC statement. Cursor operations form an exception: After FETCH, SY-SUBRC is 4 if no more records could be read. This also applies when you read a result set using EXEC SQL PERFORMING.
    EXEC SQL PERFORMING loop_output.
      SELECT connid, cityfrom, cityto
      INTO   :wa
      FROM   spfli
      WHERE  carrid = :c1
    ENDEXEC.
    Pls. Mark If useful

  • How to execute this SQL Query in ABAP Program.

    Hi,
    I have a string which is the SQL Query.
    How to execute this sql Query (SQL_STR) in ABAP Program.
    Code:-
    DATA: SQL_STR type string.
    SQL_STR = 'select * from spfli.'.
    Thanks in Advance,
    Vinay

    Hi Vinay
    Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
    REPORT dynamic_sql_example .
    DATA: BEGIN OF gt_itab OCCURS 1 ,
    line(80) TYPE c ,
    END OF gt_itab .
    DATA gt_restab TYPE .... .
    DATA gv_name(30) TYPE c .
    DATA gv_err(120) TYPE c .
    START-OF-SELECTION .
    gt_itab-line = 'REPORT generated_sql .' .
    APPEND gt_itab .
    gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
    APPEND gt_itab .
    gt_itab-line = SQL_STR .
    APPEND gt_itab .
    gt_itab-line = 'ENDFORM.' .
    APPEND gt_itab .
    GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
    PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
    IF FOUND .
    WRITE:/ gv_err .
    LOOP AT gt_result .
    WRITE:/ .... .
    ENDLOOP .
    *--Serdar

  • How to execute a SQL procedure in UNIX

    How to execute a SQL procedure in UNIX

    Check this out..
    -Sri
    << a.sql >>
    create or replace procedure junk(nout out varchar2) is
            x varchar2(20);
    begin
            select 'Sam' into x
            from dual;
            nout := x;
    end;
    << Shell script >>
    sqlplus -s / << DOC
    scott/tiger
    variable x varchar2(20);
    set autoprint on
    @a.sql
    begin
    junk(:x);
    end;
    exit
    DOC
    << Execution of Shell SCript >>
    # sh b.sh
    Procedure created.
    PL/SQL procedure successfully completed.
    X
    Sam

  • Patterns to execute a SQL Statement from a Droplet (select)

    Hi,
    I need to perform a query on a table, Example: select * from ARF_QUERY "the database used is Oracle. I would like to know if the atg has some
    standard method to perform this database connection and execute the SQL statement from a Droplet (select).
    Thank.

    I dont think there is any generic droplet to run a select query directly against a table.
    However, there are various lookup droplets available that run on the repositories.
    Like /atg/targeting/RepositoryLookup droplet. you can run it for specific id or for all.
    You might want to have a look at it in documentation of how exactly to use it.
    Thanks

  • How to execute a sql file inside a plsql file?

    It's easy to exec a plsql inside a sql. Simply
    start my_proc.plsql
    exec my_proc;
    But how to execute a sql file inside a plsql file?
    declare ...
    begin
    start my_sql.sql?
    end;
    Thanks.
    - Zac

    Doesn't work. Even though @ is different from start in this case but it just doesn't like the way sql and plsql are mixed. For example:
    DECLARE n NUMBER := 0;
    BEGIN
    select COUNT(*) INTO n from user_tab_partitions;
    DBMS_OUTPUT.put_line('Number of partitioned tables = ' || to_char(n));
    if n = 0 then
    DBMS_OUTPUT.put_line('createViewsProcs.sql');
    @createViewsProcs.sql
    else
    DBMS_OUTPUT.put_line('createPartitionViewsProcs.sql');
    @createPartitionViewsProcs.sql
    end of;
    END;
    SQL> @postimp.sql
    SQL> DECLARE n NUMBER := 0;
    2 BEGIN
    3 select COUNT(*) INTO n from user_tab_partitions;
    4
    5 DBMS_OUTPUT.put_line('Number of partitioned tables = ' || to_char(n));
    6
    7 if n = 0 then
    8 DBMS_OUTPUT.put_line('createViewsProcs.sql');
    9 @createViewsProcs.sql
    9 SET SERVEROUTPUT ON SIZE UNLIMITED;
    10 SET TERM ON;
    11 SET ECHO ON;
    12 EXEC DBMS_OUTPUT.put_line('STARTING VIEWS, PROCS, ETC, THIS MAY TAKE A FEW MINUTES');
    13 EXEC DBMS_OUTPUT.put_line(SYSTIMESTAMP());
    14
    15
    16 CREATE OR REPLACE PACKAGE db_convert AS
    17 FUNCTION ......
    32 END;
    33 /
    SET SERVEROUTPUT ON SIZE UNLIMITED;
    ERROR at line 9:
    ORA-06550: line 9, column 5:
    PL/SQL: ORA-00922: missing or invalid option
    ...

  • How to call a SQL function from an XSL expression

    Hi
    In R12, in Payroll Deposit adivce/Check writer, We need to sort the earnings tag <AC_Earnings> in to two different categories as regular and other earnings. In the DB and form level of element defintiion we have a DFF which differentiates between the two kinds of earnings. But the seeded XML that is gerneated by the check writer does not have this field.
    The seeded template displays all the earnings in one column. How can we achieve this in the template without modifying the seeded XML.
    The one approach i have is to write a function and based on the return value sort the data. For this I need to know :
    1) How to call a SQL function from an XSL expression that is allowed in BI template.
    If anyone ahs faced similar requirements please share your approach.
    Thanks
    Srimathi

    Thank u..
    but i'd seen that link wen i searched in google..
    Is it possible without using any 3rd party JARs and all?
    and more importantly plz tell me what should be preferred way to call a javascript function?
    Do it using addLoadEvent() or Windows.Load etc
    OR
    Call it thru Xsl? (I donno how to do dis)
    Thanks in Advance..
    Edited by: ranjjose on Jun 3, 2008 8:21 AM

  • How to execute a sql script in dbms_job?

    how to execute a sql script in dbms_job?

    See my response to Re: how to execute a sql script file in procedure or trigger.
    Cheers, APC

  • How to execute unix command line from cocoa?

    how to execute unix command line from cocoa?
    for example, if I want to call "ping" from cocoa, how should I do it? and how can I obtain the return value?
    thank you.
    Power G5 Quad Mac OS X (10.4.3)

    The following article may also help:
    http://cocoadevcentral.com/articles/000025.php
    Mihalis.
    Dual G5 @ 2GHz   Mac OS X (10.4.6)  

  • Hello, How do I tell sql+ to spool output file from windows to Unix server?

    Hello, How do I tell sql+ to spool output file from windows to Unix server?
    I am new to SQL+ and just learned how to spool the file. But file is saved in my local windows enviroment and since it's 2GB in size...I want to spool it directly to another remote unix server.
    Pls answer in detail... I have been to most of the thread and didn't see relevant answer to above question.
    Am I suppose to develope some script which FTP the spool file directly to the server I want to
    or
    i Have to use UTL_FILE Package ?
    Thanks for reply

    You may not be able to...
    SQL*Plus can only spool to the local machine. If you have mapped a directory on the Unix server from your Windows machine, you can specify that directory in your SPOOL command.
    You could telnet to the Unix server, run SQL*Plus there, and spool the file to a local (Unix) directory.
    If the Unix server is also the Oracle database server, you could use the UTL_FILE package rather than using SQL*Plus to spool a file.
    If the Unix server is also an FTP server, you could also FTP the file from your local machine to the server.
    Of course, I would tend to re-examine a requirement to regularly generate a 2 GB text file. It seems likely that there is a better way...
    Justin

  • How to execute 2 different application from same Application Server

    Hi,
    I would like to know that how to execute two different applications from the same Application Server with different databases?
    We are using
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Oracle Application Server 10g 10.1.2.0.2
    Regards,
    Hassan

    what type of applications you want to run from the same application server, Hassan?
    What other DB are you using to launch it beside the one you quoted? Is it the MRep DB of infra?

  • How to execute Dos Command 'Pause' from Java ?

    How to execute Dos Command 'Pause' from Java ?
    I have read the article in javaworld for Runtime.exec() anomalies.
    Can someone please give an insight on this?

    Thanks Buddy!
    That was very useful. Even though its a simple
    solution, I never thought about that.Bullshit! Reread reply #7 of http://forum.java.sun.com/thread.jspa?threadID=780193

  • How to execute unix shell script from Java ...

    Hi,
    Anyone know how to execute unix shell script from Java?
    Suppose I have several shell scripts written in perl or tcl or bash.
    I just want to catch the output of that script.
    Is there any ready to use module/object for this?
    Please let me know, this is quite urgent for my study assigment.
    Thanks in advance,
    Regards,
    me

    Look up Runtime.exec()

Maybe you are looking for

  • Windows 7 clients suddenly unable to connect to SQL database

    Our environment in a nutshell: Server1: Small Business Server 2003 R2 (Active Directory domain, it is the sole domain controller [DC]) Server2: Dedicated to SQL Server 2005 and the SAP Business One database Server3: Windows Server 2003 R2 Standard Te

  • "DBSTATUS_UNAVAILABLE" Error while importing Excel File

    Hello, I am getting following error while importing data from Excel 2003 to SQL server using SSIS 2008,  [Excel Source [1]] Error: There was an error with output "Excel Source Output" (9) on component "Excel Source" (1). The column status returned wa

  • Adobe Illustrator thumbnail view in a Picture Library?

    We are using Adobe Illustrator and we need to see the thumbnails in a picture library.  All of the other images work, but not the AI files.   We got the 16x16 icons added for AI for the details view, but we haven't been able to figure out where the t

  • PAR files need to be used

    hi can anyone specify the PAR files that need to be modified to customize the registration page thanks in advance regards yoga

  • Photos app crashes when migrating data from iphoto

    Every time I open the photos app it crashes and the migration process of the data from iphoto doesn't complete on iPad 3, is there a solutio?.