SQL Script in ABAP

Hi Everyone,
I have sql script which gives certain output from the data base files, is it possible to execute this script in ABAP, I want to embed this sql script in ABAP and get the output into an internal table how is it possible.
Can anyone suggest me on this, it will be of great use to me.
Thanks,
Prashant.

Hi
SAP uses Open SQL for accessing data from any of the databases.
Incase you want to find more details. Also look for Open SQL or Use Native SQL language in ABAP to accomplish the job.
<b> Open SQL
http://help.sap.com/saphelp_46c/helpdata/en/c9/5472f9787f11d194c90000e8353423/frameset.htm
Native SQL
http://help.sap.com/saphelp_46c/helpdata/en/c9/5472f9787f11d194c90000e8353423/frameset.htm</b>
Hope this will help.
Please reward suitable points.
Regards
- Atul

Similar Messages

  • Scripts in ABAP

    Hello gurus!
    I have a question about scripts in ABAP. We have a program that requires a lot of queries to obtain info from oracle; we already have a functional version of it but we need to upgrade and this means we have to write a lot more of queries in ABAP. Is there a way to import a script to put in a variable an execute it in ABAP to avoid all this code writing?.
    Regards IA

    Hi Armando,
    if You want to use already programed Oracle SQL Queries in ABAP with no neccessity to recode them into Open SQL (SQL in ABAP), You can probably use [Native SQL|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm]. This can be done using [EXEC SQL statement|http://help.sap.com/abapdocu_70/en/ABAPEXEC_CURSOR.htm].
    Regards,
    Adrian

  • Write to ERP Tables on HANA DB using SQL script

    Hello All,
    We are using HANA as our primary database for ABAP system and trying to feed the data to ABAP tables using SQL script and experiencing authorization errors . Please see below for more details.
    Scenario.
    I am getting no authorised error when i try to write some data to Z* tables using SQL script in HANA studio.But I am able to create new tables in the same schema.
    As shown above Query1: SAPSR1 is the schema which contains underline ABAP tables. ZGSA is existing table and now i am trying to insert new rows into it.
    Query 2&3: Creating new tables in SAPSR1 works fine.
    Can you please suggest me whether it is right approach or i need to have RFC to update these table from some other tool/app?.
    Thanks in advance,
    Naresh

    Hi Naresh,
    Obi Wan would now probably say: "this is not the functionality you're looking for".
    Even though you are working with Z-tables you really don't want to start messing with those from outside the context of the NetWeaver system.
    Instead you want to keep the control over all tables in the NetWeaver schema completely  to the SAP<sid> user and NetWeaver.
    For your data loading scenario, just write a simple ABAP report with native sql or an AMDP to do the copying of the data for you.
    Don't spread your code across the landscape and don't loosen access restrictions on your schema.
    - Lars

  • SAP ECC6 sr3 upgrade error in executing MSSCONCHECK.SQL script

    Hello all,
      I am facing this error which is very annoying , I am executing Prepare Upgrade script for ECC6 SR3 from SAP 4.7 Sr2 with windows 2003 server and MSSQL 2005 server as backend. I am facing below error
    Enter one of these options [continue] := continue
          SAPup message
    SAPup> SQL-scripts must be executed by the NT user account T47VMHOST2\t47adm.
           Check your installation of the integrated security procedure
           on host t47vmhost2 and make sure that a login for the NT user
           T47VMHOST2\t47adm exists with the following rules:
           - user T47VMHOST2\t47adm owns the role System Administrators
           - user T47VMHOST2\t47adm has the default database T47
    SAPup> Integrated security installed correctly?
                - "no"
                - "yes"
    Enter one of these options [no] := yes
    Executing script MSSCONCHECK ...
    MSSCONCHECK: Connection check failed for the user specified
          SAPup message
    SAPup> Errors were found in the logfile MSSCONCHECK.LOG
           after execution of the script MSSCONCHECK.SQL.
    SAPup> SAPup cannot proceed until these errors are fixed.
           Please, examine MSSCONCHECK.LOG, fix reported errors and then call R3UP a
    gain
    I have done a number of changes in system i checked the SIDadm user is assigned a default DB T47 and has said role assigned allready.
    I restarted the system after changes and started the prepare batch file again but with sme probelm again. so can anybody guide me on this. I seen a number of threads but there is no any concrete solution providedby them.
    will really appreciate any reply.
    Mani

    Hello Julia,
      i read those note but everything seems normal to me on my PC; it has remote access enabled, t47vmhost2/t47adm is the user configured (although its not a domain configuration (installation) but t47vmhost2 is the computer name. So its kind of local user defined in SQL with said authorization. below is the log from file MSSCONCHECK.LOG
    [SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [2].
    [SQL Native Client]Login timeout expired
    [SQL Native Client]An error has occurred while establishing a connection to the server. When
    connecting to SQL Server 2005, this failure may be caused by the fact that under the default
    settings SQL Server does not allow remote connections.
    I am still stuck in ?
    Can you please verify if i am using right DVDs
    51033495_1     NW 7.0 SR3 Languages DE,EN,ES,FR,IT,NL
    51033494_3     NW 7.0 SR3 Upgrade Export 3 of 3
    51033494_2     NW 7.0 SR3 Upgrade Export 2 of 3
    51033494_1     NW 7.0 SR3 Upgrade Export 1 of 3
    51033512_14     NW 7.0 SR3 Upgrade Master Windows Server on x64 64bit
    51033508_8     NW 7.0 SR3 Kernel 7.00 Windows Server on x64 64bit Upg ABAP
    Pleas help
    Mani

  • IF statement syntax in SQL script view

    I need to include a "IF" condition in the "SELECT" section of my SQL script view.
    I tried the following syntax's but I get the error 'Incorrect SQL syntax near 'IF'
    1.  IF(Revenue <> '0' AND Quantity <> '0', Revenue/Quantity, '0') AS Gross Price
    2.  IF(Revenue != '0' AND Quantity != '0', Revenue/Quantity, '0') AS Gross Price
    3.  IF(Revenue <> '0' AND Quantity <> '0' THEN Revenue/Quantity ELSE  '0' END) AS Gross Price
    4.  IF(Revenue != '0' AND Quantity != '0' THEN Revenue/Quantity ELSE  '0' END) AS Gross Price
    My final SQL would read like follows:
    SELECT field1, field2, IF(......) AS field3
    FROM table1
    Can anybody please help with the correct IF statement syntax to be used in the SQL script based view?

    Hi Lakshmi,
    below is the syntax for IF statement.
    IF <bool_expr1> THEN
    <then_stmts1>
    ELSEIF <bool_expr2>
    THEN <then_stmts2>
    [ELSE <else_stmts3>]
    END IF
    eg :
    BEGIN
    DECLARE found INT := 1;
    SELECT count(*) INTO found FROM books WHERE isbn = :v_isbn;
    IF :found = 0 THEN
    INSERT INTO books VALUES (:v_isbn, 'In-Memory Data Management', 1, 1, '2011', 42.75, 'EUR');
    ELSE
    UPDATE books SET price = 42.75 WHERE isbn =:v_isbn;
    END IF;
    END;
    Sreehari

  • IF Condition in a PL/SQL Script give a report error.

    Hello, I’m German and I hope you can unterstand my Question.
    First, I work with the HTML DB Version 1.6.0.0.0.87 and the Oracle Version 9.2.0.6.
    I create a SQL Report, where a PL/SQL Script return the SQL Statement for the Report. This is my source-code, I have short it...:
    Declare
    sql_str varchar(2000);
    sql_str_select varchar(1000) :=' select dim_sparte …... ';
    sql_str_from varchar(1000) := ' from faktentabelle,dim_sparte ';
    sql_str_where varchar(1000):= ' where … and faktentabelle.zeit_id = :POPUP_ZEIT ';
    sql_str_groupby varchar(1000):= ' group by dim_sparte.name, faktentabelle.zeit_id ';
    Begin
    If ( (V('POPUP_NETZGEBIET') is not NULL) and (V('POPUP_NETZGEBIET') <>
    'Alle Netzgebiete')) THEN
    sql_str_select := sql_str_select || ' ,dim_organisationseinheit.netzgebiet_name ';
    sql_str_from := sql_str_from || ' , dim_organisationseinheit ';
    sql_str_where := sql_str_where || ' and faktentabelle ... and
    dim_organisationseinheit.netzgebiet_name = :POPUP_NETZGEBIET';
    sql_str_groupby := sql_str_groupby || ' , dim_orga .... ';
    End IF;
    sql_str:= sql_str_select || sql_str_from || sql_str_where || sql_str_groupby;
    htp.print(sql_str);
    Return sql_str;
    End;
    This Script include a IF-THEN condition. The Condition is true and the sql-String-Variables are updatet.
    I can get the string with htp.print() and the Statement is OK.
    The report get a Error “report error: ORA-1403: no data found”. If I copy the printet sql String in a new Report Region with SQL String, the Report is OK. When I write IF(true) instead of IF( Condition) the Report is OK, too.
    I try ist with Varibalen V(‘name‘) and with :name. It’s always the same problem. I can’t use IF-THEN-Else Conditions in a Script.
    Please help me and say me what is the problem???
    Thanks,
    Simona

    Hi Simona,
    In the sql region below the region source see that you have " Use Generic Column Names (parse query at runtime only)" check and not " Use Query-Specific Column Names and Validate Query".
    This error you usually get when you have a mismatch in your report heading.
    Vivek
    [email protected]

  • Pl/sql script needed - Urgent

    Hi All,
    I have one problem. I have to populate a table having rows more than 500000000 $ through PL/SQL.
    For getting the idea...I have created one dummy table " T1 " with column " X " having 9 rows and
    values in source are -
    row 1 = 10
    row 5 = 20
    row 8 = 30
    Other rows(2, 3, 4, 6, 7, 9) are null.
    I want to carry fwd the values so the values in the same table will come like -
    row 1, 2, 3, 4 = 10
    row 5, 6 ,7 = 20
    row 8,9 = 30
    For resolving the problem i have written a procedure :
    DECLARE
    CURSOR cur_adb IS SELECT * FROM t1 ;
    var cur_adb%rowtype ;
    var1 number(10) ;
    BEGIN
    OPEN cur_adb ;
    LOOP
    FETCH cur_adb INTO var ;
    DBMS_OUTPUT.PUT_LINE ( 'x=') ;
    EXIT WHEN cur_adb%ROWCOUNT > 10 ;
    If var is not null
    then update t1
    set x = var ;
    var1 := VAR;
    else update t1
    set x = var1 ;
    exit;
    end if;
    END LOOP;
    CLOSE cur_adb ;
    END ;
    But it is giving me wrong result as it is fetching more rows at a time.
    Pls. send me the correct Pl/SQL script as soon as possible.
    Note: You can directaly send the procedure to [email protected] .
    Thanks & Regs,
    Ashish

    Hello,
    I got the solution by adding on more column in the source table :
    source table : T1 -> x x_id
    10 1
    2
    3
    4
    20 5
    6
    7
    30 8
    9
    The procedure is :
    SQL> DECLARE
    2 CURSOR cur_adb IS SELECT x, x_id FROM t1 ;
    3 var number(10) ;
    4 var1 number(10) ;
    5 var2 number(10) ;
    6 BEGIN
    7 OPEN cur_adb ;
    8 LOOP
    9 FETCH cur_adb INTO var , var2 ;
    10 If var is not null
    11 then var1 := VAR;
    12 elsif var is null
    13 then update t1
    14 set x = var1
    15 where x_id = var2;
    16 end if;
    17 DBMS_OUTPUT.PUT_LINE ('The value of x=' || var) ;
    18 Exit when cur_adb%ROWCOUNT > 9 or cur_adb%NOTFOUND ;
    19 END LOOP;
    20 CLOSE cur_adb ;
    21 END ;
    22 /
    The value of x=10
    The value of x=10
    The value of x=10
    The value of x=10
    The value of x=20
    The value of x=20
    The value of x=20
    The value of x=30
    The value of x=30
    The value of x=30
    PL/SQL procedure successfully completed.
    Thanks everyone for helping me........
    Regards,
    Ashish

  • Can't Upload SQL scripts or application scripts in APEX 3.1

    I have installed APEX 3.1 on an Oracle 10g database.
    I can log in to APEX, create applications, and run applications.
    One application I import is the sample OEHR application which imports correctly at the hosted site.
    However, when I try to upload an SQL script or import the sample application I get
    "Page not Found" for this page http://csora:7777/pls/apex/wwv_flow.accept
    I've included my dads.conf below and also some Apache error entries
    Alias /i/ "e:\oracle\product\10.1.0\Db\Apache\Apache\images/"
    AddType text/xml     xbl
    AddType text/x-component     htc
    <Location /pls/apex>
    Order deny,allow
    PlsqlDocumentPath docs
    AllowOverride None
    PlsqlDocumentProcedure      wwv_flow_file_mgr.process_download
    PlsqlDatabaseConnectString     csora:1521:ORCL ServiceNameFormat
    PlsqlNLSLanguage          AMERICAN_AMERICA.AL32UTF8
    PlsqlAuthenticationMode     Basic
    SetHandler          pls_handler
    PlsqlDocumentTablename     wwv_flow_file_object$
    PlsqlDatabaseUsername     APEX_PUBLIC_USER
    plsqlDefaultPage          apex     
    PlsqlDatabasePassword     hocking
    Allow from all
    </Location>
    I:[Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2864:2873,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/topnav2.gif
    [Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2924:2771,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/left_curve.gif
    [Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2944:2767,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/left_curve.gif
    [Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2972:2750,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/right_curve.gif
    [Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2940:2762,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/right_curve.gif
    [Mon Apr 14 16:19:33 2008] [error] [client 10.116.101.158] [ecid: 1208204373:198.30.4.195:2696:2924:2773,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/topnav2.gif
    [Mon Apr 14 16:21:48 2008] [error] [client 10.116.101.158] [ecid: 1208204507:198.30.4.195:2696:2948:2801,0] mod_plsql: /pls/apex/wwv_flow.accept HTTP-404 ORA-00942: table or view does not exist
    [Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2760,0] mod_plsql: /pls/apex/wwv_flow.accept HTTP-404 ORA-00942: table or view does not exist
    [Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2761,0] mod_wchandshake: incorrect uri: name="p_t04" passed in.
    [Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2761,0] Invalid URI in request -data; name="p_t04"
    Am I missing some files or directories from the 3.1 install? Any help would be appreciated since I think I'm close to having APEX fully functional.

    Val,
    In this line:
    PlsqlDocumentTablename wwv_flow_file_object$
    ...that needs to be wwv_flow_file_objects$
    Scott

  • How to test a simple PL SQL function from another PL SQL script

    Hi,
    I have created a function. Now i need to test that whether it is returning the correct values or not.
    For that, i have written anothe pl sql script and trying to call this function. Im passing all the IN parameters in that function. I assume here that OUT parameters will provide me the result. Im trying to display the OUT parameter one by one to see my result.
    I'm using toad as sql client here connected with oracle.
    pl sql script:-
    DECLARE
    BEGIN
         DBMS_OUTPUT.PUT_LINE('$$$$$$$ VINOD KUMAR NAIR $$$$$$$');
         FETCH_ORDER_PRODUCT_DATA(320171302, 1006, 6999,
    ODNumber OUT VARCHAR2, Line_Number OUT VARCHAR2,
    ServiceID OUT VARCHAR2, BilltoNumber OUT VARCHAR2,
    AnnualPrice OUT NUMBER, CoverageCode OUT VARCHAR2)
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ODNumber );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | Line_Number );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ServiceID );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | BilltoNumber );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | AnnualPrice );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | CoverageCode );
    END;
    Function:-
    Program Name : SPOT_Order_Product_Data_For_CFS.sql
    Description : Function to Validate parameters from CFS
    By : Vinod Kumar
    Date : 08/19/2011
    Modification History
    By When TAR Description
    CREATE OR REPLACE FUNCTION FETCH_ORDER_PRODUCT_DATA(orderNumber IN VARCHAR2, customerNumber IN VARCHAR2,
    productLine IN VARCHAR2, ODNumber OUT VARCHAR2,
    Line_Number OUT VARCHAR2, ServiceID OUT VARCHAR2,
    BilltoNumber OUT VARCHAR2, AnnualPrice OUT NUMBER,
    CoverageCode OUT VARCHAR2)
    RETURN VARCHAR2 IS
    lv_err_msg VARCHAR2(100) := '';
    lv_bucket_id VARCHAR2(14);
    lv_bill_number VARCHAR2(30);
    lv_anual_price NUMBER;
    lv_coverage_code VARCHAR2(8);
    lv_quote_num NUMBER(10) := NULL;
    lv_line_num NUMBER(5) := 0;
    lv_customer_number VARCHAR2(30) := customerNumber;
    lv_product_id VARCHAR2(14) := productLine;
    lv_count_quote NUMBER := 0;
    lv_quote_status VARCHAR2(5);
    lv_quote_version NUMBER(2):=0;
    BEGIN
    IF INSTR(orderNumber, '-') = 0 THEN
    lv_quote_num := orderNumber;
    ELSE
    lv_quote_num := SPT_Delimiter(orderNumber, 1, '-');
    lv_line_num := SPT_Delimiter(orderNumber, 2, '-');
    END IF;
    --Check status of the quote COM, APP
    SELECT COUNT(*) INTO lv_count_quote FROM sot_order_header WHERE ORDER_NUMBER=lv_quote_num
    AND ORDER_STATUS IN ('APP', 'COM') AND CUSTOMER_NUMBER = lv_customer_number;
    IF lv_count_quote = 0 THEN
    lv_err_msg := 'Invalid Order number';
    RETURN lv_err_msg;
    END IF;
    -- Fetch the latest version on SPOT quote
    SELECT MAX(VERSION_NUMBER) INTO lv_quote_version FROM SPT_QUOTE_HEADER WHERE QUOTE_NUMBER = lv_quote_num
    AND CUSTOMER_NUMBER = lv_customer_number;
    -- If quote is valid fetch the data in OUT parameters
    IF lv_line_num = 0 THEN
    BEGIN
    SELECT a.CUSTOMER_BILLTO_NUMBER,
    b.LINE_NUMBER, b.BUCKET_ID,
    b.ANNUAL_REF_RATE_USD, b.COVERAGE_CODE
    INTO lv_bill_number,lv_line_num,lv_bucket_id,lv_anual_price,lv_coverage_code
    FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
    WHERE a.QUOTE_NUMBER = lv_quote_num
    AND a.CUSTOMER_NUMBER = lv_customer_number
    AND a.VERSION_NUMBER = lv_quote_version
    AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
    AND a.VERSION_NUMBER = b.VERSION_NUMBER
    AND b.PRODUCT_ID = lv_product_id;
    ODNumber := lv_quote_num;
    BilltoNumber := lv_bill_number;
    Line_Number := lv_line_num;
    ServiceID := lv_bucket_id;
    AnnualPrice := lv_anual_price;
    CoverageCode := lv_coverage_code;
    RETURN '';
    EXCEPTION WHEN OTHERS THEN
    lv_err_msg := 'Multiple PIDs existing in the SPOT order, please provide the SPOT order + line number as input data';
    RETURN lv_err_msg;
    END;
    ELSE
    BEGIN
    SELECT a.CUSTOMER_BILLTO_NUMBER,
    b.BUCKET_ID, b.ANNUAL_REF_RATE_USD,
    b.COVERAGE_CODE
    INTO lv_bill_number,lv_bucket_id,lv_anual_price,lv_coverage_code
    FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
    WHERE a.QUOTE_NUMBER = lv_quote_num
    AND a.CUSTOMER_NUMBER = lv_customer_number
    AND a.VERSION_NUMBER = lv_quote_version
    AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
    AND a.VERSION_NUMBER = b.VERSION_NUMBER
    AND b.PRODUCT_ID = lv_product_id
    AND b.LINE_NUMBER = lv_line_num;
    ODNumber := lv_quote_num;
    BilltoNumber := lv_bill_number;
    Line_Number := lv_line_num;
    ServiceID := lv_bucket_id;
    AnnualPrice := lv_anual_price;
    CoverageCode := lv_coverage_code;
    RETURN '';
    EXCEPTION WHEN OTHERS THEN
              lv_err_msg := 'Multiple SPOT lines exist with same parameter';
              RETURN lv_err_msg;
    END;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    lv_err_msg := '@@@ EXCEPTION THROWN @@@ '|| SUBSTR(SQLERRM,1,120);
    RETURN lv_err_msg ;
    END;
    Don't look at the function, it might have errors but my primary concern is how to test this function. Once I start doing its testing then only i can understand any bugs(if any).
    My pl sql is not so good. Im still learning. I don't understand IN and OUT parameters are.
    I just know that IN parameters r those whick we pass in to the function wen we call it and OUT parameters are those through which we get the result.
    Thanks in advance
    Vinod Kumar Nair

    20100511 wrote:
    I wondered how I could test the output of the function from within TOAD?I usually create the following function in my developer schema:
    create or replace function BoolToChar( b boolean ) return varchar2 is
    begin
      if b then
        return( 'TRUE' );
      else
        return( 'FALSE' );
      end if;
    end;To test a function like yours, the following will do in SQL*Plus/TOAD/etc:
    begin
      DBMS_OUTPUT.put_line(
        BoolToChar( XCCC_PO_APPROVALLIST_S1.does_cpa_exist(1017934)  )
    end;
    I'm probably doing 101 things wrong here, but thought I'd ask anyway and risk being shouted at.Shout at? You reckon? I thought people risked being beaten with a lead pipe, or pelted with beer cans and stale pretzels - which makes being shouted at a really safe and viable alternative. {noformat};-){noformat}

  • How can I convert a mysql sql script to a oracle sql script

    Hi,
    We have a bunch of tables with data running on a mysql server.
    This should now be moved to an oracle 9 db.
    are there any tools to convert the import script of a mysql db
    to a format of the sql script that work for oracle ?
    Thanks
    Michael

    Oracle has a tool called Migration Toolbench, which supports MySQL 3.22 and 3.23:
    http://otn.oracle.com/tech/migration/workbench/content.html
    On this same topic, I was wondering if anybody has tried migrating from PostgreSQL to Oracle 9i. The workbench doesn't seem to support it, and feeding a pg_dump file directly into SQL*Plus is not working.

  • How to reference dynamic parameters in the PL/SQL script

    The meaning of dynamic parameter is the position and name of parameters will be changed based on the data structure of a referenced text file reading by the concerned PL/SQL script. Anybody can post a sample code will be very appreciated.

    The SQL and PL/SQL discussion forum is a good source for this kind of information.
    The URL is:
    PL/SQL

  • How can I run a SQL script file...

    How can I run a SQL script file from a location on my computer without providing the whole path?
    Is there some way I can set a "Working folder" in SQL Plus??
    Thanks!
    Tom

    You can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
    scripts.
    I would like to use another directory than the oracle/bin...
    How can I do this ??
    Hello,
    U can do this by this way:
    Save odm_script.sql file to the default Oracle
    directory i.e. Oracle-Home/bin and Run following command
    through SQL Plus.
    SQL>@Script_Name
    I hope this will resolve ur problem.
    Regards,
    Omer Saeed Khan.

  • Retrieve alert values for use as parameter in corrective action sql script

    I am trying to write a corrective action sql script to kill a session that is blocking other sessions. I have the "blocking session count" metric set and the alert is firing correctly.
    Is there any way to retrieve the sid and serial number from the alert generated and use it in a corrective action sql script?
    Here is the alert generated:
    Target Name=myproddb.world
    Target Type=Database Instance
    Host=myprodserver
    Metric=Blocking Session Count
    Blocking Session ID=SID: 522 Serial#: 5228
    Timestamp=Mar 4, 2008 5:57:12 PM EST
    Severity=Warning
    Message=Session 522 is blocking 1 other sessions
    Notification Rule Name=Testing Corrective actions
    Notification Rule Owner=sysman
    Clearly the sid, and serial # is contained within the alert Message field
    what I want to write for the sql script is :
    alter system kill session '%sid%,%serial_no%' immediate;
    and have GC pass in the sid and serial_no to the script.
    The "Target Properties" listed on the right of the Edit Corrective Action screen lists minimal details pertaining to the alert and certainly not the session sid, serial no.
    Generically, is there any way to retrieve the values from an alert and use them in a corrective action script or job?
    I've looked into getting the values from the mgmt$alert_history table, but I'm hoping that GC can pass the values to the sql script.
    thanks in advance for your help.

    Hi
    You can implementing a procedure like this.
    1. When a block session count alarms occurs, there is a column in the v$lock that you can examine.
    #!/bin/ksh
    #kill_block_session.sh
    #first export your variables
    export ORACLE_HOME=/oracle/product/10.2.0.3
    export ORACLE_SID=SIDNAME
    $ORACLE_HOME/bin/sqlplus "/ as sysdba" << EOF
    execute immediate killed_blocks;
    EOF
    # end
    The killed_blocks is a procedure:
    create procedure
    declare
    v_sid varchar2(15);
    v_serial varchar2(15);
    -- now a sql query that retrieve the sid and serial
    -- you can obtain these values from v$session and v$lock
    select vs.sid,vs.serial into v_sid,v_serial
    from v$session vs,v$lock vl
    where vs.sid=vl.sid
    and vl.block >0
    -- After this, you execute a dbms_put line with these
    -- values
    But you understant that this response action is very dangerous, because its possible that you kill sessions that the blocking are transitient.
    You must examine your enviroment and your application and establish the metric like UDM and not for only session blocking count.
    You must to see:
    - The type of block
    - The ctime time in the v$lock for to understatn the amount of time to determine that the block is need killed.
    - In my opinion you need a special UDM and deactivate the blocking sesion count
    If you want help to create this UDM send me a mail to [email protected]
    Regards
    Robert

  • How to run a sql script in oracle forms

    Hi,
    For me there is an sql script. I need to run that sql script in forms.
    Actually we will run that sql file in pl/sql developer by giving @and the file name.
    But how to run that file in forms.
    Can any one help on these.Which book I have to look.
    Thanks

    Actually there is a script files which will drop all the indexes and tables.
    DROP querry will be there for each index and each table.
    So I run the script all the indexes and all the tables will be deleted. So using forms I have to run that script.
    Thanks

  • 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

Maybe you are looking for

  • One answer to ipod not being recognised in itunes

    My 20gb ipod recently stopped being recognised in itunes but was still recognised in "My Computer". Having tried alot of the suggested solutions (more than once)nothing seemed to correct this. I resigned myself to being one of the many having a "half

  • Queries related to DMS and Archive link

    Hi Experts, 1. Is it possible to link documents in MIGO or FB03 through Archive link with documents already stored via OAWD or CV01N. 2. Can we use any single transaction code for reporting purpose where we can find all the documents stored via DMS a

  • What are the benefits of single JAVA stack?

    Dear all, what are the benefits of a single stack SAP BI/BW (JAVA) - which functionality is inside a JAVA Single Stack that is not in a Double Stack inside?

  • Essbase Data Cache Full Error

    Hi, All, I am encountering an Essbase data cache full error while running some calc scripts. I have already try to set the data cache size to 800MB to 1.6GB, and index cache to around 100MB. It is quite a large BSO Essbase, with one dimension over 10

  • Can't drag & drop photos from iPhoto to Finder.

    (I'm using iPhoto 9.4.2, mac OS 10.8.3) I can drag & drop photos from iPhoto to the Finder once. It successfully copies however many photos I had selected to the folder I wanted them copied to. But then if I try to drag and drop any more photos, it w