Using DISTINCT to filter SQL queries
Hello, I am new to the forums here, and need help with a SQL query.
I am trying to do something like this:
SELECT `comment_ID` , `comment_author_email` , `comment_subscribe`
FROM `wp_comments` FOR DISTINCT(comment_post_ID) WHERE `comment_subscribe` = 'Y'
LIMIT 0 , 100
basically I need to select three columns from one table ONLY IF:
1. the value of `comment_subscribe` = 'Y'
2. the value of `comment_post_ID` is distinct
I think I may be close, but I am new to SQL and cannot figure it out..
Any help would be greatly appreciated!
Thanks in advance.
You are very close.
What made you think putting single quotes around object names was a good idea?
Remove them.
Similar Messages
-
[DW 8.02 + PHP] how to use variables in advanced SQL queries
Hi all,
I can't find a way to use variables in an SQL query after
updating
dreamweaver 8.02.
I always get error messages that says: 'missing variable
type:myvariablename', undefined#myvariablename... and so on.
What is the correct way to use variables?
I usually set a variable in a PHP statement (example: <?
$today=date('Y-m-d'); ?>)
and then I compare this variable in the SQL query.
What is the correct syntax for variable in DW 8.02 in
advanced SQL
queries?
TIA
tonysweetman wrote:
> I'm editing a website created with DW 8.01 and MX
Kollection.
>
> I updated DW to 8.02 and now I can't edit an existing
SQL query.
> I always get an error message 'Missing variable type'
and I can't go
> on.
InterAKT released a new version of Kollection to cope with
the 8.0.2
changes. AFAIK, you should be able to download the updated
version from
your InterAKT account area.
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
Using coldfusion variables in sql queries, some unexpected results.
I've come across a somewhat perplexing problem. I'd be
interested to see if the following works for other people:
<cfset sql_var = "'something','something else'">
<cfquery name="test" datasource="db">
select id from table where somename in (#sql_var#)
</cfquery>
As it is this produces a sql error - coldfusion tries to run
the query as
select id from table where somename in
(''something'',''something else'')
That's with double single quotes around each of the strings,
even though this wasn't specified in the variable sql_var.
So I tried this:
<cfset sql_var = "something','something else">
<cfquery name="test" datasource="db">
select id from table where somename in ('#sql_var#')
</cfquery>
Where variable sql_var only has single quotes in between the
two strings, and I've added single quotes to the select statement.
This produces no error, but no results either. The sql being run is
select id from table where somename in
('something','something else')
Which is exactly as it should be. I copy and paste the exact
same query into the database and it produces results - but when
coldfusion runs the query it doesn't. Running the query with no
quotes produces a sql error, which is what I wopuld expect.
Which leaves me somewhat at a loss. Anyone got any ideas?
Running CF 6.1 (I think) using a MySQL database, if that
makes any difference to anything.That's with double single quotes around each of the strings,
even though this wasn't specified in the variable sql_var.
In Coldfusion, 'something' and "something" are the same
thing. You should expect that Coldfusion could switch from one to
the other.
Where variable sql_var only has single quotes in between the two
strings, and I've added single quotes to the select statement. This
produces no error, but no results either. The sql being run is
select id from table where somename in
('something','something else')
I don't think that is the query being run. Before passing the
string, "something','something else", to the query Coldfusion will
automatically escape the single-quotes on either side of the comma.
That is the default behaviour. The resulting query is
select id from table where somename in
('something'',''something else')
To avoid these complications, use the function
PreserveSingleQuotes(). Thus,
<cfset sql_var = "'something','something else'">
<cfquery name="test" datasource="db">
select id from table where somename in
(#preservesinglequotes(sql_var)#)
</cfquery> -
SQL Queries dont recognize Package member variables.
Hi,
I have a package defined like this:
CREATE OR REPLACE PACKAGE PROD.PKG_BSYS_COMMON
AS
MAX_RETURN_ROWS NUMBER(6) :=1000;
END PKG_BSYS_COMMON;
The problem is that I cannot use MAX_RETURN_ROWS in my SQL queries:
SELECT
FROM
CLIENT
WHERE
ROWNUM < PROD.PKG_BSYS_COMMON.MAX_RETURN_ROWS
Is there any way to use that package member variable in my queries?
This is a simplified explanation of our problem and it is very important for our business to avoid hardcoding constants in queries and define all of them in a central location. Is there a better way doing this?
Any help would be appreciated,
AlanCREATE OR REPLACE PACKAGE PKG_BSYS_COMMON
AS
function max_return_rows return number ;
END PKG_BSYS_COMMON;
CREATE OR REPLACE PACKAGE body PKG_BSYS_COMMON as
function max_return_rows return number is
begin
return(1000);
end;
end PKG_BSYS_COMMON;
select pkg_bsys_common.max_return_rows from dual;
MAX_RETURN_ROWS
1000 -
SQL Queries in Code V/s Stored Procedures
Hi Friend,
Can any one of you guide me with following..
What is faster ? using SQL Queries in Java code or using Stored Procedures which are called from code?
I understnd Stroed Procedures are faster and definitely it provides more maintainability.
If any one can give me any links or resources which outlines pros and cons of using Stored Proc and SQL Queries embedded in Java than it would be a great help..
If there are any articles which proves either of the above is a preferred way, that would also help..
Appreciate the effort in advance !!
Thanks
GurudattWell one benefit of Stored Procs is that you "compile" it on the database whereas you might build your query on the fly in java... test coverage is important in order not to have such things as a typo in a column name....
Still, if you change a table, you have to go through all the procedures in SQL and likely to do so in some of your business object... and trust me, that can be hell!
It all depends on the use of the app...
From my experience, Stored procedure are much faster than built-on-the-fly SQL (and quite faster than prepared statements depending on the JDBC driver, the re-use of connections etc...)....
IMHO, you'd probably be wise to start of with prepared statements, and when the schema seems stable enough (ie unlikely to change), look for the slower queries and convert them to stroed procedures.
If you don't have to support several databases and are tight on performance, you can even include some logic in your stored procedure (e.g. update several tables, based on various selects...etc...). The language is usually quite powerful, and that can save you the run-time of selecting, converting to object , process and update (i.e. several roud-trip between DB and app)...
Tshcuss!
Chris -
Display distinct rows from Oracle table without using "DISTINCT" keyword.
How to retrieve distinct rows from oracle table without using 'DISTINCT' keyword in SQL?
Thanks in advance.
MihirWelcome to the forum.
Besides GROUP BY you can use UNIQUE instead of DISTINCT as well, but that's probably not wanted here ;) , and the ROW_NUMBER() analytic:
SQL> create table t as
2 select 1 col1 from dual union all
3 select 1 from dual union all
4 select 2 from dual union all
5 select 3 from dual union all
6 select 4 from dual union all
7 select 4 from dual;
Table created
SQL> select col1 from t;
COL1
1
1
2
3
4
4
6 rows selected
SQL> select distinct col1 from t;
COL1
1
2
3
4
SQL> select unique col1 from t;
COL1
1
2
3
4
SQL> select col1 from t group by col1;
COL1
1
2
3
4
SQL> select col1
2 from ( select col1
3 , row_number() over (partition by col1 order by col1) rn
4 from t
5 )
6 where rn=1;
COL1
1
2
3
4 -
How to use database control to execute sql queries which change at run time
Hi all,
I need to execute sql queries using database controls , where the sql changes
at run time
based on some condition. For eg. based on the condition , I can add some where
condition.
Eg. sql = select id,name from emp where id = ?.
based on some condition , I can add the following condition .
and location = ?.
Have anybody had this kind of situation.
thanks,
sathishFrom the perspective of the database control, you've got two options:
1) use the sql: keyword to do parameter substitution. Your observation
about {foo} style sbustitution is correct -- this is like using a
PreparedStatement. To do substitution into the rest of the SQL
statement, you can use the {sql: foo} substitution syntax which was
undocumented in GA but is documented in SP2. Then, you can build up
the filter clause String yourself in a JPF / JWS / etc and pass it into
the DB control.
For example:
* @jc:sql statement="select * from product {sql: filter}"
public Product[] getProducts(String filter) throws SQLException;
This will substitute the String filter directly into the statement that
is executed. The filter string could be null, "", "WHERE ID=12345", etc.
2) you can use the DatabaseFilter object to build up a set of custom
sorts and filters and pass that object into the DB control method.
There have been other posts here about doing this, look for the subject
"DatabaseFilter example".
Hope that helps...
Eddie
Dan Hayes wrote:
"Sathish Venkatesan" <[email protected]> wrote:
Hi Maruthi,
The parameter substituion , I guess is used like setting the values for
prepared
statements.
What I'm trying to do , is change the sql at run time based on some condition.
For example ,
consider the following query :
select col1,col2 from table t where t.col3 > 1
At run time , based on some condition , I need to add one more and condition.
i.e. select col1,col2 from table t where t.col3 > 1 and t.col4 < 10.
This MAY not address your issue but if you are trying to add "optional" parameters
you may try including ALL the possible parameters in the SQL but send in null
for those params that you don't want to filter on in any particular case. Then,
if you word your query
as follows:
select col1, col2 from table t where t.col3 > 1 and (t.col4 = {col4param} or
{col4param} is null) and (t.col5 = {col5param} or {col5param} is null) ...
you will get "dynamic" filters. In other words, col4 and col5 will only be
filtered if you send in non-null parameters for those arguments.
I have not tried this in a WL Workshop database control but I've used
this strategy dozens of times in stored procedures or jdbc prepared statements.
Good luck,
Dan -
Need help in SQL Queries using GUI controls or variables
Hello, all
I have a big problem (I have already had with Visual Basic a few mounths ago) with Java while writing my SQL Queries.
I would like to know how I must do to use variable data or GUI control data in my SQL Query to select only some records.
Here, my first Query that works without any problem (no WHERE clause !!!) :
Statement requeteBedes = connectBedes.createStatement();
ResultSet resultatSeries = requeteBedes.executeQuery("SELECT * FROM Series");
initComboBoxSeries(resultatSeries);the method "initComboBoxSeries" fills a JComboBox with all the names of the series in my database.
Here comes my problem.I would like to use the value of the selected "series" in the JComboBox to search in another table of the same Database. I made another statement but it returns a Null ResultSet :
ResultSet resultatSearchAlbumsFromSeries = requeteBedes.executeQuery("SELECT * FROM bandes_dess WHERE ser_nom = '" + strComboBoxSeriesSelected + "' "); The variable strComboBoxSeriesSelected contains the value of the selected line in the combobox with all the series, filled after the first query that is here above and that works very well.
Could some one help me and tell me how I must use variables or GUI controls values in my SQL Queries or tell me if there is a place where I could find an explanation of that kind of problems (like more "advanced SQL Queries", as the ones currently used in all the Learning Java 2 books)
Thank you all for your help.
Christian.executeQuery() will never return null. At least that's what the spec says. You are probably catching an exception (probably a syntax error caused by a single quote in strComboBoxSeriesSelected) and ignoring it. Or do you mean the ResultSet contains no rows?
Anyway, to use parameterized queries, take a look at PreparedStatements. Your code should look like this using PreparedStatement:Statement requeteBedes = connectBedes.prepareStatement("SELECT * FROM bandes_dess WHERE ser_nom = ?");
requeteBedes.setString(1, strComboBoxSeriesSelected);
ResultSet resultatSeries = requeteBedes.executeQuery();Alin. -
Presentation Vairable Problem when used in a Filter defined using SQL
I am receiving the following error message when I use an Advanced SQL Filter:
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
and T35015.FISCAL_YEAR between '@{fyprompted-5}' and '@{fyprompted}' ) group by T35015.FISCAL_YEAR, T38514.FUND_FDESCR, concat(concat(T38598.DEPT_ID, ' - '), T38598.DEPT_LD) order by c2, c3, c4. [nQSError: 17011] SQL statement execution failed. (HY000)
The Filter that I have created: (Period."Fiscal Year" <= ('@{fyprompted}') AND (Period."Fiscal Year" >= ('@{fyprompted-5}')))
fiscal year is an Int data type.
I have tried different syntax and reviewed few different online forms.
The best link regarding Presentation Variables seemed to be:
http://gerardnico.com/wiki/dat/obiee/presentation_variable
I have already created a prompt on this field and specified the fyprompted as the Presentation Variable. Also, searched the error messages and codes but didn't find any thing specific.
What am I doing wrong?
Any insight would be appreciated.
Thanks.Thanks Goran:
Just to clarify. When I'm creating the prompt, for
Operator: is equal to/ is in
Show, "All Values" is presented the drop down and I have not checked (All Choices).
Default to, Can I show a Specific value, instead of SQL. (I also tried the following SQL to set the default: SELECT MIN(PERIOD."FISCAL YEAR) FROM "FINANCE GL")
Set Variables, set to Presentation Variable: pv_fiscal_year
My Filter (SQL): Period."Fiscal Year" between @{pv_fiscal_year}-5 and @{pv_fiscal_year}
I still get the following error.
Error getting drill information: SELECT "- Campus Summary".Actuals saw_0, Period."Fiscal Year" saw_1, "Finance Department"."Dept Fdescr" saw_2, Fund."Fund Fdescr" saw_3 FROM "Finance GL" WHERE ((Account."Acct Type Fdescr" IN ('50 - Revenues', '60 - Expenditures')) AND (Period."Period Descr" NOT IN ('PERIOD 998', 'PERIOD 999'))) AND (Period."Period Descr" <> 'PERIOD 0') AND (Period."Fiscal Year" between @{pv_fiscal_year}-5 and @{pv_fiscal_year})
Error Details
Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
Odbc driver returned an error (SQLExecDirectW).
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <@>: Syntax error [nQSError: 26012] . (HY000)
SQL Issued: {call NQSGetLevelDrillability('SELECT "- Campus Summary".Actuals saw_0, Period."Fiscal Year" saw_1, "Finance Department"."Dept Fdescr" saw_2, Fund."Fund Fdescr" saw_3 FROM "Finance GL" WHERE ((Account."Acct Type Fdescr" IN (''50 - Revenues'', ''60 - Expenditures'')) AND (Period."Period Descr" NOT IN (''PERIOD 998'', ''PERIOD 999''))) AND (Period."Period Descr" <> ''PERIOD 0'') AND (Period."Fiscal Year" between @{pv_fiscal_year}-5 and @{pv_fiscal_year})')}
Thanks. -
? in SQL Queries and not using prepared statements
Using EclipseLink 1.1.1
Prepared Statements are disabled
In our production server something went wrong and one of our Read Queries started erroring. A DatabaseException was thrown and we log the "getQuery.getSQLString()" statement. We found this query in the logs:
SELECT t1.ID, t1.NAME, t1.DESCRIPTION, t1.EXTREFID, t1.STYLESHEET, t1.DDSVNVERSION, t1.FIRSTNAME, t1.LASTNAME, t1.EMAILADDR, t1.PHONENUMBER, t1.ADDRESS, t1.ADDRESS2, t1.CITY, t1.STATE, t1.POSTALCODE, t1.COUNTRY, t1.ADMINACCTNAME, t1.HASDOCUMENTS, t1.HASTIMEDNOTIFICATIONS, t1.STATUS, t1.ENTRYDATE, t1.EVALEXPDATE, t1.LASTREMINDDATE, t1.FULLUSERS, t1.LIMUSERS, t1.REQUSERS, t1.ISENTERPRISE, t1.EXPDATE, t1.ISDISABLED, t1.DISABLEDDATE, t1.NEEDLICENSEAGREEMENT, t1.ISWARNINGDISABLED, t1.LOCALE, t1.TIMEZONE, t1.CURRENCY, t1.DOMAIN, t1.DOCUMENTSIZE, t1.EXTRADOCUMENTSTORAGE, t1.ONDEMANDOPTIONS, t1.SSOTYPE, t1.RESELLERID, t1.ACCOUNTREPID, t1.LASTUSAGEREPORTDATE, t1.NEXTUSAGEREPORTDATE, t1.USAGEREPORTATTEMPTS FROM T_SSOOPTIONS t0, T_CUSTOMERS t1 WHERE *((((t0.SSOENABLED = ?) AND (t1.SSOTYPE IN (?, ?))) AND (UPPER(t1.DOMAIN) = ?)) AND (t0.CUSTOMERID = t1.ID))*
Notice the values weren't entered into the where clause. We had to bounce the application to fix the problem. I've never seen this before. I've added more debugging statements to the code - so if this happens again in the future I'll have more information to report on. In the mean time I'm wondering if anyone else has every seen a problem of this nature.Database error due to invalid SQL statement.
I don't have a stack, we were catching the exception and not printing the stack :(
Like I mentioned in my first post, I added more debugging code (e.printStackTrace()). I understand this is hard to track down without more information. I was just hoping you guys had seen something like this before and had any insight. Like I mentioned before: this is on our production server. I've never seen this type of error before. That particular server (we run in a cluster mode) had been up for several days and then started generating that error. IT bounced the node and everything went back to normal. We have been using toplink for about 5 years now and have never seen this problem, until August 3rd 2009. The only thing that has changed recently is our migration from toplink 10 to EclipseLink. I was wondering if anyone knows if anything had changed in EclipseLink/toplink 11 with the generation of SQL queries.
I'll keep looking. There is more debugging code in there now. Since the error was "Database error due to invalid SQL statement" this implies the SQL was generated, exited that part of the code and was sent to the db where it failed. I'm afraid the printStackTrace won't help if this error happens again. -
Difference between Oracle 10g and Oracle 11g when using Distinct in SQL
Hi All,
When I use Distinct in Oracle 10g, the result would be sorted in ascending order automatically, while there is no sorting in the result set in Oracle 11g.
I was using plsql developer to run my sql.
May I know if anyone have the same experience before?
Is there any kind of setting in 11g that I can make the result in order? Thanks!
Edited by: user5810051 on 2011/4/6 下午 8:47As acadet says, if you want your result ordered you must specify an ORDER BY clause in your query. Just because previous versions of oracle included some ordering as part of the processing of a query, that was not a guaranteed ordering, but just a side-effect. Now that Oracle have improved the internal workings, they've removed the side-effect, and that's why you're not getting the ordering you want, because you were relying on that side-effect rather than explicitly stating the order you wanted.
-
Problem occured when create a tree table for master-detail view objects using SQL queries?
I am programming a tree table for master-detail view objects using SQL queries and these 2 view objects are not simple singel tables queries, and 2 complex SQL are prepared for master and view objects. see below:
1. Master View object (key attribute is SourceBlock and some varaible bindings are used for this view object.)
SELECT cntr_list.SOURCE_BLOCK,
sum(
case when cntr_list.cntr_size_q = '20'
then cntr_list.cntr_qty
else 0 end ) as cntr20 ,
sum(
case when cntr_list.cntr_size_q = '40'
then cntr_list.cntr_qty
else 0 end ) as cntr40 ,
sum(
case when cntr_list.cntr_size_q = '45'
then cntr_list.cntr_qty
else 0 end ) as cntr45
FROM (
SELECT yb1.BLOCK_M as SOURCE_BLOCK,
scn.CNTR_SIZE_Q,
count(scn.CNTR_SIZE_Q) AS cntr_qty
FROM SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2
WHERE
scm.cmr_n = scn.cmr_n
AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')
OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))
AND scm.shift_mode_c = :ShiftModeCode
AND scm.end_terminal_c = :TerminalCode
AND scm.start_terminal_c = yb1.terminal_c
AND scm.start_block_n = yb1.block_n
AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n
AND scm.end_terminal_c = yb2.terminal_c
AND scm.end_block_n = yb2.block_n
AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n
AND scn.status_c not in (1, 11)
AND scn.shift_type_c = 'V'
AND scn.source_c = 'S'
GROUP BY yb1.BLOCK_M, scn.CNTR_SIZE_Q
) cntr_list
GROUP BY cntr_list.SOURCE_BLOCK
2. Detail View object (key attributes are SourceBlock and EndBlock and same varaible bindings are used for this view object.)
SELECT cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK,
sum(
case when cntr_list.cntr_size_q = '20'
then cntr_list.cntr_qty
else 0 end ) as cntr20 ,
sum(
case when cntr_list.cntr_size_q = '40'
then cntr_list.cntr_qty
else 0 end ) as cntr40 ,
sum(
case when cntr_list.cntr_size_q = '45'
then cntr_list.cntr_qty
else 0 end ) as cntr45
FROM (
SELECT yb1.BLOCK_M as SOURCE_BLOCK,
yb2.BLOCK_M as END_BLOCK,
scn.CNTR_SIZE_Q,
count(scn.CNTR_SIZE_Q) AS cntr_qty
FROM SHIFT_CMR scm, SHIFT_CNTR scn, YARD_BLOCK yb1, YARD_BLOCK yb2
WHERE
scm.cmr_n = scn.cmr_n
AND (scm.plan_start_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS')
OR scm.plan_end_dt BETWEEN to_date(:DateFrom,'YYYY/MM/DD HH24:MI:SS') AND to_date(:DateTo,'YYYY/MM/DD HH24:MI:SS'))
AND scm.shift_mode_c = :ShiftModeCode
AND scm.end_terminal_c = :TerminalCode
AND scm.start_terminal_c = yb1.terminal_c
AND scm.start_block_n = yb1.block_n
AND substr(scn.start_location_c,(instr(scn.start_location_c,',',1,5)+1),instr(scn.start_location_c,',',1,6)-(instr(scn.start_location_c,',',1,5)+1)) BETWEEN yb1.slot_from_n AND yb1.slot_to_n
AND scm.end_terminal_c = yb2.terminal_c
AND scm.end_block_n = yb2.block_n
AND substr(scn.end_location_c,(instr(scn.end_location_c,',',1,5)+1),instr(scn.end_location_c,',',1,6)-(instr(scn.end_location_c,',',1,5)+1)) BETWEEN yb2.slot_from_n AND yb2.slot_to_n
AND scn.status_c not in (1, 11)
AND scn.shift_type_c = 'V'
AND scn.source_c = 'S'
GROUP BY yb1.BLOCK_M, yb2.BLOCK_M, scn.CNTR_SIZE_Q
) cntr_list
GROUP BY cntr_list.SOURCE_BLOCK, cntr_list.END_BLOCK
3. I create a view link to create master-detail relationship for these 2 view objects.
masterview.SourceBlock (1)->detailview.SourceBlock (*).
4. I create a tree table using these 2 view objects with master-detail relationship.
When I set default value for variable bindings of these 2 view objects and the matching records exist, tree table can work well. I can expand the master row to display detail row in UI.
But I need to pass in dymamic parameter value for variable bindings of these 2 view objects, tree table cannnot work again. when I expand the master row and no detail row are displayed in UI.
I am sure that I pass in correct parameter value for master/detail view objects and matching records exist.
Managed Bean:
DCIteratorBinding dc = (DCIteratorBinding)evaluteEL("#{bindings.MasterView1Iterator}");
ViewObject vo = dc.getViewObject();
System.out.println("Before MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
System.out.println("Before MasterView1Iterator ShiftModeCode="+ vo.ensureVariableManager().getVariableValue("ShiftModeCode"));
vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
vo.executeQuery();
System.out.println("MasterView1Iterator vo.getEstimatedRowCount()="+ vo.getEstimatedRowCount());
DCIteratorBinding dc1 = (DCIteratorBinding)evaluteEL("#{bindings.DetailView1Iterator}");
ViewObject vo1 = dc1.getViewObject();
System.out.println("Before DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
System.out.println("Before DetailView1Iterator ShiftModeCode="+ vo1.ensureVariableManager().getVariableValue("ShiftModeCode"));
vo1.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
vo1.ensureVariableManager().setVariableValue("DateTo", dateTo);
vo1.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
vo1.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
vo1.executeQuery();
System.out.println("after DetailView1Iterator vo1.getEstimatedRowCount()="+ vo1.getEstimatedRowCount());
5. What's wrong in my implementation? I don't have no problem to implement such a tree table if using simple master-detail tables view object, but now I have to use such 2 view objects using complex SQL for my requirement and variable bindings are necessary for detail view object although I also think a bit strange by myself.Hi Frank,
Thank you and it can work.
public void setLowHighSalaryRangeForDetailEmployeesAccessorViewObject(Number lowSalary,
Number highSalary) {
Row r = getCurrentRow();
if (r != null) {
RowSet rs = (RowSet)r.getAttribute("EmpView");
if (rs != null) {
ViewObject accessorVO = rs.getViewObject();
accessorVO.setNamedWhereClauseParam("LowSalary", lowSalary);
accessorVO.setNamedWhereClauseParam("HighSalary", highSalary);
executeQuery();
but I have a quesiton in this way. in code snippet, it is first getting current row of current master VO to determine if update variables value of detail VO. in my case, current row is possibly null after executeQuery() of master VO and I have to change current row manually like below.
any idea?
DCIteratorBinding dc = (DCIteratorBinding)ADFUtil.evaluateEL("#{bindings.SSForecastSourceBlockView1Iterator}");
ViewObject vo = dc.getViewObject();
vo.ensureVariableManager().setVariableValue("DateFrom", dateFrom);
vo.ensureVariableManager().setVariableValue("DateTo", dateTo);
vo.ensureVariableManager().setVariableValue("ShiftModeCode", shiftModeC);
vo.ensureVariableManager().setVariableValue("TerminalCode", terminalCode);
vo.executeQuery();
vo.setCurrentRowAtRangeIndex(0);
((SSForecastSourceBlockViewImpl)vo).synchornizeAccessorVOVariableValues(); -
Hi, Can I use Microsoft SQL Server Management Studio version 11.0 to write SQL queries for "SQL Server Compact 4.0 Local Database" ?
When I use Connect Object Explorer, the "Connect to Server" dialog box which pops up has only 4 selections in the Server Type Drop Down List. They are Database Engine, Analysis Services, Reporting Services & Integration Services. I have read
somewhere that there should be a compact database option. but I do not see it.
What I would like to do is use free form SQL Queries against the tables in "SQL Server Compact 4.0 Local Database" .
Once I have validated these queries, then I will use them in my Visual Studio 2012 C#, ASP.NET application. I created the Local Database using Visual Studio 2012 for use by my application.
Thank you for your help..
diana4Hello,
With SSMS 2005 we have had the Option to work with SQL CE database files, but not with higher Version of SSMS.
You can use the free SQL CE Toolbax instead; see
http://sqlcetoolbox.codeplex.com/
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Performing sql queries in java without using java libraries
i wonder whether its possible to perform sql queries beginning from create table to updating queries without using the java sql library.
has anyone written such code.You could use JNI to talk to a native driver like the Oracle OCI driver. Doing this is either exiting or asking for trouble depending on your attitude to lots of low level bugs.
-
Retrieving SQL queries used in BO reports using BO Java SDKs
Hi,
Is it possible to retrieve SQL queries generated by Canned Reports? I have 200+ reports saved in my local system and i need to retrieve SQL queries from them, this is required for documentation purpose. Please let me know if it is possible thru BO java SDKs.This is the code I am using to retrieve the SQL values.
IEnterpriseSession boEnterpriseSession = null;
boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon( boUser, boPassword, boCmsName, boAuthType);
// Get the Report Application Factory service from Crystal Enterprise
IReportAppFactory rptAppFactory = (IReportAppFactory)boEnterpriseSession.getService("", "RASReportService");
// Get the InfoStore service from Crystal Enterprise
IInfoStore boInfoStore = (IInfoStore)boEnterpriseSession.getService("", "InfoStore");
// Retrieve the report by name from Crystal Enterprise
IInfoObjects boInfoObjects = boInfoStore.query("Select SI_ID From CI_INFOOBJECTS Where SI_NAME = '" + reportName + "'");
// Open the report into a Report Document object
ReportClientDocument rcd = rptAppFactory.openDocument((IInfoObject)boInfoObjects.get(0), 0, Locale.ENGLISH);
System.out.println("SQL query \n \n");
System.out.println(rcd.getRowsetController().getSQLStatement(null, ""));
I am a newbie and I dont understand where the error lies.. Please help me out.
regards,
nitin
When run the code gives the following errors
com.crystaldecisions.sdk.occa.managedreports.ras.internal.ManagedRASException: Cannot open report document. --- 0x80004005
Unspecified error
cause:com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: 0x80004005
Unspecified error---- Error code:-2147467259 Error code name:failed
detail: 0x80004005
Unspecified error
at com.crystaldecisions.sdk.occa.managedreports.ras.internal.RASReportAppFactory.a(Unknown Source)
at com.crystaldecisions.sdk.occa.managedreports.ras.internal.RASReportAppFactory.a(Unknown Source)
at com.crystaldecisions.sdk.occa.managedreports.ras.internal.RASReportAppFactory.openDocument(Unknown Source)
at com.crystaldecisions.sdk.occa.managedreports.ras.internal.RASReportAppFactory.openDocument(Unknown Source)
at com.hcl.BO.retrieveSql.RetrieveSQL.main(RetrieveSQL.java:44)
Caused by: com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: 0x80004005
Unspecified error---- Error code:-2147467259 Error code name:failed
at com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException.throwReportSDKServerException(Unknown Source)
at com.crystaldecisions.proxy.remoteagent.s.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.if(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.if(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.a(Unknown Source)
at com.crystaldecisions.sdk.occa.report.application.ClientDocument.open(Unknown Source)
... 4 more
I am a newbie and
Maybe you are looking for
-
My iTunes says it is synching to iPhone iOS5, but nothing changes on iPhone.
I updated my iPhone 4 to the iOS5 successfully, and then I synched some of my music. That was perfect. I have now wanted to add songs to my iPhone 4, and iTunes says it is synching correctly, but nothing. My iPhone 4 still has the same music on it t
-
User exit/BADi to change the header text in MIRO transaction
Hi all, I am searching user exit or badi to change the header text in MIRO transaction. My requirement is, before post the invoice I need to populate the vendor name in Header text field(MIRO -> Details tab -> header text field ). I have tried all th
-
How to write a tab in a listbox
Hello, I work with Labview 8.5 and I try to write several sentences with tab (\t) in a listbox but it does not work. The Tabs are represented like simple space (\s) ?! See my example in attached file Nono Attachments: TabInListbox.vi 10 KB
-
Testing the DAC and ADC on Spartan 3A Starter Kit
Hi, My team is currently working on a project which uses both, the ADC and DAC components. Wewant to test each module independently. For the DAC we want to use an oscilloscope to observeif the output signal is correct. How is the connection made for
-
I purchased PSE 12 several months ago. It became corrupted (PSE 12 Organizer continually freezes) so I did an uninstall. How do I download a replacement? I still have the original software license key.