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.

Similar Messages

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • Executing the sam SQL Query again and again on the same records?

    Hi currently we have a system that will compute certain charge information base on a file finance department send to us from another system
    The problem is that their file contains of Account with bank records and account with no bank records.
    for thos account with bank records it will just send to us and we will just update it..and those account will be updated...
    but for those account that have no bank records ..it will send to us again and again..and these no bank records account will accumulate
    the finance department mention that there is not much they can do on their side except sending us the file
    is there any gd solution for this people kind to share?

    Well one simple solution which i can think of is to persist Non-bank accounts in a Serializable Object and save it in a temporary cache.
    Now before running a query on them and then trying to update the database checkout the peristed cache, check whether data records exist their or not
    if they do, dont update that records in the database.
    or define your database tables in such a way that there is an indication of abt bank & non-bak records and write a query / procedure in such a way that it do not update the duplicate non-bank records.
    Hope this might help :)
    REGARDS,
    RaHuL

  • 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

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

  • Parameter passing to custom SQL query using PL/SQL FUNCTION

    Hi
    In order to pass a parameter to the query in custom folder of a business area I created a function and mapped it to the Custome query using Discoverer Desktop. There is no error in mapping as the system does not throw any error. When I am inputting the Parameter for the input values everytime the query doesnot return any rows.
    Can anybody help in this regard

    Hi,
    I need to take the request Id as input from the user and then fetch only the data pertaining to that requet Id. As a lot of complex joins are involved I need to pass request id as parameter to the custome folder.
    The package i greated:
    CREATE OR REPLACE PACKAGE SETPARAM
    AS
    param1 varchar2(25);
    param2 varchar2(25);
    FUNCTION SET_PARAM1(p1 IN varchar2) RETURN NUMBER ;
    FUNCTION GET_PARAM1 RETURN varchar2;
    END SETPARAM;
    CREATE OR REPLACE PACKAGE BODY SETPARAM AS
    FUNCTION SET_PARAM1(p1 IN varchar2) RETURN NUMBER IS
    BEGIN
    fnd_client_info.set_org_context('138');
    param1 := p1;
    dbms_output.put_line(param1);
    RETURN 1;
    END;
    FUNCTION GET_PARAM1 RETURN varchar2 AS
    BEGIN
    RETURN param1;
    END;
    END SETPARAM;
    I registered the set_param1 function as a pl/sql function in discoverer admin.
    This function is called on the condition associated with the parameter in Discoverer Desktop when i run the report.
    In the custom folder query i have this piece in the where clause
    WHERE tnfo.request_id = NVL(APPS.SETPARAM.GET_PARAM1,7383588)
    And everytime i get the data pertaining to request id =7383588,
    Please suggest where i went wrong
    thanks
    Ashwini

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

  • 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

  • What Option Allows Permanent Change of Query in the Show SQL Query Window?

    I am trying to create a report in Crystal Reports v8.5 (or v10).  I would like to create the report by simply cutting and pasting an SQL query from SQL Designer into the appropriate place in Crystal Reports.  I can paste the query into the "Show SQL Query" window, but it reverts back to something else.  What Option do I change to allow me to do that, i.e, change the query in the "Show SQL Query" window?

    Hi Alan,
    In CR10 there is no option to past SQL qurety in Show Sql command option.  There is another option provided 'Add Commad' to execute customized SQL queries.  After connecting to your datasource before selecting tables you can choose Add Command option and past your SQL queries.
    Also you can modify the queries which you have pasted in add command.
    Thanks,
    Sastry

  • How to obtain the transformed SQL query using SEM_MATCH

    Dear all,
    Is it possible to get the transformed relational SQL query when using the SEM_MATCH prefix, by querying directly on the database. We are able to obtain the relational SQL query using Joseki/Jena, however this is not the way to go for us. We would like (if possible) to get it straight from the oracle database by logging or something.
    Kind regards.
    Max

    Hi Max,
    Just to clarify. What SEM_MATCH prefix are you talking about?
    A SEM_MATCH based query is indeed a SQL query as SEM_MATCH is a SQL table function. So if you don't want to go through Java APIs or web service endpoint, then running SEM_MATCH directly should give you what you need. Or maybe you just want to see the underlying generated (from SEM_MATCH) SQL query. If that is true, can you please tell us why?
    Thanks,
    Zhe Wu

  • How to find the backend  SQL query of the JSP page in OIC

    Does anybody how the best way to find the backend SQL QUERY of OIV JSP page?

    How To Generate Trace Files in in HTML/JSP (using Profile Option)
    •     • Note: This requires proper responsibility to set SQL Initialization statement using Profile option.      
         Step 1.     Login to the desired Form application.     
         Step 2.     Select +Profile >> System ('Find System Profile Values' screen will pop up)     
         Step 3.     Check 'User' and Type in the Username (in which the account for that user will be trace)     
         Step 4.     Type 'Initialization%' in the Profile box and Hit 'Find' (Click here for preview.)     
         Step 5.     In the User box, type the following statement and Hit 'Save' (Click here for preview)
         BEGIN FND_CTL.FND_SESS_CTL('','','TRUE','TRUE','','ALTER SESSION SET TRACEFILE_IDENTIFIER = TESTING MAX_DUMP_FILE_SIZE = 5000000 EVENTS ='||''''||' 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12'||'''');END;     
         Note:     specify any name you like to identify your trace, in this case, testing is the end name on the trace. You can also specify the amount of data allowable to be in the trace, in this case, 5000000 is the amount set. Make sure you hit 'Save' afterwards.[Quotes in the statement are all 'Single' quotes.]
              specifying TRACEFILE_IDENTIFIER value is mandatory when setting up the trace using the above profile option value
         Step 6.     Login to HTML / JSP page with username/password and start your flow. (Everything you do once login to HTML / JSP will get trace.)     
         Step 7.     Logout of HTML / JSP application once you completed with your flow.      
         Step 8.     Go back to the Profile option in the Form application and delete the Initialization SQL statement, and Hit 'Save'.     
         Step 9.     Log in to the database server or login server and retrieve your trace file.
         Identify and retrieve the trace file using the tracefile_identifier specified in Step 5.
         In this case the tracefile_identifier is “TESTING”. (Click here for Trace file locations) *     
         Note:     If you need to regenerate your trace or tracing a new flow, then repeat Step 1 to Step 8. To avoid self-confusion, choose a different name for your trace identifier everytime you set to trace.     
         Step 10.     See TKPROF section on how to format trace file into readable text.
         Trace Options Definition
         No Trace          Tracing is not activated
         Activities will not get traced.
         Regular Trace
         (Level 1)          Contains SQL, execution statistics, and execution plan.
         Provides execution path, row counts as well as produces smallest flat file.
         Trace with Binds
         (Level 4)          Regular Trace plus value supplied to SQL statement via local variables.
         Trace with Waits
         (Level 8)          Regular Trace plus database operation timings that the SQL waited to have done in order to complete, i.e. disk access.
         Trace with Binds and Waits
         (Level 12)          Regular trace with both waits and binds information.
         Contains the most complete information and will produce the largest trace file.
    ****Send me an email to [email protected],I will share the document with you.

  • Combine multiple web services with the same SQL query into one

    Hello,
    I would like to ask a question regarding combine multiple similar web services into one. Can you please tell me if it is possible to combine 4-5 web services into one since they built on the same SQL query with 5 different criterias or condition so that the user can enter any of the 5 criterias to populate the data on the form instead of having 5 different web services?
    e.g Query: Select appName, permit#, address, phone, description, type, section, from table where appName = can be 'appName, permit#, address, phone, or description' to populate the rest of the data to the form.
    Does any one have ever done some thing like this in Workbench ES? If so please assist. I know it can be easier to build it in Visual Basic, C#, or dot.net but the requirement is to build it in workbench ES.
    Thanks in advance,
    Han Dao

    If you are querying for Name, PhoneNumber, and SSN, and you queried for all people with a phone number that started with 867, you would have a potentially long list of people.  So to keep track of all of the people, we store each record in XML complex elements.  The root node is just any name you want, and the repeating element is the complex element name. 
    So using the example from above, I'm going to specify the following:
         Root Node: Result
         Repeating Element: Person
    So now when I do a query, my resultXML will look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
    </Result>
    If your query returned multiple results (like ours would probably), it would look like:
    <Result>
          <Person>
                 <Name>Alex</Name>
                 <PhoneNumber>867-5309</PhoneNumber>
                 <SSN>111-11-1111</SSN>
          </Person>
          <Person>
                 <Name>Han</Name>
                 <PhoneNumber>867-2169</PhoneNumber>
                 <SSN>222-22-2222</SSN>
          </Person>
    </Result>
    So Result and Person is just to give a little bit of structure to the xml result (containers really).  So you can name them whatever is helpful for you.
    The column name mappings map the query columns (Name, PhoneNumber, SSN) to some node in the XML (Name, PhoneNumber, SSN).  So you don't need to specify which field maps to what in the form.  Just copy the column names to the element name so you have a 1-to-1 naming.  If you want to manipulate the XML a bit though, you could do:
    Column Name               Element
    Name                            YourName
    PhoneNumber                Phone
    SSN                              Secret
    which would then make your xml look like:
    <Result>
          <Person>
                 <YourName>Alex</YourName>
                 <Phone>867-5309</Phone>
                 <Secret>111-11-1111</Secret>
          </Person>
    </Result>
    It lets you change the XML element names to whatever you want. Otherwise by default they take on their column names.
    In your form, you could bind to the WSDL through the Data Connections pane and point it to your web service.  This will then create form elements that you can just drag and drop allowing you to have the information available when the service gets ran.  Once the service is called, you can modify the field's data to get whatever information you need in order to populate other form fields. 
    If that is too confusing, feel free to send me your form (e-mail is on profile page) and I'll add comments to it to show you how to set up the form for the web service call (and also give me the link to your webservice)

  • Pass the result of a SQL Query as table_name  for another SQL Query

    Hi All,
    How to pass the result of a SQL Query as parameter to another SQL Query
    Eg: I am doing the steps below.
    1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
    2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
    Thanks

    Naveen B wrote:
    Hi All,
    How to pass the result of a SQL Query as parameter to another SQL Query
    Eg: I am doing the steps below.
    1) select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ'
    2) I want to pass the table_name from step 1 above as parameter to another query "select * from TAB1"
    ThanksYou should craete PL/SQL code with cursor which will accept a parameter and call that cursor inside the first one
    But if the first sql returns only one row, you can do it with simple sql code
    select * from (select distinct table_name as TAB1 from all_tab_cols where table_name like 'T_%' and column_name like '%XYZ')- - - - - - - - - - - - - - - - - - - - -
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • I need to set up an expense form so that our consultant can "filter" by customer type, program type, and finally the purpose of the trip. For instance: the customer types are churches, schools, organizations. The program type would be fund raising, gift p

    I need to set up an expense form so that our consultant can "filter" by customer type, program type, and finally the purpose of the trip. For instance: the customer types are churches, schools, organizations. The program type would be dependent on the customer type selection from the first list. Some examples would be: fund raising, gift planning, surveys, and others. The purpose of the trip would be dependent on the program type selected from the second list. Some examples of trip purposes would be: presentation, design, prospecting. Further, the purpose of trip selection from the third drop-down box would then have to determine the values of other fields by expense type: such as commission, airfare, hotel. etc. I've tried pop-up menu but can't figure out how to "select" from the final popup list and have it populate a field for the purpose of the trip. I've tried to look at the JavaScript examples for dependent drop-down boxes, but can't find any that quite fit what I'm trying to accomplish. I am very new to all of this. No training in writing Javascripts - just trying to wing it. The form has to be very simple for our consultants to use, but also give our office the detail we need to process through the correct account numbers. I would appreciate any detailed step-by-step instructions - kind of a javascript for dummies type of info. HELP!

    An AcroForm is the name given to the type of PDF form that you create in Acrobat. An XFA form is the type of form that you create in LiveCycle Designer. Although they are both PDF files, they are very different structurally and have significant;y different scripting models. So pay attention to the information on AcroForms and ignore anything about XFA. Be sure to get the sample PDF forms so you can look at how it works and where the scripts are placed.
    What you want to do will require scripting, and if you don't have the experience and are unable to use the information in the tutorials to create what you want, you might consider getting someone who has experience do this for you. I'll often suggest code if I can do so quickly, but what you want requires more than a few minutes.

  • Extracting the Logical sql query for the specified report  in OBIEE 11g

    Hi ,
    I want to extract the logical SQL Query for the Particular report in OBIEE 11.1.1.5.
    Any pointers related to this will be very helpful.
    Thanks,
    Sonali

    for a try please add Logical sql view to ur report it will dispaly the Logical sql for that Report..
    Hope it will helps you.

