SQL Query in JDBC

Can somebody guide me on this Q i have:
1. can we write 2 separate SQL statements when we configure a JDBC adapter?

Hi ,
<i>so can we read from two different tables at the same time when we configure a receiver adapter?</i>
In receiver JDBC Adapter you can do the insert/update/delete the data and you can execute the stored procedures.
If you want to retrieve the data from the table, then use Sender JDBC adapter. In this case you can use 2 SQL queries but it is something like update the table etc.. and it is not like selecting the data from 2 tables.Go thru given help link in my earlier post.
To read the data  from 2 different table you need to use <b>Sender JDBC adapter</b>, not receiver JDBC Adapter.
Option1 ) ideal way is to use Join conditions so that you will get one message with data from 2 different tables.
Option2) Use Stored Procedures ..
More-
configuring jdbc adapter with multiple tables
Hope this helps,
Regards,
Moorthy

Similar Messages

  • SQL Query in JDBC Sender

    Hi friends,
    Can u plz tell me when exactly we can use "Query SQL Stmt" and "Update SQL Stmt"?

    If you have a scenario that uses the JDBC adapter to connect to the "sending" system and pull data out of it, you will use these options. 
    You formulate a SQL statement that queries the database and gets certain information, the JDBC adapter then uses that information to populate the message type that you built in the integration repository. 
    You then create an update statement with SQL to tell the database what to do after it has grabbed the data it needs and populated the message type for mapping.
    Say for example you wanted to get all the data from the usr01 table in your SAP database (bad example, but bare with me) you could do something like this:
    <b>SQL QUERY STATEMENT:</b>  SELECT * FROM USR01
    And then following that you wanted to change the MANDT table (once again, don't actually run this command)
    <b>UPDATE SQL STATEMENT:</b>  UPDATE USR01 SET MANDT='100' WHERE MANDT='100'
    Message was edited by:
            Ethan West

  • SQL-Query with JDBC returns error ORA-00600

    Hi,
    I try to execute a SQL-Query using JDeveloper 3.2.3 and the Oracle JDBC-Library 8.1.7
    The following statement
    'ResultSet rset=stmt.executeQuery(SQL-String);'
    where stmt is Statement returns a Database-Error
    ORA-00600 with the Arguments [ttcgcshnd-1], [0] [], [], [], [], [], []
    when the SQL-String queries Varchar2 or CHAR-Columns.
    The Query returns correct values for numeric fields.
    The Database-Server is running on Oracle 9i
    Does anybody know, what could be the reason?
    Thanks, Harold

    I found many forums about it also, but I still haven't got solution yet.
    They talk about the cause, and report to oracle group and so on,
    but I still don't know how to solve my problem and how to enable my oracle 9i jdbc driver working.
    Need help please

  • SQL query for JDBC adapter

    Hello Everyone,
    I am using a simple SELECT to fetch data from sql DB. The only SELECT it seems to fetch data is when it is getting data from sys tables. It does not work for fetching data from application tables created in the sql DB. Could this be a authorization issue? Listed below are the different SELECT  statements used in PI and that works in SQL too.
    1. SELECT Query :  SELECT * from sys.tables
         UPDATE : <TEST>
    The above SELECT works and I can see all the xml messages in SXMB_MONI.
    2. SELECT Query : SELECT * from  sql_ztable
         UPDATE : <TEST>
    The above SELECT does not show any xml messages. There are records in the sql_ztable.  When checking the CC monitoring I get the following message below.
    Polling interval started. Length: 60.0 seconds
      Processing finished successfully
    Any suggestions?
    Thanks,
    Teresa

    Hi Teresa,
    You have to maintain the select and update statements like below.
    Select statement should be like
    Select * from TableName where fieldname = ''
    The field name should be either status field or date field or anything. You will be having some unique field in the table. This field name will ignore the unneccesary fetching records those are already fetched.
    Update statement should be like
    Update TableName set fieldname = '' where filedname = ''
    Here the field name should be same as the select statement filed name. What ever you have used in the filed name in the select statement you have to use same fieldname in the update fieldname.
    Let me know if you have any doubts. If your issue has resolved close this thread.
    Thanks,
    Raju

  • How to set a sql query time out with jdbc:oracle:thin

    should i change the JDBC driver with jdbc:oralce:XA:thin or other driver with XA?

    SQL query timeout may be set with setQueryTimeout.
    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#setQueryTimeout(int)
    A query timeout bug is fixed in Oracle JDBC Drivers release
    10.1.0.2.0 (10g)
    FIXED BUG-2249191
    In the Server Internal Driver, setting the query timeout does not
    +(and likely will never) work. The query execution will not be+
    canceled when the timeout expires, even if the query runs forever.
    Further, after the query returns, the execution of your code
    may pause for the length of the timeout.
    http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_readme101020.html

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • Why can't i use "INNER JOIN" in a query for SQL Server with JDBC??????

    Hi,
    I'm trying to execute some SQL queries and I just don't understand what's wrong.
    I�m using Tomcat and SQL Server in order to do this, but when I�m try to execute a query with a INNER JOIN statements Tomcat raise a SQL exception... at the very first time I thought there was a problem with database connection but I realize that a simple query to a table works pretty well. then I found out some problems with JDBC:ODBC.... so I install JDBC for SQL Server 2000 and test with the same simple query and works..... so, I come to a conclusion.... INNER JOIN or JOIN statements can't be used in JDBC..... please... somebody tell I�m wrong and give me a hand...
    I'm using TOMCAT 4 and JDK 1.4 SQL Server 2000
    Error occurs when executeQuery() is called.... not prepareStatement().... ??????
    Driver DriverRecResult = (Driver)Class.forName(driver).newInstance();
    Connection ConnRecResult = DriverManager.getConnection(DSN,user,password);
    PreparedStatement StatementRecResult = ConnRecResult.prepareStatement(query);
    ResultSet RecResult = StatementRecResult.executeQuery(); <---- Exception raise here
    So much tahnks in advance,

    That's exactly what I think, driver it's raising the exception, but I don't know why.... i test the same query with INNER JOIN directly from SQL Query Analyser and it's works perfectly, my problem ain't SQL, but JSP and JDBC 'cause i'm a newbie about these issues.
    Common sense tell me possible problems lie in SQLServer drivers 'cause i run the same pages on JRUN through jdbc:odbc and do works well, but by now i just depend on Tomcat.....
    I've installed SQL Server drivers for JDBC but i just find it doesn't work fully... could be the version of JDK i've installed? what version do i need?
    ( I'm running Tomcat 4 with JDK 1.4 & SQL Server 2000 W2K )
    thanks for reply.

  • Change JDBC select SQL query's where clause at runtime

    Hi,
    I have one JDBC sender channel with Select SQL Query which helps in fetching data from JDE table. We have defined where clause to fetch some particular records i.e. if ABC = NULL then fetch the record.. and then update query is used to turn that flag to "Y" i.e. ABC ="Y" so that next time the channel don't pick the same records again.
    Now the problem is that if we want to fetch some records again whose flag has been set to "Y" we cannot change the select query again and again in the production environment.
    Is there any way to change the select query of the JDBC channel at runtime e.g. Picking up some flat file where the conditions for the particular records to be picked are defined (ID=123) and changing the WHERE clause of select query in the JDBC channel for those records to be picked without using BPM.
    Thank you!
    With regards,
    Simran

    Hi Simran,
    Yes, it is possible with the help of store procedure. In SQL Server there is a IF-Else Conditional block, which you can use inside store procedure. Create a SP with 2 additional parameter something like FlagReadAgain and KeyField. Pass the flag always as True or False. For the Key field pass the record key which you want to read again if you are passing the Flag as True else pass it as 0 or whatever.
    In the procedure check if the value of flag is True -> If yes, Read the entry with key name specified in where part.
    In the else part put the query which you are using for the normal flow.
    IF (FlagReadAgain) = TRUE
    BEGIN
       SELECT EmpName, EmpAddress
       FROM Employee
       WHERE EmpID = 'E001'
    END
    ELSE
       BEGIN
         SELECT EmpName, EmpAddress
         FROM Employee
         WHERE Status = 'N'
       END
    You may also use the approach which Srini mentioned. Create an application to restore any value to intial stage so that it can be picked up by XI when it poll again.
    Choose any approach which you like.
    Regards,
    Jitender Chauhan

  • JDBC:Count Array. SQL query works but fails in JDBC

    Hi,
    I'm using the following SQL query
    "SELECT red.id, name, count(green.id) FROM red, green WHERE area = 'northeast' AND red.id = zid GROUP BY name"
    It executes perfectly from the DB command line giving me the results.
    However when I call it from within JDBC i am getting null values.
    My JDBC call ia as follows( Where lst is the above query)
    rs = st.executeQuery(lst);
    while(rs.next()){
    nidV.addElement(rs.getString("red.id"));
    nnmV.addElement(rs.getString("name"));
    nnumV.addElement(rs.getString("count(green.id)"));
    I do realize that many folks use Integer for count queries but I pull them with as Strings all the time so that's not it.
    The one diffrence between this and my other count queries is that this one returns an array (Vector) of counts.
    Any ideas?

    the problem is probably:
    SELECT red.id, name, count(green.id) ...
    nnumV.addElement(rs.getString("count(green.id)"));you can either use an alias for the column;
    SELECT red.id, name, count(green.id) COUNT_VAR
    nnumV.addElement(rs.getObject("COUNT_VAR"));or use getObject(3) as suggested by drclap.

  • How to notify in case SQL query(JDBC sender adapter) does not fetch records

    hi,
    How can we notify(by alerts or something) in case SQL query(JDBC sender adapter) does not fetch records? In channels logs it only says processing started & finished(no message is created for same).
    Thanks,
    Mayank

    Hi,
    1 ) What is exact audit log message ?
    2) Try fetching the count in SQL statement  if there are any valid records it will give the count.
        May for testing you can use <TEST> in update statement.
    3) Have you used taskTimeout parameter ?
    4) Are multiple channels polling on same table ?
    regards
    Ganga

  • Proxy to JDBC scenario need dynamic sql query for sender .

    Hi Experts,
    I am developing proxy to jdbc scenario. in this i need to pass dynamic sql query  whre we are passing classical method like below.
    while we are passing select stmt in constant and mapped with access field  and key field mapped with key field.
    MY requirement is like instead of passing select stmt in constant where i can generate dynamically and passed in one field and mapped with access field.

    Hi Ravinder,
    A simple UDF or use of graphical mapping functions in most cases should provide you everything you need to construct a dynamic SQL statement for your requirement.
    Regards,
    Ryan Crosby

  • JDBC SQL Query Transactionality

    Hi Experts,
    If possible, please can you let me know how the JDBC SQL Query Transactionality works?
    For example, in the JDBC communication channel configuration parameters,
    if I use "SELECT * FROM orders WHERE new = 'TRUE' " for the select query and;
    if I use "UPDATE orders SET new = 'FALSE' WHERE new = 'TRUE' " for the update query;
    does the UPDATE query just update the records contained in that particular record set (for a particular polling instance)?
    What happens if someone inserts new records into the orders table just before the update query executes? Will the update query update those records too? Or just those records in the record set for a particular polling instance? How does XI/PI distinguish between the records contained in the record set for (for a particular polling instance) and the records inserted just before the update query executes?
    Thanks and regards,
    Brendon

    hi,
    as far as I remember this works correctly only when you set Transaction Isolation Levels to repeatable_read or serializable
    have a look at those levels :
    http://api.openoffice.org/docs/common/ref/com/sun/star/sdbc/TransactionIsolation.html
    so I guess both of them should prevent situations you're talking about
    Regards,
    Michal Krawczyk

  • Java Web Analyzer security hole in SQL Query Spreadsheet using JDBC-ODBC bridge

    Hi,<BR><BR>I use Hyperion Analyzer 7.0.1 on Windows 2003 and relation database DB2 v8.2.<BR><BR>I did:<BR>1. log in to Java Web Analyzer<BR>2. button New<BR>3. Select Layout: Custom Report<BR>4. from toolbar pull down to desktop "SQL Spreadsheet" option<BR>5. "Enter SQL Query" window opens, from JDBC Driver drop down window select "JDBC-ODBC Bridge"<BR>6. in "JDBC Connection String" window replace "db1" string with database name<BR>7. leave JDBC Username and JDBC Password empty (this is default)<BR>8. click on "Test Connection" button.<BR>9. "Test Connection" window opens with message "Connection Succeded"!!! So connection to database without password succeeded.<BR>10. in "SQL Query window" write any SQL you wish and Database will execute the SQL.<BR><BR><b>Conclusion: Connecting Analyzer with SQL Spreadsheet option to relation database DB2 is possible without password.</b><BR><BR>Question: Is there any way to prevent users from executing "SQL Spreedsheet" option?<BR><BR>Thanks,<BR>Grofaty

    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection(dsn,"guest","guest");
    OR DriverManager.getConnection(dsn);
    System.out.println("Conection's opened");
    catch(ClassNotFoundException cnfe)
    System.err.println(cnfe);
    catch(SQLException sqle)
    System.err.println(sqle);
    try that code and double check you DSN Name . it's a good practice to greate a system DSN.
    i hope that helps.
    FEEL FREE TO ASK. WON'T BITE U
    ABDUL

  • SQL Query Help Needed

    I'm having trouble with an SQL query. I've created a simple logon page wherein a user will enter their user name and password. The program will look in an Access database for the user name, sort it by Date/Time modified, and check to see if their password matches the most recent password. Unfortunately, the query returns no results. I'm absolutely certain that I'm doing the query correctly (I've imported it directly from my old VB6 code). Something simple is eluding me. Any help would be appreciated.
    private void LogOn() {
    //make sure that the user name/password is valid, then load the main menu
    try {
    //open the database connection
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:LawOffice2000", "", "");
    Statement select = con.createStatement();
    String strTemp = "Select * From EMPLOYEES Where INITIALS = '" + txtUserName.getText() + "' Order By DATE Desc, TIME Desc";
    ResultSet result = select.executeQuery(strTemp);
    while(result.next()) {
    if (txtPassword.getPassword().toString() == result.getString("Password")) {
    MenuMain.main();
    else {
    System.out.println("Password Bad");
    System.out.println(txtUserName.getText());
    System.out.println(result.getString("Password"));
    break; //exit loop
    //close the connection
    con.close(); }
    catch (Exception e) {
    System.out.println("LawOfficeSuite_LogOn: " + e);
    return; }
    }

    The problem is here: "txtPassword.getPassword().toString() == result.getString("Password"))"
    Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same characters), use equals(), e.g. if (str1.equals(str2))...
    Example:String s1 = "foo";
    String s2 = new String("foo");
    System.out.println("s1 == s2: " + (s1 == s2)); // false
    System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out Comparison operators: equals() versus ==

  • How to view the sql query?

    hi,
      how to view the sql query formed from the xml structure in the receiver jdbc?

    You can view SAP Note at
    http://service.sap.com/notes
    But you require SMP login ID for this which you should get from your company. The content of the notes are as follows:
    Reason and Prerequisites
    You are looking for additional parameter settings. There are two possible reasons why a feature is available via the "additional parameters" table in the "advanced mode" section of the configuration, but not as documented parameter in the configuration UI itself:
    Category 1: The parameter has been introduced for a patch or a SP upgrade where no UI upgrade and/or documentation upgrade was possible. In this case, the parameter will be moved to the UI and the documentation as soon as possible. The parameter in the "additional parameters" table will be deprecated after this move, but still be working. The parameter belongs to the supported adapter functionality and can be used in all, also productive, scenarios.
    Category 2. The parameter has been introduced for testing purposes, proof-of-concept scenarios, as workaround or as pre-released functionality. In this case, the parameter may or may not be moved to the UI and documentation, and the functionality may be changed, replaced or removed. For this parameter category there is no guaranteed support and usage in productive scenarios is not supported.
    When you want to use a parameter documented here, please be aware to which category it belongs!
    Solution
    The following list shows all available parameters of category 1 or 2. Please note:
    Parameter names are always case-sensitive! Parameter values may be case-sensitive, this is documented for each parameter.
    Parameter names and values as documented below must be used always without quotaton marks ("), if not explicitly stated otherwise.
    The default value of a parameter is always chosen that it does not change the standard functionality
    JDBC Receiver Adapter Parameters
    1. Parameter name: "logSQLStatement"
                  Parameter type: boolean
                  Parameter value: true for any string value, false only for empty string
                  Parameter value default: false (empty String)
                  Available with: SP9
                  Category: 2
                  Description:
                  When implementing a scenario with the JDBC receiver adapter, it may be helpful to see which SQL statement is generated by the JDBC adapter from the XI message content for error analysis. Before SP9, this can only be found in the trace of the JDBC adapter if trace level DEBUG is activated. With SP9, the generated SQL statement will be shown in the details page (audit protocol) of the message monitor for each message directly.
                  This should be used only during the test phase and not in productive scenarios.
    Regards,
    Prateek

Maybe you are looking for

  • Schedule line items facility in PS

    Hi friends, There is the Schedule lines functionality in Sales Order. This is used for planning the despatch schedules date wise. Now I am attaching a Finished Goods BOM to an activity in a Project, say of 50 quantity. Is there any standard functiona

  • Address book crashes whenever I try to open it.

    Whenever I try to open Address Book, I receive the messge, "Address Book quit unexpectedly."  Problem Details and System Configuration are then shown, with the option to click "OK" or "Reopen."  Most of the time, when I click "Reopen," I receive the

  • Virtualize an existing windows 8.1 installation on arch

    Hi, 3 days ago I installed arch and I'm very delighted. Originally coming from windows I installed ubuntu on my laptop a few months back. Linux instantly grabbed my attention. So when I decided to buy a new desktop PC I compared various distros and a

  • Hana db filesystem directory structure and process command line

    Hi experts, Could someone provide please actual directory structure of Hana db filesystem? Generally speaking, I need to model some Hana db(of 1.0, 1.5 versions) entities. Among them: Schemas Data files Log files Important configuration files Databas

  • Notes keeps crashing in OSX 10.8 ML

    I have two user accounts on my MBA (late 2010 one for me and one for my wife. Having upgraded today the Notes app on one user account keep crashing when it opens.  In the other it is absolutely fine and syncing with iCloud as it is supposed to. Is th