In clause with default_where
hi all,
i am using forms6i.
i have to query a data block with in clause query
Go_Block('EMPLOYEE_MASTER');
Set_Block_Property('EMPLOYEE_MASTER',Default_Where,'emp_dept IN ('''||:dept||''''||')');
Execute_Query;in my code 'dept ' is the field where i input the value. the problem is if pass multiple department then i have to passit like
it','accounts. that means quotes are required before and after comma.
is this is the way to input multiple valule sepeated by comma, or do we have any alternative way to input a multiple string.
Please advice.
Thanks..
Hi GD,
Set_Block_Property('EMPLOYEE_MASTER',Default_Where,'emp_dept IN ('''||:dept||''''||')');If :dept has numeric values like 1,2,3,4 then the above line will work.
If so, this means there is a reference to a single value, not a list of values. Can the user enter a list in the :DEPT field (eg: A,B,C,etc...)?yes, right now i am giving input to :DEPT like a,b,c. But the way i am input the data is wrong?If :DEPT field (eg: A,B,C,etc...)? has such non-numeric values then it will not work because the IN clause in such a scenario will be looking for something like:
emp_dept in ('A', 'B', 'C')Hope this helps
Best Regards
Arif Khadas
Similar Messages
-
How can I pass multiple condition in where clause with the join table?
Hi:
I need to collect several inputs at run time, and query the record according to the input.
How can I pass multiple conditions in where clause with the join table?
Thanks in advance for any help.
Regards,
TDIf you are using SQL-Plus or Reports you can use lexical parameters like:
SELECT * FROM emp &condition;
When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
SELECT &columns FROM &tables &condition;
But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
Best of luck! -
Decode in order by clause with desc
I want to user order by clause with decode + desc order.
somthing like
ORDER BY DECODE ('SALE', e.sale, 'SALE DESC' ????)
????-> How to use desc order with decode
Thanks in advanceI thought smart people in this OTN community will understand that I am trying to order by the thisdate column that is timestamp datatype:). My apologize for not being that specific.
The query I gave is a simple version of the stored procedure I am using. The point is I need to order by - depending on one of the parameters that is passed to the procedure. In simplest decode statements, its something like
order by decode(p_in_var,'ABC','thisdate asc','DEF','thisdate desc',thisdate asc)
Here p_in_var is varchar input parameter to the stored procedure.
Please let me know if there is any more information needed.
Thx! -
How to Use SQL Query having IN Clause With DB Adapter
Hi,
I am using 11.1.1.5 want to find out how to Use SQL Query having IN Clause With DB Adapter. I want to pass the IN values dynamically. Any ideas.
Thanksinvoke a stored procedure, it's safer than trying to put together an arbitrary SQL statement in the JCA adapter
-
Hii,
I have an issue with using where clause with time stamp. My requirement is to
select * from driver_on_policy
where last_change_datetime = '2001-03-06 19:00:06'
date is in this form 6/3/2001 7:00:06 PM
thnks
samIf you want to use '6/3/2001 7:00:06 PM', then
where last_change_datetime = to_timestamp('6/3/2001 7:00:06 PM','DD/MM/YYYY HH:MI:SS PM')If you can use a literal string in ANSI standard YYYY-MM-DD HH24:MI:SS format, then just
where last_change_datetime = timestamp '2001-03-06 19:00:06' (That 'DD/MM' might need to be switched around to 'MM/DD' if you are in America.)
Message was edited by:
William Robertson -
SQL IN clause with a Tool variable
We are using using Forte 3.M.2 (just upgraded from 3.G, finally).
Platform is AIX 4.3. Database is DB2 (UDB) (version 5.2 i think).
True, I haven't tried my code on any other platform. I think it should work on NT, because one of our other teams members has set up an NT laptop for portable demos. And it has DB2 (NT version i guess) loaded on it.
Dynamic sql is not really that bad, if you have to go that route to build your list.
Let me know how it goes.
Steven Barnes
Daniel González de Lucas <danieleam.es> 07/28/00 04:06AM >>>We are getinng some trouble, the DB Manager seems to try to convert
:OfficeList to a unique integer lets say:
:OfficeList value is 3,4,7
so the IN clause
trying with Oracle 8.1.5 converts 3,4,7 in a unique integer (a extrange
value because doesn't match with 3,4 nor 7).
trying with SQL Server 6.5 gives an error converting 3,4,7 to a unique
tinyint.
The idea is that with your sintax the DB Manager must split the TextData
into 3 integer values. I think that it works fine in some DB Managers and
not in others.
Which release and vendor of DB Manager you use?
Which Forté release?
Thank you very much in advance.
Daniel.
----- Original Message -----
From: "Steve Barnes" <DHS9126dhs.state.il.us>
To: <danieleam.es>; <kamranaminyahoo.com>
Sent: Thursday, July 27, 2000 1:55 PM
Subject: Re: (forte-users) SQL IN clause with a Tool variable
I needed to have an "IN" clause for some numbers. Here's how I did it:
GetOffices():TextData method...
Offices : TextData = new ;
for (x : integer) in sql select MyIntegerColumn
from MY_TABLE
where whatever condition
on session MyDBSession do
Offices.Concat(x) ;
Offices.Concat(',') ;
end for ;
return (Offices.CopyRange(0,Offices.ActualSize -1)) ; // get rid of lastcomma
in actual sql.....
OfficeList : TextData ;
OfficeList = GetOffices() ;
sql select * from MyTable where MyField in (:OfficeList)
on session MyDBSession ;
Works very well.
Steven Barnes
Daniel González de Lucas <danieleam.es> 07/27/00 05:32AM >>>Hello,
To do a select we have two options:
select * from MyTable
where MyField in ('a','b','c')
we would like to do the same but using a forté variable in the IN clause.
select * from MyTable
where MyField in (:ToolVar)
What should we do and what kind of variable or array of variables shouldwe use in ToolVar to do the same than in first option?
>
Has anybody done this without a dynamic query?
Best regards
Daniel
For the archives, go to: http://lists.xpedior.com/forte-users and use
the login: forte and the password: archive. To unsubscribe, send in a new
email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com -
SQL IN clause with Bind parameter?
Hi
I have a simple task that hasn't been so simple to figure out. I want to allow a user to search for one or more comma-separated values in a simple JClient ADF app. Is there a way to use a SQL IN clause with a single bind variable? e.g. SELECT TITLE FROM CITATION WHERE ID IN (:0)
When I pass a single value it works fine but a comma separated list doesn't.
Thanks
JohnUpdate: I wanted to combine the techniques found in two of Steve Muench's articles -
1) Providing Default Values for View Object Bind Variables (so I could display an ADF-bound JPanel with defaults)
http://radio.weblogs.com/0118231/stories/2004/10/07/providingDefaultValuesForViewObjectBindVariables.html
2) Array of String Domain Example (so a user could enter one or more comma-separated values into a text box for DB searches)
http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
I learned some helpful stuff about the framework but spent lots of time banging my head against the wall because the two examples wouldn't work when directly combined. To best understand this, be sure to study Steve's examples above.
In example 1 Steve passes an array of objects (Object[] DEFAULT_VALUES) to the ViewObject's where clause using the setWhereClauseParams(Object[] values). However, in example 2 he creates an Oracle Array which contains an Oracle ArrayDescriptor, Connection, and array of values to pass to the "IN" bind variable. Also, example 1 allows for multiple bind vars to be included whereas example 2 allows for an array of data to be passed to a single bind var. Even though my code provides an array to a single bind var (per ex. 2) it should still allow for the passage of multiple bind vars with minimal code modification.
Code from Steve's example 1 was copied into my EmpView ViewObject but certain modifications were necessary:
1) Change the ViewObject's DEFAULT_VALUES from Object[] to String[].
2) Modify the executeQueryForCollection() method in the ViewObject to call a function which will set the bind variables as Oracle Arrays (effectively converting the "params" data type from that of String[] to Oracle Array[])
3) Create a setManagerID(String[]) method in the EmpView object and expose it to the client.
(there are a number of others so it's best for you to go through the code and compare)
I finally got it working so I'm attaching the code, however beware - I'm new to this so there may be other, better ways to go about it. Also, there are no framework bind vars so that section of code is never executed...it compiles but may fail at run time.
In order for this to work I suggest you use JDev to re-create the EmpView and Panel1 objects. This will ensure that the necessary ADF framework components are generated. Once complete, then copy in the code provided.
*File: EmpViewImpl.java
*Created as Read-Only access view object with the
*query:
*select manager_id, last_name from hr.employees
*where manager_id IN
*(select * from TABLE(CAST(:0 as TABLE_OF_VARCHAR)))
*order by manager_id
package model;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import oracle.jbo.domain.Array;
import oracle.jbo.server.ViewObjectImpl;
import oracle.sql.ArrayDescriptor;
// --- File generated by Oracle ADF Business Components Design Time.
// --- Custom code may be added to this class.
// --- Warning: Do not modify method signatures of generated methods.
public class EmpViewImpl extends ViewObjectImpl implements model.common.EmpView
private ArrayDescriptor descriptor;
private final static String[] DEFAULT_VALUES_STRING = new String[]{"100"};
private final static int NUM_DEFAULT_VALUES = DEFAULT_VALUES_STRING.length;
* This is the default constructor (do not remove)
public EmpViewImpl()
protected void executeQueryForCollection (Object qc, Object[] params, int numUserParams)
Object pars[] = null;
// Bind default variables only if none have been provided by the user
if (numUserParams == 0)
numUserParams = NUM_DEFAULT_VALUES;
int numFwkSuppliedBindVals = (params != null) ? params.length : 0;
if (numFwkSuppliedBindVals > 0)
// Allocate a new Object[] array with enough room for both user- and framework-supplied vars
Object[] newBinds = new Object[numFwkSuppliedBindVals + numUserParams];
// Copy the framework-supplied bind variables into a new Object[] array
// leaving enough slots at the beginning for the user-supplied vars
System.arraycopy(params, 0, newBinds, numUserParams, numFwkSuppliedBindVals);
// Now copy in the user-supplied vars to the beginning of the array
System.arraycopy(DEFAULT_VALUES_STRING, 0, newBinds, 0, numUserParams);
params = newBinds;
} else
params = DEFAULT_VALUES_STRING;
// We have to call this method to convert the default values into the proper Oracle Array expected by the query.
// If you set a debugger breakpoint at this line you can see that the "params" data type changes from String[] to Object[]
setWhereClauseParamsToDefaultValues();
// Now retrieve the params of the new data type
params = this.getWhereClauseParams();
super.executeQueryForCollection(qc, params, numUserParams);
private void setWhereClauseParamsToDefaultValues()
this.setManagerID(DEFAULT_VALUES_STRING);
private Connection getCurrentConnection() throws SQLException
// Create a bogus statement so that we can access our current connection
// JBD note - Does this get run each time??
PreparedStatement st = getDBTransaction().createPreparedStatement("commit", 1);
Connection conn = st.getConnection();
st.close();
return conn;
private synchronized void setupDescriptor(Connection conn) throws SQLException
descriptor = new ArrayDescriptor("TABLE_OF_VARCHAR", conn);
* setManagerID
* Exposed to client to accept an array of values (presumably passed in by user-entry into text box
* @param aryMan
public void setManagerID(String[] aryMan)
Array arr = null;
try
// Find the connection
Connection conn = getCurrentConnection();
//Create the ArrayDescriptor by looking for our custom data type in our connected DB
if(descriptor == null)
setupDescriptor(conn);
// Create the Oracle Array by passing in the descriptor, connection, and object array of data
arr = new Array(descriptor, conn, aryMan);
} catch (SQLException se)
System.out.println("SQL Exception: " + se.getMessage());
// Now we can set the WHERE clause parameter bind variable (index = 0) to the Oracle Array
if (arr != null) setWhereClauseParam(0, arr);
* FILE: Panel1.java
* Created as an empty panel. Then a JTextField, a
* JButton, and an EmpView1 table were dragged on.
* A custom actionPerformed method was created for the
* JButton which grabs the data from the text box.
* The user can enter either a single manager id or
* multiple, comma-separated ids.
* All code in this class was created by JDev except
* for the Jbutton action
package view;
import java.awt.*;
import javax.swing.*;
import model.common.*;
import oracle.jbo.ApplicationModule;
import oracle.jbo.SQLStmtException;
import oracle.jbo.uicli.jui.*;
import oracle.jbo.uicli.controls.*;
import oracle.jbo.uicli.binding.*;
import oracle.jdeveloper.layout.*;
import oracle.adf.model.*;
import oracle.adf.model.binding.*;
import java.util.ArrayList;
import oracle.jdeveloper.layout.VerticalFlowLayout;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.table.TableModel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Panel1 extends JPanel implements JUPanel
* NOTE: You need to have previous created the Oracle8 type named
* ==== TABLE_OF_VARCHAR by doing the following at the SQL*Plus
* command prompt:
* create type table_of_varchar as table of varchar2(20)
// Panel binding definition used by design time
private JUPanelBinding panelBinding = new JUPanelBinding("Panel1UIModel");
private VerticalFlowLayout verticalFlowLayout1 = new VerticalFlowLayout();
private JTextField jTextField1 = new JTextField();
private JButton jButton1 = new JButton();
private JTable jTable1 = new JTable();
* The default constructor for panel
public Panel1()
* the JbInit method
public void jbInit() throws Exception
this.setLayout(verticalFlowLayout1);
jTextField1.setText("jTextField1");
jButton1.setText("jButton1");
jButton1.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
jButton1_actionPerformed(e);
this.add(jTextField1, null);
this.add(jButton1, null);
this.add(jTable1, null);
jTable1.setModel((TableModel)panelBinding.bindUIControl("EmpView1", jTable1));
public static void main(String [] args)
try
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch(Exception exemp)
exemp.printStackTrace();
Panel1 panel = new Panel1();
panel.setBindingContext(JUTestFrame.startTestFrame("DataBindings.cpx", "null", panel, panel.getPanelBinding(), new Dimension(400, 300)));
panel.revalidate();
* JUPanel implementation
public JUPanelBinding getPanelBinding()
return panelBinding;
private void unRegisterProjectGlobalVariables(BindingContext bindCtx)
JUUtil.unRegisterNavigationBarInterface(panelBinding, bindCtx);
private void registerProjectGlobalVariables(BindingContext bindCtx)
JUUtil.registerNavigationBarInterface(panelBinding, bindCtx);
public void setBindingContext(BindingContext bindCtx)
if (panelBinding.getPanel() == null)
panelBinding = panelBinding.setup(bindCtx, this);
registerProjectGlobalVariables(bindCtx);
panelBinding.refreshControl();
try
jbInit();
panelBinding.refreshControl();
catch(Exception ex)
panelBinding.reportException(ex);
private void jButton1_actionPerformed(ActionEvent e)
// Get the user-supplied values
String txt = jTextField1.getText();
String[] mIds = txt.split(",");
// Now trim
for (int i=0; i<mIds.length; i++)
mIds[i] = mIds.trim();
ApplicationModule am = (ApplicationModule)panelBinding.getDataControl().getDataProvider();
EmpView vo = (EmpView)am.findViewObject("EmpView1");
vo.setManagerID(mIds);
try
vo.executeQuery();
} catch (SQLStmtException s)
System.out.println("Query failed: " + s.getMessage()); -
SQL query in SQL_REDO Logminor showing where clause with ROWID
SQL query in SQL_REDO Logminor showing where clause with ROWID. I dont wanted to use rowid but wanted to use actual value.
OPERATION SQL_REDO SQL_UNDO
DELETE delete from "OE"."ORDERS" insert into "OE"."ORDERS"
where "ORDER_ID" = '2413' ("ORDER_ID","ORDER_MODE",
and "ORDER_MODE" = 'direct' "CUSTOMER_ID","ORDER_STATUS",
and "CUSTOMER_ID" = '101' "ORDER_TOTAL","SALES_REP_ID",
and "ORDER_STATUS" = '5' "PROMOTION_ID")
and "ORDER_TOTAL" = '48552' values ('2413','direct','101',
and "SALES_REP_ID" = '161' '5','48552','161',NULL);
and "PROMOTION_ID" IS NULL
and ROWID = 'AAAHTCAABAAAZAPAAN';
DELETE delete from "OE"."ORDERS" insert into "OE"."ORDERS"
where "ORDER_ID" = '2430' ("ORDER_ID","ORDER_MODE",
and "ORDER_MODE" = 'direct' "CUSTOMER_ID","ORDER_STATUS",
and "CUSTOMER_ID" = '101' "ORDER_TOTAL","SALES_REP_ID",
and "ORDER_STATUS" = '8' "PROMOTION_ID")
and "ORDER_TOTAL" = '29669.9' values('2430','direct','101',
and "SALES_REP_ID" = '159' '8','29669.9','159',NULL);
and "PROMOTION_ID" IS NULL
and ROWID = 'AAAHTCAABAAAZAPAAe';
Please let me know solution/document which will convert SQL redo rowid value with actual value.
Thanks,Please enclose your output within tag so that people here can read it easily and help you. Also the reason that why you want to remove rowid?
Salman
Edited by: Salman Qureshi on Mar 20, 2013 3:53 PM -
Where clause with a combination of And and Or statements - Basic question
Hi,
I have a where clause with a combination of And and Or statements... May I know which one would run first
Here is the sample
WHERE SITE_NAME = 'Q' AND ET_NAME IN ('12', '15') AND TEST_DATE > DATE OR SITE_NAME = 'E' AND ET_NAME IN ('19', '20')
can you please explain how this combination works
Thanks in advanceHi,
This reminds me of a great story. It's so good, it probably didn't really happen, but it's so good, I'm going to repeat it anyway.
IBM once had an "executive apptitude test" that they would give to job applicants. There were some questions you might call general knowlege or trivia questions, and each question had a weight (for example, answering an unimportant queestion might score one point, an important question might be 5 points.) One of the questions was "What is the standard width of a mobile home?", and the weight of the question was -20: answering the question correctly did serious harm to your score. The reasoning was that the more you knew about mobile homes, the less likely you were to be their kind of executive.
Now, as to your question, the correct answer is: I don't know. I don't want to know. Mixing ANDs and ORs without grouping them in parentheses is a really bad idea. Even if you get it right, it's going to confuse the next person who has to look at that code. Use parentheses to make sure the code is doing what you want it to do.
If you really want to find out, it's documented in the SQL language manual. Look up "Operators, prcedence"
http://docs.oracle.com/cd/E11882_01/server.112/e26088/operators001.htm#sthref815
You can easily do an experiment, using scott.emp, or even dual, where
WHERE (x AND y)
OR zproduces different results from
WHERE x
AND (y OR z) -
ORA-00907: missing right parenthesis when using group by clause with xmlagg
I have the following query and I am getting ORA 00907 Error when I am using group by clause with the xmlagg function.
select xmlelement("Mitigation",
xmlelement("m_szMethodName",tm.DisplayName),
xmlelement("SubstanceInterferenceProtocolList",
(select xmlagg(xmlelement("MitigationProtocol",
xmlelement("m_szMethodName",tm.DisplayName),
xmlelement("m_szInterferenceProtocolName",tmp.protocol_name),
xmlelement("m_szInterferenceSubstance",tmp.intf_mtrl_prod_code),
xmlelement("m_ProtocolParameters",
xmlelement("m_szProtocolName",tmp.protocol_name),
xmlelement("m_Consumables",
xmlelement("Consumable",
xmlelement("m_szConsumId", xrl.rgnt_pack_name),
xmlelement("m_szProductCode",xrl.pack_prod_code),
xmlelement("m_nVolume",tmp.fluid_vol),
xmlelement("m_szProtocolStep",xps.protocol_step_name))),
xmlelement("m_ProtParamList",
xmlagg(
xmlelement("ParameterValues",
xmlelement("m_szProtocolName",tmp.protocol_name),
xmlelement("m_Time",xpsd.parameter_ntime_value))
group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code)
order by tmp.ccd_test_id, tmp.intf_mtrl_prod_code, xps.protocol_step_intprotocolstep )
from XPR_tdef_mitigation_protocol tmp, xp_reagentlist xrl,
xpr_protocol_settings xps, xpr_protocol_settings_default xpsd
where tmp.ccd_test_id = tm.ccd_test_id
and tmp.ccd_test_id = xrl.ccd_test_id
and tmp.pack_prod_code = xrl.pack_prod_code
and tmp.intf_type = 1
and xps.protocol_name = xpsd.protocol_name
and xps.protocol_step_name = xpsd.protocol_step_name
and xps.ps_action_parameterlist = xpsd.ps_action_parameterlist
and xps.protocol_name = tmp.PROTOCOL_NAME
from XPtoXPRTdef_defn_mapping tm
where tm.DisplayName = 'SYPH'If I remove the xmlagg clause along with the group by clause, the query runs fine and give me the output.
But in that XML format of the output is incorrect for my application.
Could someone help here?Hi,
userAtoZ wrote:
I have the following query and I am getting ORA 00907 Error when I am using group by clause with the xmlagg function.
... xmlagg(
xmlelement("ParameterValues",
xmlelement("m_szProtocolName",tmp.protocol_name),
xmlelement("m_Time",xpsd.parameter_ntime_value))
group by tmp.ccd_test_id,tmp.intf_mtrl_prod_code)Please don't post unformatted code. When posting any formatted text on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
If the code above were formatted well, so that you could match each '(' with its closing ')', it would look something like this:... xmlagg ( xmlelement ( "ParameterValues"
, xmlelement ( "m_szProtocolName"
, tmp.protocol_name
, xmlelement ( "m_Time"
, xpsd.parameter_ntime_value
group by tmp.ccd_test_id
, tmp.intf_mtrl_prod_code
This is exactly what you posted, only the whitespace has been changed.
This makes it clear that the GROUP BY is inside the parentheses with the argument to XMLAGG. You can have an ORDER BY clause there, but not a GROUP BY clause. -
Hi,
I have a requirement where I need to display a list of employees, performance rating and manager id. I want to display the emplyees first whos manager is as manager_id as input parameter. So lets say a manager logs in, he should see his reportees first and then therest. How can I implemet this in SQL? I am trying first clause with order by but not sure how to do that here. A help on this would be appreciated.
procedure
display_list(manager_id in varchar2)
Output is:
emp_id
manager_id
performance_rating
Edited by: Nandini on Apr 28, 2013 10:48 PMYou can use a CASE statment, which will check the MANGER_ID column against the passed manager id value, as shown below..
order by
case when manager_id = :input_manager_id then 0
else 1
end,manager_id,performace_rating desc -
Generate a where clause with outer join criteria condition: (+)=
Hi,
In my search page, I use Auto Customization Criteria mode, and I build where clause by using get Criteria():
public void initSrpQuery(Dictionary[] dic, String userName) {
int dicSize = dic.length;
StringBuffer whereClause = new StringBuffer(100);
Vector parameters = new Vector(5);
int clauseCount = 0;
int bindCount = 1;
for(int i=0; i < dicSize; i++){
String itemName = (String)(dic.get(OAViewObject.CRITERIA_ITEM_NAME));
Object value = dic[i].get(OAViewObject.CRITERIA_VALUE);
String joinCondition = (String)dic[i].get(OAViewObject.CRITERIA_JOIN_CONDITION);
String criteriaCondition = (String)dic[i].get(OAViewObject.CRITERIA_CONDITION);
String criteriaDataType = (String)dic[i].get(OAViewObject.CRITERIA_DATATYPE);
String viewAttributename = (String)dic[i].get(OAViewObject.CRITERIA_VIEW_ATTRIBUTE_NAME);
String columnName = findAttributeDef(viewAttributename).getColumnNameForQuery();
if((value != null) /*&& (!("".equals((String).trim())))*/){
if(clauseCount > 0){
whereClause.append(" AND ");
whereClause.append(columnName + " " + criteriaCondition + " :");
whereClause.append(++bindCount);
parameters.addElement(value);
clauseCount++;
If I want to generate following where clause:
select
,emp.name
,emp.email
,emp.salesrep_number
,comp.name
,gs.srp_goal_header_id
,gs.status_code
,gs.start_date
,gs.end_date
from g2c_goal_shr_emp_assignments_v emp
,jtf_rs_salesreps rs
,xxg2c_srp_goal_headers_all gs
,cn_comp_plans_all comp
where 1 = 1
and rs.salesrep_id = gs.salesrep_id (+)
and gs.comp_plan_id = comp.comp_plan_id (+)
and gs.period_year (+) = :1 -- :1 p_fiscal_year
How can I generate a where clause with outer join : gs.period_year (+) = :1 ? Will I get '(+)=' from get(OAViewObject.CRITERIA_CONDITION)?
thanks
LeiIf you are using SQL-Plus or Reports you can use lexical parameters like:
SELECT * FROM emp &condition;
When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
SELECT &columns FROM &tables &condition;
But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
Best of luck! -
Having clause with Analytic function
can you pls let me know if we can use HAVING clause with analytic function
select eid,empno,sum(sal) over(partition by year)
from employee
where dept = 'SALES'
having sum(sal) > 10000I m getting error while using the above,
IS that we can use HAVING clause with partition by
Thanks in advanceYour having clause isn't using an analytical function, is using a regular aggregate function.
You also can't use analytical functions in the where clause or having clause like that as they are windowing functions and belong at the top of the query.
You would have to wrap the query to achieve what you want e.g.
SQL> ed
Wrote file afiedt.buf
1 select deptno, total_sal
2 from (
3 select deptno,sum(sal) over (partition by deptno) as total_sal
4 from emp
5 )
6 group by deptno, total_sal
7* having total_sal > 10000
SQL> /
DEPTNO TOTAL_SAL
20 10875
SQL> -
Dynamic where clause with loop statement
Hi all,
is it possible to use a dynamic where clause with a loop statement?
Can you please advise me, how the syntax needs to be?
Thanks for your suggestions,
kind regards, Kathrin!Hi Kathrin,
If u are in ECC 6.0, please go through the code...
REPORT zdynamic_select.
TYPES:
BEGIN OF ty_sales,
vbeln TYPE vbak-vbeln, " Sales document
posnr TYPE vbap-posnr, " Sales document item
matnr TYPE vbap-matnr, " Material number
arktx TYPE vbap-arktx, " Short text for sales order item
kwmeng TYPE vbap-kwmeng, " Order quantity
vkorg TYPE vbak-vkorg, " Sales organization
kunnr TYPE vbak-kunnr, " Sold-to party
netwr TYPE vbak-netwr, " Net Value of the Sales Order
END OF ty_sales.
DATA :
gt_sales TYPE STANDARD TABLE OF ty_sales,
wa_sales TYPE ty_sales.
DATA: ob_select TYPE REF TO cl_rs_where.
DATA: ob_from TYPE REF TO cl_rs_where.
DATA: ob_where TYPE REF TO cl_rs_where,
gv_source TYPE abapsource.
START-OF-SELECTION.
*Step 1 : Prepare the select fields.
PERFORM zf_build_select.
*Step 2 : Build the from clause for the select
PERFORM zf_build_from.
*Step 3 : Build the where clause for the select
PERFORM zf_build_where.
*Step 4 : Execute the dynamic select
SELECT (ob_select->n_t_where)
FROM (ob_from->n_t_where)
INTO CORRESPONDING FIELDS OF TABLE gt_sales
WHERE (ob_where->n_t_where).
LOOP AT gt_sales INTO wa_sales.
WRITE : /5 wa_sales-vbeln,
15 wa_sales-vkorg,
20 wa_sales-kunnr,
40 wa_sales-netwr,
50 wa_sales-posnr,
60 wa_sales-matnr,
70 wa_sales-arktx,
90 wa_sales-kwmeng.
ENDLOOP.
*& Form zf_build_select
FORM zf_build_select .
CREATE OBJECT ob_select.
*Build the table name/field name combination
*Add Sales order header fields
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAK'
i_fieldname = 'VBELN'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAK'
i_fieldname = 'VKORG'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAK'
i_fieldname = 'KUNNR'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAK'
i_fieldname = 'NETWR'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
*Add Sales order item fields
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAP'
i_fieldname = 'POSNR'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAP'
i_fieldname = 'MATNR'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAP'
i_fieldname = 'ARKTX'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
CALL METHOD cl_rs_where=>build_tabname_fieldname
EXPORTING
i_tabname = 'VBAP'
i_fieldname = 'KWMENG'
i_sign = '~'
IMPORTING
e_combined = gv_source.
*Add the where line
CALL METHOD ob_select->add_line
EXPORTING
i_line = gv_source.
ENDFORM. " zf_build_select
*& Form zf_build_from
FORM zf_build_from .
CREATE OBJECT ob_from.
*Add opening bracket
CALL METHOD ob_from->add_opening_bracket
CLEAR gv_source.
*Add the join condition.This can be made
*fully dynamic as per your requirement
gv_source = 'VBAK AS VBAK INNER JOIN VBAP AS VBAP'.
*Add the where line
CALL METHOD ob_from->add_line
EXPORTING
i_line = gv_source.
CLEAR gv_source.
*Add the join condition.This can be made
*fully dynamic as per your requirement
gv_source = 'ON VBAKVBELN = VBAPVBELN'.
*Add the where line
CALL METHOD ob_from->add_line
EXPORTING
i_line = gv_source.
*Add the closing bracket
CALL METHOD ob_from->add_closing_bracket
ENDFORM. " zf_build_from
*& Form zf_build_where
FORM zf_build_where .
DATA :
lv_field TYPE REF TO data,
lv_field_low TYPE REF TO data,
lv_field_high TYPE REF TO data.
CREATE OBJECT ob_where.
*Add the field VBELN : Sales Document
*Use this method if you want to assign a single value to a field
*Set the value for VBELN : Sales Document Number
CALL METHOD ob_where->add_field
EXPORTING
i_fieldnm = 'VBAK~VBELN'
i_operator = '='
i_intlen = 10
i_datatp = 'CHAR'
IMPORTING
e_r_field = lv_field.
CALL METHOD ob_where->set_value_for_field
EXPORTING
i_fieldnm = 'VBAK~VBELN'
i_value = '0000120020'.
*Use this method if you want to assign a range of values
*Set a range for the Sales Document number
CALL METHOD ob_where->add_field_between_2values
EXPORTING
i_fieldnm = 'VBAK~VBELN'
i_intlen = 10
i_datatp = 'CHAR'
IMPORTING
e_r_field_low = lv_field_low
e_r_field_high = lv_field_high.
CALL METHOD ob_where->set_2values_for_field
EXPORTING
i_fieldnm = 'VBAK~VBELN'
i_value_low = '0000120020'
i_value_high = '0000120067'.
*Set the 'AND' Clause
CALL METHOD ob_where->add_and.
*Add the field MATNR : Material
CALL METHOD ob_where->add_field
EXPORTING
i_fieldnm = 'MATNR'
i_operator = '='
i_intlen = 18
i_datatp = 'CHAR'
IMPORTING
e_r_field = lv_field.
*Set the value for the Material field
CALL METHOD ob_where->set_value_for_field
EXPORTING
i_fieldnm = 'MATNR'
i_value = '000000000050111000'.
*Set the 'AND' Clause
CALL METHOD ob_where->add_and
*Add the field VKORG
CALL METHOD ob_where->add_field
EXPORTING
i_fieldnm = 'VKORG'
i_operator = '='
i_intlen = 4
i_datatp = 'CHAR'
IMPORTING
e_r_field = lv_field.
*Set the value for VKORG : Sales Organization
CALL METHOD ob_where->set_value_for_field
EXPORTING
i_fieldnm = 'VKORG'
i_value = 'GMUS'.
ENDFORM. " zf_build_where -
Mysterious where clause with japanese
enviroment:
PL/SQL Develope, Version 7.1.0.1337, Windows XP Professional 5.1 Build 2600 (Service Pack 2)
Here is the problem, when i add a where clause with japanese, the data evaporated:
SQL> select * from ja_test;
EXECUTABLE_NAME DESCRIPTION
XX00MRP0411C 需要供給データ作成マネージャ
SQL> select * from ja_test j where j.description = '需要供給データ作成マネージャ';
EXECUTABLE_NAME DESCRIPTION
SQL>
thanks in advance!Thanks for replies and Sorry for my rashness, maybe the following
scripts could explain the problem more well. I create a table named
ja_test with two fields(EXECUTABLE_NAME and DESCRIPTION), both of the
type is varchar2, and there is only one record in the table,
but the DESCRIPTION contains JAPANESE characters, when i use a where
clause like this "where j.executable_name = 'XX00MRP0411C';", everything
seems work fine, but when the where clase include JAPANESE characters
like this "j.description = '需要供給データ作成マネージャ';", even if
the "j.description" is copied form database, no records returned:
SQL> select * from ja_test j where j.executable_name = 'XX00MRP0411C';
EXECUTABLE_NAME DESCRIPTION
XX00MRP0411C 需要供給データ作成マネージャ
SQL> select * from ja_test j where j.description = '需要供給データ作成マネージャ';
EXECUTABLE_NAME DESCRIPTION
SQL> desc ja_test;
Name Type Nullable Default Comments
EXECUTABLE_NAME VARCHAR2(30)
DESCRIPTION VARCHAR2(240) Y
SQL>
Maybe you are looking for
-
How to build an "Exit Course" button at the end of a course
Hello, As I am building my courses I cannot for the life of me figure out how to add a button at the end of my course that will end my course. If they click through the course and answer the quiz they are getting credit but once they get to the resul
-
Hi All, I have a RFC to File scenario. This was working fine. But now, for few days there are no messages in XI. The files are also not in the ftp. I tried to check activate the channels, but still there are no messages. Need your replies and suggest
-
How can i find the form config in SAP. I want to find out which is the standard PO form or SO form.
-
the website I am trying to go in is www.marinacraft.com.my Staff working there told me there is no problem with their website.
-
How do I reset my contacts list
I don't want my I-phone syncing with my outlook contacts, how do I set that up?