Maybe you are looking for

  • On how many computers can I use Creative Cloud simultaneously?

    I have for instance a computer downstairs, and one on the 1st floor. Is it possible to run Lightroom on both computers at the same time? (I use it upstairs, and my mother downstairs)

  • PI sender communication channel not reading files from NFS directory

    Hello, I have a sender communication channel configured to read file from NFS directory which is on ECC server. A program in ECC generates the file and puts it on the ECC server in the output directory. PI sender communication channel is supposed to

  • Please Apple, let us keep pages as it was...

    Installing mavericks brings pages 5.0 along somehow. PAGES 5.0 IS A TOTAL DISASTER. Worst, you can't do anything about it! I have several computers i use in office, home, all shynced, made the mistake of updating to Mavericks and pages come along on

  • Weighting Key in Vendor Evaluation

    Hi all, Is there any configuration by which the weighting key is defaulted? My client uses only one weighting key and whenever a vendor evaluation is run, they want the weighting key to be autopopulated. FYI No customization. Is this possible only th

  • Rebate Management in SD

    Hi Guys, I have got a new scenario, where I have been stuck. I have to give the 5% extra rebate to a customer on the basis on quarterly sale. Scenario: I use to give monthly rebate of 5 to 8% to a customer. Now if the purchasing of a customer is grea