Result of the Explain SQL function database-specific ?

Hello, gurus...
I'm not able to find the "secondary index" information in ST05 + Explain.
Is the Explain SQL function database-specific ?
We're running SAP ECC 6.0 on a MSSQL database....
Please advice.

Is the Explain SQL function database-specific ?
yes it is. It must be database specific because it shows what the database is doing.
But also MSSQL shows you the index information.
Check the Explain, and search for clustered index seek, behind you will something like
tablename1, telling you that the first index was used. Primary index is tablename0.
Siegfried

Similar Messages

  • Help w/MaxDB Function; also: how does the "Debug SQL" function work?

    Hi there forum folks,
    In my former life, I was a Basis guy, but I haven't had the pleasure of working directly with SAP applications in a few months.  My current project is to attempt to use MaxDB in a real estate environment.  We're tracking home listings so that we can build statistical reports... such as "what agents are in the Top 100 in postal code X?"
    Anyway, as part of this project, I have attempted to construct my very first MaxDB database function.  Unfortunately, it doesn't give me the answers I'm hoping to see.  Here's the function:
    CREATE FUNCTION COUNT_LISTINGS (AGENTID CHAR(10)) RETURNS FIXED(6,1) AS
      VAR COLISTINGAGENTID CHAR(10);
          LISTINGAGENTID   CHAR(10);
          MLSNUMBER        CHAR(7);
          UNITS            FIXED(6,1);
      SET UNITS = 0;
      DECLARE FUNCTIONRESULT CURSOR FOR
        SELECT MLSNUMBER,
               LISTINGAGENTID,
               COLISTINGAGENTID FROM FREDDIE.GLAR_SOLDS
         WHERE LISTINGAGENTID = :agentid OR COLISTINGAGENTID = :agentid;
      IF $COUNT IS NULL THEN
        BEGIN
          CLOSE FUNCTIONRESULT;
          RETURN UNITS;
        END
      ELSE
        SET $RC = 0;
      WHILE $RC = 0 DO BEGIN
        FETCH FUNCTIONRESULT INTO :mlsnumber, :listingagentid, :colistingagentid;
        IF ( LISTINGAGENTID   = AGENTID AND COLISTINGAGENTID IS NULL ) OR
           ( COLISTINGAGENTID = AGENTID AND LISTINGAGENTID   IS NULL ) THEN
          SET UNITS = UNITS + 1
        ELSE
          SET UNITS = UNITS + 0.5;
      END;
    CLOSE FUNCTIONRESULT;
    RETURN UNITS;
    I've tried to follow the official MaxDB documentation.  My first deviation from that standard was the use of the "$COUNT" variable (instead of the "$RC" variable) immediately after the DECLARE/SELECT statement above.  When I tried to use $RC, for either a successful or unsuccessful query, $RC was always set to a non-zero value.
    I believe I'm past that, but now my issue is down around that FETCH statement.  The UNITS variable doesn't end up with the value I expect.  I know that it can be terribly confusing to try to analyze someone else's logic, but here's a brief narrative that describes what I'm trying to do...
    The GLAR_SOLDS table holds one line for each home sold.  It's keyed by the MLSnumber.  Each record also stores up to four agents who've been involved in the transaction: the listing agent, the co-listing agent, the selling agent, and the co-selling agent.  The database function I've written above pertains to the listing side only.  If I can get this to work, a separate function will process the selling side.  If no co-listing agent is involved in a given sell, that agent should get credit for 1 unit sold.  If he/she has help from a co-listing agent, the agent should only get credit for 1/2 unit sold.
    Also, does anyone know how the "Debug SQL" functionality is supposed to work within Database Studio?  When I right-mouse click on my function, and follow the path thru "Debug As...", after entering the connection & function arguments, I'm presented with an empty screen.  If you could point me to some documentation somewhere, I'd gratefully read it.
    I'm using MaxDB 7.7.06.09 on Windows XP (WIN32) with MaxDB Database Studio 7.7.06.09 (build 009-123-202-944).
    Thanks everyone for your help & advice.
    ~Fred

    Fred,
    please either provide the full SQL statements for your example or stick with mine.
    I'm not going to build it up myself a second time to suit yours now.
    >  But now, my issue is how do I store the resultant data in its own table?
    So where is the problem?
    INSERT INTO <target table> (field 1, field 2, ...)  (<your query>)  UDPATE DUPLICATES-
    With my tables this looks like this:
    create table sell_result (list_agent varchar(20) primary key, SUM_CREDIT fixed (10,2))
    insert
    into sell_result (list_agent,sum_credit)
        ( select list_agent, sum (credit) as SUM_CREDIT
          from ( select sh.object_id,lag.name as list_agent, 1 as credit
                 from soldhomes sh join agents lag on lag.id = sh.list_agent_id
                union all
                 select sh.object_id, lag.name as list_coagent, 0.5 as credit
                 from soldhomes sh join agents lag on lag.id = sh.list_coagent_id
          group by list_agent
    update duplicates
    Check what we have now
    sqlcli db770=> select * from sell_result
    | LIST_AGENT           | SUM_CREDIT        |
    | -------------------- | ----------------- |
    | Lars                 |              4.50 |
    | Lisa                 |              3.00 |
    | Mona                 |              2.50 |
    | Paul                 |              2.50 |
    4 rows selected (600 usec)
    Now add some sales data...
    Insert into soldhomes values (11, 1, 2, NULL, NULL)
    Insert into soldhomes values (12, 2, NULL, NULL, NULL)
    Insert into soldhomes values (13, 2, NULL, NULL, NULL)
    Re-run the INSERT command and you're done:
    sqlcli db770=> select * from sell_result
    | LIST_AGENT           | SUM_CREDIT        |
    | -------------------- | ----------------- |
    | Lars                 |              5.50 |
    | Lisa                 |              3.00 |
    | Mona                 |              5.00 |
    | Paul                 |              2.50 |
    4 rows selected (390 usec)
    Neat, isn't it?

  • Need to pass value from check box to the pl/sql function in process

    My requirement is to use single value check box and pass the flag value to the pl/sql function.
    The function need to interpret the flag and execute accordingly.
    In this case checkbox name is P1_DELETE and it returns Delete, if checked.
    Anonymous block with in the process looks as follows:
    declare
    l_result VARCHAR2(1024);
    begin
    l_result := test_function(:P1_DELETE);
    end;

    Hi Visu,
    checkboxes in APEX are handled as arrays, namely APEX_APPLICATION_GLOBAL.VC_ARR2. To pass and process the checked values of checkboxes in a pl/sql function or procedure you could use the following way, assuming you have a checkbox named P1_DELETE with a single return value of "Delete"
    DECLARE
        l_checkbox_values apex_application_global.vc_arr2;
    BEGIN
        l_checkbox := :P1_DELETE;
        -- calling function test_function processing the value
        test_function(NVL(l_checkbox(1), 'SOME_OTHER_VALUE'));
    END;If the checkbox is not checked then the array at position 1 is null and you have to process that as you like.
    If your checkbox would be a group than the array would be colon separated such as 1:2:3:4 etc. and you would have to loop the array like:
        FOR idx IN 1..l_checkbox.COUNT LOOP
            test_function(l_checkbox(idx));
        END LOOP;Hope that helps.
    Andreas

  • Using Case when statement in catalog doesnt result in the correct sql

    I am running into an issue on my current project wherein, I am not able to see the correct formula in the physical query as I am seeing it in the logical query:
    Logical query:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_SRC_PATH='/shared/Email/SFDC_InitRespTimel_Main';SELECT s_0, s_1, s_2, s_3, s_4, s_5 FROM (
    SELECT
    0 s_0,
    "CIN"."Calendar"."FIis Yr Nm" s_1,
    "CIN"."Calendar"."Fis Qtr Nm" s_2,
    "CIN"."SF Origin Dim"."Group" s_3,
    **CASE WHEN MIN("CIN"."SF_EailMsg_L"."Msg Dt") IS NOT NULL THEN SUM(TIMESTAMPDIFF(SQL_TSI_HOUR,MIN("SF_EailMsg_L"."Msg Dt"),"CIN"."SF_Case_L_Fact"."Created Dt"))/count("CIN"."SF_Case_L_Fact"."Case Number") END s_4,**
    **REPORT_AGGREGATE(CASE WHEN MIN("CIN"."SF_EailMsg_L"."Msg Dt") IS NOT NULL THEN SUM(TIMESTAMPDIFF(SQL_TSI_HOUR,MIN("SF_EailMsg_L"."Msg Dt"),"CIN"."SF_Case_L_Fact"."Created Dt"))/count("CIN"."SF_Case_L_Fact"."Case Number") END BY "CIN"."Calendar"."Fis Qtr Nm","CIN"."SF Origin Dim"."Group") s_5**
    FROM "CIN"
    WHERE
    (("Calendar"."FISCAL_YEAR_NAME" IN ('FY2011', 'FY2012', 'FY2013')) AND ("SF_EailMsg_L"."Status" = '3') AND ("Calendar"."FISCAL_QUARTER_NAME" <> 'Q1 FY2011'))
    ) djm ORDER BY 1, 2 ASC NULLS LAST, 3 ASC NULLS LAST, 4 ASC NULLS LAST
    Physical Query:
    select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4
    from
    (select T13596.CRTDDT_DT as c1,
    T4813.FISCAL_YEAR_NAME as c2,
    T4813.FISCAL_QUARTER_NAME as c3,
    T13313.GRP as c4,
    ROW_NUMBER() OVER (PARTITION BY T4813.FISCAL_QUARTER_NAME, T13313.GRP, T13596.CRTDDT_DT ORDER BY T4813.FISCAL_QUARTER_NAME ASC, T13313.GRP ASC, T13596.CRTDDT_DT ASC) as c5
    from
    DW_SF_EMLMSSG_L T13275,
    SF_ORGN_L_DIM T13313,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_L T13596 /* SF_CS_L_Fact */
    where ( T4813.CALENDAR_KEY = T13596.CRDT_KEY and T13275.PRNTID = T13596.ID and T13275.STTS = '3' and T13313.ORGN_KEY = T13596.ORGN_KEY and (T4813.FISCAL_YEAR_NAME in ('FY2011', 'FY2012', 'FY2013')) and T4813.FISCAL_QUARTER_NAME <> 'Q1 FY2011' )
    ) D1
    where ( D1.c5 = 1 )
    WITH
    SAWITH0 AS (select min(T13275.MSSGDT_DT) as c1,
    count(T13596.CSNMBR) as c2,
    T4813.FISCAL_YEAR_NAME as c5,
    T4813.FISCAL_QUARTER_NAME as c6,
    T13313.GRP as c7
    from
    DW_SF_EMLMSSG_L T13275,
    SF_ORGN_L_DIM T13313,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_L T13596 /* SF_CS_L_Fact */
    where ( T4813.CALENDAR_KEY = T13596.CRDT_KEY and T13275.PRNTID = T13596.ID and T13275.STTS = '3' and T13313.ORGN_KEY = T13596.ORGN_KEY and (T4813.FISCAL_YEAR_NAME in ('FY2011', 'FY2012', 'FY2013')) and T4813.FISCAL_QUARTER_NAME <> 'Q1 FY2011' )
    group by T4813.FISCAL_QUARTER_NAME, T4813.FISCAL_YEAR_NAME, T13313.GRP)
    select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7
    from
    (select D1.c1 as c1,
    D1.c2 as c2,
    min(D1.c1) over (partition by D1.c6, D1.c7) as c3,
    sum(D1.c2) over (partition by D1.c6, D1.c7) as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    ROW_NUMBER() OVER (PARTITION BY D1.c6, D1.c7 ORDER BY D1.c6 ASC, D1.c7 ASC) as c8
    from
    SAWITH0 D1
    ) D1
    where ( D1.c8 = 1 )
    I want to know if you have seen this scenario earlier?
    Basically, the case statement in the logical sql is not getting executed correctly in the physical sql. Also,I see a SAWWITH0 in the query. Have you seen this before.
    If you have any inputs on how to fix this, please share.
    Thanks in advance.
    -Mayank Sharma

    Hello,
    This is the logical and physical query that I am getting now.
    My question is that, why am I not seeing the division operator (/) anywhere in the physical query. I am worried that the physical query is not being executed correctly.
    Please clarify:
    SET VARIABLE QUERY_SRC_CD='Report',SAW_DASHBOARD='/shared/Email/Email',SAW_DASHBOARD_PG='Initial Resp Time',SAW_SRC_PATH='/shared/Email/SFDC_InitRespTimel_Main';SELECT s_0, s_1, s_2, s_3, s_4, s_5 FROM (
    SELECT
    0 s_0,
    "CIN"."Calendar"."FIis Yr Nm" s_1,
    "CIN"."Calendar"."Fis Qtr Nm" s_2,
    "CIN"."SF Origin Dim"."Group" s_3,
    CASE WHEN MIN("CIN"."SF_EailMsg_L"."Msg Dt") IS NOT NULL THEN SUM(TIMESTAMPDIFF(SQL_TSI_HOUR,MIN("SF_EailMsg_L"."Msg Dt"),"CIN"."SF_Case_L_Fact"."Created Dt"))*1.0/count("CIN"."SF_Case_L_Fact"."Case Number")*1.0 END s_4,
    REPORT_AGGREGATE(CASE WHEN MIN("CIN"."SF_EailMsg_L"."Msg Dt") IS NOT NULL THEN SUM(TIMESTAMPDIFF(SQL_TSI_HOUR,MIN("SF_EailMsg_L"."Msg Dt"),"CIN"."SF_Case_L_Fact"."Created Dt"))*1.0/count("CIN"."SF_Case_L_Fact"."Case Number")*1.0 END BY "CIN"."Calendar"."Fis Qtr Nm","CIN"."SF Origin Dim"."Group") s_5
    FROM "CIN"
    WHERE
    (("Calendar"."FISCAL_YEAR_NAME" IN ('FY2011', 'FY2012', 'FY2013')) AND ("SF_EailMsg_L"."Status" = '3') AND ("Calendar"."FISCAL_QUARTER_NAME" <> 'Q1 FY2011'))
    ) djm ORDER BY 1, 2 ASC NULLS LAST, 3 ASC NULLS LAST, 4 ASC NULLS LAST
    [2012-10-25T22:20:58.000+00:00] [OracleBIServerComponent] [TRACE:2] [USER-23] [] [ecid: a5bccb33dce3bd12:-c49596b:13a898b42b5:-8000-0000000000007756] [tid: 601c] [requestid: 1d4c0001] [sessionid: 1d4c0000] [username: weblogic] -------------------- General Query Info: [[
    Repository: Star, Subject Area: CIN, Presentation: CIN
    [2012-10-25T22:20:58.000+00:00] [OracleBIServerComponent] [TRACE:2] [USER-18] [] [ecid: a5bccb33dce3bd12:-c49596b:13a898b42b5:-8000-0000000000007756] [tid: 601c] [requestid: 1d4c0001] [sessionid: 1d4c0000] [username: weblogic] -------------------- Sending query to database named CIN (id: <<177780>>), connection pool named CINADMIN: [[
    select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4
    from
    (select T13596.CRTDDT_DT as c1,
    T4813.FISCAL_YEAR_NAME as c2,
    T4813.FISCAL_QUARTER_NAME as c3,
    T13313.GRP as c4,
    ROW_NUMBER() OVER (PARTITION BY T4813.FISCAL_QUARTER_NAME, T13313.GRP, T13596.CRTDDT_DT ORDER BY T4813.FISCAL_QUARTER_NAME ASC, T13313.GRP ASC, T13596.CRTDDT_DT ASC) as c5
    from
    DW_SF_EMLMSSG_L T13275,
    SF_ORGN_L_DIM T13313,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_L T13596 /* SF_CS_L_Fact */
    where ( T4813.CALENDAR_KEY = T13596.CRDT_KEY and T13275.PRNTID = T13596.ID and T13275.STTS = '3' and T13313.ORGN_KEY = T13596.ORGN_KEY and (T4813.FISCAL_YEAR_NAME in ('FY2011', 'FY2012', 'FY2013')) and T4813.FISCAL_QUARTER_NAME <> 'Q1 FY2011' )
    ) D1
    where ( D1.c5 = 1 )
    [2012-10-25T22:20:58.000+00:00] [OracleBIServerComponent] [TRACE:2] [USER-18] [] [ecid: a5bccb33dce3bd12:-c49596b:13a898b42b5:-8000-0000000000007756] [tid: 601c] [requestid: 1d4c0001] [sessionid: 1d4c0000] [username: weblogic] -------------------- Sending query to database named CIN (id: <<178213>>), connection pool named CINADMIN: [[
    select D1.c1 as c1,
    D1.c2 as c2,
    D1.c3 as c3,
    D1.c4 as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7
    from
    (select D1.c1 as c1,
    D1.c2 as c2,
    min(D1.c1) over (partition by D1.c6, D1.c7) as c3,
    sum(D1.c2) over (partition by D1.c6, D1.c7) as c4,
    D1.c5 as c5,
    D1.c6 as c6,
    D1.c7 as c7,
    ROW_NUMBER() OVER (PARTITION BY D1.c6, D1.c7 ORDER BY D1.c6 ASC, D1.c7 ASC) as c8
    from
    (select min(T13275.MSSGDT_DT) as c1,
    count(T13596.CSNMBR) as c2,
    T4813.FISCAL_YEAR_NAME as c5,
    T4813.FISCAL_QUARTER_NAME as c6,
    T13313.GRP as c7
    from
    DW_SF_EMLMSSG_L T13275,
    SF_ORGN_L_DIM T13313,
    CIN_CALENDARS_DIM T4813,
    DW_SF_CS_L T13596 /* SF_CS_L_Fact */
    where ( T4813.CALENDAR_KEY = T13596.CRDT_KEY and T13275.PRNTID = T13596.ID and T13275.STTS = '3' and T13313.ORGN_KEY = T13596.ORGN_KEY and (T4813.FISCAL_YEAR_NAME in ('FY2011', 'FY2012', 'FY2013')) and T4813.FISCAL_QUARTER_NAME <> 'Q1 FY2011' )
    group by T4813.FISCAL_QUARTER_NAME, T4813.FISCAL_YEAR_NAME, T13313.GRP
    ) D1
    ) D1
    where ( D1.c8 = 1 )

  • The troubles with creating SQL function in Java

    Hi!
    I use Oracle 10g and connect to it from Java application. I need in creating SQL functions from Java code.
    In Java I have:
    Statement stm = null; try{     stm = dbConnection.createStatement();     stm.executeUpdate( query ); }catch(SQLException ex){     throw ex; }finally{     try{ stm.close(); }catch(Exception ex){ stm.close(); } }
    And I'm passing the next SQL function:
    create or replace function get_me return number is
    result number;
    begin
    select 5 into result from dual;
    return result;
    end;
    This code is run successful, but I can't call this funtion, because it has status Invalid
    I'm looked the next error: PLS-00103: Encountered the symbol "" when expecting one of the following: . @ % ; is authid as cluster order using external character deterministic parallel_enable pipelined aggregate
    But I don't understand, What the matter? From Oracle Enterprise Manager I can create this function without problems. So, I wrote the wong Java code. Also, I can't find my error :(
    May be, do u have the some ideas?
    Thank you very much!

    Post the whole pl/sql code please.
    To run PL/SQL from within java you'll need callablestatement.
    [here |http://www.idevelopment.info/data/Programming/java/jdbc/PLSQL_and_JDBC/CallPLSQLFunc.java] an example : http://www.idevelopment.info/data/Programming/java/jdbc/PLSQL_and_JDBC/CallPLSQLFunc.java

  • Get result from PL/SQL function through XDBUri (10g)

    Hi!
    I have to call a PL/SQL function that takes two parameters and return one parameter. (I will do this from Oracle Service Bus).
    It is possible to get relational data as xml through an XDBUri type over http by using the XML DB functionality. But is it possible to get the result of a PL/SQL function as XML as well?
    I have tried to wrap the PL/SQL procedure inside a view, but cant get the variable to be bound into the sql.
    I have tried with stuff like this:
    create or replace view test (a, b)
    as
    select function(a, b) from dual
    But since I dont have a table returning the values i cant get it work.
    If I can make this view, I can call it through the XDMUri type.
    Sombody that can help me to manage this?
    /Helge
    Edited by: user3169245 on 03.apr.2009 12:06

    Here's a code snippet that may help
    package com.oracle.st.xmldb.pm.xfiles;
    import com.oracle.st.xmldb.pm.multipart.InputStreamProcessor;
    import com.oracle.st.xmldb.pm.multipart.MultipartInputStream;
    import java.io.IOException;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import oracle.jdbc.OracleConnection;
    import oracle.jdbc.OracleDriver;
    import oracle.jdbc.OracleCallableStatement;
    import com.oracle.st.xmldb.pm.multipart.MultipartProcessor;
    import com.oracle.st.xmldb.pm.multipart.MultipartProcessorImpl;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.PrintWriter;
    import java.io.Reader;
    import java.io.StringReader;
    import java.io.StringWriter;
    import java.io.Writer;
    import java.sql.DatabaseMetaData;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.Enumeration;
    import oracle.jdbc.OraclePreparedStatement;
    import oracle.jdbc.OracleResultSet;
    import oracle.jdbc.OracleTypes;
    import oracle.sql.BLOB;
    import oracle.sql.CLOB;
    import oracle.xdb.XMLType;
    import oracle.xml.parser.v2.XMLDocument;
    import org.w3c.dom.Attr;
    import org.w3c.dom.CDATASection;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Text;
    public class XFilesServlet extends HttpServlet implements InputStreamProcessor {
        public static String TARGET_PATH      = "target";
        public static String STYLESHEET_PATH      = "stylesheet"; 
        private static String CREATE_RESOURCE_SQL =
        "begin " +
        "  XFILES_SOAP_SERVICES.UPLOADRESOURCE" +
        "  ( " +
        "    P_RESOURCE_PATH => :1, " +
        "    P_CONTENT => :2, " +
        "    P_CONTENT_TYPE => :3," +
        "    P_DESCRIPTION => :4," +
        "    P_LANGUAGE => :5," +
        "    P_CHARACTER_SET => :6," +
        "    P_DUPLICATE_POLICY => :7" +
        "  );" +
        "end;";
        private static String GET_FOLDER_HTML_PAGE_SQL =
        "select xdburitype('/XFILES/lite/Folder.html').getClob() from dual";
        private static String WRITE_LOG_RECORD_SQL =
        "begin xfiles_logging.enqueue_log_record(:1); end;";
        private OracleConnection dbConnection;
        private OracleCallableStatement createResource;
        private OracleCallableStatement writeLogRecord;
        private DatabaseMetaData dbMetadata;
        private static final int FILE_UPLOAD = 1;
        private static final int PUBLISH_RSS = 2;
        private static final int DB_REST_SERVICE = 3;
        private static final int FORCE_AUTHENTICATION = 4;
        private static final int SET_PASSWORD = 5;
        private static final int DISPLAY_XML = 6;
        private static final int ENABLE_RSS = 7;
        public static final int XDB_ACCESS_DENIED = 31050;
        private static String SERVLET_ROOT = "/sys/servlets/XFILES";
        private static final String FILE_UPLOAD_PATH = "fileUpload";
        private static final String PUBLISH_RSS_PATH = "publishRSS";
        private static final String SET_PASSWORD_PATH = "setPassword";
        private static final String DB_REST_SERVICE_PATH = "dbRestService";
        private static final String FORCE_AUTHENTICATION_PATH = "doAuthentication";
        private static final String DISPLAY_XML_PATH = "displayXML";
        private static final String ENABLE_RSS_PATH = "enableRSS";
        public static String POST_UPLOAD_URL = "postUploadRedirect";
        public static String DULPLICATE_POLICY = "duplicatePolicy";
        public static String SOURCE_FILE_PATH = "sourceFilePath";
        public static String RESOURCE_FILENAME = "targetFileName";
        public static String RESOURCE_DESCRIPTION = "description";
        public static String UPLOAD_LANGUAGE = "UploadLanguage";
        public static String UPLOAD_CHARACTERSET = "UploadCharset";
        public static String PASSWORD = "password";
        public static String XML_DOCUMENT = "content";
        public static String XML_CHUNK = "chunk";
        public static String RESOURCE_ID = "resid";
        public static String DATABASE_SCHEMA = "DatabaseSchema";
        public static String PACKAGE  = "Package";
        public static String METHOD = "Method";
        public static String SQL_CALL = "SqlOperation";
        protected XMLDocument logRecord;
        protected Element parameterList;
        protected Element timings;
        protected int currentOperation;
        public String xmlContent;
        public static String XML_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS000";
        public static String LOG_TIMESTAMP_FORMAT = "HH:mm:ss.SSS000";
        protected SimpleDateFormat xmlDateFormatter  = new SimpleDateFormat(XML_TIMESTAMP_FORMAT); 
        private String postUploadURL;
        private String targetFolder;
        private String onDuplicateAction;
        private String sourceFile;
        private BLOB   resourceContent;
        private String contentType;
        private String resourceName;
        private String resourceComment;
        private String uploadLanguage;
        private String uploadCharacterSet;
        public XFilesServlet() {
        private void logParameter(Document doc)
           this.parameterList.appendChild(logRecord.importNode(doc.getDocumentElement().cloneNode(true),true));
        private void logParameter(String parameterName, String[] values)
          Element e = this.logRecord.createElement(parameterName);
          this.parameterList.appendChild(e);
          if (values != null)
            Attr a = this.logRecord.createAttribute("Length");
            e.setAttributeNode(a);
            a.setValue(Integer.toString(values.length));
            for (int i = 0; i < values.length; i++)
              Element v = this.logRecord.createElement("parameterValue");
              e.appendChild(v);
              Text t = this.logRecord.createTextNode(values);
    v.appendChild(t);
    a = this.logRecord.createAttribute("Index");
    v.setAttributeNode(a);
    a.setValue(Integer.toString(i));
    public void logParameter(String parameterName,String value)
    Element e = this.logRecord.createElement(parameterName);
    this.parameterList.appendChild(e);
    if (value != null)
    Text t = this.logRecord.createTextNode(value);
    e.appendChild(t);
    private void logParameterCDATA(String parameterName,String value)
    Element e = this.logRecord.createElement(parameterName);
    this.parameterList.appendChild(e);
    if (value != null)
    CDATASection c = this.logRecord.createCDATASection(value);
    e.appendChild(c);
    private void logException(Exception e) {
    Element stackTrace = this.logRecord.createElement("StackTrace");
    this.logRecord.getDocumentElement().appendChild(stackTrace);
    this.appendException(stackTrace,e);
    private void appendException(Element stackTrace, Throwable error)
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    error.printStackTrace(pw);
    pw.flush();
    pw.close();
    Text t = this.logRecord.createCDATASection(sw.toString());
    stackTrace.appendChild(t);
    if (error.getCause() != null)
    Element causedBy = this.logRecord.createElement("CausedBy");
    stackTrace.appendChild(causedBy);
    appendException(causedBy,error.getCause());
    else {
    if (error instanceof ServletException) {
    ServletException se = (ServletException) error;
    if (se.getRootCause() != null) {
    Element causedBy = this.logRecord.createElement("CausedBy");
    stackTrace.appendChild(causedBy);
    appendException(causedBy,se.getRootCause());
    private void logTimestamp(String eventName)
    Timestamp ts = new Timestamp(System.currentTimeMillis());
    Element element = logRecord.createElement(eventName);
    this.timings.appendChild(element);
    Text text = logRecord.createTextNode(this.xmlDateFormatter.format(ts));
    element.appendChild(text);
    protected void initiateLogging(HttpServletRequest request)
    throws IOException
    this.logRecord = new XMLDocument();
    Element root = this.logRecord.createElement("XFilesLogRecord");
    this.logRecord.appendChild(root);
    Element e = this.logRecord.createElement("HttpRequest");
    root.appendChild(e);
    Element e1 = this.logRecord.createElement("ServletName");
    Text t = this.logRecord.createTextNode(this.getClass().getName());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("HttpMethod");
    t = this.logRecord.createTextNode(request.getMethod());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("RequestURI");
    t = this.logRecord.createTextNode(request.getRequestURI());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("PathTranslated");
    t = this.logRecord.createTextNode(request.getPathTranslated());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("RequestURL");
    t = this.logRecord.createTextNode(new String(request.getRequestURL()));
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("Protocol");
    t = this.logRecord.createTextNode(request.getProtocol());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("ServerName");
    t = this.logRecord.createTextNode(request.getServerName());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("ContentType");
    t = this.logRecord.createTextNode(request.getContentType());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("LocalAddr");
    t = this.logRecord.createTextNode(request.getLocalAddr());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("LocalName");
    t = this.logRecord.createTextNode(request.getLocalName());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("LocalPort");
    t = this.logRecord.createTextNode(Integer.toString(request.getLocalPort()));
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("Port");
    t = this.logRecord.createTextNode(Integer.toString(request.getServerPort()));
    e1.appendChild(t);
    e.appendChild(e1);
    this.timings = this.logRecord.createElement("Timestamps");
    root.appendChild(this.timings);
    logTimestamp("Init");
    e = this.logRecord.createElement("Remote");
    root.appendChild(e);
    e1 = this.logRecord.createElement("RemoteHost");
    t = this.logRecord.createTextNode(request.getRemoteHost());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("RemoteAddress");
    t = this.logRecord.createTextNode(request.getRemoteAddr());
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("RemotePort");
    t = this.logRecord.createTextNode(Integer.toString(request.getRemotePort()));
    e1.appendChild(t);
    e.appendChild(e1);
    e1 = this.logRecord.createElement("RemoteUser");
    t = this.logRecord.createTextNode(request.getRemoteUser());
    e1.appendChild(t);
    e.appendChild(e1);
    e = this.logRecord.createElement("RequestHeaders");
    root.appendChild(e);
    Enumeration headerNames = request.getHeaderNames();
    while (headerNames.hasMoreElements())
    String headerName = (String) headerNames.nextElement();
    e1 = this.logRecord.createElement(headerName);
    t = this.logRecord.createTextNode(request.getHeader(headerName));
    e1.appendChild(t);
    e.appendChild(e1);
    this.parameterList = this.logRecord.createElement("ServletParameters");
    root.appendChild(parameterList);
    public void writeLogRecord(XMLDocument logRecord) throws SQLException , IOException {
    XMLType xml = new XMLType(this.dbConnection, logRecord);
    this.writeLogRecord.setObject(1, xml);
    this.writeLogRecord.execute();
    this.dbConnection.commit();
    protected String readParameter(HttpServletRequest request,String parameterName,String defaultValue)
    String value = request.getParameter(parameterName);
    if (value != null)
    if (value.length() == 0) {
    value = null;
    if (value == null) {
    value = defaultValue;
    logParameter(parameterName,value);
    return value;
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException
    try {
    try {  
    initiateLogging(request);
    initializeDatabaseConnection();
    String requestURI = request.getRequestURI();
    this.currentOperation = getOperation(requestURI);
    switch (this.currentOperation) {
    case DB_REST_SERVICE:
    restResponse(request,response);
    break;
    default:
    response.sendError(HttpServletResponse.SC_NOT_FOUND);
    logTimestamp("Complete");
    writeLogRecord(this.logRecord);
    this.dbConnection.commit();
    catch (Exception e) {
    try {
    this.dbConnection.rollback();
    logTimestamp("Exception");
    logException(e);
    writeLogRecord(this.logRecord);
    catch (Exception wle) {
    System.out.println("XFilesServlet : Fatal error while logging Error : ");
    e.printStackTrace(System.out);
    System.out.flush();
    wle.printStackTrace(System.out);
    System.out.flush();
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    finally {
    try {
    this.createResource.close();
    this.writeLogRecord.close();
    catch (SQLException e) {
    System.out.println("XFilesServlet : Fatal error while closing statements : ");
    e.printStackTrace(System.out);
    response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (IOException ioe) {
    System.out.println("XFilesServlet : Fatal error while Sending Error Status : ");
    ioe.printStackTrace(System.out);
    System.out.flush();
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    doGet(req, res);
    private void initializeDatabaseConnection() throws SQLException {
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    OracleDriver ora = new OracleDriver();
    this.dbConnection = (OracleConnection) ora.defaultConnection();
    this.createResource = (OracleCallableStatement) this.dbConnection.prepareCall(this.CREATE_RESOURCE_SQL);
    this.writeLogRecord = (OracleCallableStatement) this.dbConnection.prepareCall(this.WRITE_LOG_RECORD_SQL);
    this.dbMetadata = this.dbConnection.getMetaData();
    private int getOperation(String requestURI) {
    String servletTarget = requestURI.substring(this.SERVLET_ROOT.length()+1);
    if (servletTarget.indexOf('/') > -1) {
    servletTarget = servletTarget.substring(0,servletTarget.indexOf("/"));
    if (servletTarget.equals(this.FILE_UPLOAD_PATH)) return FILE_UPLOAD;
    if (servletTarget.equals(this.FORCE_AUTHENTICATION_PATH)) return this.FORCE_AUTHENTICATION;
    if (servletTarget.equals(this.PUBLISH_RSS_PATH)) return this.PUBLISH_RSS;
    if (servletTarget.equals(this.DB_REST_SERVICE_PATH)) return this.DB_REST_SERVICE;
    if (servletTarget.equals(this.SET_PASSWORD_PATH)) return this.SET_PASSWORD;
    if (servletTarget.equals(this.DISPLAY_XML_PATH)) return this.DISPLAY_XML;
    if (servletTarget.equals(this.ENABLE_RSS_PATH)) return this.ENABLE_RSS;
    return 0;
    public void processParameter(String name, String value)
    throws SQLException {
    logParameter(name,value);
    if (name.equals(this.TARGET_PATH)) {
    this.targetFolder = value;
    if (name.equals(this.POST_UPLOAD_URL)) {
    this.postUploadURL = value;
    if (name.equals(this.UPLOAD_LANGUAGE)) {
    this.uploadLanguage = value;
    if (name.equals(this.UPLOAD_CHARACTERSET)) {
    this.uploadCharacterSet = value;
    if (name.equals(this.DULPLICATE_POLICY)) {
    this.onDuplicateAction = value;
    if (name.equals(this.SOURCE_FILE_PATH)) {
    this.sourceFile = value;
    if (name.equals(MultipartProcessor.MULTIPART_CONTENT_TYPE)) {
    this.contentType = value;
    if (name.equals(this.RESOURCE_FILENAME)) {
    this.resourceName = value;
    if (name.equals(this.RESOURCE_DESCRIPTION)) {
    this.resourceComment = value;
    createNewResource();
    private void restResponse(HttpServletRequest request, HttpServletResponse response)
    throws IOException, SQLException, ServletException {
    String requestURI = request.getRequestURI();
    String restTarget = requestURI.substring(this.SERVLET_ROOT.length() + this.DB_REST_SERVICE_PATH.length()+1);
    if (restTarget.contains("//")) {
    // Cannot have // in URL
    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
    return;
    if (restTarget.length() < 4) {
    // URL is too short to be valid - Minumum is /A/B
    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
    return;
    if (!restTarget.startsWith("/")) {
    // Invalid URL
    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
    return;
    if (!restTarget.substring(1).contains("/")) {
    // URL must contain /Schema/Method, may Contain /Schema/Package/Method
    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
    return;
    String schemaName = restTarget.substring(1,restTarget.substring(1).indexOf("/")+1);
    restTarget = restTarget.substring(schemaName.length()+1);
    logParameter(this.DATABASE_SCHEMA,schemaName);
    String packageName = null;
    if (restTarget.substring(1).contains("/")) {
    // URL contains /Schema/Package/Method
    packageName = restTarget.substring(1,restTarget.substring(1).indexOf("/")+1);
    restTarget = restTarget.substring(packageName.length()+1);
    logParameter(this.PACKAGE,packageName);
    if (restTarget.substring(1).contains("/")) {
    // URL must be /Schema/Method or /Schema/Package/Method, anything else is junk
    response.sendError(HttpServletResponse.SC_BAD_REQUEST);
    return;
    String methodName = restTarget.substring(1);
    logParameter(this.METHOD,methodName);
    int responseCode = verifyTarget(request,schemaName,packageName,methodName);
    if (responseCode != HttpServletResponse.SC_OK) {
    System.out.println("Status Code = " + responseCode);
    response.sendError(responseCode);
    return;
    String target = "\"" + schemaName + "\".";
    if (packageName != null) {
    target = target + "\"" + packageName + "\".";
    target = target + "\"" + methodName + "\"";
    int index;
    Enumeration parmNames;
    String sqlStatementText =
    "begin" + "\n" +
    " :1 := " + target + "(" + "\n";
    index = 1;
    parmNames = request.getParameterNames();
    while (parmNames.hasMoreElements()) {
    index++;
    sqlStatementText = sqlStatementText + "\"" + parmNames.nextElement() + "\" => :" + index + " ";
    if (parmNames.hasMoreElements()) {
    sqlStatementText = sqlStatementText + ",\n";
    sqlStatementText = sqlStatementText + ");\nend;";
    logParameterCDATA(this.SQL_CALL,sqlStatementText);
    OracleCallableStatement statement = (OracleCallableStatement) this.dbConnection.prepareCall(sqlStatementText);
    index = 1;
    parmNames = request.getParameterNames();
    while (parmNames.hasMoreElements()) {
    index++;
    String parameterName = (String) parmNames.nextElement();
    String parameterValue = (String) request.getParameter(parameterName);
    logParameter(parameterName,parameterValue);
    statement.setString(index,parameterValue);
    XMLType xml = null;
    try {
    statement.registerOutParameter(1,OracleTypes.OPAQUE,"SYS.XMLTYPE");
    statement.execute();
    xml = (XMLType) statement.getObject(1);
    statement.close();
    catch (SQLException sqle) {
    statement.close();
    if (xml != null) xml.close();
    if (sqle.getErrorCode() == this.XDB_ACCESS_DENIED) {
    logTimestamp("RequestAuthorization");
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
    return;
    ServletException se = new ServletException("Unexpected SQL Error",sqle);
    throw se;
    response.setContentLength(0);
    response.setContentType("text/xml");
    xml.writeToOutputStream(response.getOutputStream());
    xml.close();
    response.getOutputStream().flush();
    response.getOutputStream().write( new byte[] {'\r','\n'} );
    // response.getOutputStream().flush();
    response.getOutputStream().close();
    response.setStatus(HttpServletResponse.SC_OK);
    private int verifyTarget(HttpServletRequest request, String schemaName, String packageName, String methodName)
    throws SQLException {
    int response = HttpServletResponse.SC_NOT_FOUND;
    boolean parameterValid = false;
    ResultSet procedure = null;
    procedure = this.dbMetadata.getProcedures(packageName,schemaName,methodName);
    while (procedure.next()) {
    response = HttpServletResponse.SC_OK;
    response = verifyMandatoryParameters(request,schemaName,packageName,methodName);
    if (response == HttpServletResponse.SC_OK) {
    response = verifyOptionalParameters(request,schemaName,packageName,methodName);
    return response;
    private int verifyMandatoryParameters(HttpServletRequest request, String schemaName, String packageName, String methodName) throws SQLException {
    // Check Mandatory Parameters are present.
    ResultSet columns = null;
    columns = this.dbMetadata.getProcedureColumns(packageName,schemaName,methodName,"%");
    while (columns.next()) {
    short nullable = columns.getShort(12);
    String columnName = columns.getString(4);
    if (nullable == DatabaseMetaData.procedureNoNulls) {
    if (request.getParameter(columnName) == null) {
    columns.close();
    return HttpServletResponse.SC_BAD_REQUEST;
    return HttpServletResponse.SC_OK;
    private int verifyOptionalParameters(HttpServletRequest request, String schemaName, String packageName, String methodName) throws SQLException {
    // Check Optional Parameters are valid
    Enumeration parms = request.getParameterNames();
    ResultSet column = null;
    while (parms.hasMoreElements()) {
    String columnName = (String) parms.nextElement();
    column = this.dbMetadata.getProcedureColumns(packageName,schemaName,methodName,columnName);
    if (!column.next()) {
    column.close();
    return HttpServletResponse.SC_BAD_REQUEST;
    column.close();
    return HttpServletResponse.SC_OK;

  • Unable to retreive the return value of pl/sql function using DB Adapter

    Dear Experts,
    I am using DB Adapter in my BPEL Process. Using DB Adapter I am invoking a PL / SQL function. I am able to send two input parameters for the pl/sql function. But I dont know how to retrieve the return value from the function. Please suggest me.
    Thanks,
    Rajesh

    Yes I am returning a value from PL/SQL function.
    Please see the code segments below,
    FUNCTION "TD_INSERT" (a TDINIT_TYPE, stops TDDETAIL_TABLE )
    RETURN VARCHAR2
    AS
    td_no Number;
    td_id Number;
    stop TDDETAILFULL_TYPE;
    length number;
    BEGIN
    insert into TD_INIT values( ----passing all the values here --------- );
    select max(tdno) into td_no from TD_INIT ;
    length := stops.count;
    for i in 1.. length loop
    stop := stops(i);
    insert into TD_DETAIL_FULL values(
    td_no, ------- );
    end loop;
    commit;
    RETURN td_no;
    END;
    Thanks,
    Rajesh

  • Return the two values in PL/SQL function

    Hi,
    How to create the PL/SQL function to return two values based on arguments?
    Can anyone suggest me the idea?
    TIA,

    Dhiva wrote:
    How to create the PL/SQL function to return two values based on arguments?A function can return only a single "+thing+".
    That thing can be a scalar value (single value). Such as date, number or string. E.g.
    create or replace function F... return number is ..That thing can be a non-scalar value (array). E.g.
    create or replace type TNumberArray is table of numbner;
    create or replace function F... return TNumberArray is ..That thing can be a complex scalar structure (record/object type) E.g.
    create or replace function F... return EMP%RowType is ..That thing can be a complex non-scalar structure (array of object/record types). E.g.
    create object TNameValue is object(
      name varchar2(30),
      value varchar2(4000)
    create or replace TNameValueArray is table of TNameValue;
    create or replace function F... return TNameValue is ..The bottom line is think structured data. A function can return a single variable. But that variable can (and should be) a proper structured data variable - and can be complex and can be non-scalar.

  • Extracting data of data type 'real' from the sql server database

    Hi,
    In my job, my source is a sql server database.
    I am connecting to the source sql server database using ODBC (sqlserver driver) in the datastore.
    In one of my source tables i have a field of data type real.If one of the value is 3.45678 , data services brings it in as 3.456780, which is OK, but if the real value is 4.7 in source, data services brings it  as 4.699997. I want it to be brought in as 4.700000 and not as 4.699997(i.e it is expanding upto 6 digits after the decimal point).
    Is this a default behavior of how data services reads the 'real' data types or is it because of how the ODBC sql server driver reads the data ?
    Is the above problem connected to an option in the DS.config file called
    LAZY_DECIMAL_CONVERSION which is set as true in our file.Should i set as false and will it solve this problem?
    Thanks in Advance.

    I tried reproducing your case, I read a value with real datatype from sql server DB. For me the values are coming fine, 4.7 is read as 4.700000 or 4.528 as 4.528000. I have also checked the value of LAZY_DECIMAL_CONVERSION, it is true. So I dont think it is a problem with that being set to true. Try something out with the Column properties in Query transform.
    I am using DS 3.2/ SQLSERVER 2008.
    Edited by: Lakhan Lalla on Oct 31, 2011 12:04 PM

  • Problem with empty report parameters when passed to PL/SQL function

    Hi,
    We have come across what appears to be a bug in the JRC. When passing a report parameter to a PL/SQL function as a parameter, empty parameters are changed before being sent to the function. More specifically, an empty string "" ends up as the value "(')" in the PL/SQL function parameter. In our report we print the report parameters on the first page so we know that the parameters are OK before being passed to the database.
    The problem exists for version 12.2.203, 12.2.204 and 12.2.205 of the JRC.
    We have identified a workaround, but it is not exactly elegant: Before executing the report we modify all empty  parameters ("") to " " . In the PL/SQL function, we trim all parameters before using them.
    We call the function using a command object with a sql syntax like this example:
    select * from table (qa_batch_release.get_qa_br('{?p_report_id}','{?p_reg_set_number}','{?p_cr_number}','{?p_change_id_decode}','{?p_country_id}','{?p_mfg_item_no}','{?p_4_no}','{?p_5_no}','{?p_7_no}'))
    The PL/SQL function is a table returning function.
    Best regards, Thor

    Hi Kishore,
    using #COLUMN_VALUE# would probably not make much sense, because normally a report has multiple columns and not just the numeric column which you want to verify if it's negative. But APEX will fire the template condition for each column, because the report template is a column cell template.
    What you can do to make it more generic is to use for example
    #CHECK_AMOUNT#
    in the template and provide a not displayed column in your SQL statement which contains your value which is named CHECK_AMOUNT. For example:
    SELECT NAME
         , BALANCE
         , BALANCE AS CHECK_AMOUNT
    FROM XXX;Because this CHECK_AMOUNT column would be a generic name, you can use this template in all your reports as long as you provide this column.
    Thope that helps
    Patrick

  • XMLType schema detail lost in pl/sql function for a jdeveloper webservice

    If I write a very simple pl/sql procedure to wrap as a web service to return the XML from an XMLtype table column, the jdeveloper (11.1.1.3) web service generation process seems to ignore the detail
    of the registered XMLTypes' schema, and converts the 'output' to an xsd:string in the generated WSDL file, which has knock on effect that generated data controls are 'dumb' in only seeing output as a string, and providing no real data functionality at XML schema level. Since I know web service data controls work fine when provided with the correct level of detail in the WSDL, what am I missing in terms of pursuading jdeveloper to generate wsdl's with full xsd schema info for the return XMLType?
    This is my table:
    ID NOT NULL NUMBER(12)
    SPEC SYS.XMLTYPE(XMLSchema "http:
    //localhost:8080/public/demo
    /xsd/sample2.xsd" Element "b
    ooks") STORAGE BINARY
    PRD_ID NOT NULL NUMBER(10)
    ISSUE NOT NULL NUMBER(6)
    EDIT_NO NOT NULL NUMBER(6)
    PUBLISHED_BY_PEO_ID NUMBER(10)
    PUBLISHED_ON_DT DATE
    EFFECTIVE_FROM_DT NOT NULL DATE
    EFFECTIVE_TO_DT DATE
    =======================================================
    This is the XML Schema:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="urn:books"
    xmlns:bks="urn:books">
    <xsd:element name="books" type="bks:BooksForm"/>
    <xsd:complexType name="BooksForm">
    <xsd:sequence>
    <xsd:element name="book"
    type="bks:BookForm"
    minOccurs="0"
    maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="BookForm">
    <xsd:sequence>
    <xsd:element name="author" type="xsd:string"/>
    <xsd:element name="title" type="xsd:string"/>
    <xsd:element name="genre" type="xsd:string"/>
    <xsd:element name="price" type="xsd:float" />
    <xsd:element name="pub_date" type="xsd:date" />
    <xsd:element name="review" type="xsd:string"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:string"/>
    </xsd:complexType>
    </xsd:schema>
    =================================================
    This is the pl/sql:
    function GetSpecificationById (p_spec_id in NUMBER) return XMLType
    IS
    l_specification sys.XMLType;
    BEGIN
    select specification
    into l_specification
    from specifications
    where id = p_spec_id;
    return l_specification;
    EXCEPTION
    WHEN OTHERS THEN -- handles all other errors
    ROLLBACK;
    END GetSpecificationById;
    ==============================================
    And this is the generated WSDL:
    <?xml version="1.0" encoding="UTF-8" ?>
    <wsdl:definitions
    name="MyWebService1"
    targetNamespace="http://devsafetrytrailcom/MyWebService1.wsdl"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://devsafetrytrailcom/MyWebService1.wsdl"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    >
    <wsdl:types>
    </wsdl:types>
    <wsdl:message name="MyWebService1_getspecificationbyid">
    <wsdl:part name="pSpecId" type="xsd:decimal"/>
    </wsdl:message>
    <wsdl:message name="MyWebService1_getspecificationbyidResponse">
    *<wsdl:part name="result" type="xsd:string"/>*
    </wsdl:message>
    <wsdl:portType name="MyWebService1">
    <wsdl:operation name="getspecificationbyid" parameterOrder="pSpecId">
    <wsdl:input message="tns:MyWebService1_getspecificationbyid"/>
    <wsdl:output message="tns:MyWebService1_getspecificationbyidResponse"/>
    </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="MyWebService1" type="tns:MyWebService1">
    <soap:binding style="rpc"
    transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getspecificationbyid">
    <soap:operation soapAction="http://devsafetrytrailcom/MyWebService1.wsdl/getspecificationbyid"/>
    <wsdl:input>
    <soap:body use="literal"
    namespace="http://devsafetrytrailcom/MyWebService1.wsdl"
    parts="pSpecId"/>
    </wsdl:input>
    <wsdl:output>
    <soap:body use="literal"
    namespace="http://devsafetrytrailcom/MyWebService1.wsdl"
    parts="result"/>
    </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="MyWebService1">
    <wsdl:port name="MyWebService1Port" binding="tns:MyWebService1">
    <soap:address location="http://localhost:7101/SafetyTrail-Model-context-root/MyWebService1Port"/>
    </wsdl:port>
    </wsdl:service>
    </wsdl:definitions>
    Edited by: user592403 on Jul 26, 2010 9:57 AM

    Anyone seen this problem before??

  • Question about PL/SQL Function in report

    Hi all. I have a (basic) question about using a PL/SQL function in a report. In my report page I have an item (PL/SQL function) that has the following syntax:
    return username from t1
    where username like 'Le%'
    I reference this item in an email process. Ideally this function would return all usernames that begin with 'Le' in the drafted email; however, its not looping so I'm only getting a return on the first name.
    I have a few books on PL/SQL but I'm not exactly sure where to start - I imagine there is a loop process I need to integrate into the function but, like I said, I'm not sure.
    I would have posted this to the PL/SQL forum but also wanted some feedback on whether or not using this method is the best way forward. Essentially I have a table with usernames and just want to send email messages based on some simple logic.
    Thanks!
    Len

    Hi Sergio,
    First, it's an honor to have you reply to my post. Thanks!
    To be more specific,
    T1 is a table containing the results from a user security scan. Username is a column in this table containing user names. What I have done is create a page in HTML DB with the following elements:
    1. An 'Item' containing the PL/SQL function that is hidden. The purpose of this Item is to generate information from T1 that meets the simple logic parameters - in this case, the user names that begin with "Le". I have called this Item P145_TT
    2. A 'Process' containing references to HTMLDB_MAIL. The 'Process' looks similar to this:
    HTMLDB_MAIL.SEND(
    P_TO => '[email protected]',
    P_FROM => 'Anon Email Account',
    P_BODY => 'Note: This message was automatically generated. Do not attempt to reply to this email.
    These are the users that begin with Le: '||:P145_TT||' ',
    P_SUBJ => 'Summary');
    3. A 'Button' to submit the process and (hopefully) send the message containing all users that adhere to the logic in the function.
    4. If I use 'return username from t1...' I will get a username generated, but like I said previously, it only gives me the first and does not loop.

  • Need to obtain updateable ResultSet via call to PL/SQL function

    I'm using JDBC and the Oracle JDBC driver to call a PL/SQL function that returns a SYS_REFCURSOR. I do this via a CallableStatement object and then cast the output parameter to a ResultSet object. However, I want this ResultSet object I end up with to be updateable. The following code throws an exception stating "Invalid operation for read only resultset: updateString ":
    cstmt2 = con.prepareCall("{? = call get_upload_entry_for_update(?)}",
                             ResultSet.TYPE_FORWARD_ONLY,
                             ResultSet.CONCUR_UPDATABLE);
    cstmt2.registerOutParameter(1, OracleTypes.CURSOR);
    cstmt2.setInt(2, newUploadId);
    cstmt2.execute();
    rs = (ResultSet) cstmt2.getObject(1);
    rs.next();
    rs.updateString("UPLOAD_FILENAME", fileName);
    // . . .So even though, I create the CallableStatement such that ResultSets should be updateable, it's not allowing me to do any updates. Also, in case you're wondering, inside the PL/SQL function, the query on which the cursor is based is a select statement which does specify "for update" at the end.
    I can get it to work as follows using a Statement object that executes the SELECT statement directly instead of a CallableStatement that executes a PL/SQL function:
    Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    rs = stmt.executeQuery("select UPLOAD_FILENAME, UPLOAD_FILE from rf_upload where upload_id = "+newUploadId+" for update");
    rs.next();
    rs.updateString("UPLOAD_FILENAME", fileName);
    //. . . Although this works, the project I'm working has a goal to encapsulate all SQL into Functions and Stored Procedures so I'd like to get it working that way instead.
    So the bottom-line question is: Using the Oracle JDBC driver, how can I call a PL/SQL function in such a way that I can obtain an updateable ResultSet object?
    Thanks for any suggestions. I'd be happy to clarify anything that's unclear.

    Hmmm...
    I'm still scratching my head about this one, just not sure it's doable, but I'll point out something, maybe it will give you a clue...
    In your code, you have:
    cstmt2 = con.prepareCall("{? = call get_upload_entry_for_update(?)}",
                             ResultSet.TYPE_FORWARD_ONLY,
                             ResultSet.CONCUR_UPDATABLE);I don't think the ResultSet parameters do anything towards your goal of getting an updatable result set via the returned cursor, those parameters affect the result set produced if you were to call:
    ResultSet rs2 = cstmt2.executeQuery();and not the result set generated by:
    rs = (ResultSet) cstmt2.getObject(1);Futhermore, while the "FOR UPDATE" is almost certainly something you want to do, it also doesn't affect the cursor (I think) but merely locks the affected rows in the DB.
    You might try calling rs.getType() and rs.getConcurrency() on the ResultSet you get from getObject, though I suspect they'll merely confirm the bad news that the cursor your getting back isn't right...
    You also might try the Oracle-specific getCursor call:
    rs = ((OracleCallableStatement)cstmt2).getCursor (1)instead of getObject, though I don't think it will help...
    I've been curious enough to dig around through most of my handy references and Oracle's docs and MetaLink and come up mostly empty, although almost 5 years ago Oracle Support said:
    " Reference Cursors from a pl/sql stored procedure are not updateable in any language."

  • SQL report region source to call a pl/sql function using DB link

    Hi - I have a pl/sql function fn_dbtype(id NUMBER) defined in database X. The pl/sql function executes couple DML statements and returns a string (a SELECT query). I am able to call this function using SQL Plus (Connected to Database X) as below and it works fine:
    declare
    vSQL VARCHAR2(100);
    begin
    vSQL := fn_dbtype(1);
    end;
    The DML operations completed fine and vSQL contains the "Select" query now.
    In APEX:
    I am trying to create a SQL report in APEX using SQL query(PL/SQL function returning a sql statement) option. I am trying to figure out what to put in the region source so that the output of the "Select" query is displayed in the report.
    Moreover APEX is hosted in a different database instance. So I would need to call this pl/sql function using a DB Link.
    Please let me know what I need to put in the region source to execute the pl/sql function which returns the "Select" query thereby displaying the query output in the report. Thanks.
    Edited by: user709584 on Mar 19, 2009 2:32 PM
    Edited by: user709584 on Mar 19, 2009 2:34 PM

    try something like this:
    return fn_dbtype(1)@dblink;

  • Pass a value from a PL/SQL function to a javascript (html header) ? ?

    Hey Guys,
    Have a question regarding how to pass a value from a PL/SQL function to a javascript in the HTML Header.
    I have created a PL/SQL function in my database, which does looping.
    The reason for this is:  On my apex page when the user selects a code, it should display(or highlight buttons) the different project id's present for that particular code.
    example= code 1
    has project id's = 5, 6, 7
    code 2
    has project id's = 7,8
    Thank you for your Help or Suggestions
    Jesh
    The PL/SQL function :
    CREATE OR REPLACE FUNCTION contact_details(ACT_CODE1 IN NUMBER) RETURN VARCHAR2 IS
    Project_codes varchar2(10);
    CURSOR contact_cur IS
    SELECT ACT_CODE,PROJECT_ID
    FROM ACTASQ.ASQ_CONTACT where ACT_CODE = ACT_CODE1;
    currec contact_cur%rowtype;
    NAME: contact_details
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 6/25/2009 1. Created this function.
    BEGIN
    FOR currec in contact_cur LOOP
         dbms_output.put_line(currec.PROJECT_ID || '|');
         Project_codes := currec.PROJECT_ID|| '|' ||Project_codes;
    END LOOP;
    RETURN Project_codes;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END contact_details;
    /

    Jesh:
    I have made the following modifications to your app to get it to work as I thing you need it to.
    1) Changed the source for the HTML Buttons Region(note use of id vs name for the Buttons)
    <script>
    function hilitebtn(val) {
    //gray buttons
    $x('graduate').style.backgroundColor='gray'
    $x('distance').style.backgroundColor='gray'
    $x('career').style.backgroundColor='gray'
    $x('photo').style.backgroundColor='gray'
    //AJAX call to get project-ids
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=GETPROJECTS',0);
    get.addParam('x01',val)
    gReturn = get.get();
    var arr=gReturn.split(':');  //dump into array
    get = null;
    for (i=0;i<arr.length;i++) {
    // alert('val=' + arr);
    if ( arr[i]==5)
    $x('graduate').style.backgroundColor='red';
    if ( arr[i]==6)
    $x('distance').style.backgroundColor='red';
    if ( arr[i]==7)
    $x('career').style.backgroundColor='red';
    if ( arr[i]==8)
    $x('photo').style.backgroundColor='red';
    </script>
    <table cellpadding='0' cellspacing='0' border='0'>
    <tr><td>
    <input type='button' id='graduate' value='Graduate'>
    </td>
    <td>
    <input type='button' id='distance' value='Distance'>
    </td>
    <td>
    <input type='button' id='career' value='Career/Tech'>
    </td>
    <td>
    <input type='button' id='photo' value='Photos'>
    </td>
    </tr></table>
    2) Defined the application process  GETPROJECTS as DECLARE
    IDS varchar2(1000);
    l_act_code varchar2(100) :=4;
    begin
    IDS:='';
    l_act_code := wwv_flow.g_x01;
    for x in(
    SELECT ACT_CODE,PROJECT_ID
    FROM ASQ_CONTACT
    where ACT_CODE = l_act_code)
    LOOP
    IDS := IDS || X.PROJECT_ID|| ':' ;
    END LOOP;
    HTP.PRN(IDS);
    END;
    3) Changed the 'onchange' event-handler on p1_act_code to be 'onchange=hilitebtn(this.value)'
    4) Added the JS to the HTML Page Footer <script>
    hilitebtn($v('P1_ACT_CODE'));
    </SCRIPT>

Maybe you are looking for