Parsing giving different SQL ID from actually executing SQL?

I think this is worth a thread on its own.
Env: 11.2.0.3 on HP-UX Itanium
Scenario:
1. parse a sql statement using the following
  c := dbms_sql.open_cursor;
  dbms_sql.parse(c, v_sql, dbms_sql.NATIVE);
  dbms_sql.close_cursor(c);2. Row appears in v$SQL with expected SQL_ID and plan_hash_value of 0.
3. In Toad, actually execute the <sql statement>
3. Second row appears in V$SQL with different SQL_ID and plan_hash_value non 0.
What's going on? Why do we get two different SQL_IDs for the same sql text executed by the same user?
Edited by: Dropbear67 on Feb 13, 2013 6:23 PM

>
I think SB is right, it's in the translation.
As for why it's important.. Well I am being given SQL_ID's by the dev team and being asked to go create and fix baseline plans for them. I can get the SQL from V$SQL from the SQL_ID provided, but when I go to run the query myself, I end up with a different SQL ID (and different PLAN_HASH_VALUE because I'm running it in a different optimizer env, but thats irrelevant for here). This causes more work for me to then go search the v$SQL views to try and find the SQL I just ran.
Why do I need to find my new SQL_ID? Because I then use it to lock in the baseline plan which I just created by running the query. I need to know it's SQL_ID and the PLAN_HASH_VALUE.
One would have thought you could just run
select * from table (dbms_xplan.display_cursor()); but that doesn't seem to always play ball - why? maybe a matter for another thread one day
>
Well now, after a day and a half, that we know what it is you are really trying to do you might want to look through this 4 part article: SQL Plan Management - Creating SQL Plan baselines.
It is written by Maria Colgan, a developer on Oracle's Optimizer development team. - can't get a better source of info than that.
Sounds like you already have significant experience with baselines so you may already be familiar with most of this. But it will certainlly be useful to others.
https://blogs.oracle.com/optimizer/entry/sql_plan_management_part_1_of_4_creating_sql_plan_baselines
>
This first post in our series, describes the concepts of SQL Plan Management and how to create SQL plan baselines. The second part will describe how and when these SQL plan baselines are used. The third part will discuss evolution, the process of adding new and improved plans to SQL plan baselines. Finally, the fourth part will describe user interfaces and interactions with other Oracle objects (like stored outlines).
You can create a SQL plan baseline in several ways: using a SQL Tuning Set (STS); from the cursor cache; exporting from one database and importing into another; and automatically for every statement. Let's look at each in turn. The examples in this blog entry use the Oracle Database Sample Schemas so you can try them yourself
>
And Tanel Poder's article 'SQL_ID is just a fancy representation of hash value might be of interest.
http://blog.tanelpoder.com/2009/02/22/sql_id-is-just-a-fancy-representation-of-hash-value/

Similar Messages

  • Why is my Package just stopping when going from one Execute SQL Task to another Execute SQL Task

    I have one flow constraint going for my one Execute SQL Task to another Execute SQL Task. It's executing #1 and successfully and just stops there rather than continuing on to Execute SQL Task #2. Why would it just stop? My constraint is NOT conditional...just
    a straight ole flow constraint.
    Any help is greatly appreciated and Thanks in Advance for your help.
    PSULionRP

    Hi PSULionRP,
    First make sure the color of the Precedence Constraint is green (Success) or blue (Completion) other than red (Failure). Then, make sure the Execute SQL Task is not disabled (right click the executable, and “Disable” option is available in the right-click
    menu). 
    Regards,
    Mike Yin
    TechNet Community Support

  • Is there any way to call a sql file from a pl/sql block

    Hi,
    I want to call a sql file from a pl/sql block.
    the pl/sql block has an exception handler. The pl/sql block will execute the sql file and in case it throws error then the exception handler will take care of it.
    The sql file will be a master file and it will itself call other sql files.
    is it possible to call any sql file from pl/sql block ?

    When you say "sql file", what precisely do you mean? Do you have a file that has just SQL statements? Or do you have SQL*Plus scripts?
    Where are the files stored? Are they on your client machine? Or the database server?"which in turn calls other sql files" seems to imply that the answer to the first question is that you have SQL*Plus scripts. If you have SQL*Plus scripts, you need SQL*Plus to execute them. PL/SQL is running in the Oracle database, SQL*Plus is a client application. It is not practical to have PL/SQL call SQL*Plus. Since you've already ruled out the best of the bad options, it appears that the answer is no, you can't have your PL/SQL run these files.
    As Alex points out, that's probably a good thing. It sounds like your application has been designed incorrectly. If you need PL/SQL, you should be creating stored procedures and functions and calling those from PL/SQL. Having PL/SQL depend on code in flat files outside the database is not a good idea.
    Justin

  • SQL Error 58004. Executed SQL Statement

    Hi experts, we working with SAP-MAM 3.0 database DB2E Version 9.1.2 ,  when I try install the MAM30 show me this message.
    Please, Can i reinstall the DB2E application for fix this error, or there are other solution?
      u2022 Excepción al tratar el métodoSMARTSYNC : com.sap.ip.me.spi.persist.IPersistenceException: char processor: SQL Error 58004. Executed SQL statement: [INSERT INTO M8_PROPERTIES("KEY","VALUE") values ('KEY_INCONSISTENT_DATA','X')] : char processor: SQL Error 58004. Executed SQL statement: [INSERT INTO M8_PROPERTIES("KEY","VALUE") values ('KEY_INCONSISTENT_DATA','X')]
    u2022 java.lang.RuntimeException: SQLState:58004, error code:-1 : SQLState:58004, error code:-1
    u2022

    Moved thread to DB6 forum.

  • How to execute a script(.sql) file from a PL\SQL procedure

    I would like to know how to execute a .sql file from a stored procedure and the result of it should update a table. My .sql file contains select statements.

    Hi!
    just go through the following piece of code -
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    str varchar2(200);
      3  begin
      4    str := '@C:\RND\Oracle\Misc\b.sql';
      5    execute immediate(str);
      6* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at line 5ORA-00900: invalid SQL statement
    Cause: The statement is not recognized as a valid SQL statement. This error can occur if the Procedural Option is not installed and a SQL statement is issued that requires this option (for example, a CREATE PROCEDURE statement). You can determine if the Procedural Option is installed by starting SQL*Plus. If the PL/SQL banner is not displayed, then the option is not installed.
    Action: Correct the syntax or install the Procedural Option.
    Regards.
    Satyaki De.

  • Pausing and resuming a PL/SQL proc from oracle PL/SQL DEVELOPER tool

    I need to test a PL/SQL on how it reacts to an exception. I need to PAUSE it, do something outside of the proc and then resume the proc. Is there a PROMPT command in PL/SQL where it would wait for user input? Can I use DBMS_OUTPUT.GET_LINE to do this? Where does the GET_LINE raed its input from?

    Perhaps the following demo will help. It uses straight SQL, since the PRIMARY KEY stuff does not require any sort of PL/SQL.
    I set up 2 sessions in SQLPlus.
    Session 1 - create a table with a primary key, insert and do not commit:
    session 1:
    C:\Users\Hans>sqlplus test/test
    SQL*Plus: Release 10.2.0.1.0 - Production on Sat Oct 10 15:40:13 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> create table abc ( a number primary key enable);
    Table created.
    SQL> insert into abc values (1);
    1 row created.Go to session 2 and insert:
    C:\Users\Hans>sqlplus test/test
    SQL*Plus: Release 10.2.0.1.0 - Production on Sat Oct 10 15:36:45 2009
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> insert into abc values (1);it hangs here.
    Switch back to session 1 and commit;
    SQL> commit;
    Commit complete.
    SQL>and in session 2 I see
    insert into abc values (1)
    ERROR at line 1:
    ORA-00001: unique constraint (TEST.SYS_C006468) violated
    SQL>Trying this for different test cases: session 1 insert value (2) and session s, insert value (3)
    Session 1
    SQL> insert into abc values (2);
    1 row created.
    SQL>Session 2
    SQL> insert into abc values (3);
    1 row created.
    SQL>Back to session 1
    SQL> commit;
    Commit complete.
    SQL>Back to session 2
    SQL> insert into abc values (3);
    1 row created.
    SQL>So I conclude that dups will block during insert.
    For your original question - SQL and PL/SQL are run in separate engines. PL/SQL sends the SQL command to the SQL engine, which runs that and returns any return info (rowset, error, ...).
    So any questions about SQL and SQL transaction control may be handled in a purely SQLPlus (or TOAD or SQLDeveloper) test case.
    OTOH, questions about PL/SQL can be answered using a debug environment such as SQLDeveloper - see http://www.oracle.com/technology/obe/sqldev/plsql_debug/plsql_debug.htm

  • Calling a SQL script from the PL/SQL block.

    Hello All,
    I am using oracle 11g database.
    My requirment is as follows. I have a SQL script to alter the table. But before alter the table I need to test some condition , if the condition satisfy then I have to alter the table through the SQL script. For the checking the condition I have to use the plsql block and inside I need to call the SQL script.
    Can I call a SQL script from PL/SQL block, if yes then how?
    I am tring to use START, RUN and @ command but it is throughing error.
    Thanks
    SUN

    [PL/SQL manual|http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/functions55a.htm#77600] Ctrl-F start, finds nothing. [SQLPlus manual|http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/toc.htm] Ctrl-F start finds this. Isn't it wonderful that Oracle documents this stuff so we don't have to guess.
    Can I call a SQL script from PL/SQL block, if yes then how? No.
    You could call the stored procedure in a SQL*Plus script before the alter table and have it raise an exception if the condition is not met and have the script quit when there is an error.

  • Calling SQL scripts from subdirectories using SQL*Plus 9.2.0.1

    Is it possible to run an SQL script that in turn calls other SQL scripts from subdirectories? This seemed to work fine using SQL*Plus 8.1.7
    Did it break in 9.2.0.1?
    Any fixes available?

    Ryan,
    What exactly is your problem? Can you tell me any errors you are seeing? Platform?
    Alison

  • Executing multiple sql statements from a single sql file

    Hi, I am Vijay Krishna.
    I want to drop user, drop tablespace, create tablespace and create user from a single executable file or a single sql file. The command should be in sequence. How can we achieve it? Can I anybody help me in this regard. I want this as soon as possible. It's urgent. Kindly post a reply.
    Also, how can we know the oracle home directory from a java program? The problem is we should know the Oracle home directory and use it for creating the tablespace. In the userinterface we will give just for a new database user creation. I will be really thankfull if anybody can help me in this regard.

    It is showing any error messages.
    I will diplay the entire batch file which we are using.
    sqlplus / as sysdba
    drop user examination cascade;
    drop tablespace examination;
    create tablespace examination
    datafile 'C:\oracle\product\10.1.0\oradata\orcl\examination.dbf'
    size 500M autoextend on;
    create user examination identified by examination
    default tablespace examination
    quota unlimited on examination;
    grant connect, resource to examination;
    exit;
    when i run the batch file from the DOS prompt it is entering into the sql prompt and coming out in a fraction of a second. We are just seeing a screen coming and going. But no error messages are being displayed.
    first we thought that as we are giving the create tablespace and create user in the same file we created another file and tried without having the create commands. Even then the user didn't get dropped.

  • Execute an SQL Script from Java (myScript.sql) ?

    Hello!
    I am a writing an SQL Script so that I can re-create my database on another server (im using my laptop to test it on first though).
    I'm connecting to mySQL server using JDBC which works fine, but I was wondering
    how can I run an entire script file, say myScript.sql from within a Java class??
    (an SQL Script is simply a file containing the regular SQL commands and expressions that you might enter at an sql command line prompt)
    example of an SQL Scritp: myScript.sql>>
    //#create new db
    CREATE DATABASE sample_db;
    //#set active db
    USE sample_db;
    //#set table paramaters
    CREATE TABLE monkeys
    (name CHAR(20),
      age INT UNSIGNED,
      sex ENUM('M','F')
    //#create standard monkeys
    INSERT INTO monkeys(name,age,sex) VALUES("Sammy",10,"M");
    INSERT INTO monkeys(name,age,sex) VALUES("Muncht",12,"M");
    INSERT INTO monkeys(name,age,sex) VALUES("Jill",8,"F");
    //#get recordset
    SELECT * FROM monkeys WHERE age < 50;Thanks for your help!

    The way I understand it is that your mysql.sql script file uses ';' as a delimeter between statements. So now what you can do is that read the whole file and put it inside a string/stringbuffer. Now put this string/stringbuffer to a stringTokenizer with delimeter set as ';'. this way you will recieve your exact statements without scratching your heads as where the statements begin/ends. :-)
    Now once you have your statements than its just a matter of executing them against the database.
    hope this helps.

  • How to use the EBS PL/SQL API from outside PL/SQL

    Hi,
    our attempts to call the stored procedures/functions of the EBS PL/SQL API via JDBC revealed the following issues:
    1. Logical values cannot be exchanged through boolean parameters as the OCI has no notion of this type. Instead we need to write PL/SQL wrappers converting boolean to integer and vice versa. Is that true or are we missing something?
    2. Complex values cannot be exchanged through record types as only PL/SQL code has a notion of this type. Instead we need to write PL/SQL wrappers converting record values to object type values. Is that true or are we missing something?
    3. Types must be defined outside of packages, i.e. in the schema, for whatever reason. Instead we need to write PL/SQL wrappers converting values of types defined in packages to values of types defined in the schema. Is that true or are we missing something?
    4. It is possible to let functions return tables so the results can be queried using SELECT * FROM TABLE. Such functions are called "table functions". Is there something similar for the other direction, i.e. is it possible to call a stored procedure and pass in a table value through an sql INSERT statement?
    5. Do we really have to write all those wrapper routines on our own or is there a PL/SQL library providing such? If not, is there some kind of code generation facility that can generate such wrappers?
    Thanks and Regards,
    Konrad

    Hi Helios,
    I belive its better to move your issue on Forum Home » Database » SQL and PL/SQL which you can get more quick responseYou are probably right! I was thinking about a different forum but I did not see this one. I just posted the question there...
    Still, if somebody has an idea here as well, just let me know ;-)
    Konrad

  • BSP Application connection to SQL Express DB to execute SQL Queries

    Hi There everyone,
    I am not sure if I am posting this discussion in the correct section, but please try and help me out.
    I have been tasked to write a BSP Application in the ABAP Workbench.  The purpose of this application is to enable our Weighbridge operators to execute pre-defined SQL Queries by selecting certain criteria from the Application.  The application is based on an HTML frontend which includes the Web Form (Input Fields, Submit buttons).  We have 6 Weighbridges, each has its own HTML page in this application.
    What I need to achieve is the following;
    I need to know how I must setup the connection between the BSP Application and the SQL Express DB.  Each Weighbridge has its own dedicated SQL Express instance + DB.  These SQL Instances are not on the same host as where the BSP Application is located, I think the correct term is "External SQL Instances".  Everything is on the same domain though.
    What code would I need to add to the "OnInitialize" section in the BSP Application, to be able to establish the connection to the SQL Express database using Windows Authentication?
    And what code would I need to attach to my submit buttons in the "OnInputProcessing" in the BSP Application, to execute a SQL Query to that DB and display the results in .CSV format back to the user?
    I have attached 2 screenshots of what the BSP Application interface looks like.  (This is what the user sees)
    I am very new to creating BSP's, and I have never had to link to SQL from HTML / PHP before, so I basically have no knowledge of this.
    Any help will be greatly appreciated.

    Sorry for the late reply.
    Yes, database is always available and online, not involved in Log Shipping or other things.
    At the time of the connection failure I can find the following in the log of the application:
    ProcessID:2452 ,ThreadID:4768 : NI-I - 24/08/2012-15:12:20 - \PCV/src/ni/src/pcvnireceive.cpp - 4741 - Thread 4768 - Receive Thread Started for Remote Node 043SBTMS10DRSP: In Thread index 1:
    ProcessID:2452 ,ThreadID:4768 : NI-I - 24/08/2012-15:12:40 - \PCV/src/ni/src/pcvnireceive.cpp - 4968 - Thread 4768 - Receive Thread Ended for Remote Node 043SBTMS10DRSP: In Thread index 1:
    ProcessID:2452 ,ThreadID:4768 : NI-I - 24/08/2012-15:12:40 - \PCV/src/ni/src/pcvnireceive.cpp - 115 - Thread 4768 - Merge Memory Usage: KB Allocated = 2186, KB in use = 889
    ProcessID:2452 ,ThreadID:1408 : NiJ - E - 25/08/2012-19:35:29 - \PCV/src/ni/src/pcvnijournal.cpp - 2842 - PcvNiJournal::isRetrievePending() - DB Exception.Error: TCP Provider: The specified network name is no longer available.
    Communication link failureQuery timeout expired - State:08S01,Native:64,Origin:[Microsoft][SQL Server Native Client 10.0] State:08S01,Native:64,Origin:Microsoft][SQL Server Native Client 10.0]
    State:S1T00,Native:0,Origin:[Microsoft][SQL Server Native Client 10.0]

  • 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}

  • Execute SQL Task with Parameter - from DB2 to SQL Server

    I am pulling data from DB2 to SQL Server.
    1st Execute SQL task runs the following against DB2:
    SELECT TIMESTAMP(CHAR(CURRENT_DATE - (DAY(CURRENT_DATE)-1) DAYS - 1 MONTH)) as START_MONTH
    FROM SYSIBM.SYSDUMMY1;
    I'm storing it as a Result Set.
    Next I have a Data Flow Task.  This pulls data from DB2 where the date matches the parameter.
    FROM SCHEMA.TABLE t
    WHERE DATE_TIME_COLUMN= ?
    This works fine. Guessing, because the parameter source is DB2 and the Data Flow source is DB2.
    The problem is, I want to remove existing data for the same date in the SQL table.  IE, if I'm pulling March 2014 data from DB2, I want to be sure there is no March 2014 data in the SQL table.  The main use is for re-runs.
    So, I added another Execute SQL task after the first one that assigns the variable, and before the Data Flow Task. This runs the following statement against SQL Server:
    DELETE FROM
    database.dbo.table
    WHERE DATE_TIME_FIELD >= ?
    The package fails at the new Execute SQL Task with the following error message:
    Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "DELETE FROM
    SBO.dbo.tblHE_MSP_FEE_BUCKETS
    WHERE T..." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
    correctly.
    Task failed: Execute SQL Task
    SSIS package "Load_MSP_Fee_Buckets_SQL.dtsx" finished: Success.
    The program '[14240] Load_MSP_Fee_Buckets_SQL.dtsx: DTS' has exited with code 0 (0x0).
    I am assuming this is something to do with the Parameter source being DB2, and trying to use against SQL?
    Any suggestions on how to make this work??
    Thanks,
    -Al H

    Parameter name is unrecognized
    is the key, how come DB2 is related if it runs against SQL Server
    What I think is happening you do not use the OLEDB connection to SQL Server.
    Likewise, if it is ADO then the query needs to be
    DELETE FROM
    database.dbo.table
    WHERE DATE_TIME_FIELD >= @MyDate
    Arthur My Blog

  • Execute .sql scripts from a remote login

    Hello,
    1) How do I execute a remote sql script from sqlplus?
    SQL>@remote_server:$HOME/test_sql.sql ...this did not work, which would work?
    2) Another question, in sqlplus I can do...! echo testing123>$HOME/test123.txt.
    How do I do this within a store procedure?
    This does not work, which would work?
    declare
    v_test varchar2(300) := '! echo testing123>$HOME/test123.txt';
    begin
    execute immediate v_test;
    end;
    /

    Re Q2.
    I take it that's an sqlplus feature on unix as it doesn't work on windows:
    SQL> ! echo testing123>$HOME/test123.txt
    SP2-0734: unknown command beginning "! echo tes..." - rest of line ignored.
    SQL>Also the reason this isn't working from within PL/SQL is that the execute immediate statement is used to send SQL statements to the SQL engine. What you are attempting to do is to send sqlplus commands to the SQL engine which obviously knows nothing about sqlplus commands. Those commands are very specific to the sqlplus executable and will only work in that environment.
    ;)

