How to validate string parameter in subprogram where clause.
Hi All,
I m using forms6i, I have receive one string parameter from some other Form. I want to check this parameter value in my subprograms where clause (Particularly IN clause).
For Example the parameter name : P_PARA1 and its value 'AA','BB','CC'
my code like this..
select ....
from <tab name>
wehre ....
and column_name in(:parameter.para1)*
plz help me hw can i handle this situation.
I Did't get any error value, but the in where clause :parameter value added '' quotes at runtime.
For example
declare
cursor c1 is (p_p1 IN VARCHAR2) IS
select ...
from ...
where <columnname> IN (p_p1);
begin
open C1(:PARAMETER.P_para1);
now i have checked the selection query while running form in SQL Monitor, below like that
select ..
from ...
where <columnname> IN ('''AA'','''BB'');
hw its added the extra ' quote..
Similar Messages
-
How to pass the parameter in the where clause of the select statement
Hi All,
Iam getting one of the value from the Input otd and using this value i need to query one of the tables in oracle database and selected the table using the oracle eway otd like shown below .
otdRISKBLOCK_1.getRISKBLOCK().select() .
where clause in side the select takes a string parameter as Iam getting the string parameter from the input otd and passing this to where clause by creating a string literal after deployment it is giving an error saying "ORA-00920: invalid relational operator".
can any one throw some input on this .
Thanks in Advance
SrikanthYou will see this error if the search condition was entered with an invalid or missing relational operator.
You need to include a valid relational operator such as
=, !=, ^=, <>, >, <, >=, <=, ALL, ANY, [NOT] BETWEEN, EXISTS, [NOT] IN, IS [NOT] NULL, or [NOT] LIKE in the condition. in the sql statement.
Can you throw some more light on how are you designing your project? -
How to validate a user input for where clause?
I have a situation to validate a where clause which is input by the user.
Because the query will be run against huge tables and we need to notify the user if they input the clause is not valid.
I use the below query to try:
Select 'A' from blablabla where user_input_where_clause and 1=0;
however, it can not capture the error when the user input:
'name=123' while the right condition should be name='123'.
Can you pls advise ?In this particular case, Oracle will not even try to run the SQL statement because of the syntax error. IF the WHERE condition supplied does not make sense, Oracle will not execute the statement, so it does not matter if the query accesses huge tables.
SQL> Select 'A' from blablabla where 'name=123' and 1=0 ;
Select 'A' from blablabla where 'name=123' and 1=0
ERROR at line 1:
ORA-00920: invalid relational operator
SQL>IF you have a restriction as to what type/value can user specify for the where condition (asuming it would make sense to SQL engine), you would have to do it before submitting to the database.
Note, however, that user could specify any condition they like, having potentially damaging effects. -
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! -
Re: [iPlanet-JATO] How to make an OR in the WHERE clause of a SELECT
Harry,
If you get a reference to your model, you can set the
whereClauseOverride with exactly the string you want to use. Keep in
mind that you are dealing with a the raw SQL where clause, therefore,
you must use the actual table column names and not the model's logical
field names as they could be different.
QueryModelBase queryModel = (QueryModelBase)getModel(PersonModel.class);
// you must add the "WHERE" as well
String whereClause = "WHERE firstName LIKE '%max' OR lastName LIKE '%max%'";
queryModel.setWhereClauseOverride(whereClause);
Keep in mind that this will override all where criteria: static and
dynamic where criteria. Static criteria can be declared in your model
class: setStaticWhereCriteriaString(STATIC_WHERE_CRITERIA).
You could optionally get the entire SQL statement and replace the
__WHERE__ token yourself with a string replace technique. In fact, if
you want to add an ORDER BY, you will need to get the SQL and append to
the end.
queryModel.getSelectSQL();
Hope this helps. Let me know if you have any questions
craig
hlamer wrote:
Hi,
if I add criterias to my model
with "SelectQueryModel.addUserWhereCriterion()" they will be concated
with AND.
How can I add a criteria with OR?
I want something like:
SELECT personId, firstName, lastName
FROM Person
WHERE firstName LIKE "%max"
OR lastName LIKE "%max%"
Thanks.
Harry
For more information about JATO, including download information, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jspRewritten your query wuth tags as well
{code}select "P_CIRCUITS_FIBER"."PORTS_1",
"P_CIRCUITS_FIBER"."PORTS_2",
CASE WHEN CPORT.ID = (select REGEXP_SUBSTR(ports_1,'[^,]+',1,1) from p_circuits_fiber)
THEN "CPORT"."PORT_NO" END PORT_NO_1,
CASE WHEN CPORT.ID = (select REGEXP_SUBSTR(ports_2,'[^,]+',1,1) from p_circuits_fiber)
THEN "CPORT"."PORT_NO" END PORT_NO_2
from "CPORT",
"P_CIRCUITS_FIBER"
where p_circuits_fiber.fiber_id = :P4000_CIRCUIT_NO
and (select REGEXP_SUBSTR(ports_1,'[^,]+',1,1) from p_circuits_fiber) = "CPORT"."PORT_NO" "PORT_NO_1"
and (select REGEXP_SUBSTR(ports_2,'[^,]+',1,1) from p_circuits_fiber) = "CPORT"."PORT_NO" "PORT_NO_2"{code}
Now we can see two columns references which should not be there.
I even not sure to understand why those two conditions are in the WHERE clause. But for sure, CPORT.ID cannot be equal to two values unless they are same.
Is there only one row in p_circuits_fiber ?
Nicolas. -
How to dynamically update columns in a where clause to a SQL query in OSB?
Hi Gurus,
I have a requirement where in we need to dynamically update a where clause to a SQL query in OSB(11.1.1.6.0).
For example:
If the JCA sql string is "select * from emp where emp_id = 100 and emp_status ='Permanent'" now i want to change this where clause and the new query has to be like "select * from emp where emp_name like 'S%' and emp_dept like 'IT' ". basically we need to change the where clause dynamically.
We can also use "fn-bea:execute-sql()" in a xquery but I don't want to use this function as creates a new connection.
I have done some home work and found out --> as per the DOC "http://docs.oracle.com/cd/E23943_01/dev.1111/e15866/jca.htm#OSBDV943" section: "25.5.2 JCA Transport Configuration for Proxy and Business Services", when a business service is created by using JCA, we can see Interaction Spec Properties under JCA Transport Tab. This will have a property "SqlString' and we can over ride it. But I am unable to figure out how to over ride the value. I have tried by using Transport Headers activity but no luck. Please guide me how to achieve this?
Thanks in advance
SuryaI solved my problem.
In my header renderer, I simply added a line to set the text to the object value "label.setText( (String) value );" (where label is an instance of a JLabel.
Thank you to who took some time to think about it.
Marc -
Error witth a parameter in a WHERE clause
Hi experts I have the following code from an abap programa
I have done a conection with Sql
And I want to do a SELECT.. WHERE one value from a column in the table is the same that the ones I write like an input parameter... but when is done the comparation
appears the 207 error from Sql I don't know how to fix it
Please help me ¡¡
REPORT Z_CONEXBD_ARACELI2.
DATA: c_copi TYPE FLIGHTS-COPILOT.
DATA: c_pilot TYPE FLIGHTS-PILOT.
DATA: c_id TYPE FLIGHTS-ID.
DATA: con_name LIKE dbcon-con_name VALUE 'CON'.
*Here is the declaration of the parameter
PARAMETERS: P_PILOT LIKE FLIGHTS-PILOT.
EXEC SQL.
SET CONNECTION :con_name
ENDEXEC.
IF sy-subrc <> 0.
Connection not yet opened.
EXEC SQL.
CONNECT TO :con_name
ENDEXEC.
endif.
Do something on connection 'con_name'
EXEC SQL.
select PILOT, COPILOT, ID
into :c_pilot, :c_copi, :c_id
from FLIGHTS
*Here is the where clause comparing with the parameter P_PILOT
Where PILOT = P_PILOT
ENDEXEC.
*Commit the changes on 'con_name'
EXEC SQL.
COMMIT
ENDEXEC.
EXEC SQL.
SET CONNECTION :con_name
ENDEXEC.
EXEC SQL.
DISCONNECT :con_name
ENDEXEC.
WRITE: /5 'CATALOGO DE VUELOS'.
WRITE: /5 :c_copi, :c_pilot, :c_id.
Thank you very much
Edited by: ARACELI GONZALEZ on Jun 9, 2008 3:51 AMHi , I think this is a post for abap programmers.
Antonio. -
How can we use form variable in where clause while personalization
Dear,
I have a requirment for using select in personalization, actully we have created temporary table, now we want to get data from select satatement on event"when-new-record-instance' trigger, now in action tab i have selected action which is property and message, in message column showing value "${item.q_res.transaction_id.value}" it shows on validate button but when this form variable use in action type(property) which is consist on select statement "=SELECT to_char(QTY) FROM TEST_TABLE where transaction_id = ${item.q_res.transaction_id.value}" system didn't get value pressing validate button although there is a single record in customize table while without where cluase was getting data perfectly.
please advice.>
I am looking for to decode the actual db value something in different for my report.
like if A then Accepted
elseif R then Rejected
elseif D then Denied
these conditions I have to check in where clause.
>
what are you trying to do?
may be you are looking for
select * from tab1,tab2
where a.tab1 = b.tab2
and
(decode(:code, 'A','Accepted') = <table_column>
or
decode(:code, 'R','Rejected') = <table_column>
or
decode(:code, 'D','Denied') = <table_column>
) -
Add a parameter in the where clause in mdx
I need check for a value from a Dimension and filter in the MDX Query as below...
select {[Measures].[AMOUNT]} ON COLUMNS,
{([Organisation Structure].[ALL Organisation Structures], [Account Detail].[ALL Account Details], [Monthly Calendar].[ALL Monthly Calendars])} ON ROWS
from [Annu]
where Filter([useridentity].[All Users].Children, (InStr([useridentity].[All Users].CurrentMember.Properties("Caption"), "14,1") > 0.0))
From the above query, we are checking if the ALL Users value is 14,1 then it is filtering but I want to pass the value as parameter something like where Filter([useridentity].[All Users].Children, (InStr([useridentity].[All Users].CurrentMember.Properties("Caption"),
@value) > 0.0)) and @value should be assigned the values from one of the dimensional attributes..
Thanks in advance...
RamarajuCHi Ramaraju ,
I am adding an example on AW to make it easier to solve your problem .. Please notice the @datasrc you need to insert, all the quote marks and the strtomember function in case you need to ..
EXEC sp_addlinkedserver
@server='OLAP_LINKED',
@srvproduct='',
@provider='MSOLAP.4', -- For SQLServer 2008 R2
@datasrc='YourServarName', -- Can be localhost if you're working on the server
@catalog='Adventure Works DW 2008R2 SE'
declare @EPN varchar(100)
declare @sql varchar(2000)
set @EPN = '[Ship Date].[Fiscal].[Fiscal Year].&[2008]'
set @sql = 'SELECT * FROM OPENQUERY(OLAP_LINKED,''Select {[Measures].[Internet Sales Amount] } on columns, {[Product].[Product Categories].[All Products]} on rows from [Adventure Works] where STRTOMEMBER('''''+@EPN+''''') '')'
EXEC (@sql)
I hope we are on our way toward the solution :)
Regards, David . -
How to use a function in a Where Clause?
Hi,
I've got a doubt. If MY_FUNCT is a function that returns a boolean, can I use it in a where clause for writing a query like this?:
select ...
from table a
where ...
and MY_FUNC (a.field) = true
Thanks!
Edited by: Mark1970 on 2-lug-2010 3.27Bear in mind that this could kill your performance.
Depending on what you're doing, how many tables and other predicates are involved, you might want to try to eliminate all other data early before applying your function predicate otherwise your function might be called more times than you might have imagined. Strategies for this include subquery factoring and the old ROWNUM trick for materialising an inline view.
If performance is impacted, you might also want to consider using a function-based index provided that the function is deterministic. -
How to dynamically add field name in where clause of select query in web dynpro?
Hello,
Can any body tell me how i can use select query with dynamic wheere condition.
i have a requirement like there are multiple input fields and i want to select data from two database
and condition may vary .Hi
In the where clause you need to write like
WHERE NAME LIKE 'DE%'
Regards
Sudheer -
How can I avoid hard-coding this where clause in the inner select?
This is extremely fast, but I have to hard-code the inner-most where clause, and I obviously can't do that. I know how to work-around it by creating a function that takes the CUSTOMER_ID and returns the ORDER_ID from the most recent payment, and that's reasonably fast, but I thought it would be worthwhile to see if there was a way to do this in straight SQL. I also know that better design could make the problem go away.
Very much appreciate it if you could take a look and let me know if there's any way to get this kind of performance without hard-coding.
Thanks,
create or replace view customer_view as
select customer.customer_id,
customer.customer_name,
select t.order_id
from (
select payment.order_id
from payment
where payment.customer_id = 1 -- <-- Here's the line where I'm hard-coding the customer_id. Is there any way to reference the customer_id without hard-coding this?
order by payment.payment_date desc
) t
where rownum = 1
) as latest_order_id
from customer
select * from customer_view where customer_id = 1; <-- I want that inner-most select to use this customer_id, without having to hard-code it.Hi Matt,
Something like this could be a possibility (Not tested)
create or replace view customer_view as
select customer.customer_id,
customer.customer_name,
(select min (t.order_id)
keep (dense_rank first order by payment.payment_date desc)
from payment
where payment.customer_id = customer.customer_id)
as latest_order_id
from customer;Regards
Peter -
How to define SQL that contains "in" where clause in VO?
I don't want to define "in" caluse in a programatical way in VO like below. I want to use a declariable way to define in clause using varaible bindings.
Can it be implemented?
private String getInClauseWithParamNames(List termCodes) {
//logic to form the in clause with multiple bind variables
StringBuffer inClause = new StringBuffer();
if(termCodes !=null){
for (int i = 1; i < termCodes.size() + 1; i++) {
inClause.append(":termC" + (i));
if (i < termCodes.size()) {
inClause.append(",");
return inClause.toString();
public Row[] getYardFixedSlots(List termCodes) {
if(termCodes != null && !termCodes.isEmpty()){
String inClause = getInClauseWithParamNames(termCodes);
//setting the where cluase to use the generated in clause
this.setWhereClause("YardFixedSlot.TERMINAL_C in (" + inClause + ")");
////clearing all existing where clause params if any
this.setWhereClauseParams(null);
if(getVariableManager() !=null){
this.getVariableManager().clearVariables();
//setting values for all bind variables one by one in the in clause
for (int i = 0; i < termCodes.size(); i++) {
//defining the named bind variables programatically
this.defineNamedWhereClauseParam("termC" + (i + 1), null, null);
//setting the value for each named bind variable
this.setNamedWhereClauseParam("termC" + (i + 1), termCodes.get(i));
this.setRangeSize(-1);
//executing the query
this.executeQuery();
//returning the rows from query result
return this.getAllRowsInRange();I test it using model tester.
I try to write a test program to test it. when run it in jdeveoper, why it always run model tester instead of run my test program?
package com.psa.citos.ypc.model.views.shift;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.RowSet;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
public class TestClient {
public static void main(String[] args) {
TestClient testClient = new TestClient();
String amDef = "com.psa.citos.ypc.model.services.AppModule";
String config = "AppModuleLocal";
ApplicationModule am = Configuration.createRootApplicationModule(amDef,config);
// Work with your appmodule and view object here
// 1. Find the vessel view object instance.
FindVesselListByVVCodesImpl vesselList = (FindVesselListByVVCodesImpl)am.findViewObject("FindVesselListByVVCode1");
vesselList.setvv_csv_list("23981,23818,23132");
// 2. Execute the query
vesselList.executeQuery();
// 3. Iterate over the resulting rows
while (vesselList.hasNext()) {
Row customer = vesselList.next();
// 4. Print the person's email
System.out.println("AbbrVesselM: " + customer.getAttribute("AbbrVesselM"));
Configuration.releaseRootApplicationModule(am, true); -
Parsing an input parameter for the where clause or record select value
In my limited CR experience, I've always used a command database connection so that I can write my own SQL. However, now I have to parse a pipe delimited parameter to get my value for the where clause, so I'm selecting several tables and joining them through the Database Expert Links tab. All works fine, but after doing that and then parsing the parameter with the below formula in the Select Expert, I notice that there is no where clause in the SQL query, and although the report eventually displays the proper values, it runs through thousands of records first. Here is my Select Expert - Record formula:
StringVar array Parm1;
Parm1 := Split({?DATA_AREA}, "|");
{SO_ORDERS.CASE_ID} = Parm1[2]
If I change "Parm1[2]" on the last line to a valid Case ID, then there is a where clause in the SQL and the report generates immediately.
It seems like the record select formula is applied AFTER all of the records (without a where clause) are searched when I use the parsed parameter value, but when I hard code a valid value, it places that into the where clause BEFORE the sql is executed. Is there a way to get the parameter parsed first and then use that parsed value in the SQL where clause?
Thanks.
BillYes crystal will run the query first to get 100% data and then applies record selection condition. To increase the performance you need to pass the where condition at the command level instead of report level. So you need to create a report using add command like this
select * from tablename where field={?Parameter}
{?Parameter} is a command level parameter.
Now insert this report as a subreport in another report which has no connection but has a parameter
{?DATA_AREA} and create a formula like this in the main report
Split({?DATA_AREA}, "|")[2]
Now right click on the subreport and go to change subreport links and add this formula from main report and link this to sub report parameter {?Parameter} without linking any database field from the subreport.
Now your subreport runs with the where clause to get the data.
Regards,
Raghavendra -
How to pass parameters to function in where clause....
I have a select statement like this
SELECT XX_AIR_TICKET_EMP_BAL(:P2) from dual
is it possible to pass to variable p2 from where clause
like
SELECT XX_AIR_TICKET_EMP_BAL(:P2) from dual
where :p2 = :p1
user can enter only in p1 so that p2 should get passed.
Reson for this wierd requirement:In Oracle apps i cant use bind variable in select clause value set..? please ignore this reason if u are not in oracle apps...
Tell me the solution..
Is there any way...
setting some env variavle aor anything[email protected] wrote:
I have a select statement like this
SELECT XX_AIR_TICKET_EMP_BAL(:P2) from dualWhy a SELECT statement? This calls the SQL engine. The function is PL/SQL. This now needs the SQL engine to context switch to the PL engine. The PL engine runs and returns a value (across memory boundaries) to the SQL engine. The SQL engine now needs to return that value as part of the output from a SQL cursor.
Why do all this? Surely it is a lot easier and better for performance to call the PL engine directly using an anonymous PL block. E.g.
begin
:P3 := XX_AIR_TICKET_EMP_BAL(:P2);
end;
is it possible to pass to variable p2 from where clause
like
SELECT XX_AIR_TICKET_EMP_BAL(:P2) from dual
where :p2 = :p1Why?
This can be done as part of the PL block as follows:
begin
if :P2 = :P1 then
:P3 := XX_AIR_TICKET_EMP_BAL(:P2);
end if;
end;But then why construct conditional statements dynamically?
It would be a lot easier to have a new function that does the condition, e.g.
create or replace function getAirTicket( p1 number, p2 number ) return number is
begin
if p1 = p2 then
return( XX_AIR_TICKET_EMP_BAL(p2) );
else
return( null );
end if;
end;
Maybe you are looking for
-
Hi. I have a 1GHZ eMac G4 that I got second hand several months ago. Recently, I've noticed that there is a high pitch noise that it makes when I first turn it on or wake it from sleep. This noise only lasts for a minute or so, but it is very high in
-
Hi, Please help me in checking how the AP_SUPPLIER_SITES_ALL.EDI_ID_NUMBER is getting populated and if it is being shown in the front end? -pat
-
Error when Installating iTunes 10.5.1
I am trying to update iTunes to 10.5.1 and I get this error message and won't finish the installation. The download seems to be okay but I can't update. I have tried restarting the computer and trying the install again but didn't have any luck. Any h
-
I want to format my hard disk. but i want to take a copy of my oracle database so anyone can please give me the solution for how to take a back up and again how to reload to my new oracle database? if it succeeded is it possible to retain all the sch
-
I love playing Zuma Blitz and other games on Facebook, but it now takes literally forever to load the games and when they're finally loaded I play once and they hang-up. I have played using Internet Exployer 8 and also using Firefox 3.6 . I have also