CRM 2011: Creating SQL Query through MSCRM

I have been asked to create some kind of query through SQL to find all open opportunities that have an activity record associated to that opportunity.
Is this something that can be done through SQL? If so how do I join these two tables together?
Thanks in advance

You can do this in SQL, though you can also easily access this directly in CRM using Advanced Find.
When accessing data via SQL, the supported route is to use the filtered views, rather than querying the tables directly. Each entity has an associated filtered view, for example the opportunity entity has a filtered view called FilteredOpportunity.
You can join opportunities to activities using the regaridngobjectid field on the ActivityPointer entity
select * from FilteredOpportunity o join FilteredActivityPointer a on o.opportunityid = a.regardingobjectid
Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

Similar Messages

  • Creating sql query using 3 tables

    There is database (supposed to be relational but it is not) and
    I cannot change the tables and it is very difficult to create SQL query.
    Please, help!
    First table T1
    a1 char 20
    time timestamp
    a2 char 7 (the same as t2.a2 when is trimmed)
    a3 number 5,0
    a4 number 8,4
    a5 number 7,3
    Second table T2
    a2 char 15
    b1 number 1,0
    b2 char 1,0
    b3 char 4
    a3 number 5,0
    Third table T3
    b3 char 4
    c1 char 4
    c2 number 7,3
    c3 number 8,4
    So, I need to create query (is it possible at all!?) from those 3 tables (a1, a2, b1,b2,b3, a4, a5, c2,c3
    where time is within interval (from, to), a3 in interval (1,2,3,4), t2.b3=t3.b3, t1.a2=t2.a2
    group by or sorted by a1, then, a2.
    Any suggestion is welcome!
    Thanks!
    By the way, I will use this query in Crystal Reports.

    As I already mentioned, I received another conditions for the query, and when I create a new one, I
    First table T1
    a1 number 5,0
    a2 char 7 (the same as t2.a2 when is trimmed)
    a3 number 8,4
    a4 number 7,3
    a_time timestamp
    Second table T2
    a2 char 15
    b1 number 1,0
    b2 char 1,0
    b3 char 4
    b4 char 4
    Third table T3
    c1 char 4
    c2 number 7,3
    c3 number 8,4
    b3 char 4
    where if c1='MIN' c2, c3 return min values,
    and if c1='MAX' c2,c3 return max values
    SQL query:
    select t1.a1, t1.a2, t2.b1, t2.b2, t2.b3, t1.a3, t1.a4, t3.c1,
    t3.c2, t3.c3, t2.b4
    from t1, t2, t3
    where (TRIM(t1.a2)=TRIM(t2.a2)
    and t1.a1=19
    and ((to_char(t1.a_time, 'YYYY-MM-DD') >= '2006-03-15')
    and (to_char(t1.a_time, 'YYYY-MM-DD') <= '2006-03-16')))
    and t3.b3=t2.b3)
    order by t1.a_time
    Result set:
    a1, a2, b1, b2, b3, a3, a4, c1('MAX'), c2', c3', b4
    a1, a2, b1, b2, b3, a3, a4, c1('MIN'), c2", c3", b4
    So when I executed SQL query it returns 2 rows for the same a2.
    I want to get 1 row for each a2 together with c3 (c4) min and c3 (c4) max values.
    How to name columns for c2 min and c2 max (the same for c3) in order to retreive 1 row per a2 value, something like this:
    a1, a2, b1, b2, b3, a3, a4, c2min, c2max, c3min, c3max, b4
    Thanks

  • How to create sql query for item master with operator LIKE with variables?

    hi all,
    How to create sql query for item master with
    operator LIKE(Contains,Start With,End With) with variables using query generator in SAP B1 ?
    Jeyakanthan

    Hi Jeyakanthan,
    here is an example (put the like statement into the where field)
    SELECT T0.CardCode, T0.CardName FROM OITM T0 WHERE T0.CardName Like '%%test%%'
    The %% sign is a wildcard. If you need start with write 'test%%' and otherwise ends with '%%test'. For contains you need '%%test%%'. You also could combinate this statements like 'test%%abc%%'. This means starts with test and contains abc.
    Regards Steffen

  • Fail to create SQL query report because of ORA-00923

    Hi expert,
    I would like to SQL query report using the following query:
    select min(identified_date) first_identified,
    max(actual_COMPLETE) last_closed,
    count(id) total_issues,
    sum(decode(status,'Open',1,0)) open_issues,
    sum(decode(status,'Pending',1,0)) pending_issues,
    sum(decode(status,'Resolved',1,0)) closed_issues,
    sum(decode(status,'Will Not Resolve',1,0)) not_resolve_issues,
    sum(decode(status,
    'Open',decode(priority,null,1,0),
    0)) open_no_prior,
    sum(decode(status,
    'Open',decode(priority,1,1,0),
    0)) open_prior_1,
    sum(decode(status,
    'Open',decode(priority,'2',1,0),
    0)) open_prior_2
    sum(decode(status,
    'Open',decode(priority,3,1,0),
    0)) open_prior_3,
    sum(decode(status,
    'Open',decode(priority,'4',1,0),
    0)) open_prior_4,
    sum(decode(status,
    'Open',decode(priority,5,1,0),
    0)) open_prior_5
    from SOFTPROJ_issues
    where project_id = :P83_PROJECT
    However, I got the following error during the steps of creation:
    1 error has occurred
    Query cannot be parsed, please check the syntax of your query. (ORA-00923: FROM¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿)
    I wonder why if it is getting the error because I could create the report with the following query without problems:
    select min(identified_date) first_identified,
    max(actual_COMPLETE) last_closed,
    count(id) total_issues,
    sum(decode(status,'Open',1,0)) open_issues,
    sum(decode(status,'Pending',1,0)) pending_issues,
    sum(decode(status,'Resolved',1,0)) closed_issues,
    sum(decode(status,'Will Not Resolve',1,0)) not_resolve_issues,
    sum(decode(status,
    'Open',decode(priority,null,1,0),
    0)) open_no_prior,
    sum(decode(status,
    'Open',decode(priority,1,1,0),
    0)) open_prior_1,
    sum(decode(status,
    'Open',decode(priority,3,1,0),
    0)) open_prior_3,
    sum(decode(status,
    'Open',decode(priority,5,1,0),
    0)) open_prior_5
    from SOFTPROJ_issues
    where project_id = :P83_PROJECT
    1 error has occurred
    Query cannot be parsed, please check the syntax of your query. (ORA-00923: FROM¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿)
    The difference is to add the followings only:
    sum(decode(status,
    'Open',decode(priority,'2',1,0),
    0)) open_prior_2
    sum(decode(status,
    'Open',decode(priority,'4',1,0),
    0)) open_prior_4,
    Does anyone have any idea to resolve the issue?
    Thanks in advance,
    Rui

    By putting a comma after open_prior_2:
    sum(decode(status,
    'Open',decode(priority,'2',1,0),
    0)) open_prior_2,Sima

  • CRM 2011 With SQL 2012 Miroring

    Hi, I just installed crm 2011 with 2 noeuds sql server 2012 configured with mirroring,and automatic failover.
    when I restart the main noeud ( active) :
    failover OK :
    noeud active = secondary
    noeud secondary= active
    I just applied the following article https://technet.microsoft.com/en-us/library/hh699791(v=crm.5).aspx 
    CRM OK  but delpoiement CRM console (MMC) does not work.
    error :
    FX:{1ac9de3e-24ae-480d-9e15-65386b76e433}
    Impossible d'ouvrir la base de données "MSCRM_CONFIG" demandée par la connexion.La connexion a échoué.
    Échec de l'ouverture de session de l'utilisateur 'CONTOSO\Administrateur'.
    à System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
    à System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
    à System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
    à System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    à System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
    à System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
    à System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
    à System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
    à System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance,
    SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
    à System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
    à System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
    à System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    à System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
    à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
    à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
    à System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
    à System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
    à System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
    à System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
    à System.Data.SqlClient.SqlConnection.Open()
    à Microsoft.Crm.CrmDbConnection.Open()
    à Microsoft.Crm.Setup.Server.Utility.CrmServerUtility.GetConfigDatabaseVersion(String sqlServerName, String configDatabaseName)
    à Microsoft.Crm.Tools.Admin.DMSnapInController.IsConfigDBVersionSupported()
    à Microsoft.Crm.Tools.Admin.DMSnapInHelper.DisplayMessageBoxIfConfigDBNotSupported(Console console)
    à Microsoft.Crm.Tools.Admin.DMSnapIn.OnInitialize()
    à Microsoft.ManagementConsole.SnapInBase.Initialized()
    à Microsoft.ManagementConsole.Internal.SnapInClient.Microsoft.ManagementConsole.Internal.ISnapInClient.Initialize(ISnapInPlatform snapInPlatform)
    à Microsoft.ManagementConsole.Executive.SnapInInitializationOperation.OnStart()
    à Microsoft.ManagementConsole.Executive.RunningOperationsTable.EnqueueOperation(Operation operation)
    à Microsoft.ManagementConsole.Advanced.FrameworkSnapInFactory.Microsoft.ManagementConsole.Advanced.ISnapInFactory.CreateSnapIn(Int32 bookkeepingId, String snapInKey, Object& snapIn)
    "contoso\administrateur" and "network service" have role sysadmin in 2 noeuds SQL.
    could you help me.
    thanks,

    Is the deployment pointing at the virtual SQL server name for the cluster, rather than for a single one of the servers?
    Hope this helps.
    Adam Vero, Microsoft Certified Trainer | Microsoft Community Contributor 2011
    UK CRM Guru Blog

  • Creating SQL Query to determine similar customers

    I have a table that contains two columns: CustomerID and ItemID.
    There are 480 CustomerIDs and more than 5000 ItemIDs. The table shows what all items have been bought by each customer.
    I need to write a procedure where i can determine which all customers are 'Like Customers' (It means if a Customer C1 buys Items A, B and C where another customer C2 buys A, B, C, D, E then we can say that C1 and C2 are 'Like Customers' since, they both
    bought A, B, C.  It is also possible that both the customers bought B,C,D or C,D,E or any other combination)
    I would also like to know whether this kind of problem can be better solved in SSMS or SQL Server Business Intelligence Devp Studio (using data mining techniques)?

    For future reference, posting DDL and providing sample data makes it easier to answer your questions...
    Anyway, based on the size of your table, simple T-SQL should do the trick.
    -- a little test data.
    CREATE TABLE #temp (
    CustomerID INT,
    ProductID INT
    INSERT #temp (CustomerID,ProductID) VALUES
    (1,1),
    (1,2),
    (1,3),
    (1,4),
    (1,5),
    (2,4),
    (2,5),
    (2,6),
    (2,7),
    (3,2),
    (3,3),
    (3,8),
    (3,9),
    (4,10),
    (4,11),
    (4,12),
    (4,13),
    (5,1),
    (5,2),
    (5,12),
    (5,13),
    (6,1),
    (6,5),
    (6,7),
    (6,10),
    (7,1),
    (7,2),
    (7,3),
    (7,4),
    (7,5)
    -- the actual solution
    SELECT
    t1.CustomerID AS Customer1,
    t2.CustomerID AS Customer2,
    COUNT(*) AS CommonItemCount
    FROM
    #temp t1
    JOIN #temp t2
    ON t1.CustomerID < t2.CustomerID
    AND t1.ProductID = t2.ProductID
    GROUP BY
    t1.CustomerID,
    t2.CustomerID
    HAVING
    COUNT(*) >= 2 -- set this to whatever threashold value you deem as "similar"
    ORDER BY
    t1.CustomerID,
    t2.CustomerID
    HTH,
    Jason
    Jason Long

  • Run sql query through batch file

    how to create a batch file so that on running the batch file,
    I should get into the database using username and password and create the table and insert values inside that table

    kindly, if you are using windows you can create 2 files as following:
    a.bat
    b.sql
    put the files under spacific folder for example d:\bat folder
    -first file a.bat will contain the following:
    sqlplus apps/apps@yourdb @d:\bat\B.sql
    exit
    -second file b.sql will contain any sql statments you want as following:
    create table a (a1 number, a2 varchar2(100))
    insert into a (a1,a2) values(1,'Test')
    commit
    exit;
    hope this help you
    Regards ...
    Edited by: shedo76 on 28/04/2012 03:14 ص

  • Need help creating SQL Query

    Hi,
    I have this table
    declare @t_date table(cut_off datetime)
    insert into @t_date
    select '20140930'
    union
    select '20140716'
    union
    select '20140715'
    union
    select '20140714'
    union
    select '20140627'
    union
    select '20140625'
    I need this result: Dates nearests to end of month
    In the table on example, I need this output
    2014-09-30
    2014-07-16
    2014-06-27
    Can anyone help me?
    Thanks a lot in advance.
    declare @t_date table(cut_off datetime)
    insert into @t_date
    select '20140930' --this is OK cause eom
    union
    select '20140716' --this is OK cause is the nearest to eom(07)
    union
    select '20140715' --this is KO cause is not the nearest to eom(07)
    union
    select '20140714' --this is KO cause is not the nearest to eom(07)
    union
    select '20140627' --this is OK cause is the nearest to eom(06)
    union
    select '20140625' --this is KO cause is not the nearest to eom(06)

    Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. You have no keys! Learn how to follow ISO-11179 data element naming conventions and formatting rules.
    Temporal data should use ISO-8601 formats. It is the only –- repeat, only -– format allowed in ANSI/ISO Standard SQL! Code should be in Standard SQL as much as possible and not local dialect. We would use the correct INSERT INTO syntax. 
    Oh, that silly “t_” is called a “tibble” and we laugh at it. 
    CREATE TABLE Foobar_Dates
    (foobar_date DATE NOT NULL PRIMARY KEY);
    INSERT INTO Foobar_Dates
    VALUES
    ('2014-06-25'),
    ('2014-06-27'),
    ('2014-07-14'),
    ('2014-07-15'),
    ('2014-07-16'),
    ('2014-09-30'),
    >> I need this result: for each month I need the date nearest to end of month <<
    Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
    Build good tools and re-use them! 
    The report period table gives a name to a range of dates that is common to the entire enterprise. 
    CREATE TABLE Month_Periods
    (month_name CHAR(10) NOT NULL PRIMARY KEY
       CHECK (month_name LIKE '[12][0-9][0-9][0-9]-[01][0-9]-00'),
     month_start_date DATE NOT NULL,
     month_end_date DATE NOT NULL,
      CONSTRAINT date_ordering
        CHECK (month_start_date < month_end_date),
    etc);
    These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
    data format required by Standard SQL and it is language independent. 
    SELECT M.month_name, MAX(F.foobar_date), 
           OVER (PARTITION BY M.month_name)
      FROM Foobar_Dates AS F, 
           Month_Periods AS M 
     WHERE F.foobar_date BETWEEN M.month_start_date AND M.month_end_date;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Need a logic for creating SQL query

    Hi Experts,
    Could you please help me to get the follwing desired output . thanks
    Actual Data:
    ABC01-02
    XYZ02-03
    PQR78-79
    LMN1-5
    Expected/Desired Output:
    ABC01
    ABC02
    XYZ02
    XYZ03
    PQR78
    PQR79
    LMN1
    LMN5
    Please let me know if you need any further information. Thanks in Advance.
    Regards
    Raghav

    Hi!
    In case you would like to get all entries:
    WITH
        mylist AS (SELECT 'ABC01-02' AS val FROM dual UNION ALL
                   SELECT 'XYZ02-03' AS val FROM dual UNION ALL
                   SELECT 'PQR78-79' AS val FROM dual UNION ALL
                   SELECT 'LMN1-5' AS val FROM dual
        details AS (SELECT regexp_substr(val, '\D+') AS s,
                           to_number(regexp_substr(val, '\d+', 1, 1)) AS xfrom,
                           to_number(regexp_substr(val, '\d+', 1, 2)) AS xto,
                           lpad('0', length(regexp_substr(val, '\d+', 1, 2)), '0') as xpattern
                      FROM mylist
        lines AS (SELECT ROWNUM AS yrow FROM dual CONNECT BY ROWNUM < 100
    SELECT s || trim(to_char(yrow, xpattern)) AS xresult
      FROM details JOIN lines ON (xfrom <= yrow AND xto >= yrow)
    ORDER BY xresult;Result:
    ABC01
    ABC02
    LMN1
    LMN2
    LMN3
    LMN4
    LMN5
    PQR78
    PQR79
    XYZ02
    XYZ03Best regards,
    Matt
    Edited by: Matt Schulz on 27.02.2013 14:41
    Edited by: Matt Schulz on 27.02.2013 14:43

  • SQL query execution in DB02 hangs if record set is more than 50000

    Hi,
    We are facing issue in a report performance. The return is using native SQL query.
    There are custom views created ar database level for pricing/maetrial and stock. The native sql query is written on these views. The report takes around 15 mins to run in background .
    We are trying to analyse the native SQL query through DB02. I tried fetching records for one particular
    custom view to make out if its indexing issue or something else.When i using TOP 35000 records with select query runs fine with this dataset or less than this . If i increase it to 40000 system doesn;t show anything in SQL ouptut. And above one lakh records system gives timeout.
    The count in this view gives some 10 lakh records which I don't feel is v.v.huge that query that too native sql takes so much time.
    Any help on this will be highly appreciated.
    Regards
    Madhu

    what do you expect from that poor information.
    do you change data or onyl select.
    If you use SAP and ABAP, then you should also use Open SQL.
    Otherwise it is possible to run the SQL Trace with Native SQL, it is anyway only Native SQL, what the trace sees.
    Use package size and it will probably work fine.
    Siegfried

  • Tool for visually building an SQL query?

    Hello,
    Can anybody recommend a good tool that allows building an Oracle SQL query through a visual interface (similar to MS Access query builder)?
    I checked Oracle SQL Developer (from Oracle) but apparently it only allows building SELECT queries visually, I need to be able to create UPDATE and INSERT statements as well...
    Thank you,
    M.R.

    I'm not very clear on what you want or what you are trying to 'simulate'.
    If you are looking for a way to "build a gui" that allows you to simultaneously modify multiple rows of data in a table:
    This sounds like a "tabular form" in Oracle APEX (which is free with all editions of Oracle including the free XE edition. )
    URL for the out-of-the-box sample "application" that demonstrates a Tabular Form for modifying the EMP table:
    https://apex.oracle.com/pls/apex/f?p=71793:4
    name/password:  demo/demo
    Feel free to sign up for a free account to play with it.
    MK

  • Datasource works with java code but not with sql:query dataSource=...

    Hello everyone! I have a small problem with binding a DataSource object via JNDI and retrieving it in a web application. This is the case:
    I did not wish to make the DataSource available through the server.xml, because I want to create applications that can be bundled in a simple .war file. So I create the DataSource when the context is created in the contextInitialized() method of ServletContextListener like this:
    InitialContext initialContext = new InitialContext();
    Properties properties = new Properties();
    properties.setProperty( "driverClassName", "com.mysql.jdbc.Driver" );
    properties.setProperty( "factory",   "org.apache.commons.dbcp.BasicDataSourceFactory" );
    properties.setProperty( "username", servletContext.getInitParameter( "dbUser" ) );
    properties.setProperty( "password", servletContext.getInitParameter( "dbPass" ) );
    properties.setProperty( "url",      servletContext.getInitParameter( "dbUrl" ) );
    properties.setProperty( "defaultAutoCommit", "false" );
    properties.setProperty( "maxActive",         "25" );
    properties.setProperty( "initialSize",       "15" );
    properties.setProperty( "maxIdle",           "10" );
    properties.setProperty( "testOnBorrow",      "true" );
    properties.setProperty( "testOnReturn",      "true" );
    properties.setProperty( "testWhileIdle",     "true" );
    properties.setProperty( "validationQuery",   "SELECT 1" );
    properties.setProperty( "removeAbandoned",   "true" );
    DataSource dataSource = BasicDataSourceFactory.createDataSource( properties );
    initialContext.rebind( "daers", dataSource );Please comment if you think this is a bad idea!
    All the above seems to work fine. When I try to retrieve the DataSource in a .jsp file then it all works fine like this:
    <% try {
            javax.naming.InitialContext initialContext = new javax.naming.InitialContext();
            java.sql.Connection conn = ( ( javax.sql.DataSource )initialContext.lookup( "daers" )).getConnection();
            java.sql.Statement statement = conn.createStatement();
            java.sql.ResultSet resultSet = statement.executeQuery("SELECT users.name FROM users;");
            while (resultSet.next()) {
                System.out.println(resultSet.getString(1));
        } catch ( java.sql.SQLException e ) {
            e.printStackTrace();
        } catch ( javax.naming.NamingException e ) {
            e.printStackTrace();
    %>But when I try to execute the same sql query through the appropriate JSTL taglib I get a:
    javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"The JSTL code I use is this:
    <sql:query dataSource = "daers" var = "query" scope = "page">
            SELECT users.name
            FROM users
        </sql:query>I do put both of the two above pieces of code in the same .jsp page and the first works but the second causes the exception...
    Any clues..?
    Is it illegal to lookup a DataSource in <sql: dataSource=...> if the DataSource is not registered in the server.xml file..?
    If so, do I have any alternatives (like putting the DataSource as a servlet context variable)..?

    I added a response in your original message:
    http://forum.java.sun.com/thread.jspa?messageID=9629812
    Let's keep to it since splitting things across two posts might be confusing.

  • Using '(' and less than operator in an xsql page sql query

    Dear All,
    I tried to use left parenthesis '(' and less than operator in an sql query through an xsql page, it doesn't let to use them.
    Do you know how to use those in an xsql page?
    Thanks for your help.
    Mustafa

    Following is the xsql page that I tried to run:
    <?xml version="1.0"?>
    <xsql:query xmlns:xsql="urn:oracle-xsql" connection = "bib" rowset-element="bib" row-element="book">
    (SELECT year,title,last,first,' ' as affiliation,publisher,price
    FROM book,author
    WHERE year=2001 and bookid=parentid
    UNION
    SELECT year,title,last,first,affiliation,publisher,price
    FROM book,editor
    WHERE year=2001 and bookid=parentid)
    INTERSECT
    (SELECT year,title,last,first,' ' as affiliation,publisher,price
    FROM book,author
    WHERE publisher='Publisher1' and bookid=parentid
    UNION
    SELECT year,title,last,first,affiliation,publisher,price
    FROM book,editor
    WHERE publisher='Publisher1' and bookid=parentid)
    </xsql:query>
    This is the error message generated after running:
    <ERROR>java.sql.SQLException: ORA-01009: missing mandatory parameter</ERROR>
    When I remove the parentheses it works but this results in a different result set.
    Can anybody tell me the reason?
    Thanks,
    Mustafa
    null

  • SQL query generating data in SQL management studio but not in CUIC interface

    Hello,
    I'm working on a UCCE 9.0 system
    I created SQL query for a  report.
    Whenever I run the query inside the SQL management studio, it works and generates data, but when I run it in the CUIC interface it works but generates nothing. As you can see in the below snapshot, it contains 209 records that are not being displayed.
    Any help would be greatly apprciated

    Is it a custom report ? Can you right click on your Custom Report and click on Edit Views. You need to check whether you have Grid Headers Listed.
    Regards,
    Senthil

  • Facing problem in constructing a sql query

    I want a SQL Query through which I can Select all the values in a column of a table( which is Primary Key and another field in the table refers this field) I want to select all the values of the primary key which are either reffered by a particular value of the referring field or all the parents corrosponing to the value or their parents or their parents.... until I get a value which doen't refers any value.

    I want a SQL Query through which I can Select all the values in a column of a table( which is Primary Key and another field in the table refers this field) I want to select all the values of the primary key which are either reffered by a particular value of the referring field or all the parents corrosponing to the value or their parents or their parents.... until I get a value which doen't refers any value. Hi
    Did u try using Self Join
    I think that might solve the problem
    Sri

Maybe you are looking for

  • How can I use TopLink for querys that have two and more tables?

    I use TopLink today, and I can use one table to query, but how can I use TopLink for querys that have two and more tables? Thank you for see and answer this question.

  • Touch smart 23

    I want to buy a Pavilion Touchsmart 23 and connect a Pavilion 23xi to use as a second monitor. How do I connect the two as there is no HDMI out on the Touchsmart? This question was solved. View Solution.

  • How to increase file size on solaris 10 from 2g

    HI All, how can i increase the file size on solaris 10 from 2gb . please reply complete steps. or any helpful tutorials thanks

  • Service invoice

    hi, here when i go for service invoice verification, when i entered service entry sheet no., then no item appears , then i go in PO , cheacked the PO , there is the indicator deselected service based IV, GR BASED IV IS ON, can i modify, in PO , becau

  • Weirdness and a Reload OS 507 message...

    Hello all Wel, yesterday night thing got weird. I plugged my bb curve8900 into my mac and wanted to transfer some files. I got a message saying that my OS could be updated so I figured sure. I oked this and then, aftr some time, my Curve went dead...