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>
Similar Messages
-
Using a variable in SQL to store intermediate results
I'm new to Crystal Reports, so pardon my ignorance.
I need to write a SQL statement in Crystal Reports (Ver. 11) that uses results from a query and stores them in a variable for further use in the statement. Something like this:
DECLARE @my_variable INT;
SET @my_variable=
CASE
WHEN DATEPART (m,{?Date})<7
THEN DATEPART (yyyy,( DATEADD (year,-1, {?Date})))
ELSE DATEPART (yyyy,( DATEADD (year,0, {?Date})))
END
(Where {?Date} is a date parameter)
Is it possible to achieve this in the above form or some other form in Crystal Reports?
ThanksSimple answer... When I used the variable, I marked it as a string. There is an email address setting.
-
Using Bind variables in SQL PLUS Report
using Bind variables in SQL PLUS Report. This report gets the arguments from the application concurrent program. Now my need is to convert the start_date and end_date to bind Variables to improve the performance. I have commented the original code in 'prompt List of Unapproved Adjustments' and used my Bind Variable but it is giving an error
error: Bind Variable "ENDING_DATE" not declared
Report Date and Time:
26-OCT-2010 15:44:13
List of Unapproved Adjustments
Bind Variable 'ENDING_DATE" not declared
Please see below the code for the sql plus report:
define p_org_id = '&1'
define p_fy_begin_date = '&2'
define p_start_date = '&3'
define p_end_date = '&4'
define p_conversion = '&5'
declare
variable begin_date date;
exec :begin_date := p_start_date;
variable ending_date date;
exec :ending_date := p_end_date;
/* Begin
:begin_date := to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS');
:ending_date := to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS');
End; */
set newpage none
set termout off
set pagesize 55
set linesize 180
set heading on
set feedback off
set wrap off
set space 1
set heading on
begin
dbms_application_info.set_client_info('&p_org_id');
end;
prompt
prompt Report Date and Time:
prompt ----------------------
select to_char(sysdate,'DD-MON-YYYY HH24:MI:SS')
from dual ;
prompt
prompt List of Unapproved Adjustments
prompt -------------------------------
select b.trx_number,
a.adjustment_number,
f.user_name created_by
from apps.ar_adjustments a,
apps.ra_customer_trx b,
apps.fnd_user f
where a.customer_trx_id = b.customer_trx_id
and a.status <> 'A'
and a.created_by = f.user_id
and a.creation_date between :begin_date
and :ending_date
-- and a.creation_Date between to_date('&p_start_date','YYYY/MM/DD HH24:MI:SS')
-- and to_date('&p_end_date','YYYY/MM/DD HH24:MI:SS')
order by
b.trx_number ;Hi
Please go to customization part of the report and verify..You have set a default value out there ..And also verify your lov and look at the values ..If it is again giving you the problem ..pl delete the report and develop it again from the scratch it will be solved...
vishnu
null -
Use of Input Variables in SQL-Queries Sometimes Not Possible
Only in simple SELECT-statements the use of input variables ([%0], [%1], etc.) work without problems.
In more complex queries the use of these variables is not possible (e.g. SELECT-statements with sub-queries, sometimes when UNION is used - but I couldn't find any general rule when the problems will arise; sometimes two different queries with the same query-structure behave in different ways when these variables are used).
In these cases the query is not executed - not even the input-window to enter values into the input variables is displayed. The query stops with some strange error-messages in the status line. These error-messages doesn't have any relation to the actual query - sometimes it refers to field-names never used in the query or refers to syntax error which do not exist.
If the input variables are replaced by constant values there are no problems so there can't be any syntax errors - the only difference is the presence or absence of input variables.
Example:
provided that the queries have a certain complexity
SELECT ...
FROM ... OINV Tx ...
WHERE ... Tx.DocDate >= [%0] ...
does not work,
SELECT ...
FROM ... OINV Tx ...
WHERE ... Tx.DocDate >= '1.1.2007' ...
works!
Does anybody have run into the same problem and now if it is a bug of SAP-BO or an error on behalf of the user? Does anybody know a way to correct the problem?
Thanks in advance!
Frank
By the way: Are there any rules where exactly input variables can be used in a query?
Only in SELECT-statements? Where there exactly?
In statements outside of SELECT?Only SAP Partners Can access service.sap.com/notes, but I think it is possible to search in them from the customer portal as well.
Here are summary of the two notes mentioned before this:
730960:
<i>
The following query is an example for how to define variables in long
queries rather than using "Fixed Declares".
You need to use exactly the same template as follows, do not delete
"comments" from this query.
The only changes you need to do :
1. In the first and in the fifth rows you need to select the table to which you would like to relate the variable e.g. in this example, the variable is related to the table VPM1 - 'Payments to Vendors - Rows'.
2. In the fourth and in the eighth rows you need to select the field to which you would like to define the variables e.g. in this example, the variable is the field 'DueDate'.
/SELECT FROM [dbo].[VPM1] T0/
declare @fromdate as datetime
/* WHERE */
set @fromdate = /* T0.DueDate */ '[%0]'
/SELECT FROM [dbo].[VPM1] T1/
declare @tilldate as datetime
/* WHERE */
set @tilldate = /* T0.DueDate */ '[%1]'
select OVPM.docnum, VPM1.dueDate,VPM1.CheckNum, VPM1.Branch,
VPM1.BankCode, VPM1.CheckSum, OVPM.CardName,
case
when OPCH.docnum is null then VPM2.docEntry
else OPCH.docnum
end as 'docnum'
from OVPM INNER join VPM1 on OVPM.docnum = VPM1.docnum
left join VPM2 LEFT JOIN OPCH ON VPM2.DocEntry = OPCH.DocEntry
on OVPM.docnum = VPM2.docnum
where OVPM.Canceled = 'N' AND VPM1.DueDate >=@fromdate AND
VPM1.DueDate <=@tilldate
</i>
955295:
<i>
Using SAP Business One Survey Variables (parameters) in a 'Set' SQL Statement can give an error in the Query Generator.
For Example:
Declare @Num as numeric(2)
Set @Num = [%0]
Select T0.DocNum
From ORDR T0
Where DocNum = @Num
Other terms
query, SQL, parameter, survey, variable, query generator, set, declare, [%0], table, error, SAP Business One
Reason and Prerequisites
FAQ
Solution
In such cases you need to put in an SQL remark statement a reference field in the DB for the Survey Variable (any field).
For Example: (to make the above query work)
Declare @Num as numeric(2)
Set @Num = /* T0.DocNum */ [%0]
Select T0.DocNum
From ORDR T0
Where docnum = @Num
</i> -
Coldfusion Creating Random SQL Queries
Here is an error I received from one of our sites:
Syntax error or access violation: You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'WHERE user_id = '19152'
AND paid = 0' at line 1
Here is the generated sql it tried to run:
SELECT SUM(hours) AS totalHours FROM records WHERE user_id =
'19152' WHERE user_id = '19152' AND paid = 0
Obviously there is two where statements.
Now look at the method that generated this:
<cffunction name="GetTotalUnpaidHours" access="public"
returntype="numeric" output="false">
<!--- Get total sum of unpaid hours
--------------------------------------------------->
<cfscript>
sql = "SELECT SUM(hours) AS totalHours ";
sql = sql & "FROM records ";
sql = sql & "WHERE user_id = '#variables.user_id#' ";
sql = sql & "AND paid = 0";
hours = SqlQuery(sql);
if ( IsNumeric(hours.totalHours) ) return hours.totalHours;
else return 0;
</cfscript>
</cffunction>
This is about as simple as it gets. Build an SQL string, pass
it to the SqlQuery() method with just globally available wrapper of
the CFQUERY tag, and return the result.
How and why would it append the WHERE statement twice. This
is not the first error like this from our high traffic production
site. 99% of the time it works as this method is called 1000's of
times a day by 1000's of users going in and out of their account
every all day. It is not limited to just this example as I've seen
similar instances of this happening with incorrect queries all over
the app. Tested and retested the code and have never been able to
reproduce these types of results.
Any comments or suggestions would be greatly appreciated.
It's essential that this application be 100% reliable.
AnthonyWebPexDev,
Interesting. Dan Bracuk could be right about it being a scope
problem. If the sql variable isn't local to the function I can
kindof see how you might end up with two where clauses in the sql
string.
> Build an SQL string, pass it to the SqlQuery() method
with just globally available
> wrapper of the CFQUERY tag, and return the result.
Assuming the functions are contained in a cfc, is the cfc
stored in the session or application scope? -
How to use substitution variable in sql
Hai All
I have two tables Rgpmain and Rgpitem the fields are
Rgpmain
unitid,periodid, docno, vendcode ,vendname, part_taken_by and .....
Rgpitem
unitid, periodid, docno, partno, partname .... And i need to give some values in runtime using sub variable
i need to to four values in sub function and i will give one value and i need the result of one variable
The qurey will like this
Select * from rgpmain m, rgpitem i where unitid=1 and periodid=14 and m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and vendcode ='&p_vendcode'
Or
m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and vendname like '&p_vendname%'
Or
m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and partname like '&p_partname%'
or
m.unitid=i. unitid and m.periodid= i.periodid and m.docno = i.docno and partno ='&p_partno'
This is my query
And while i am executing there are four options showing to enter..
My need is i need enter only one field Ie vendcode and execute the vendcode like ABC01 then i need the only
the result that belong to vendcode ABC01 but my query giving all the rows
Pls tell me what is wrong with my query
Thanks In Advance
Srikkanth.MHai
Thanks Man i under stood that nv2 if 1 col is null then it will return 2 col or els 1 col but i working with large
database and i need four or five column using sub. Pls tell whats went wrong with my query when i am executing
one by one at the first time its works fine but next time it returns 1000 rows. pls tell me how to use four or five columns
Regards
srikkanth.M -
Using bind variables with sql statements
We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
Is there anybody our there with an idea of what is happening here?
Code snippet:
Dim OraSession As OracleInProcServer.OraSessionClass
Dim OraDatabase As OracleInProcServer.OraDatabase
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
Dim RS As OracleInProcServer.OraDynaset
strSQLstatement= "Select * from my_table where igz= [my_bind] "
Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
OraDatabase.Parameters("my_bind").Value = myValue
RS.Refresh
Cheers and thanks a lot :)
Michael SonntagWe connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
Is there anybody our there with an idea of what is happening here?
Code snippet:
Dim OraSession As OracleInProcServer.OraSessionClass
Dim OraDatabase As OracleInProcServer.OraDatabase
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
Dim RS As OracleInProcServer.OraDynaset
strSQLstatement= "Select * from my_table where igz= [my_bind] "
Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
OraDatabase.Parameters("my_bind").Value = myValue
RS.Refresh
Cheers and thanks a lot :)
Michael Sonntag -
Using SQLCMD variables in SQL Server Unit Test Project
Is it possible to use SQLCMD variables in my SQL Server Unit Test Project? In my test initialize script I'd like to set a database name variable, something like this:
:SETVAR MyDatabase "mydatabase"
SELECT * FROM [$(MyDatabase)].[mytable]
but I get syntax errors when I run the test. Any suggestions how I can get this to work.
Result Message: Initialization method
myTest.TestInitialize threw exception. System.Data.SqlClient.SqlException: System.Data.SqlClient.SqlException:
Incorrect syntax near ':'..Hi Kevin,
What is the error?
This should work only thing i could see is no scheme specified.
SQL Server uses dbo as default schema.
In your case:
:SETVAR MyDatabase "mydatabase"
SELECT * FROM [$(MyDatabase)].dbo.[mytable]
Also check your instance collation if its Case sensitive then specify database and table name as exact case.
Example:
:SETVAR MyDatabase "[mydatabase]"
:setvar schemavar "[dbo]"
:setvar tablevar "[mytable]"
SELECT * FROM $(MyDatabase).$(schemavar).$(tablevar) -
Use of Variable - Refreshing the Queries in Workbook
Hi All,
I have a workbook which contains 5 Queries. All these queries uses the same variable. While I am refreshing all the queries in the workbook, it pops-up the variable input screen 5 times.
Here I just want the variable screen appear to be once and the same input be taken to all the queries.
We are in 3.x.
In 7.x Analyzer, I know that When you have multiple queries(with variables) embedded in a single workbook, we can use "Change Variables" icon to acheive the same.
How can I achieve this in 3.5.
Thanks in advance.
Siva
Edited by: Siva Reddy S on Jun 9, 2009 10:32 AMHi Joke,
Thanks for your reply.
The option "save and reuse variable values" is something to do with the input values to save and reuse the same for the next time execution.
Here I just wanted to input the variable at one query and the same value needs to be taken to all the queries. The Variable used in all the queries is the same one.
Thanks again..
Any body any inputs.
Siva -
Error using presentation variable in SQL Expression
Hi all,
I'm receiving an error - '...Error getting drill information...' due to a presentation variable being used in a SQL Expression. It probably has something to do with a data type issue. I've narrowed the error to the use of the presentation variable.
I'm setting a presentation variable, pres_mth_nme_to, from a dashboard prompt. The prompt contains a month name.
I'm using the presentation variable as part of a SQL Expression in a filter. The gist of the SQL Expression is to use the
presentation variable in a CASE and set a value accordingly. For example:
Column: Month Sort Value
Operator: Between
Value: *10*
SQL Expression: *Case @{pres_mth_nme_to}{some default} WHEN 'NOV' THEN '10' WHEN 'DEC' THEN '11' WHEN 'JAN' THEN '12' WHEN 'FEB' THEN '13' WHEN...END*
The month name is character. If I were to hard code this, I don't recieve the error. For example:
CASE 'SEP' WHEN 'NOV' THEN '10' WHEN 'DEC' ...END
There something going on with the data type from the prompt and it being used in the comparison. If I use a CAST, the problem still exists.
CASE CAST(@{pres_mth_nme_to} as char(3)) WHEN 'NOV' THEN ... END
If I'm in Answers, the problem doesn't exist, I'm assuming because of the default values. If I'm on the dashboard, it does exist, I'm assuming because of recieving the prompt value.
I don't know what I'm missing. Any suggestions?
Thanks.DJ,
if the formula presented by you is exactly true, i mean it was not fabricated to present as an example in the forum, you should include the presentation variable in single quotes.
i.e. your formula must look somthing like
Case '@{pres_mth_nme_to}{some default}' WHEN 'NOV' THEN '10' WHEN 'DEC' THEN '11' WHEN 'JAN' THEN '12' WHEN 'FEB' THEN '13' WHEN...END
let me know if it did solve the issue...
-bifacts
http://www.obinotes.com
Edited by: bifacts on Oct 25, 2010 1:50 PM -
Error using bind variables with SQL server with SQL92 mode
I am using 2 bind variable in my VO (JDBC positional) . The mode is SQL 92 for ADF BC. I do not use the bind variable directly but in a view criteria. I see following error in the logs.
The logs show the query executed and error. I tried both ways - making bind variable required and not required. I have set -Djbo.SQLBuilder=SQLServer property. My other page works which has an updatable VO.
JDEV version is - JDEVADF_11.1.1.7.0_GENERIC_130226.1400.6493
<ViewObjectImpl> <getQueryHitCount> [4567] Estimated Row Count for ViewObject: [oracle.epm.fm.bc4j.queries.admin.UserOnSystemROVO]AdministrationAM.UserOnSystemROVO1, Query Statement:
<ViewObjectImpl> <getQueryHitCount> [4568] "SELECT count(1) FROM (SELECT * FROM (SELECT
TABLE1.SUSERNAME USERNAME,
TABLE2.SMODULENAME MODULENAME,
TABLE2.LACTIVITYCODE ACTIVITYCODE,
TABLE2.DSTARTTIME STARTTIME,
TABLE2.SSERVERNAME SERVERNAME,
TABLE2.SAPPNAME APPNAME,
TABLE2.LSESSIONID SESSIONID,
TABLE2.LSESSIONSTATUS SESSIONSTATUS,
TABLE2.LUSERID USERID,
TABLE2.DSTILLALIVETS STILLALIVETS,
TABLE2.LTASKID TASKID,
TABLE2.SACTIVITYDESC ACTIVITYDESC,
TABLE1.LUSERID USERID1,
TABLE1.SUSERDESC USERDESC
FROM
TABLE2 TABLE2,
TABLE1 TABLE1
WHERE
TABLE2.LUSERID = TABLE1.LUSERID) QRSLT WHERE ( ( ( ( UPPER(SERVERNAME) = UPPER(?) ) OR ( ? IS NULL ) ) AND ( ( UPPER(APPNAME) = UPPER(?) ) OR ( ? IS NULL ) ) ) )) ESTCOUNT"
<ViewObjectImpl> <getQueryHitCount> [4569] Bind params for ViewObject.getQueryHitCount: UserOnSystemROVO1
<ViewRowSetImpl> <doSetWhereClauseParam> [4570] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(0, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4571] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(1, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4572] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(4, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4573] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(5, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4574] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(2, null, null)
<ViewRowSetImpl> <doSetWhereClauseParam> [4575] UserOnSystemROVO1 ViewRowSetImpl.doSetWhereClause(3, null, null)
<ADFLogger> <addContextData> Estimated row count
<BaseSQLBuilderImpl> <bindParamValue> [4576] Binding null of type 12 for 1
<BaseSQLBuilderImpl> <bindParamValue> [4577] Binding null of type 12 for 2
<BaseSQLBuilderImpl> <bindParamValue> [4578] Binding null of type 12 for 3
<BaseSQLBuilderImpl> <bindParamValue> [4579] Binding null of type 12 for 4
<BaseSQLBuilderImpl> <bindParamValue> [4580] Binding null of type 12 for 5
<ViewObjectImpl> <getQueryHitCount> [4581] ViewObjectImpl.getQueryHitCount failed...
<ViewObjectImpl> <getQueryHitCount> [4582] java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver]Invalid parameter binding(s).
at weblogic.jdbc.sqlserverbase.dda4.b(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda4.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda3.b(Unknown Source)
at weblogic.jdbc.sqlserverbase.dda3.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddb8.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddb9.a(Unknown Source)
at weblogic.jdbc.sqlserverbase.ddb9.setNull(Unknown Source)
at weblogic.jdbc.wrapper.PreparedStatement.setNull(PreparedStatement.java:622)
at oracle.jbo.server.BaseSQLBuilderImpl.bindParamValue(BaseSQLBuilderImpl.java:2215)
at oracle.jbo.server.BaseSQLBuilderImpl.bindParametersForStmt(BaseSQLBuilderImpl.java:3687)
at oracle.jbo.server.ViewObjectImpl.bindParametersForCollection(ViewObjectImpl.java:22684)
at oracle.jbo.server.ViewObjectImpl.getQueryHitCount(ViewObjectImpl.java:4944)
at oracle.jbo.server.ViewObjectImpl.getQueryHitCount(ViewObjectImpl.java:4857)
at oracle.jbo.server.QueryCollection.getEstimatedRowCount(QueryCollection.java:4204)
at oracle.jbo.server.ViewRowSetImpl.getEstimatedRowCount(ViewRowSetImpl.java:2677)
at oracle.jbo.server.ViewObjectImpl.getEstimatedRowCount(ViewObjectImpl.java:10632)After making all the bind variables not required, the error is no longer coming.
-
Decode using bind variable in SQL
I have decode statement in my SQL query which is used to define the VO object. I want to select a column depending on the value entered for the bind variable :1. dont know how to implement this in OAF - any pointers will be appreciated.
decode(:1,'XO2C_CUST_SERV_REP',XO2C_CUST_SERV_REP,'XO2C_ACCOUNT_MGR',XO2C_ACCOUNT_MGR,'XO2C_CTS_ENGINEER',XO2C_CTS_ENGINEER ) "contact names"
Thanks!!I have decode statement in my sql for the VO and the VO is executed when the user clicks the GO button(user initiated search and over-riding the default Go button).
When I click the Go button , I am calling a method called Uneditable in my AM which appends the decode variable using the whereclause append but it is failing with an exception "java.sql.SQLException: Missing IN or OUT parameter at index:: 1". Can someone let me know if I am doing anything indifferently which is causing the program/sql query to fail.
Binding style of the VO is "Oracle Named" - is this causing the problem?
ProcessFormRequest:
=============
if ("ClickGo".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM)))
OAApplicationModule am = pageContext.getApplicationModule(webBean);
System.out.println("Go Button pressed>> "+am);
OATableBean table = (OATableBean) webBean.findChildRecursive("USSContactMainVO1");
System.out.println("before QueryData");
//table.queryData(pageContext,false);
System.out.println("before Boolean executeQry");
Boolean executeQuery = BooleanUtils.getBoolean(false);
System.out.println("Get PartyName");
String v_PartyName = pageContext.getParameter("xxPartyName");
System.out.println("Get SalesContactQry");
String v_SalesContact = pageContext.getParameter("SalesContact_qry");
System.out.println("Party Name :" + v_PartyName + " Sales contact:" + v_SalesContact);
Serializable[] parameters = {v_PartyName, v_SalesContact,executeQuery };
Class[] paramTypes = { String.class, String.class, Boolean.class };
am.invokeMethod("uneditable",parameters,paramTypes);
Uneditable(AM)
=========
public void uneditable(String v_PartyName, String v_SalesContact,
Boolean executeQuery){
System.out.println("Im in uneditable..to call VO");
USSContactMainVOImpl vo1= getUSSContactMainVO1();
String Voqry =vo1.getQuery();
//System.out.println("Query is :"+ Voqry);
StringBuffer whereClause = new StringBuffer(100);
Vector parameters = new Vector(3);
int clauseCount = 0;
int bindCount = 0;
System.out.println("debug1");
vo1.setWhereClauseParams(null); // Always reset
System.out.println("check the params");
if ((v_SalesContact != null) && (!("".equals(v_SalesContact.trim()))))
System.out.println("Sales:"+v_SalesContact);
whereClause.append(v_SalesContact);
System.out.println("bindcount");
whereClause.append(++bindCount);
clauseCount++;
System.out.println("setWhereclas");
vo1.setWhereClause(whereClause.toString());
System.out.println("setWhereclasParam");
vo1.setWhereClauseParams(null);
System.out.println("setWhereclasParam-2");
vo1.setWhereClauseParam(0,v_SalesContact);
if ((v_PartyName != null) && (!("".equals(v_PartyName.trim()))))
whereClause.append(" Party_Name like :");
whereClause.append(++bindCount);
clauseCount++;
vo1.setWhereClause(whereClause.toString());
vo1.setWhereClauseParams(null);
//vo1.setWhereClauseParam(0,v_PartyName);
vo1.setWhereClauseParam(1,v_PartyName);
System.out.println("Query is :" + vo1.getQuery()); //prints this debug msg but fails while executnig the vo
vo1.executeQuery();
Row[] rows1=vo1.getAllRowsInRange();
USSContactMainVORowImpl row = null;
for (int i = 0; i < rows1.length; i++)
System.out.println(" Rows Found "+i);
row = (USSContactMainVORowImpl)rows1;
row.setAttribute("CTSEngineer_TR",Boolean.FALSE);
//end of uneditable
It appends the 2nd parameter and prints System.out.println("Query is :" + vo1.getQuery()) without any issues but think fails when trying to execute the VO.
Error Stack :
=======
oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (SELECT hp.party_name,hp.party_number registry_id, hps.party_site_number Site_Number, hca.account_number,
hca.account_name acc_desc,
hl.address1
|| ''
|| hl.city
|| ''
|| hl.postal_code
|| ''
|| hl.state "Address",
xagv.xo2c_entering_unit "Entering_Unit",
DECODE(hou.Short_code,'USS CA OU','CA','USS USA OU','US') "Operating_Unit",DECODE('.',null,null) "CTS", DECODE(:1,'Customer Service Rep',XO2C_CUST_SERV_REP,'Account Manager',XO2C_ACCOUNT_MGR,'CTS Engineer',XO2C_CTS_ENGINEER ) "Contact Names" FROM hz_parties hp,
hz_party_sites hps,
hz_cust_accounts hca,
hz_cust_acct_sites_all hcs,
hz_locations hl,
xo2c_ship_to_sales_o_agv xagv,
hr_operating_units hou
WHERE 1 = 1
AND hp.party_id = hps.party_id
AND hp.party_id = hca.party_id
AND hcs.party_site_id = hps.party_site_id
AND hca.cust_account_id = hcs.cust_account_id
AND hps.location_id = hl.location_id
AND hcs.status = 'A'
AND xagv.party_site_id = hps.party_site_id
AND xagv.party_site_id = hcs.party_site_id
AND hou.ORGANIZATION_ID=hcs.ORG_ID) QRSLT WHERE (CTS Engineer1 Party_Name like :2)
at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
at oracle.apps.fnd.framework.OAException.wrapperInvocationTargetException(Unknown Source)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
## Detail 0 ##
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1566)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2996)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:857)
at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:666)
at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3655)
at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:742)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:891)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:805)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:799)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3575)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.server.USSContactMainAMImpl.uneditable(USSContactMainAMImpl.java:244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
java.sql.SQLException: Missing IN or OUT parameter at index:: 1
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1566)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2996)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
at oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:857)
at oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:666)
at oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:3655)
at oracle.jbo.server.OAJboViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQueryForCollection(Unknown Source)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:742)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:891)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:805)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:799)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:3575)
at oracle.apps.fnd.framework.server.OAViewObjectImpl.executeQuery(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.server.USSContactMainAMImpl.uneditable(USSContactMainAMImpl.java:244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
at xxuss.oracle.apps.xo2c.contactmaintenance.webui.USSContactMainCO.processFormRequest(USSContactMainCO.java:105)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
Edited by: MyOAF on Jan 14, 2010 11:03 PM -
Using substitution variable in sql -- Issue
Hello All
I am trying to do a sql operation from command prompt of my system and that sql requires substitution variable which i am passing it but when i pass the variable ( there are two) the first one assign as " \c" and second gets both what i am passing.
I am not sure what exactly happening here, i have done this on AIX but here its not working any ideas?
System : uname -a
Linux ## 2.6.18-128.1.1.el5 #1 SMP Mon Jan 26 13:58:24 EST 2009 x86_64 x86_64 x86_64 GNU/LinuxAIX and Linux are not the same. An output of "\c" may indicate a compatibility issue of your shell script with your current command line interpreter (shell). A \c can be used to suppress a newline with the echo command. Bash understands both formats echo -n and echo \c, but other shells like Ksh don't. Try to run your script under a Bash, which is the default under Linux. If the problem persists you will need to post your script for any further analysis.
-
Can we use repository variables in SQL statement of column prompt?
Hi Dudes,
Below is the query
SELECT "- End Date"."End Fiscal Year" FROM "Consumer Sector" WHERE ("- End Date"."End Fiscal Year" = valueof (current_year)) or ("- End Date"."End Fiscal Year" = valueof (current_year) -1)
when use this sql in criteria prompt getting error.
Please suggest .
thanks.sriMake sure your syntax is correct it should be like VALUEOF("CURRENT_YEAR")-1
If you still have issues then VALUEOF("CURRENT_YEAR")-1 cast it to int before you subtract.
If helps pls mark as correct else let share error message -
Use of variables in SQL statements
Hi,
I am looking for for a way to set a variable which will be referenced several times within a UNION query.
Something like:
Var=3
SELECT * FROM VIEW_1 WHERE FIELD_1 = Var
UNION
SELECT * FROM VIEW_2 WHERE FIELD_1 = Var
UNION
SELECT * FROM VIEW_3 WHERE FIELD_1 = Var
Instead of something like:
SELECT * FROM VIEW_1 WHERE FIELD_1 = 3
UNION
SELECT * FROM VIEW_2 WHERE FIELD_1 = 3
UNION
SELECT * FROM VIEW_3 WHERE FIELD_1 = 3I'm sure that for this you were requiring a database solution and not a sqlplus solution ? If so, then you have a couple of options:-
1) change the Var to a function call and have the function return a packaged variable or value in a lookup table that you can set as you require [ i.e. WHERE FIELD_1 = your_function ].
2) use an application context, such that you set an attribute within the context and use it within the view [ i.e. WHERE FIELD_1 = SYS_CONTEXT( 'your_context', 'your_attribute' ) ].
In both methods, you will need to set the value of your variable before referencing the view. The view therefore becomes "parameterised" in this sense.
It might be possible that your view is mergeable. By this I mean that Oracle might be able to push a predicate against the view inside it instead, such that Oracle rewrites this:-
SELECT <cols>
FROM your_union_view
WHERE field_1 = 3;
...and takes that value of field_1 = 3 and "pushes" it into your_union_view itself, in which case you will not need to worry about any of the above solutions. You can test this out by removing the where clauses from your view definition and running an explain plan against a query of the form above. If you see a "VIEW" step in the results, then the view is not mergeable in its current form and you should revert to the methods I listed.
Regards
Adrian
For this you can use application contexts
Maybe you are looking for
-
IMac G5 System Profiler doesn't work?
My system profiler doesn't open. Cannot find in anywhere, applications or any other area. Is it Lost. Can I reinstall, any help would be appreciated ImacG5 Mac OS X (10.3.9)
-
Can't find a zip file with latest document on datamining business example
I had found a zip file that had something like 30 pdf's in it that were very helpful and can't find it again. It had the latest example of how to do a promotional study of sales from an electronic store. I remember it showed a graph of quickly showin
-
TS4006 can i use find iphone on windows pc using icloud
I want to know if i can use find iphone on my windows pc via the icloud....and if so how do i do it....i have icloud on my pc and im set up on my ipad....
-
For a while now, I've just been putting up with it, but thought I'd give it a shot here. It's not completely unbearable, just mildly annoying as I must reboot the system. No data is ever lost. I just make sure to save my work constantly. Anyway, atta
-
Will Characteristic Derivation in KEPM using Plan Method COPY
Dear All, While performing Planning using KEPM transaction with Plan Method Copy. Characteristic Derivation is not working. System Construction We have put a derivation step in KEDR that needs to populate a Custom Characteristic WWXXX with a certain