Possible to execute custom SQL query?

Is it possible to execute a custom SQL query and get back a collection of
objects with Kodo JDO? Query expression languages like JDOQL are all very
well (I actually think JDOQL is pretty messy), but sometimes when you've
got a complex query (and you know you're using a RDBMS) it is best
accomplished in a SQL statement. I see Kodo has extended JDOQL, which is
good, but developing custom extensions seems to be limited to implementing
kodo.jdbc.query.JDBCFilterListener where you can customise the where
clause. What I want to be able to do is to specify the entire SQL string.
I am looking into using Kodo JDO for my organisation, and being able to
use custom SQL is something i would expect (and something we can do with
our current O/R mapping product (TopLink)).
Regards,
Alex

Patrick Linskey wrote:
On Tue, 30 Sep 2003 10:57:13 +0000, Alex wrote:
being able to use custom SQL is something i would expect
We absolutely agree. Take a look at the samples/customSQL example in the
Kodo distribution.
-Patrick
Patrick Linskey
SolarMetric Inc.Hi Patrick,
I have downloaded kodo-jdo-3.0.0RC1 for windows for evaluation, but there
is no samples/customSQL directory.
Alex.

Similar Messages

  • Execute custom SQL query in OIM11g

    Hi,
    Can you please provide me some java code snippet to execute a custom sql query and also to get db connection to execute this query in OIM 11g. I am going to run this query in an adapter.
    Thanks a lot for ur help.
    Mike

    Hey Mike,
    Use the below sample code to get db connection and then to execute a query in OIM11g.
    String query = "SELECT UD_ADUSER_EMAIL FROM UD_ADUSER WHERE upper(UD_ADUSER_UID) like '%TESTU%'";
    Connection con = Platform.getOperationalDS().getConnection();
    PreparedStatement preparedStatement = con.prepareStatement(query);
    ResultSet resultSet = preparedStatement.executeQuery();
    while(resultSet.next())
    System.out.println("Output:"+resultSet.getString(1));
    }

  • It is possible to execute a SQL query from OMBPlus?

    We have some simple SQL scripts we'd like to be able to incorporate into our existing TCL scripts, instead of having to run them outside of OMBPlus in sqlplus. Is is possible to run a SQL SELECT query from OMBPlus and/or TCL? And get a result set back to iterate through?
    Thanks,
    Jim C.

    You can execute SQLPlus from OMB or just get down and use JDBC to execute the SQL, see others posts on forum such as below;
    How to run SQL from OMB+
    Cheers
    David

  • How to operate multiple querys using DB Adapter and 'Execute Custom SQL'

    I have a requirment that I need to create database adapter in your BPEL process with 'Execute Custom SQL' to operate multiple query in DB in one atomic
    here are the details:
    inbound request:
    <ns1:Query_bpelProcessRequest>
    <ns1:input>
    <ns1:ItemDetail>
    <ns1:ItemID>1123DDDS</ns1:ItemID>
    </ns1:ItemDetail>
    <ns1:ItemDetail>
    <ns1:ItemID>1126EWWA</ns1:ItemID>
    </ns1:ItemDetail>
    <ns1:ItemDetail>
    <ns1:ItemID>11208FSAA</ns1:ItemID>
    </ns1:ItemDetail>
    </ns1:input>
    </ns1:Query_bpelProcessRequest>
    I use for-each fuction in XSLT to mapping the all ItemID value:
    <xsl:template match="/">
    <xsl:for-each select="/tns:Query_bpelProcessRequest/tns:input/tns:ItemDetail">
    <ns1:QueryFromDB_Input>
    <ns1:ItemID>
    <xsl:value-of select="tns:ItemID"/>
    </ns1:ItemID>
    </ns1:QueryFromDB_Input>
    </xsl:for-each>
    </xsl:template>
    and in DB Adapter I use the 'Execute Custom SQL' to query the CONTENT value according the ItemID value:
    select distinct CONTENT from agile.item where ITEM_NUMBER=’<ItemID>’
    However, in the result, It only query the first item value for <ns1:ItemID>1123DDDS</ns1:ItemID>
    <<QueryFromDB_InputVariable><part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="QueryFromDB_Input_msg">
    <QueryFromDB_Input xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/db/QueryFromDB" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/QueryFromDB">
    <ns1:ItemID>1123DDDS</ns1:ItemID>
    </QueryFromDB_Input>
    </part></QueryFromDB_InputVariable>
    <QueryFromDB_OutputVariable><part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="QueryFromDB_OutputCollection">
    <QueryFromDB_OutputCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/QueryFromDB">
    <QueryFromDB_Output>
    <ITEM_NUMBER>1123DDDS</ITEM_NUMBER>
    <CONTENT >SJIFESSFFJ</CONTENT >
    </QueryFromDB_Output>
    </QueryFromDB_OutputCollection>
    </part></QueryFromDB_OutputVariable>
    the other two querys are not operated.
    what can I do to operate multiple querys??
    Thanks

    Hi Rod,
    I are using while loop and assign array inputvalue to the inputvarable of DBadapter now, but actually it doesn't work.
    Throw expection
    <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"><part name="summary"><summary>XPath query string returns multiple nodes.
    According to BPEL4WS spec 1.1 section 14.3, The assign activity part and query /client:ItemsQuery_bpelProcessRequest/client:input/client:inputDetail/client:ProductID["ItemIndex"] should not return multipe nodes.
    Please check the BPEL source at line number "89" and verify the part and xpath query /client:ItemsQuery_bpelProcessRequest/client:input/client:inputDetail/client:ProductID["ItemIndex"].
    Possible reasons behind this problems are: some xml elements has maxOccurs > 1 or the xml data is invalid according to XML Schema.
    To verify whether XML data received by a process is valid, user can turn on validateXML switch at the domain administration page.
    </summary>
    </part></selectionFailure>
    my inbound XSD:
    <element name="ItemsQuery_bpelProcessRequest">
    <complexType>
    <sequence>
    <element name="input" type="tns:inputType"/>
    </sequence>
    </complexType>
    </element>
    <complexType name="inputType">
    <sequence>
    <element name="inputDetail" minOccurs="0" maxOccurs="unbounded">
    <complexType>
    <sequence>
    <element name="ProductID" type="string" minOccurs="0"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    <element name="ItemsQuery_bpelProcessResponse">
    <complexType>
    <sequence>
    <element name="result" type="tns:outputType"/>
    </sequence>
    </complexType>
    </element>
    <complexType name="outputType">
    <sequence>
    <element name="ItemOutput" minOccurs="0" maxOccurs="unbounded">
    <complexType>
    <sequence>
    <element name="item_id" type="string" minOccurs="0"/>
    </sequence>
    </complexType>
    </element>
    </sequence>
    </complexType>
    DB Adapter XSD:
    <xs:schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/QueryItem" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/QueryItem" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="QueryItem_Input" type="QueryItem_Input"/>
    <xs:complexType name="QueryFrom_Input">
    <xs:sequence>
    <xs:element name="ProductID" type="xs:string" nillable="true"/>
    </xs:sequence>
    </xs:complexType>
    <xs:element name="QueryItem_OutputCollection" type="QueryItem_OutputCollection"/>
    <xs:complexType name="QueryItem_OutputCollection">
    <xs:sequence>
    <xs:element name="QueryItem_Output" type="QueryItem_Output" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="QueryItem_Output">
    <xs:sequence>
    <xs:element name="item_id" type="xs:string" nillable="true"/>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>
    the bpel assign:
    <assign name="Initial_Index">
    <copy>
    <from expression="0"/>
    <to variable="ItemIndex"/>
    </copy>
    </assign>
    <while name="While_1"
    condition="bpws:getVariableData('ItemIndex')&lt;ora:countNodes('inputVariable','payload','/client:ItemsQuery_bpelProcessRequest/client:input/client:inputDetail/client:ProductID)">
    <sequence name="Sequence_1">
    <assign name="Assign_QueryInput">
    <copy>
    <from variable="inputVariable" part="payload"
    query='/client:ItemsQuery_bpelProcessRequest/client:input/client:inputDetail/client:ProductID{bpws:getVariableData('ItemIndex')}'/>
    <to variable="QueryItem_InputVariable"
    part="QueryItem_nput_msg"
    query="/ns2:QueryItem_Input/ns2:ProductID"/>
    </copy>
    </assign>
    <invoke name="Invoke_QueryDB" partnerLink="QueryItem"
    portType="ns1:QueryItem_ptt"
    operation="QueryItem_PSFT"
    inputVariable="QueryItem_InputVariable"
    outputVariable="QueryItem_OutputVariable"/>
    <assign name="Assign_Output">
    <copy>
    <from variable="QueryItem_OutputVariable"
    part="QueryItem_OutputCollection"
    query="/ns2:QueryItem_OutputCollection/ns2:QueryItem_Output/ns2:item_id"/>
    <to variable="outputVariable" part="payload"
    query='/client:ItemsQuery_bpelProcessResponse/client:result/client:ItemOutput/client:item_id{bpws:getVariableData('ItemIndex')}'/>
    </copy>
    <copy>
    <from expression="bpws:getVariableData('ItemIndex')+1"/>
    <to variable="ItemIndex"/>
    </copy>
    </assign>
    </sequence>
    </while>
    I use {} instead of  []  for array,  because [] seams not reveal in this message board
    seems I can't assign array values to the DB inputvalue, Are there any solutions for this ?
    I still haven't found any way for operating multiple querys using DB Adapter.
    Thanks
    Edited by: user1065212 on 07-Jan-2010 19:39
    Edited by: user1065212 on 07-Jan-2010 19:41
    Edited by: user1065212 on 07-Jan-2010 19:44
    Edited by: user1065212 on 07-Jan-2010 19:45

  • Using information from ItResource for executing custom sql in OIM 11g

    I need executing a custom sql query using a connection of a ItResource. How can I get the instance of connection for to execute the sql query ? Someone have a idea of how i make this ? Help me ...
    Tks

    HashMap itAttribute = new HashMap();
    itAttribute.put("IT Resources.Name","IT-DB01");
    tcITResourceInstanceOperationsIntf itResource=null;
    tcResultSet resItResKey;
    resItResKey = itResource.findITResourceInstances(itAttribute);
    long iTesourceKey = resItResKey.getLongValue("IT Resource.Key");
    tcResultSet resItRes = itResource.getITResourceInstanceParameters(iTesourceKey);
    Append following lines:-
              HashMap<String, String> hashMap = new HashMap<String, String>();
              int countResultGetITResourceInstanceParameters = resItRes .getRowCount();
              for(int i = 0; i < countResultGetITResourceInstanceParameters; i++) {
                   resultGetITResourceInstanceParameters.goToRow(i);
                   hashMap.put(
                             resItRes .getStringValue(ZAPConstants.IT_RESOURCES_TYPE_PARAMETER_NAME),
                             resItRes .getStringValue(ZAPConstants.IT_RESOURCES_TYPE_PARAMETER_VALUE)
              return hashMap;

  • Can we implement the custom sql query in CR for joining the two tables

    Hi All,
    Is there anyway to implement the custom sql query in CR for joining the two tables?
    My requirement here is I need to write sql logics for joining the two tables...
    Thanks,
    Gana

    In the Database Expert, expand the Create New Connection folder and browse the subfolders to locate your data source.
    Log on to your data source if necessary.
    Under your data source, double-click the Add Command node.
    In the Add Command to Report dialog box, enter an appropriate query/command for the data source you have opened.
    For example:
    SELECT
        Customer.`Customer ID`,
        Customer.`Customer Name`,
        Customer.`Last Year's Sales`,
        Customer.`Region`,
        Customer.`Country`,
        Orders.`Order Amount`,
        Orders.`Customer ID`,
        Orders.`Order Date`
    FROM
        Customer Customer INNER JOIN Orders Orders ON
            Customer.`Customer ID` = Orders.`Customer ID`
    WHERE
        (Customer.`Country` = 'USA' OR
        Customer.`Country` = 'Canada') AND
        Customer.`Last Year's Sales` < 10000.
    ORDER BY
        Customer.`Country` ASC,
        Customer.`Region` ASC
    Note: The use of double or single quotes (and other SQL syntax) is determined by the database driver used by your report. You must, however, manually add the quotes and other elements of the syntax as you create the command.
    Optionally, you can create a parameter for your command by clicking Create and entering information in the Command Parameter dialog box.
    For more information about creating parameters, see To create a parameter for a command object.
    Click OK.
    You are returned to the Report Designer. In the Field Explorer, under Database Fields, a Command table appears listing the database fields you specified.
    Note:
    To construct the virtual table from your Command, the command must be executed once. If the command has parameters, you will be prompted to enter values for each one.
    By default, your command is called Command. You can change its alias by selecting it and pressing F2.

  • Execute custom SQL in DB Adpater errors out in Production - urgent please.

    Hi,
    I get this error when running the process in PROD at invoking delete operation that I'm doing by selecting the execute custom SQL option while defining the DB adapter. It worked fine in TEST environment but errors out in PROD env.
    Any suggestions on why? Its urgent.
    Thanks
    -Prapoorna
    The state of this instance is Faulted
    <messages><input><InvokeDelete_InputVariable><part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="DeleteDataInput_msg"><DeleteDataInput xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/DeleteData"/>
    </part></InvokeDelete_InputVariable></input><fault><remoteFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="code"><code>17410</code>
    </part><part name="summary"><summary>file:/prod/app/bpel/as/bpel/domains/verint/tmp/.bpel_SynchOTLLoad_1.0_0259c5f142631959ec0fb067d23fe98e.tmp/DeleteData.wsdl [ DeleteData_ptt::DeleteData(DeleteDataInput_msg) ] - WSIF JCA Execute of operation 'DeleteData' failed due to: Pure SQL Exception.
    Pure SQL Execute of delete from xxhxc_timeattend_to_otl where report_date >= TRUNC(ADD_MONTHS(sysdate, -1),'MM') failed. Caused by java.sql.SQLException: No more data to read from socket.
    ; nested exception is:
    ORABPEL-11633
    Pure SQL Exception.
    Pure SQL Execute of delete from xxhxc_timeattend_to_otl where report_date >= TRUNC(ADD_MONTHS(sysdate, -1),'MM') failed. Caused by java.sql.SQLException: No more data to read from socket.
    The Pure SQL option is for border use cases only and provides simple yet minimal functionality. Possibly try the "Perform an operation on a table" option instead.
    </summary>
    </part><part name="detail"><detail>No more data to read from socket</detail>
    </part></remoteFault></fault></messages>

    Looks like in production you have much more data than you do in your test environments.
    It could be something wrong with your rollback segments. Is there any other activity happening when this is running?
    What happens when you run this command inside SQLPlus?
    cheers
    James

  • Error while executing a sql query for select

    HI All,
    ORA-01652: unable to extend temp segment by 128 in tablespace PSTEMP i'm getting this error while i'm executing the sql query for selecting the data.

    I am having 44GB of temp space, while executing the below query my temp space is getting full, Expert please let us know how the issue can be resolved..
    1. I dont want to increase the temp space
    2. I need to tune the query, please provide your recomendations.
    insert /*+APPEND*/ into CST_DSA.HIERARCHY_MISMATCHES
    (REPORT_NUM,REPORT_TYPE,REPORT_DESC,GAP,CARRIED_ITEMS,CARRIED_ITEM_TYPE,NO_OF_ROUTE_OF_CARRIED_ITEM,CARRIED_ITEM_ROUTE_NO,CARRIER_ITEMS,CARRIER_ITEM_TYPE,CARRIED_ITEM_PROTECTION_TYPE,SOURCE_SYSTEM)
    select
    REPORTNUMBER,REPORTTYPE,REPORTDESCRIPTION ,NULL,
    carried_items,carried_item_type,no_of_route_of_carried_item,carried_item_route_no,carrier_items,
    carrier_item_type,carried_item_protection_type,'PACS'
    from
    (select distinct
    c.REPORTNUMBER,c.REPORTTYPE,c.REPORTDESCRIPTION ,NULL,
    a.carried_items,a.carried_item_type,a.no_of_route_of_carried_item,a.carried_item_route_no,a.carrier_items,
    a.carrier_item_type,a.carried_item_protection_type,'PACS'
    from CST_ASIR.HIERARCHY_asir a,CST_DSA.M_PB_CIRCUIT_ROUTING b ,CST_DSA.REPORT_METADATA c
    where a.carrier_item_type in('Connection') and a.carried_item_type in('Service')
    AND a.carrier_items=b.mux
    and c.REPORTNUMBER=(case
    when a.carrier_item_type in ('ServicePackage','Service','Connection') then 10
    else 20
    end)
    and a.carrier_items not in (select carried_items from CST_ASIR.HIERARCHY_asir where carried_item_type in('Connection') ))A
    where not exists
    (select *
    from CST_DSA.HIERARCHY_MISMATCHES B where
    A.REPORTNUMBER=B.REPORT_NUM and
    A.REPORTTYPE=B.REPORT_TYPE and
    A.REPORTDESCRIPTION=B.REPORT_DESC and
    A.CARRIED_ITEMS=B.CARRIED_ITEMS and
    A.CARRIED_ITEM_TYPE=B.CARRIED_ITEM_TYPE and
    A.NO_OF_ROUTE_OF_CARRIED_ITEM=B.NO_OF_ROUTE_OF_CARRIED_ITEM and
    A.CARRIED_ITEM_ROUTE_NO=B.CARRIED_ITEM_ROUTE_NO and
    A.CARRIER_ITEMS=B.CARRIER_ITEMS and
    A.CARRIER_ITEM_TYPE=B.CARRIER_ITEM_TYPE and
    A.CARRIED_ITEM_PROTECTION_TYPE=B.CARRIED_ITEM_PROTECTION_TYPE
    AND B.SOURCE_SYSTEM='PACS'
    Explain Plan
    ==========
    Plan
    INSERT STATEMENT ALL_ROWSCost: 129 Bytes: 1,103 Cardinality: 1                                                        
         20 LOAD AS SELECT CST_DSA.HIERARCHY_MISMATCHES                                                   
              19 PX COORDINATOR                                              
                   18 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002 :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                         
                        17 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,103 Cardinality: 1                                    
                             15 HASH JOIN RIGHT ANTI NA PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 129 Bytes: 1,098 Cardinality: 1                               
                                  4 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 63 Bytes: 359,283 Cardinality: 15,621                          
                                       3 PX SEND BROADCAST PARALLEL_TO_PARALLEL SYS.:TQ10001 :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                     
                                            2 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621                
                                                 1 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1001Cost: 63 Bytes: 359,283 Cardinality: 15,621           
                                  14 NESTED LOOPS ANTI PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 40,256,600 Cardinality: 37,448                          
                                       11 HASH JOIN PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 65 Bytes: 6,366,160 Cardinality: 37,448                     
                                            8 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1002               
                                                 7 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1002Cost: 1 Bytes: 214 Cardinality: 2           
                                                      6 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 1 Bytes: 214 Cardinality: 2      
                                                           5 INDEX FULL SCAN INDEX CST_DSA.IDX$$_06EF0005 Cost: 1 Bytes: 214 Cardinality: 2
                                            10 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448                
                                                 9 MAT_VIEW ACCESS FULL MAT_VIEW PARALLEL_COMBINED_WITH_PARENT CST_ASIR.HIERARCHY :Q1002Cost: 63 Bytes: 2,359,224 Cardinality: 37,448           
                                       13 TABLE ACCESS BY INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT CST_DSA.HIERARCHY_MISMATCHES :Q1002Cost: 0 Bytes: 905 Cardinality: 1                     
                                            12 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT SYS.HIERARCHY_MISMATCHES_IDX3 :Q1002Cost: 0 Cardinality: 1                
                             16 INDEX RANGE SCAN INDEX PARALLEL_COMBINED_WITH_PARENT CST_DSA.IDX$$_06EF0001 :Q1002Cost: 1 Bytes: 5 Cardinality: 1

  • How to execute a sql query in VO????

    Hi every body.
    Can you show me the way to execute a sql query in VO.
    For example: I have a viewobject1, and I add a new method void execSQL() before the last '}' of the java file of viewobject1 like this:
    public void execSQL() {
    String strSql = "Select sysdate from dual";
    I want to execute strSql query and return a Resultset, how can I perform ???
    Thanks a lot.

    The executeQuery method in ViewObjectImpl does not return a ResultSet.
    ViewObjectImpl voImpl;
    voImpl.setQuery(strSql);
    voImpl.executeQuery();

  • How can I use the Rownum/Customized SQL query in a Mapping?

    Hi,
    * I need to use a Rownum for populating one of the target field? How to create a mapping with Rownum?
    * How can I use an Dual table in OWB mapping?
    * Can I write Customized SQL query in OWB? How can I achieve this in a Mapping?
    Thanks in Advance
    Kishan

    Hi Niels,
    As I'm sure you know, the conundrum is that Reports doesn't know how many total pages there will be in the report until it is all done formatting, which is too late for your needs. So, one classical solution to this problem is to run the report twice, storing the total number of pages in the database using a format trigger, and throwing away the output from the first run when you don't know the total number of pages.
    Alternatively, you could define a report layout so that the number of pages in the output is completely predictable based upon, say, the number of rows in the main query. E.g., set a limit of one, two, ... rows per page, and then you'll know how many pages there will be simply because you can count the rows in a separate query.
    Hope this helps...
    regards,
    Stewart

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

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

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

  • How to execute this SQL Query in ABAP Program.

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

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

  • Incorrectly read attributes with custom SQL query

    Hi folks,
    I'm trying to read in a random sampling of records from a table, so I tried:
    ReadAllQuery q = new ReadAllQuery();
    q.setReferenceClass(Foo.class);
    q.addPartialAttribute("bar");
    q.setSQLString("select * from Foo sample(10)");
    q.useCursoredStream(100,100, new ValueReadQuery("select count(*) from Foo sample(10)"));
    This all worked fine, the Foos were retrieved, but after the first dozen or so, all the "bar" attributes were null, which they should not be. This only occurs when using a custom SQL string. I tried bringing back all the objects (i.e., without using setSQLString) and examining them and all the "bar"s were present. But when I use setSQLString the attributes don't get read correctly.
    Can anyone tell me what I'm doing wrong? Is there a better way to do it?
    Thanks,
    Bryn

    Okay, here's the actual code:
    ReadAllQuery q = new ReadAllQuery();
    q.setReferenceClass(ActivityCenter.class);
    boolean useCustom = true;
    if (useCustom) {
    q.setSQLString("SELECT SetupDt, TerminationDt, ReinstateDt, IID, upDt, ID, " +
    "Stat, SubType, Acct FROM ACtr");
    q.useCursoredStream(100,100, new ValueReadQuery("select count(IID) from actr"));
    } else {
    q.useCursoredStream(100,100);
    session.logMessages();
    activityCenters = (CursoredStream) session.executeQuery(q);
    ActivityCenter ac = (ActivityCenter) activityCenters.read();
    if (ac.getAccount() == null) {
    System.err.println(ac.getID() + ": Oops!");
    } else {
    System.err.println(ac.getID() + ": Has account!");
    System.exit(0);
    So, everything about this program is the same - how the mapping is done, how things get initialized, everything. The only difference is whether I use a custom SQL query or not. Here's what it looks like when I run it both ways:
    First, custom:
    DatabaseSession(2433702)--Connection(393272)--SELECT SetupDt, TerminationDt, ReinstateDt, IID, upDt, ID, Stat, SubType, Acct FROM ACtr
    1.1: Oops!
    Now, without the custom SQL:
    DatabaseSession(393272)--Connection(7896086)--SELECT SetupDt, TerminationDt, ReinstateDt, IID, upDt, ID, Stat, SubType, Acct FROM ACtr
    DatabaseSession(393272)--Connection(7896086)--SELECT
    //bunch of fields from the Acct attribute...
    FROM Acct WHERE (IID= 'ffbe5c47f3ea762cfd50fbe9e6d6de6')
    1.1: Has account!
    Notice that the first query on Actr is identical in both cases. Also note there are no null Actr.acct fields in the database:
    SQL> select * from actr where actr.acct is null;
    no rows selected
    SQL>
    This is on Oracle 9i, with the thin jdbc driver.
    Also, I was curious that you asked if I was using partial attributes - when I try to add a partial attribute when using the custom SQL string, I get exceptions like this one:
    java.lang.ClassCastException: oracle.toplink.internal.queryframework.CallQueryMechanism
    at oracle.toplink.queryframework.ObjectLevelReadQuery.initializeDefaultBuilder(Unknown Source)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.getExpressionBuilder(Unknown Source)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.addPartialAttribute(Unknown Source)
    at jenkon.magellan.util.MLMulator.getActivityCenters(MLMulator.java:782)
    at jenkon.magellan.util.MLMulator.run(MLMulator.java:897)
    at jenkon.magellan.util.MLMulator.main(MLMulator.java:943)
    Thanks,
    Bryn

  • Submit button executes a sql query

    In my servlet I'd like to create a submit button, and when it is clicked I want to execute an sql query.
    For example;
    If I write a name; I want to add that name to my table in my database.
    Could you give an example please?
    Thank you

    PreparedStatement ps = con.prepareStatement("insert into foo (name, birthdate) values (?, ?)"); // double check my sql insert syntax. I'm not sure if it's right.
    String theName = ...; // get name from what user enters
    Date theBirthDate =...; // likewise birthdate
    ps.setString(1, theName);
    ps.setDate(2, theBirthDate);
    ps.executeUpdate(); Look at the APIs or google for java preparedstatement tutorial or something for more info.

  • Obtaining "rows selected" value after custom sql query in Database adaptor

    We are executing a custom query in a database adaptor. With other technologies (JDBC, etc.) the result of a query will not only produce a result set but a count of the number of rows selected. E.G. the script output of Oracle SQL Developer will print out something like:
    9999 rows selected
    at the end of the script output.
    I would like to obtain this value for a BPEL process. Of course, I could execute a 2nd query whose where clause is identical to the first, but selects count(*) instead. However, this is not only inefficient but (in rare circumstances in an active database) could be wrong.
    It is not obvious to this BPEL novice how to obtain the row selected value as well as the result set in one Invoke. Is this possible?

    This may not be the only solution - but it is how I have done it in the past.
    Following the invoke step of the adapter, use an assign/copy step to populate an integer BPEL variable using the count xpath function...
    <assign name="Initialize">
    <copy>
    <from expression="count(bpws:getVariableData('Invoke_Query_OutputVariable','MyTableQueryCollection','/ns3:MyTableQueryCollection/ns3:MyTableQuery'))"/>
    <to variable="NumberOfRecordsReturned"/>
    </copy>
    </assign>
    That should assign the number of records returned by the query.
    I hope that helps.
    Rod.
    Edited by: Rod Tunnels on Dec 15, 2009 1:16 PM

Maybe you are looking for

  • Creative Audigy Platinum Installation Help with Pentium 4 3.2GHz HT Enab

    :mansad: Dear Fellows,I have recently upgraded to a new Pentium 4 machine. The config is as follows:Pentium 4 3.2eGHz MB cache HT (Hyper-Threading Enabled)Intel Original 865GBF MainboardGB Kingston DDR 400MHz RAM20GB SATA WD HDDSound Blaster Audigy P

  • How to create and export a still frame from a movie in iMovie 09

    Disclaimer: Apple does not necessarily endorse any suggestions, solutions, or third-party software products that may be mentioned in the topic below. Apple encourages you to first seek a solution at Apple Support. The following links are provided as

  • Problem Replacing pages in Adobe Acrobat 8 Pro

    I have a 130 page PDF document with hundreds of links, all of which work and display in their proper position on all pages in original document. I have generated new pages to replace most existing pages & I'm having a problem with the links. Both the

  • Cannot get an invoice created with IWork Numbers to open correctly in Excel

    I used the Template in Numbers to create an invoice,and it's great. However, I cannot seem to open this file in Excel no matter how I send it, no matter how I save it. Have saved as windows friendly, have saved as Excel file. I have to be able to hav

  • Fonts in Dreamweaver CS6

    Hi! I'm having problems with using the Myriad Pro font in Dreamweaver CS6. Although the font is in the list of fonts, the selection becomes green in css and when previewing it in a browser, it transforms into the second choise, which is Arial. Is Myr