SQL Adapter Issue

Does the SOA SQL Adapter support to return a collection of records when the Query contains multiple values for a single key ?
Can I provide a query like
Select EmployeeID, Salary from Employees where EmployeeID = 345 or EmployeeID = 4545 or EmployeeID = 7777
The SQL Adapter configuration wizard does not have a way to specify the query above.
In the last step of the wizard, I hard coded the above query but the SQL adapter is only returning a single record instead of 3 records.

Thanks for your response!
Let me describe my scenario in more detail.
The Client invoking the web-service will be passing information about various employees.
The XSLT will extract all the EmployeeID's from the Client Request and will build a string like
EmployeeID=1234 or EmployeeID=5678 or EmployeeID=9999.
Now a parameter called EID will be populated with the above string value.
In the SQL Adapter Wizard, I have the query Select EmployeeId, Ssn from Employees where EID. Note that EID is a parameter. I cannot declare 3 or 4 paramenters because the client can send hundreds of EmployeeID's. I don't know how many.
SOA suite runs this fine but only one row is returned.
So my question is For one column but multiple Selection criteria values for this column, Will SQL Adapter support returning a collection?
Edited by: user6796085 on Jun 28, 2010 11:24 AM

Similar Messages

  • SQL Adapter issue at run-time

    Hi Everyone,
    I am getting below issues while processing few of the message, Description="Description not provided" is common across all the below listed error. Please let us know if any of you have ecountered this kind of issues.
    Error #1:
    A message sent to adapter "SQL" on send port "XXX_1.0.0.0_XXX.ERPCustomerMasterOrch_SQLMasterCustomer_bc81e333b5b7dac4" with URI "SQL://SQLInstance//URI" is suspended. 
     Error details: HRESULT="0x80004005" Description="Description not provided"
     MessageId:  {B11BAA86-CB14-4E56-8342-8E9BA987D207}
     InstanceID: {54873A0A-CFC0-4CA0-8A61-716AF4863C68}
    Warning #3
    The adapter "SQL" raised an error message. Details "HRESULT="0x80004005"
    Description="Description not provided"".
    Warning #2
    The adapter failed to transmit message going to send port "SR_PortName" with URL "SQL://SQLInstance/DBName/". It will be retransmitted after the retry interval specified for this Send Port. Details:"HRESULT="0x80004005"
    Description="Description not provided"
    Warning #1:
    The adapter "SQL" raised an error message. Details "HRESULT="0x80004005"
    Description="Description not provided"
    Thanks!

    Hi,
    Please try checking the user account or user group on which the send  port runs (check host instance) has sufficient rights
    on:
    1. the database which contains the table,
    2. the user defined table  itself or the stored
     procedure.
    It should have connect permissions to the database and executing permissions.
    And you can refer here
    http://biztalkconnect.blogspot.in/2011_05_01_archive.html
    Hope it can help you.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • WCF-SQL adapter issue

    Hi all,
    I have ne issue with adapter when i am polling data from sqldb the dataset is creating in biztalk how can i add the elements in that,i am using this first time.
    Regards,
    Raman

    What do you mean "add the elements"?
    If you add a column to the SQL ResultSet, just add the corresponding Element to the Schema in the Schema Designer.
    If the ResultSet changes significantly, you can just re-run the Wizard.
    There is nothing special or remotely complicated about this.

  • WCF-SQL Adapter Hangs in Active State for hours

    I'm at a new client, and doing a simple test with a content-based-routing solution picks up a file, maps it, and is supposed to update a SQL database.  The WCF-SQL send port is stuck in the "active" state.  No messages in EventLog.  If there's
    an issue, I don't know why it doesn't just suspend.
    Any ideas?
    Thanks,
    Neal Walters

    Hi Neal,
    Few things to check IMO,
    Check if the host instance is running properly
    Check the version of the Host instance, If required make the host instance to 32 bit. 
    If it is using any schemas then make sure the binaries are deployed and gace'ed
    Try to restart the BizTalk host instance to see if it makes a difference
    Check if your SQL Database Instance is UP and running , Make sure the BizTalk service Account has proper rights on the SQL server and has execute permission on the SQL Stored procedure (if using one)
    Check if you have anything on the SQL server event viewer.
    Try to complete you routing of file using a send port also which will copy the input message to a temp folder location , Try  Using Failed Message Routing to see
    if it helps!
    There is an article
    Configuring a Port Using the WCF-SQL Adapter for further reference. 
    HTH,
    Naushad Alam
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or
    Mark As Answer
    alamnaushad.wordpress.com
    My new TechNet Wiki
    "BizTalk Server: Performance Tuning & Optimization"

  • WCF-SQL xmlpolling issue

    I have an issue with the xml im getting back from biztalk using a wcf-sql adapter.
    Im getting a strange blank namespace on a child element.
    <ShippedPackages xmlns="http://Correct.Schema">
    <Package xmlns="">
    <SALESORG>4000</SALESORG>
    <SOLDTO>5111632</SOLDTO>
    <PICKUP>5314125</PICKUP>
    <SOURCE>14</SOURCE>.....
    Im getting this blank namespace in <package>
    here are my settings for the receive location
    the receive pipeline is 'XMLreceive'
    XmlStoredProcedureRootNodeName - ShippedPackages
    XmlStoredProcedureRootNodeNamespace - http://Correct.Schema
    inbound operation type is xmlpolling
    PolledDataAvailableStatement - SELECT COUNT(*) as count FROM [Shopping].[dbo].[VW_DHLGMPartner_ShippedPackages]
    Pollingstatement - SELECT * FROM [Shopping].[dbo].[VW_DHLGMPartner_ShippedPackages] AS Package
    FOR XML AUTO, ELEMENTS
    Any ideas would be great
    Thanks

    Hi,
    Please follow the blog ->
    All about Legacy SQL Adapter and migrating it to WCF SQL Adapter
    Snippet from the blog which says:
    Issue
    Records fetched by WCF Sql Adapter have blank XMLNS with every record unlike the legacy Sql Adapter where there are no such blank namespaces coming
    along. This results in validation failure wherever the polled schema is being used as a SOURCE SCHEMA.
    Resolution
    Additionally following 2 changes need to be made: 
    Need to feed in the "PolledDataAvailableStatement" as it is a mandatory field before the polling operation could start.
    Marked "UseAmbientTransactions" as false to eliminate the error.
    For the blank namespace problems - the
    ElementFormDefault property needs to be set to 'False'.
    Rachit
    Please mark as answer or vote as helpful if my reply does

  • BTS 2010: SQL Adapter Class not registered

    Hi,
    after adding a host instance to the SQL Adapter, we receive every time a Class not registered error. The host instance is 32-bit and default for the SQL Adapter.
    Any ideas or is anyone facing the same issue?
    KR
    Peter

    I would suggest to refer the post below before repairing.
    The
    error threshold has been exceeded. The receive location is shutting down
    Looks like a mismatch between 32 bit calls executing in 64 bit host, confirm that your host is indeed a 32 bit host.
    Try to check below things
    1) check the account have access in db
    2) Check the BizTalk server build configuration, what is Platform target (Any CPU/ 32 Bit/ 64 bit) ?
    3) Try for another 32 bit Host Instance which have both receive and send handler (like 32 bit BizTalkServerApplication default host instance)
    4) check installed adapter pac bit version.
    Rachit
    Please mark as answer or vote as helpful if my reply does

  • SQL Adapter Error

    Hi All,
    I am getting the below mentioned error in the SQL adapter used in ALL.EXCEPTIONS send port in Microsoft.Practices.ESB application.
    The adapter "SQL" raised an error message. Details "[DBNETLIB][ConnectionRead (WrapperRead()).]General network error. Check your network documentation."
    I am unable to comprehend as what this error implies. Please provide your inputs and help in solving this issue.
    Thank You.
    Regards,
    Mandar Dharmadhikari

    I found this KB article.
    http://support2.microsoft.com/default.aspx?scid=kb;en-us;229564&Product=sql2k
    I hope it helps.
    Rachit

  • SQL Performance issue: Using user defined function with group by

    Hi Everyone,
    im new here and I really could need some help on a weird performance issue. I hope this is the right topic for SQL performance issues.
    Well ok, i create a function for converting a date from timezone GMT to a specified timzeone.
    CREATE OR REPLACE FUNCTION I3S_REP_1.fnc_user_rep_date_to_local (date_in IN date, tz_name_in IN VARCHAR2) RETURN date
    IS
    tz_name VARCHAR2(100);
    date_out date;
    BEGIN
    SELECT
    to_date(to_char(cast(from_tz(cast( date_in AS TIMESTAMP),'GMT')AT
    TIME ZONE (tz_name_in) AS DATE),'dd-mm-yyyy hh24:mi:ss'),'dd-mm-yyyy hh24:mi:ss')
    INTO date_out
    FROM dual;
    RETURN date_out;
    END fnc_user_rep_date_to_local;The following statement is just an example, the real statement is much more complex. So I select some date values from a table and aggregate a little.
    select
    stp_end_stamp,
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    stp_end_stampThis statement selects ~70000 rows and needs ~ 70ms
    If i use the function it selects the same number of rows ;-) and takes ~ 4 sec ...
    select
    fnc_user_rep_date_to_local(stp_end_stamp,'Europe/Berlin'),
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    fnc_user_rep_date_to_local(stp_end_stamp,'Europe/Berlin')I understand that the DB has to execute the function for each row.
    But if I execute the following statement, it takes only ~90ms ...
    select
    fnc_user_rep_date_to_gmt(stp_end_stamp,'Europe/Berlin','ny21654'),
    noi
    from
    select
    stp_end_stamp,
    count(*) noi
    from step
    where
    stp_end_stamp
    BETWEEN
    to_date('23-05-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')      
    AND
    to_date('23-07-2009 00:00:00','dd-mm-yyyy hh24:mi:ss')
    group by
    stp_end_stamp
    )The execution plan for all three statements is EXACTLY the same!!!
    Usually i would say, that I use the third statement and the world is in order. BUT I'm working on a BI project with a tool called Business Objects and it generates SQL, so my hands are bound and I can't make this tool to generate the SQL as a subselect.
    My questions are:
    Why is the second statement sooo much slower than the third?
    and
    Howcan I force the optimizer to do whatever he is doing to make the third statement so fast?
    I would really appreciate some help on this really weird issue.
    Thanks in advance,
    Andi

    Hi,
    The execution plan for all three statements is EXACTLY the same!!!Not exactly. Plans are the same - true. They uses slightly different approach to call function. See:
    drop table t cascade constraints purge;
    create table t as select mod(rownum,10) id, cast('x' as char(500)) pad from dual connect by level <= 10000;
    exec dbms_stats.gather_table_stats(user, 't');
    create or replace function test_fnc(p_int number) return number is
    begin
        return trunc(p_int);
    end;
    explain plan for select id from t group by id;
    select * from table(dbms_xplan.display(null,null,'advanced'));
    explain plan for select test_fnc(id) from t group by test_fnc(id);
    select * from table(dbms_xplan.display(null,null,'advanced'));
    explain plan for select test_fnc(id) from (select id from t group by id);
    select * from table(dbms_xplan.display(null,null,'advanced'));Output:
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / T@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "T"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "ID"[NUMBER,22]
       2 - "ID"[NUMBER,22]
    34 rows selected.
    SQL>
    Explained.
    SQL>
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$1
       2 - SEL$1 / T@SEL$1
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$1" "T"@"SEL$1")
          OUTLINE_LEAF(@"SEL$1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "TEST_FNC"("ID")[22]
       2 - "ID"[NUMBER,22]
    34 rows selected.
    SQL>
    Explained.
    SQL> select * from table(dbms_xplan.display(null,null,'advanced'));
    PLAN_TABLE_OUTPUT
    Plan hash value: 47235625
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   1 |  HASH GROUP BY     |      |    10 |    30 |   162   (3)| 00:00:02 |
    |   2 |   TABLE ACCESS FULL| T    | 10000 | 30000 |   159   (1)| 00:00:02 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SEL$F5BB74E1
       2 - SEL$F5BB74E1 / T@SEL$2
    Outline Data
      /*+
          BEGIN_OUTLINE_DATA
          FULL(@"SEL$F5BB74E1" "T"@"SEL$2")
          OUTLINE(@"SEL$2")
          OUTLINE(@"SEL$1")
          MERGE(@"SEL$2")
          OUTLINE_LEAF(@"SEL$F5BB74E1")
          ALL_ROWS
          OPTIMIZER_FEATURES_ENABLE('10.2.0.4')
          IGNORE_OPTIM_EMBEDDED_HINTS
          END_OUTLINE_DATA
    Column Projection Information (identified by operation id):
       1 - (#keys=1) "ID"[NUMBER,22]
       2 - "ID"[NUMBER,22]
    37 rows selected.

  • Notice update or delete in Database via WCF SQL Adapter

    Hi Folks,
    i try to notice any changes in a database table via SQL Adapter: so i check for a special column wich contains '0' for new datasets and '1' for those i already copied via BizTalk.
    This works fine as long as you only insert datasets, update or delete is not recocnized...
    Whats the best or possible way to react on these actions too?
    Thanks for your Ideas!

    Hi,
    I am shure there are many different approaches so here is what I have in mind:
    In case you need to react to deleted rows in your original table you need a sub table to trigger your biztalk for datasets that do not exist any longer.
    In this table you need 2 colums:
    first one to correlate to your original data row (id),
    second one to hold the status: For ex. 0= new, 1=update, 3=deleted
    Then you need a
    Trigger event on your original table that sets the status for the modified data id in your new table.
    You can then poll on this sub table as you already mentioned in your question.

  • How do you configure a WCF-SQL adapter to write data from a SQL2012 "always on" database?

    Hi All,
    I have a BizTalk environment. I have to write the data from BizTalk to the database which is configured using ALWAYS ON availability group.
    I use WCF-SQL adapter to write the data. My question is this setup a supported?

    The answer is NO.
    Refer: Can
    I use a BizTalk WCF-SQL send adapter with a SQL 2012 Always on Database?
    A snippet quoted below.
    In summary (in order of preference):
    Disable AlwaysOn Availability Groups / Mirroring on SQL server if you need to connect to this SQL server which has this enabled
    Disable transactions and implement logic to be able to handle duplicates .
    Disable transactions and handle the duplicates or lost messages with custom logic (e.g. Send twice and compare and implement error handling). You need to write your own DTC handling this which
    is probably very complicated.
    Disable transactions and live with risk of duplicates or lost messages without handling duplicates.
    Refer: SQL Server AlwaysOn feature does not support MSDTC transactions.
    Rachit
    Please mark as answer or vote as helpful if my reply does

  • How to track the sql commands issued against database

    Hello, We are using an interface developed by oracle forms. Its giving some error while pressing an icon. I can not able to trace out from where it arises. This error is displayed by form developed by oracle forms. I dont have source code to track it. I would like to know , which SQL statement rises the error, so that I can update the oracle object and can able to solve the problem if I can able to find the exect SQL statment issued before the error was displayed. kindly help me . thanks.

    habfat wrote:
    Hello, We are using an interface developed by oracle forms. Its giving some error while pressing an icon. I can not able to trace out from where it arises. This error is displayed by form developed by oracle forms. I dont have source code to track it. I would like to know , which SQL statement rises the error, so that I can update the oracle object and can able to solve the problem if I can able to find the exect SQL statment issued before the error was displayed. kindly help me . thanks.Hmm, well kind of a silly but still, if you don't have source code of the form( you said so) so even if you would come to know what statement is raising the error, how would you go and edit it ? Did I miss some thing? And you asked for a sql statement ? How did you come to know that its a sql statement that is causing the error? And if that's actually a sql statement error, isn't it associated with a meaningful message ?
    Find the developer who coded the application, he would be the best person to track the error and tell you its resolution IMO.
    HTH
    Aman....

  • Jdbc-odbc java error using SQL adapter in o9iASWireless

    I've used the SQL adapter in the previous releases of wireless without any problem. Most of the time I would use it for all the wireless PLSQL applications in the Oracle database and it works very OK.
    I have also used it to connect with a SQLserver database to try out some queries. In this case I would use the standard JDBC/ODBC bridge driver from SUN.
    In release 2.0 I can't connect with this SQL Server database anymore.
    I've added a system DSN to the ODBC configuration of the Windows 2000 server. This will give access to a internal SQL server database via TCP. A password username is required.
    When I try to add a SQLservice in the service designer using the SQL adapter I will use the following parameters:
    JDBC connect string: JDBC:ODBC:<DSNNAME>
    JDBC driver: sun.jdbc.odbc.JdbcOdbcDriver
    un: <username>
    pw: password>
    Query (without ';'): select count(*) from <tablename>
    Minimum number of Database connections in the pool 5
    Maximum number of Database connections in the pool 100
    Increment size for the connection pool 1
    Idle Timeout (in minutes) 30
    Now I get the following error:
    2/8/03 2:27:59 PM ERROR : [ApplicationServerThread] webtool.common.PtgErrorLog.outputError(PtgErrorLog.java:28)
    oracle.cabo.servlet.event.PageEventException: java.lang.ClassCastException: sun.jdbc.odbc.JdbcOdbcConnection,page=Page[name=designer/MasterServiceInitCreate],event=PageEvent[name=goto,source=wizardNav,fromPage=designer/MasterServiceInitCreate,JDBC_DRIVER=sun.jdbc.odbc.JdbcOdbcDriver,JDBC_CONNECT_STRING=jdbc:odbc:<DSNNAME>,CONNPOOL_INC=1,CONNPOOL_MIN=5,CONNPOOL_IDLETIMEOUT=30,USERNAME=<USERNAME>,value=4,SQLTYPE=QUERY,CONNPOOL_MAX=100,STATEMENT=select count(*) from bedrijven,PASSWORD=<PASSWORD>],rootCause=oracle.panama.adapter.AdapterException: java.lang.ClassCastException: sun.jdbc.odbc.JdbcOdbcConnection
    at oracle.cabo.servlet.event.BasePageFlowEngine.handleRequest(Unknown Source)
    at oracle.cabo.servlet.AbstractPageBroker.handleRequest(Unknown Source)
    at oracle.panama.webtool.common.PtgPageBroker.handleRequest(PtgPageBroker.java:152)
    at oracle.cabo.servlet.PageBrokerHandler.handleRequest(Unknown Source)
    at oracle.cabo.servlet.BajaServlet.doGet(Unknown Source)
    at oracle.cabo.servlet.BajaServlet.doPost(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:211)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:309)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:633)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:235)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:695)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:248)
    at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:62)
    I got the error 'java.lang.ClassCastException: sun.jdbc.odbc.JdbcOdbcConnection' in my log and tried to find out the meaning of this error at java.sun.com. It's stil not clear what exactly causes the error but it looks like a data formatting error.
    java.lang.ClassCastException
    (Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. For example, the following code generates a ClassCastException:
    Object x = new Integer(0);
    System.out.println((String)x); )
    Is it just a data formatting problem or has it something to do with the JDBC/ODBC driver version of the JDK from the appliction server release 2.0.
    I remember that I was always able to connect to the SQL server database with previous releases also with a count query. I've also used JDK 1.3.1 with o9iAS release 1.0.2.1.
    Any suggestions for a solution?
    Thanks in advance for your help.

    try this link:
    http://community.eapps.com/showthread.php?p=8

  • PL/SQL speed issues when using a variable

    I have a very strange issue that is causing problems.
    I am running Golden connecting to a 11g database.
    I created a procedure to insert records into a table based on a query. The source query includes variables that I have populated prior to the insert statement. The problem is that if I use the variable for one very specific where statement, the statement goes from running in less than 1 second, to running in 15 minutes. It gets even more strange though. Not only does a 2nd variable not cause any problems, the exact same variable in the same statement works fine.
    This procedure takes 15 minutes to run.
    declare
        v_start_period date;
        v_end_period date;
    begin
        select add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
        from dual;
        insert into RESULTS_TABLE
                (first_audit_date, last_audit_date,
                data_column1, data_column2, data_column3)
            select
                a.first_audit_date, a.last_audit_date,
                b.data_column1, b.data_column2, b.data_column3
            from
                SOURCE_TABLE_1 b,
                (select marker_id, min(action_time) as first_audit_date, max(action_time) as last_audit_date
                    from SOURCE_TABLE_2
                    where action_time >= v_start_period and action_time < v_end_period
                    group by marker_id) a
            where b.marker_id = a.marker_id
                and exists (select 1 from SOURCE_TABLE_2
                    where marker_id = b.marker_id
                    and action_time >= v_start_period and action_time < v_end_period
                    and action_type = 'XYZ');
        commit;
    end;This procedure runs in less than 1 second, yet returns the exact same results.
    declare
        v_start_period date;
        v_end_period date;
    begin
        select add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
        from dual;
        insert into RESULTS_TABLE
                (first_audit_date, last_audit_date,
                data_column1, data_column2, data_column3)
            select
                a.first_audit_date, a.last_audit_date,
                b.data_column1, b.data_column2, b.data_column3
            from
                SOURCE_TABLE_1 b,
                (select marker_id, min(action_time) as first_audit_date, max(action_time) as last_audit_date
                    from SOURCE_TABLE_2
                    where action_time >= v_start_period and action_time < trunc(sysdate,'mm')
                    group by marker_id) a
            where b.marker_id = a.marker_id
                and exists (select 1 from SOURCE_TABLE_2
                    where marker_id = b.marker_id
                    and action_time >= v_start_period and action_time < v_end_period
                    and action_type = 'XYZ');
        commit;
    end;The only difference between the two is where I replace the first v_end_period variable with trunc(sysdate,'mm').
    I've been googling for possible solutions and keep running into something called "parameter sniffing". It appears to be a SQL Server issue though, as I cannot find solutions for Oracle. I tried nesting the insert statement inside it's own procedure with new variables populated by the old variables, but nothing changed.
    Edited by: user_7000017 on Jan 8, 2013 9:45 AM
    Edited by: user_7000017 on Jan 8, 2013 9:52 AM Put the code in code tags.

    You are not describing procedures. You are listing anonymous PL/SQL blocks.
    As for the code - this approach to assigning PL/SQL variables are highly questionable. As the functions are native PL/SQL functions too, there is no need to parse and execute a SQL cursor, do context switching, in order to assign values to PL/SQL variables.
    This is wrong:
    select
        add_months(trunc(sysdate,'mm'), -1), trunc(sysdate,'mm')
        into v_start_period, v_end_period
    from dual;This is correct:
    v_start_period := add_months(trunc(sysdate,'mm'), -1);
    v_end_period := trunc(sysdate,'mm');Just as you would not use +"select 1 into plVariable from dual;+", instead of a standard variable assignment statement like +"plVariable := 1;"+.
    As for the performance/execution difference. Does not make sense. I suggest simplifying the code in order to isolate the problem. For example, take that in-line SQL (aliased as a in the main SQL) and create a testcase where it uses the function, versus a PL/SQL bind variable with the same data type and value as that returned by the function. Examine and compare the execution plans.
    Increase complexity (if no error) and repeat. Until the error is isolated.
    The 1st step in any troubleshooting, is IDENTIFYING the problem. Without knowing what the problem is, how can one fix it?

  • Video Adapter Issues?

    I just went through a download of recommended Lenovo updates and now have problems starting up the computer.  I get consistent blue screen telling me that I may have memory or video adapter issues.  Is this a video adapter or is there another cause?  I wasn't getting this prior to the update at the end of July...

    What ThinkPad exactly are we discussing here?
    Cheers,
    George
    In daily use: R60F, R500F, T61, T410
    Collecting dust: T60
    Enjoying retirement: A31p, T42p,
    Non-ThinkPads: Panasonic CF-31 & CF-52, HP 8760W
    Starting Thursday, 08/14/2014 I'll be away from the forums until further notice. Please do NOT send private messages since I won't be able to read them. Thank you.

  • Oracle 11g - External Table/SQL Developer Issue?

    Oracle 11g - External Table/SQL Developer Issue?
    ==============================
    I hope this is the right forum for this issue, if not let me, where to go.
    We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04
    We are trying to use oracle external table to load text files in .csv format. Here is our data look like.
    ======================
    Date1,date2,Political party,Name, ROLE
    20-Jan-66,22-Nov-69,Democratic,"John ", MMM
    22-Nov-70,20-Jan-71,Democratic,"John Jr.",MMM
    20-Jan-68,9-Aug-70,Republican,"Rick Ford Sr.", MMM
    9-Aug-72,20-Jan-75,Republican,Henry,MMM
    ------ ALL NULL -- record
    20-Jan-80,20-Jan-89,Democratic,"Donald Smith",MMM
    ======================
    Our Expernal table structures is as follows
    CREATE TABLE P_LOAD
    DATE1 VARCHAR2(10),
    DATE2 VARCHAR2(10),
    POL_PRTY VARCHAR2(30),
    P_NAME VARCHAR2(30),
    P_ROLE VARCHAR2(5)
    ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
    DEFAULT DIRECTORY P_EXT_TAB_D
    ACCESS PARAMETERS (
    RECORDS DELIMITED by NEWLINE
    SKIP 1
    FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
    REJECT ROWS WITH ALL NULL FIELDS
    MISSING FIELD VALUES ARE NULL
    DATE1 CHAR (10) Terminated by "," ,
    DATE2 CHAR (10) Terminated by "," ,
    POL_PRTY CHAR (30) Terminated by "," ,
    P_NAME CHAR (30) Terminated by "," OPTIONALLY ENCLOSED BY '"' ,
    P_ROLE CHAR (5) Terminated by ","
    LOCATION ('Input.dat')
    REJECT LIMIT UNLIMITED;
         It created successfully using SQL Developer
    Here is the issue.
    It is not loading the records, where fields are enclosed in '"' (Rec # 2,3,4,7)
    It is loading all NULL value record (Rec # 6)     
    *** If we remove the '"' from input data, it loads all records including all NULL records
    Log file has
    KUP-04021: field formatting error for field P_NAME
    KUP-04036: second enclosing delimiter not found
    KUP-04101: record 2 rejected in file ....
    Our questions
    Why did "REJECT ROWS WITH ALL NULL FIELDS" not working?
    Why did Terminated by "," OPTIONALLY ENCLOSED BY '"' not working?
    Any idea?
    Thanks in helping.

    I don't think this is a SQLDeveloper issue. You will get better answers in the Database - General or perhaps SQL and PL/SQL forums.

Maybe you are looking for

  • How to create a dynamic mapping of columnar at the Runtime using ADF or JSF

    How to create a dynamic GUI at the Runtime using ADF or JSF in JDeveloper 11g. What I am trying to build is to allow the user to map one column to another at the run time. Say the column A has rows 1 to 10, and column B has rows 1 to 15. 1. Allow the

  • Mobile Account problems

    Hello, We just moved a user's home directory to another x-serve, the account itself authenticates to Active Directory which points the home directory to an x-serve, however, upon reboot, the computer/mobile account still seems to want to go the previ

  • I can hear sound on headphones, but not on laptop speakers (stereo)

    I have been installing my audio on my Arch Linux and i am currently stucked  here. When i check if my modules are properly loaded i get this outputs which in both cases indicates that my modules had been auto detected: http://shrani.si/f/1/Dr/3VA6qi6

  • Looping .swfs on a timer?

    I created a .swf, and I would like the whole thing to replay once every minute infinitely. Has anyone ever done this, and if so, using what code? In my .swf I have all my content in one movieclip on the main timeline. Thanks in advance.

  • Best way to create an appliance

    I need to create an appliance.  I can: 1.  Export an existing Vm as an appliance from vsphere client 2.  Use a program like VMware studio to create it for me What is the best way to create it?  The goal is to make it as easy to administer within vCen