Maybe you are looking for

  • Can't attach more than one file at once in Yahoo! Mail using Firefox 15.0

    This problem appeared right after the new and improoved Flash Player was installed, when using Firefox 14.0.1. Problem persists with the new Firefox 15.0 (installed, not updated). It also takes a long time for Firefox to load the Attach button. I don

  • Can't save iBot on success start of scheduler

    Hi All, I have a problem that I need some help with and I'm hoping someone can help. I've configured the BI Scheduler and started it - it starts up successfully: 2011-01-28 15:31:31 [16020] Metadata Database Type: Oracle 10g R2 Data Source Name: DEV

  • Sales Pricing in the Project Builder

    I'm using DP81 in order to create quotation (AP sales document type). How can I change the item quantity in it ? Saving the quotation from DP81 the quantity field is gray ; I'm not allowed to change quotation item quantity. Isn't it? Thanks Gabriella

  • Calling one screen to anther

    Hello Experts, i created 2 screens,in my code i called the first screen like CALL SCREEN '1000' STARTING AT 10 10 ENDING AT 70 15. actually the requirement is to disable the first screen and call the second screen. some conditon check i write syntax

  • Personal Hotspot option not found on my iPhone 4S Using airtel?

    Personal Hotspot option not found on my iPhone 4S Using airtel connection. Do any one wat may be the reason?