Sql Query to MVC View via LINQ
I have a Query that is returning the proper results in Sql Server View that runs the query below:
SELECT CertificateNumber, COUNT(*) AS LoginCount, InsertDate
FROM dbo.LogIns
GROUP BY CertificateNumber, InsertDate
Results:
40050004289468 1
2015-03-22
40050004417374 1
2015-03-22
40160015050974 1
2015-03-22
40250024398851 1
2015-03-22
711511 9
2015-03-22
90021255342381 6
2015-03-22
40060005110838 2
2015-03-23
40070006178842 1
2015-03-23
40070006216238 1
2015-03-23
40070006282800 1
2015-03-23
40110010957264 1
2015-03-23
40250024090870 1
2015-03-23
4045004499703 9 1
2015-03-23
711511 13
2015-03-23
I am trying to return the same results to an MVC 5 View:
I imported the view from the db:
Model:
public partial class LogInView
public string CertificateNumber { get; set; }
public Nullable<int> LoginCount { get; set; }
public Nullable<System.DateTime> InsertDate { get; set; }
Controller:
public ActionResult LoginActivity()
return View(db.LogInViews.OrderByDescending(i => i.InsertDate).ToList());
View:
@model IEnumerable<GCadmin.Models.LogInView>
ViewBag.Title = "LoginActivity";
<h2>LoginActivity</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.InsertDate)
</th>
<th>
Card Number
</th>
<th>
@Html.DisplayNameFor(model => model.LoginCount)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@item.InsertDate.Value.ToShortDateString()
</td>
<td>
@Html.DisplayFor(modelItem => item.CertificateNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.LoginCount)
</td>
</tr>
</table>
Result:
3/23/2015 40060005110838
2
3/23/2015 40070006178842
1
3/23/2015 40070006216238
1
3/23/2015 40070006282800
1
3/23/2015 40110010957264
1
3/23/2015 40250024090870
1
3/23/2015 4045004499703 9
1
3/23/2015 711511
13
3/22/2015 40050004289468
1
3/22/2015 40050004417374
1
3/22/2015 40160015050974
1
3/22/2015 40250024398851
1
3/23/2015 711511
13
3/22/2015 90021255342381
6
The 711511 on 3/23 is repeated.
I cant figure this one out.
Thanks, Doug
In the listing of the original query output, might the extra space be part of the issue? (2nd from the last entry).
4045004499703 9
1 2015-03-23
Similar Messages
-
Need help with SQL Query with Inline View + Group by
Hello Gurus,
I would really appreciate your time and effort regarding this query. I have the following data set.
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
Please Ignore '----', added it for clarity
I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
The query should return the following data set
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
The following is my query. I am kind of lost.
select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
from (
select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
from INVOICE
group by sequence_id,check_date, check_number, invoice_number, vendor_number
) A, INVOICE B
where A.sequence_id = B.sequence_id
Thanks,
NickIt looks like it is a duplicate thread - correct me if i'm wrong in this case ->
Need help with SQL Query with Inline View + Group by
Regards.
Satyaki De. -
Passing an argument in the SQL Query of a View Object
Hi,
It is possible that this question has been asked before, however I have searched for a half an hour in the forums and couldn't find a solution.
I am also new to using JDeveloper and ADF. Here's the situation:
I am developing an application that doesn't have to do anything else then displaying data from a database. Pretty straightforward actually.
Now I have made a vew pages with several collapsible panels (af:showDetailHeader) and have setup the datasources (or so I thought).
All that remains is:
- drag & drop a view object, from the application module that I created, onto the collabsible panels, so a child element gets created which displays data from the database.
- hack the layout so it looks like I want it to.
The problem that I have is the following:
I am using a 'User'-class that contains values I need when quering the database.
That User-object is part of a user-session.
What I want, for example, is to use the 'getPersonId()' function of that User-object and pass the argument to a SQL-query of a certain view-object.
The query would become something like:
'SELECT * FROM people WHERE people.personId = :someNumber'.
Now I've read some stuff about variable binding, which is complemented by something like (backing bean code):
getDBTransaction().getRootApplicationModule().getACertainViewObject().setWhereClauseParameter(1, user.getPersonId());
The examples I have found that might match my wishes are not using business components, but EJB's. I am having difficulty with understanding the 'how'-part of variable binding.
Also, I do not know enough of ADF to be able to create a situation like:
'User loads page, collapsible panel 1 is fully shown, the others are undisclosed.'
(meaning, that for panel1 a query has been executed.)
'User clicks on collapsible panel 2 which triggers a backingbean that somehow retrieves data from a view object'.
I would appreciate any help that somebody can give.
If it is not too much of a problem, please provide code snippets in case you have a solution. I am new to ADF :(.
-edit
I am using JDeveloper 10.1.3.3.0 in case that is of any importance.
Message was edited by:
Hugo BoogHello Stijn,
I didn't think about a referenced bean rule in the faces-config.
I added it right away and I am now able to set parameters of a View-object, not using a page button and before the page loads. You made my day!
In case anyone ever reads this post again, the summary of how to generate a table based on a View-object using dynamic parameters.:
1a: Go to faces-config.xml -> Overview tab'
1b: Go to the menuitem "Referenced Beans"
1c: Click on 'new' and select the existing bean you want to access data from and input a name. In this example I use name="user"
2: Create a View-object using the wizard.
2a: Specify the query you want in the menuitem 'SQL Statement'.
Add the 'parameters' you want to. You will have something like:
"SELECT * FROM someTable WHERE table.columnname LIKE :someArgument".
- hint: if you want the result to become something like:
"SELECT * FROM someTable WHERE table.columnname LIKE '%someArgument%'" then you have to add the '%'-characters in your code itself (read: someClass.setParameter("%" + someArgument);).
2b: In the menuitem 'Bind Variables' you have to add the variables you are referring to in the query. If you look at the query in 2a, then you have to add a variable with name "someArgument".
2c: Add the View-object to a Application Module (create one if nessecairy).
3a: Open a .jsp(x) file. Drag the View-object created in step 2 from the 'Data Controls'-pane to the page.
3b: Click on the '+' of the View-object in the 'Data Controls'-pane and open 'Operations' and drag 'ExecuteWithParams' to your page as a button.
3c: We do not want to use a button, the action has to be executed immediatly. So In the page source remove the lines that were created after dropping 'ExecuteWithParams'.
3d: Right-click on the page and select "Go to Page Definition".
3e: Go to the action id that is called 'ExecuteWithParams#', where # is a number.
Change the id to something useful.
3f: Change the NDValue so it corresponds with the value you want.
Example:
<action id="getAddressData" IterBinding="AddressesView1Iterator"
InstanceName="MyHRServiceModuleDataControl.AddressView1"
DataControl="MyHRServiceModuleDataControl" RequiresUpdateModel="true" Action="95">
<NamedData NDName="someArgument" NDType="java.lang.String"
NDValue="#{user.personId}"/>
</action>
Note: It is possible to use the value of a Backing Bean in NDValue.
Note 2: user is the bean I referred to in the faces-config.xml!
3g: Under the executables item, add an 'invokeAction' to pass the parameter to the View-object before your JSP-file loads:
<executables>
<invokeAction Binds="getAddressData"
id="loadAddressDataOfPersonIdInSession"
Refresh="prepareModel"/>
Thank Stijn Haus for this :) -
Using IN keyword in an sql query in a view criteria
Hi,
I am using jdev 11.1.1.1.0 and defined an lov query/viewobject as
select a, b, c from myTable
I now need to predefine filtering for lov search functionality and need something like the following
select a, B, c from myTable where B in ('X','Y')
I could not find a way to do it (i.e. specify the use of IN Keyword) in the Create View Criteria dialog box. I tried to define OR, but is that the best way to redefine IN as i have a long list (the above is just an example)
(( ( (UPPER(B_FLAG) = UPPER('X') ) ) OR ( (UPPER(DISPLAY_FLAG) = UPPER('Y') ) ) ))If you know how many variables are in your "in" You can just write this in the sql query of your VO:
http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/images/t136.gif
From this tutorial:
http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/developriaapplication_long.htm#ah1 -
Hi
I have an SQL that has poor performance when querying a 3 table view.
I have tried to tune the view by adding an additional index but the EXPLAIN plan does not change. In fact, the plan is ONLY using fields specified in the the views join conditions and not the WHERE clause.
I have created an index EKET~Z1 with the column for table (T003)
EINDT
and I have also tried another index EKKO~Z2 with the columns for table T001
BSART
BSTYP
EKORG
The query is as follows:
SQL Statement
SELECT
"MANDT" , "EBELN" , "EBELP" , "ETENR" , "EKKO_LOEKZ" , "BSTYP" ,
"BSART" , "BUKRS" , "EKORG" , "EKGRP" , "STATU" , "AEDAT" , "ERNAM" ,
"BEDAT" , "LIFNR" , "ADRNR" , "WAERS" , "EKPO_LOEKZ" , "EKPO_BSTYP" ,
"TXZ01" , "MATNR" , "EMATN" , "WERKS" , "MATKL" , "IDNLF" , "MENGE" ,
"MEINS" , "NETPR" , "NETWR" , "PSTYP" , "KNTTP" , "WEPOS" , "ANFNR" ,
"PRDAT" , "KONNR" , "KTPNR" , "ELIKZ" , "EREKZ" , "EINDT" , "SLFDT" ,
"LPEIN" , "EKET_MENGE" , "EKET_WEMNG" , "BANFN" , "BNFPO" , "MBDAT" ,
"WADAT" , "WEBRE" , "FRGRL" , "ZZKONNR" , "ZZKTPNR" , "MAHNZ" ,
"MAHN1" , "MAHN2" , "MAHN3" , "INFNR"
FROM
"ZPO_DETAIL"
WHERE
"MANDT" = ? AND "EKORG" = ? AND "BSTYP" = ? AND "BSART" = ? AND
"WERKS" = ? AND "EINDT" < ? AND "EKPO_LOEKZ" <> ? AND "ELIKZ" <> ?
ORDER BY
"EBELN" , "EBELP" , "ETENR"
VIEW DETAILS
CREATE VIEW ZPO_DETAIL
(MANDT,
EBELN,
EBELP,
ETENR,
EKKO_LOEKZ,
BSTYP,
BSART,
BUKRS,
EKORG,
EKGRP,
STATU,
AEDAT,
ERNAM,
BEDAT,
LIFNR,
ADRNR,
WAERS,
EKPO_LOEKZ,
EKPO_BSTYP,
TXZ01,
MATNR,
EMATN,
WERKS,
MATKL,
IDNLF,
MENGE,
MEINS,
NETPR,
NETWR,
PSTYP,
KNTTP,
WEPOS,
ANFNR,
PRDAT,
KONNR,
KTPNR,
ELIKZ,
EREKZ,
EINDT,
SLFDT,
LPEIN,
EKET_MENGE,
EKET_WEMNG,
BANFN,
BNFPO,
MBDAT,
WADAT,
WEBRE,
FRGRL,
ZZKONNR,
ZZKTPNR,
MAHNZ,
MAHN1,
MAHN2,
MAHN3 )
AS SELECT
T0003."MANDT",
T0003."EBELN",
T0003."EBELP",
T0001."ETENR",
T0002."LOEKZ",
T0002."BSTYP",
T0002."BSART",
T0002."BUKRS",
T0002."EKORG",
T0002."EKGRP",
T0002."STATU",
T0002."AEDAT",
T0002."ERNAM",
T0002."BEDAT",
T0002."LIFNR",
T0002."ADRNR",
T0002."WAERS",
T0003."LOEKZ",
T0003."BSTYP",
T0003."TXZ01",
T0003."MATNR",
T0003."EMATN",
T0003."WERKS",
T0003."MATKL",
T0003."IDNLF",
T0003."MENGE",
T0003."MEINS",
T0003."NETPR",
T0003."NETWR",
T0003."PSTYP",
T0003."KNTTP",
T0003."WEPOS",
T0003."ANFNR",
T0003."PRDAT",
T0003."KONNR",
T0003."KTPNR",
T0003."ELIKZ",
T0003."EREKZ",
T0001."EINDT",
T0001."SLFDT",
T0001."LPEIN",
T0001."MENGE",
T0001."WEMNG",
T0001."BANFN",
T0001."BNFPO",
T0001."MBDAT",
T0001."WADAT",
T0003."WEBRE",
T0002."FRGRL",
T0003."ZZKONNR",
T0003."ZZKTPNR",
T0003."MAHNZ",
T0003."MAHN1",
T0003."MAHN2",
T0003."MAHN3"
FROM
SAPCEP."EKET" T0001,
SAPCEP."EKKO" T0002,
SAPCEP."EKPO" T0003
WHERE
T0002."MANDT" = T0003."MANDT" AND
T0002."EBELN" = T0003."EBELN" AND
T0003."MANDT" = T0001."MANDT" AND
T0003."EBELN" = T0001."EBELN" AND
T0003."EBELP" = T0001."EBELP"
EXPLAIN PLAN
Execution Plan for SQL Optimizer
TABLENAME COLUMN OR INDEX STRATEGY PAGECOUNT
T0003 RANGE CONDITION FOR KEY 15758
MANDT (USED KEY COLUMN)
T0001 JOIN VIA MULTIPLE KEY COLUMNS 8632
MANDT (USED KEY COLUMN)
EBELN (USED KEY COLUMN)
T0002 JOIN VIA MULTIPLE KEY COLUMNS 40109
MANDT (USED KEY COLUMN)
EBELN (USED KEY COLUMN)
EBELP (USED KEY COLUMN)
NO TEMPORARY RESULTS CREATED
SHOW RESULT IS COPIED , COSTVALUE IS 31186
SHOW QUERYREWRITE - APPLIED RULES:
SHOW MergeFromSelectOrView 1
The statistics are up-to-date.
Any tips would be welcome.
Thanks
Doug> I have created an index EKET~Z1 with the column for table (T003)
> EINDT
>
> and I have also tried another index EKKO~Z2 with the columns for table T001
> BSART
> BSTYP
> EKORG
>
SQL Statement
>
> SELECT
> "MANDT" , "EBELN" , "EBELP" , "ETENR" , "EKKO_LOEKZ" , "BSTYP" ,
> FROM
> "ZPO_DETAIL"
> WHERE
> "MANDT" = ? AND "EKORG" = ? AND "BSTYP" = ? AND "BSART" = ? AND
> "WERKS" = ? AND "EINDT" < ? AND "EKPO_LOEKZ" <> ? AND "ELIKZ" <> ?
> ORDER BY
> "EBELN" , "EBELP" , "ETENR"
>
> EXPLAIN PLAN
> -
>
> Execution Plan for SQL Optimizer
>
> TABLENAME COLUMN OR INDEX STRATEGY PAGECOUNT
>
> T0003 RANGE CONDITION FOR KEY 15758
> MANDT (USED KEY COLUMN)
>
> T0001 JOIN VIA MULTIPLE KEY COLUMNS 8632
> MANDT (USED KEY COLUMN)
> EBELN (USED KEY COLUMN)
>
> T0002 JOIN VIA MULTIPLE KEY COLUMNS 40109
> MANDT (USED KEY COLUMN)
> EBELN (USED KEY COLUMN)
> EBELP (USED KEY COLUMN)
>
> NO TEMPORARY RESULTS CREATED
> SHOW RESULT IS COPIED , COSTVALUE IS 31186
> SHOW QUERYREWRITE - APPLIED RULES:
> SHOW MergeFromSelectOrView 1
>
>
> The statistics are up-to-date.
> Any tips would be welcome.
Hi Doug,
here we go...
What MaxDB version are you using? Did you check whether the DB parameters all comply to the recommendations?
If so, what are the cardinalities of the columns you indexed (a.k.a. how many different values do each of them contain?)
If the specification of BSART, BSTYP and EKORG does not reduce the number of rows to be retrieved to a large extent, then the indexaccess is likely to produce additional work.
Anyhow, the join order looks a bit odd here - this might be the problem caused by having set OPTIMIZE_OPERATOR_JOIN_COSTFUNC = YES in a MaxDB version between 7.6.04 and 7.6.06.
So make sure it's set to NO (see note 814704 MaxDB Version 7.6 parameter settings for OLTP/BW).
regards,
Lars -
MS SQL query slow using view column as criteria
HI,
I am experiencing a very frustrate problem. I have 2 tables, and create a view
to union these 2 tables, when do a select on this view using the column of the
view as criteria is took more 1 minutes, but the query runs fine in Qurey Analyzer.
Anybody has the same experience? is this the problem with jdbc?I searched http://e-docs.bea.com/wls/docs70/index.html, also searched the documentation
for wls6.1, wls5.1. As you pointed I searched support site, they are all the customer
case, it's not formal documentation.
Joe Weinstein <[email protected]> wrote:
>
>
jen wrote:
Thanks. but I search on the table is fine (the same column). is thereany db setting
could be tuned? so the view is the problem? No, it's a client decision/issue. If you defined your tables to have
nvarchar columns
the jdbc driver's parameter values would be fine as-is.
I searched "useVarChars" on whole
site and can't find anything.Which site? This is a property of the weblogic.jdbc.mssqlserver4.Driver.
I just went to www.bea.com/support and entered useVarChars in the Ask
BEA
question panel and got hits...
Joe
Joe Weinstein <[email protected]> wrote:
Jen wrote:
Sorry it's my bad. I am testing on wls81, but the problems is on wls70,so they
are using different drivers.
You are the magic man. It worked on wls81 now. I am sure it will curethe problem
on wls70. Is there any documentation on this? Why it is not a problemon some
databse server? ThanksSure. The issue has to do with the MS client-DBMS protocol having evolved
from
an 8-bit (7-bit really) character representation. Now it has a newer
16-bit
way, to transfer NVARCHAR data. Java characters are all 16-bit, so
by default
a JDBC driver will send Java parameters over as NVARCHAR data. This
is
crucial
for Japanese data etc. However, once simple ASCII data is transformed
to an
NVARCHAR format, the DBMS can't directly compare it to varchar data,
or use it
in index searches. The DBMS has to convert the VARCHAR data to NVARCHAR,
but it
can't guarantee that the converted data will retain the same ordering
as the index,
so the DBMS has to do a table scan!
The properties I suggested are each driver's way of allowing you
to say "I'm
a simple American ;) I am using simple varchar data so please sendmy
java
strings that way.". This allows the DBMS to use your varchar indexes
in queries.
Joe Weinstein at BEA
Joe Weinstein <[email protected]> wrote:
Jen wrote:
It doesn't cure the problem. Here is my pool
<JDBCConnectionPool DriverName="weblogic.jdbc.sqlserver.SQLServerDriver"Name="test_pool"
Password="{3DES}fKSovViFe5kHzl/vTs0LVQ==" Properties="user=user;PortNumber=1543;useVarChars=true;ServerName=194.20.2.10;DatabaseName=devDB"
Targets="admin" TestTableName="SQL SELECT COUNT(*) FROM sysobjects"URL="jdbc:bea:sqlserver://194.20.2.10:1543"/>
Strange is some database is fine.Oh, sorry. I thought it was the older weblogic driver. Change the
useVarChars=true to sendStringParametersAsUnicode=false
Let me know... Also, I suggest changing the TestTableName to "SQL
select
1".
For MS, that will be much more efficient than involving a full count
of sysobjects!
Joe
Joe Weinstein <[email protected]> wrote:
Jen wrote:
You are right. Tadaa! Am I Kreskin, or what? ;) Here's what I recommend:
In your pool definition, for this driver add a driver property:
useVarChars=true
and let me know if it's all better.
Joe
I am using weblogic jdbc driver weblogic.jdbc.mssqlserver4.Driver.
here is the code:
getData(Connection connection, String stmt, ArrayList arguments)
PreparedStatement pStatement=null;>>>>>>>> ResultSet resultSet=null;>>>>>>>> try {>>>>>>>> pStatement = connection.prepareStatement(stmt);>>>>>>>> for (int i = 1; i <= arguments.size(); i++) {>>>>>>>> pStatement.setString(i, (String) arguments.get(i-1));>>>>>>>> resultSet = pStatement.executeQuery(); //this statement takesmore than 1
min.
Joe Weinstein <[email protected]> wrote:
Jen wrote:
HI,
I am experiencing a very frustrate problem. I have 2 tables,
and
create
a view
to union these 2 tables, when do a select on this view using
the
column
of the
view as criteria is took more 1 minutes, but the query runs
fine
in
Qurey Analyzer.
Anybody has the same experience? is this the problem with jdbc?
I have suspicions... Show me the jdbc code. I'm guessing it's
a
PreparedStatement,
and you send the search criterion column value as a parameter
you
set
with a
setString().... Let me know... (also let me know which jdbc driveryou're
using).
Joe -
Tuning SQL Query calling multiple views
Dear All,
I have a complex scenario in which I have created views in 3 levels for sales and Service separately so total no of views are 6.
Level 2 calls view in Level 1 and Level 3 calls level 2 in sales as well as services.
Finally Level 4 has the union of sales and Service Level 3 view.
There are 5 tables used in total and all have been indexed for better performance.
The cube processing for the above scenario has processing time of 6 mins.
The goal is to bring it down to 2-3 mins.
The amount of data currently we are looking at is not more than 2-3 GB.
Can anybody help me fine tune this scenario?
Thanks, Franco.Run the queries the cube is using in SSMS and turn on the Include Actual Execution Plan option.
https://msdn.microsoft.com/en-us/library/ms189562.aspx?f=255&MSPPError=-2147217396
Straight up it may suggest missing indexes which you can test to see if they improve the query performance. You can't take these suggestions as gospel - sometimes SQL Server gets it wrong - so you need to test them.
After that look in the query plan for any table scan operators. Unless you are actually retrieving every row in a table you shouldn't have any of these and they can probably be removed by placing a properly considered index on the table.
After that look for any RID Lookups or Key Lookups. These can generally be resolved fairly easily by adding the columns being looked up as "include" columns in the indexes.
Here are some links that might get you started.
Reading Execution Plans: http://www.mssqltips.com/sqlservertip/1873/how-to-read-sql-server-graphical-query-execution-plans/
Resolving Table Scans http://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/
Resolving Lookups: http://blog.sqlauthority.com/2009/11/09/sql-server-removing-key-lookup-seek-predicate-predicate-an-interesting-observation-related-to-datatypes/
Those are the obvious things - and generally the easiest to achieve. Performance tuning is a big area. It may be that the database queries are already performing perfectly well and the time being spent is processing the cube itself so you need
to establish where the time is going. There is no point trying to tune the database queries if they are already working well.
LucasF -
Help with sql query on materialized view logs
I am in need of a query to find out what tablespace and snap shot site a long list of materialized view logs are associated with.
something like below except tablespace and snap_shot_site are not an option for this table.
select log_owner, master, log_table, tablespace, snap_shot_site from dba_mview_logs;What is the refresh method set as?
Could you paste the full MV log creation script and the corresponding MV creation script. -
Retrieve underlying SQL query for deski report via java SDK in BOXIR2
Hi all,
I am trying to retrieve underlying SQL queries of a deski report in BOXIR2. However I find the error as
oDataProvider = oDocumentInstance.getDataProviders().getItem(i1);
System.out.print(oDataProvider.getName());
oSQLDataProvider = (SQLDataProvider) oDataProvider;
oSQLContainer_root = oSQLDataProvider.getSQLContainer();
But "This feature is not supported for desktop Intelligence " exception has occured.
I am running the same query for Webi, and I did not find any issue . After several time spending in google, it appears to me that this code is supported by webi only. But "This feature is not supported for desktop Intelligence " exception has occured.
Please help me to find out the solution in java SDK. If its not supported by Java SDK, then could you please provide me any workaround , e.g. any macro . Any help !!
Regards,
Nita
Edited by: Nita Prasad on Aug 11, 2009 11:20 AM
Edited by: Nita Prasad on Aug 11, 2009 11:25 AMHi Fritz,
I am not getting the way.. how to open the deski report programmatically. I am writing the code in this way:
Dim oInfoObjects1 As CrystalInfoStoreLib.InfoObjects
Set oInfoObjects1 = oInfoStore.Query("SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='" & oInfoObject.Title & "' AND SI_ID='" & oInfoObject.Id & "' order by SI_NAME")
Dim oInfoObject1 As CrystalInfoStoreLib.InfoObject
Dim UserCount1 As Integer
UserCount1 = oInfoObjects1.ResultCount
MsgBox "SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME=' " & oInfoObject.Title & " ' AND SI_ID=' " & oInfoObject.Id & " ' order by SI_NAME"
MsgBox " Total number of Deski reports are : [" & UserCount1 & "]", vbOKOnly
Dim j As Integer
For j = 1 To UserCount1
Set oInfoObject1 = oInfoObjects1.Item(i)
sFile_ReportList = StrConv(oInfoObject1.Title, vbLowerCase) & ".rep"
sFile_Output = "D:\TraceWrite1\ " & StrConv(oInfoObject1.Id & "_" & oInfoObject1.Title, vbLowerCase) & ".txt"
sFile_ReportListTemp = StrConv(oInfoObject1.Files.Item(j), vbLowerCase)
MsgBox "[" & sFile_ReportList & "]", vbOKOnly
If Dir(sFile_ReportList) = "" Then
MsgBox "The text file [" & sFile_ReportList & "] for the DeskI documents does not exist!" & vbCrLf & "Aborting process."
Exit Sub
End If
I am getting the error on line ... If Dir(sFile_ReportList) = "" Then... The code is not able to locate the deski report path.
Is this the correct way to get a deski report information? Please let me know, If I am going in the right direction.
Edited by: Nita Prasad on Aug 18, 2009 3:47 PM -
Hi I need to create a simple view like this
No Count
10 15
to get the No i am using a function which would normally return 1 value like 10 above but could sometimes return 2 numbers in the following format 10:5
When I get a number like this i need to split it into 2 rows in the view with the same count.
No Count
10 15
5 15
at the moment i get this
No Count
10:5 15
5 15
I can use plsql or sql thanks in advance
kirkNot sure i was clear enough so heres my view as it stands
CREATE OR REPLACE FORCE VIEW "Q_ABSENCE" ("OWNERID", "OWNERTYPE", "TYPE", "ITEMCOUNT") AS
select distinct 'No',
count(*) as itemcount
from sick_absence
where ab_proccessed =2
and AB_COORDPROCESSED = 'No'
group by ab_owner
Which would return the following data
NO Count
10 2
5 4
4:3 2
2 1
234:23 4
I need it to return
No Count
10 2
5 4
4 2
3 2
2 1
234 4
23 4
thanks for your time
Kirk -
SQL query for Bitwise operation via SSRS
I am trying to write a query to display data in a SSRS report where we can select multiple values from a list parameter.
The WHERE clause in the query has to filter based on the selected values with the statement below.
I need to be able to pass each of the selected values from the SSRS report to replace the value
1 below. I can get it to work if only one parameter value is selected, but not if multiples are selected.
How do I get it to loop through each of the selected values and input that in to my where statement.
where customer_communication_preferences & 1 <> 0
Thanks in advance.I can pass the values across and use a function to split them out without an issue. Each time I try to run it as a stored procedure I can the error that:
SP:
CREATE Proc [dbo].[Get_CCP]
(@MultiVal nvarchar(max))
AS
select customer_number,
customer_communication_preferences
FROM ts_customer
WHERE customer_state = 'A'
and (customer_communication_preferences & (SELECT Val from dbo.fn_String_To_Table(@MultiVal,',',1))) <> 0
Then I do:
Get_CCP'4096' --This works
Get_CCP'4096,1024' --This error with the error :
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. -
Need to return CLOB as String type from SQL query
I have a table that contains a CLOB column, which should be accessible to a JDBC client (JReports) that does not understand how to extract CLOB from a result set.
A possible workaround would be to translate the CLOB type into a normal string on the database side as part of the SQL query (or a view), so that the client can handle it. For that to work, we would need a type conversion within the query itself.
Rather then
SELECT clob_column FROM my_table
we would need something like
SELECT to_char(clob_column) FROM my table
Unfortunately to_char does not work, but possibly there are other ways to achieve it.
nullHi Christo
Works fine. Just had to change the parameter order:
DBMS_LOB.substr(clob_column,4000,1) converts the CLOB to a VARCHAR
Thanks a lot,
Thomas
null -
Passing entire SQL query to BIP server from Forms
Hi
I want to pass the entire SQL statement or only a WHERE clause dynamically constructed on Forms side to BI Publisher server at runtime.
I have come across this article:
http://blogs.oracle.com/BIDeveloper/2009/12/dynamic_sql_query_in_data_template.html
It mentions about using pwhereclause which could be constructed dynamically.
Is it possible to pass the entire SELECT statement and has anyone done this before? May I have some tips on this?
Thanks and kind regards,
AparnaMy requirement is as follows:
1) I have a customised application which contains the definition of the report (report id, report name, the screen id on which the report is to appear as a record in the list and so on). This is where I would like to record the SQL statement which will be used to retrieve data for the report.
2) Once I launch the report from my application, it will pass SQL statement and other data (template, format, output file name, path where the output file will be saved, URL from which the output file will be launched after saving).
Thus, on BI Publisher server side, I shall only create a report, and will create a data template that will reference the SQL query that has been passed from application. I don't want to even specify parameters in Bi Publisher and want to specify them only in the application.
Is this possible?
Currently, I'm using a web service called 'PublicReportService' of BI Publisher to pass template, format, output file name, report path etc.). However, I am not sure how to pass an SQL query from Oracle Forms via this web service to BI Publisher.
Can someone please guide me?
Thanks and kind regards,
Aparna -
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 -
Invalid column Index error - While consuming Calculation view via Native SQL
Hi Experts,
I am trying to consume a Calculation view (sql script one) , which has input parameters, via Native SQL in a ABAP program .
Code snippet for the same would be as follows , Upon execution, it throws an error "Invalid Column Index (8) error " . Can anyone help what could be the issue here ?
Thanks in Advance,
Suma
REPORT ZTEST_HANA2.
*Report to consume Calculation view (script based) from ABAP
PARAMETERS: ip_docnr type BELNR_D,
ip_gjahr type GJAHR,
ip_bukrs type BUKRS,
ip_blgr type FAGL_RLDNR.
DATA: LO_SQL_STMT TYPE REF TO CL_SQL_STATEMENT,
LO_CONN TYPE REF TO CL_SQL_CONNECTION,
LO_RESULT TYPE REF TO CL_SQL_RESULT_SET,
LV_SQL TYPE STRING,
LR_DATA TYPE REF TO DATA.
DATA: LX_SQL_EXC TYPE REF TO CX_SQL_EXCEPTION,
LT_SEPMAPPS_CLSDINV TYPE TABLE OF SEPMAPPS_CLSDINV,
LV_TEXT TYPE STRING.
TRY.
lv_sql = |SELECT * FROM "_SYS_BIC"."DEMO-ABAP/CA_GET_FI_DATA" | &&
|WITH PARAMETERS ('placeholder'= ('$$p_DOCNR$$','{ ip_docnr }'),| &&
|'placeholder'=('$$p_GJAHR$$','{ ip_gjahr }')| &&
|,'placeholder'= ('$$S_BUKRS$$','{ ip_bukrs }')| &&
|,'placeholder'= ('$$p_base_ledger$$','{ ip_blgr }') )| .
LO_CONN = CL_SQL_CONNECTION=>GET_CONNECTION( ).
"Create an SQL statement to be executed via the connection
LO_SQL_STMT = LO_CONN->CREATE_STATEMENT( ).
"Execute the native SQL query
LO_RESULT = LO_SQL_STMT->EXECUTE_QUERY( LV_SQL ).
"Read the result into the internal table lt_sepmapps_clsdinv
GET REFERENCE OF LT_SEPMAPPS_CLSDINV INTO LR_DATA.
LO_RESULT->SET_PARAM_TABLE( LR_DATA ).
LO_RESULT->NEXT_PACKAGE( ).
LO_RESULT->CLOSE( ).
LO_CONN->CLOSE( ).
CATCH CX_SQL_EXCEPTION INTO LX_SQL_EXC.
LV_TEXT = LX_SQL_EXC->GET_TEXT( ).
MESSAGE LV_TEXT TYPE 'E'.
ENDTRY.Hi Suma,
Post the SQL you success run directly on Studio together with error message (even if is the Invalid column index error).
Check there if the parameters case is working properly... Is it really this confusing options:
p_GJAHR
S_BUKRS
p_base_ledger
Why not all lower or all upper? Anyhow you must test and find which option works according your modeling
Regards, Fernando Da Rós
Maybe you are looking for
-
Can't search contents of files only file names.
I am really stuck guys. It's been aggrevating me for days. I tried to download 3rd party programs for searching in files and it still doesn't work. I checked the forums here and people only have trouble searching for kinds of files. Even when I use s
-
HP Color LaserJet CM1312nfi MFP Mystery Wake on LAN
The printer wakes unexpectedly, and unpredictably on the network. I cannot determine what, if anything, is waking it. The printer wakes and goes into calibration without any users on the network and without any print jobs. Mystery wake on LAN.
-
If I have a puzzle of pieces of real recordings scattered over my timeline - how can I know the filename of a certain snippet in my Media folder? That can be useful sometimes, e.g. if you want to edit it using an audio editor, or if you want to re-bu
-
I can not make delta load for some component of public sector management
Hello All: I´am using these three data source 0PU_IS_PS_31, 0PU_IS_PS_32 and 0PU_IS_PS_42 and I realize that I can not make delta loads. When I make the full load everything is correct even when I made the delta, the problem is that the Delta load is
-
Start up error with unlock button doing nothing
So, when i close my laptop for the night, the next mourning i start it up again, but this time it just comes up with a blank screen, with 3 buttons: unlock, timer, and exposer. Timer and exposer well, just made the 3 seonds apper and exposer do its t