XSQL Using bind params with sql LIKE clause
I am unable to use a bind-param with the LIKE clause in a SELECT statement.
eg call .../temp.xsql?name=N
XSQL query is this:
<xsql:query max-rows="-1" bind-params="name">
SELECT last_name
FROM emp
WHERE last_name LIKE '?%'
</xsql:query>
I have tried a few combinations so far with no success eg:
WHERE last_name LIKE '{@name}%'
WHERE last_name LIKE ?||%
Any ideas?
I highly recommend using XSQL's real bind variable feature wherever you can. You can read about it in the XSQL Online Documentation (Search for the "Using Bind Variables" section).
Using this feature is more performant and more secure than using textual substitution variables.
Here's what your page looks like using textual substitution:
<page connection="UTD4" xmlns:xsql="urn:oracle-xsql">
<xsql:query null-indicator="yes" >
SELECT * FROM TC_HL7_SEG WHERE SEGMENT_CODE LIKE '{@code}%'
</xsql:query>
</page> .
And here's what it would look like using real bind variables:
<page connection="UTD4" xmlns:xsql="urn:oracle-xsql">
<xsql:query null-indicator="yes" bind-params="code">
SELECT * FROM TC_HL7_SEG WHERE SEGMENT_CODE LIKE ?||'%'
</xsql:query>
</page> .
Using real bind variables allows the database to avoid reparsing the SQL statement everytime, which improves performance.
Steve Muench
JDeveloper/BC4J Development Team
Author, Building Oracle XML Applications
Similar Messages
-
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.
-
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 bind variable with IN clause
My application runs a limited number of straight up queries (no stored procs) using ODP.NET. For the most part, I'm able to use bind variables to help with query caching, etc... but I'm at a loss as to how to use bind variables with IN clauses. Basically, I'm looking for something like this:
int objectId = 123;
string[] listOfValues = { "a", "b", "c"};
OracleCommand command = new OracleCommand();
command.Connection = conn;
command.BindByName = true;
command.CommandText = @"select blah from mytable where objectId = :objectId and somevalue in (:listOfValues)";
command.Parameters.Add("objectId", objectId);
command.Parameters.Add("listOfValues", listOfValues);
I haven't had much luck yet using an array as a bind variable. Do I need to pass it in as a PL/SQL associative array? Cast the values to a TABLE?
Thanks,
NickNevermind, found this
How to use OracleParameter whith the IN Operator of select statement
which contained this, which is a brilliant solution
http://oradim.blogspot.com/2007/12/dynamically-creating-variable-in-list.html -
How to use bind variables with XMLTABLE?
I tried to use bind variables with xmltable statment. Here, my testcase:
create or replace function wsdltest return xmltype as
l_dummy xmltype;
l_stt clob;
l_name varchar2(500);
l_xml clob;
BEGIN
l_xml :=
'<definitions name="F1" targetNamespace="http://xmlns.oracle.com/orawsv/XFILES/F1" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/orawsv/XFILES/F1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/XFILES/F1" elementFormDefault="qualified">
<xsd:element name="SVARCHAR2-F1Input">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="A-VARCHAR2-IN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="F1Output">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RETURN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="F1InputMessage">
<part name="parameters" element="tns:SVARCHAR2-F1Input"/>
</message>
<message name="F1OutputMessage">
<part name="parameters" element="tns:F1Output"/>
</message>
<portType name="F1PortType">
<operation name="F1">
<input message="tns:F1InputMessage"/>
<output message="tns:F1OutputMessage"/>
</operation>
</portType>
<binding name="F1Binding" type="tns:F1PortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="F1">
<soap:operation soapAction="F1"/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</operation>
</binding>
<service name="F1Service">
<documentation>Oracle Web Service</documentation>
<port name="F1Port" binding="tns:F1Binding">
<soap:address location="http://localhost:8080/orawsv/XFILES/F1"/>
</port>
</service>
</definitions>';
-- OK
l_stt := 'select * from xmltable(XMLNAMESPACES(''http://www.w3.org/2001/XMLSchema'' AS "XSD", default ''http://schemas.xmlsoap.org/wsdl/''),
''//definitions/types/XSD:schema/XSD:element[@name="SVARCHAR2-F1Input"]''
passing xmltype(:1)
columns
ab xmltype path ''.'' ) t';
EXECUTE IMMEDIATE l_stt INTO l_dummy using l_xml;
-- ERROR ORA-01006
l_name := '"SVARCHAR2-F1Input"';
l_stt := 'select * from xmltable(XMLNAMESPACES(''http://www.w3.org/2001/XMLSchema'' AS "XSD", default ''http://schemas.xmlsoap.org/wsdl/''),
''//definitions/types/XSD:schema/XSD:element[@name=:2]''
passing xmltype(:1)
columns
ab xmltype path ''.'' ) t';
EXECUTE IMMEDIATE l_stt INTO l_dummy using l_xml, l_name;
return l_dummy;
END;
Any idea ?
Thanks in advance
CyrylWhy are you using dynamic SQL statements? Why not just use something like this instead in your PL/SQL. I also replaced the leading // in your Xpath with just / since you start from the root node.
select *
INTO l_dummy
from xmltable(XMLNAMESPACES('http://www.w3.org/2001/XMLSchema' AS "XSD", default 'http://schemas.xmlsoap.org/wsdl/'),
'/definitions/types/XSD:schema/XSD:element'
passing xmltype(l_xml)
columns
ab xmltype path '.' ) t;Also, the above returns two rows, which I suspect is not what you want. Here is the pure SQL version for you to debug.
select *
from xmltable(XMLNAMESPACES('http://www.w3.org/2001/XMLSchema' AS "XSD", default 'http://schemas.xmlsoap.org/wsdl/'),
'/definitions/types/XSD:schema/XSD:element'
passing xmltype('<definitions name="F1" targetNamespace="http://xmlns.oracle.com/orawsv/XFILES/F1" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://xmlns.oracle.com/orawsv/XFILES/F1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://xmlns.oracle.com/orawsv/XFILES/F1" elementFormDefault="qualified">
<xsd:element name="SVARCHAR2-F1Input">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="A-VARCHAR2-IN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="F1Output">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RETURN" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="F1InputMessage">
<part name="parameters" element="tns:SVARCHAR2-F1Input"/>
</message>
<message name="F1OutputMessage">
<part name="parameters" element="tns:F1Output"/>
</message>
<portType name="F1PortType">
<operation name="F1">
<input message="tns:F1InputMessage"/>
<output message="tns:F1OutputMessage"/>
</operation>
</portType>
<binding name="F1Binding" type="tns:F1PortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="F1">
<soap:operation soapAction="F1"/>
<input>
<soap:body parts="parameters" use="literal"/>
</input>
<output>
<soap:body parts="parameters" use="literal"/>
</output>
</operation>
</binding>
<service name="F1Service">
<documentation>Oracle Web Service</documentation>
<port name="F1Port" binding="tns:F1Binding">
<soap:address location="http://localhost:8080/orawsv/XFILES/F1"/>
</port>
</service>
</definitions>'
columns
ab xmltype path '.' ) t -
Using Entity Framework with SQL Azure - Reliability
(This is a cross post from http://stackoverflow.com/questions/5860510/using-entity-framework-with-sql-azure-reliability since I have yet to receive any replies there)
I'm writing an application for Windows Azure. I'm using Entity Framework to access SQL Azure. Due to throttling and other mechanisms in SQL Azure, I need to make sure that my code performs retries if an SQL statement has failed. I'm trying to come up with
a solid method to do this.
(In the code below, ObjectSet returns my EFContext.CreateObjectSet())
Let's say I have a function like this:
public Product GetProductFromDB(int productID)
return ObjectSet.Where(item => item.Id = productID).SingleOrDefault();
Now, this function performs no retries and will fail sooner or later in SQL Azure. A naive workaround would be to do something like this:
public Product GetProductFromDB(int productID)
for (int i = 0; i < 3; i++)
try
return ObjectSet.Where(item => item.Id = productID).SingleOrDefault();
catch
Of course, this has several drawbacks. I will retry regardless of SQL failure (retry is waste of time if it's a primary key violation for instance), I will retry immediately without any pause and so on.
My next step was to start using the Transient Fault Handling library from Microsoft. It contains RetryPolicy which allows me to separate the retry logic from the actual querying code:
public Product GetProductFromDB(int productID)
var retryPolicy = new RetryPolicy<SqlAzureTransientErrorDetectionStrategy>(5);
var result = _retryPolicy.ExecuteAction(() =>
return ObjectSet.Where(item => item.Id = productID).SingleOrDefault;
return result;
The latest solution above is described as ahttp://blogs.msdn.com/b/appfabriccat/archive/2010/10/28/best-practices-for-handling-transient-conditions-in-sql-azure-client-applications.aspx Best Practices for Handling Transient Conditions in SQL Azure Client
Application (Advanced Usage Patterns section).
While this is a step forward, I still have to remember to use the RetryPolicy class whenever I want to access the database via Entity Framework. In a team of several persons, this is a thing which is easy to miss. Also, the code above is a bit messy in my
opinion.
What I would like is a way to enforce that retries are always used, all the time. The Transient Fault Handling library contains a class called ReliableSQLConnection but I can't find a way to use this with Entity Framework.
Any good suggestions to this issue?Maybe some usefull posts
http://blogs.msdn.com/b/appfabriccat/archive/2010/12/11/sql-azure-and-entity-framework-connection-fault-handling.aspx
http://geekswithblogs.net/iupdateable/archive/2009/11/23/sql-azure-and-entity-framework-sessions-from-pdc-2009.aspx -
Performance on searching a name field with the like clause
Hi. We run 2012 std and I suspect we'll be running into challenges as my user has expressed an interest in searching data based on a like clause across a contact name column that is varchar(80). The like clause is shown below. The
question is whether or not an index on this column will (if we make one) even be used when a like clause is introduced? And any other advice the community may offer. I'll ask my user if they could limit the search to patterns that match starting
in position 1 but suspect they'll say no. Currently the table has 1.5 million rows , one pk, and is approx 1100 bytes wide if varchars are fully used.
where ltrim(rtrim(e.[ContactName])) like '%' +IsNull(@contactName1,'') + '%'Hi. We run 2012 std and I suspect we'll be running into challenges as my user has expressed an interest in searching data based on a like clause across a contact name column that is varchar(80). The like clause is shown below. The
question is whether or not an index on this column will (if we make one) even be used when a like clause is introduced? And any other advice the community may offer. I'll ask my user if they could limit the search to patterns that match starting
in position 1 but suspect they'll say no. Currently the table has 1.5 million rows , one pk, and is approx 1100 bytes wide if varchars are fully used.
where ltrim(rtrim(e.[ContactName])) like '%' +IsNull(@contactName1,'') + '%'
Hi db042190,
>> The question is whether or not an index on this column will (if we make one) even be used when a like clause is introduced?
A simple index use an exact value in order to compare it (it orer the tree according to the value). For most cases it will not be a good solution for filtering by "like" (in some cases it can help you use "index scan", but it will not
be able to use "index seek"). There are several options that can help in this issue dapending on your interface and the way you use the data:
(1) Full Text Index as Olaf mentioned
(2) Another option, which is very useful in some cases, based on using an external table, which store list of searching words (if the user try a new search then you can scan the original table, which this is one-time-job for each new word). This is actually
work on the same idea of using FTS, but it is more flexible and give you direct control if you need to use word searching and not phrase/free-text searching. This table is indexed and the search is done on this table, and not the original table. Those two
tables have relations many-to-many, and you use a simple JOIN to get the results
>> limit the search to patterns
This can be a game changer!
There is a simple solution that might help you in this case which is very useful! you can create a computed column that store the value according to your patterns, and then create index on that
column. For example if the your pattern is filter by "starting with 10 specific char" then you can use simple LEFT function like in this code:
CREATE TABLE t (LongText nvarchar(MAX), MyPatSearch as convert(nvarchar(10),LEFT(LongText,10)));
GO
CREATE NONCLUSTERED INDEX IX_MyPatSearch ON t (MyPatSearch);
GO
* using computed column with string like in this example, you have to use CONVERT since Data type is requirements for index computed column.
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
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 -
Using bind variable in dynamic where clause and concatenate with query
Hi,
In my procedure i am framing where clause dynamically with bind variable,When i am concatenate this with my sql query for REF CURSOR i got sql command not properly ended exception.
Is it possible to pass values to the bind variable through the dynamic variable/value?
Please advise
Thanks in advance
Siva
IF in_applicationId IS NOT NULL THEN
optional_where := optional_where || ' AND a.APPLICATION_ID like '||':e%';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id'||',in_applicationId';
END IF;
My query is like this
open Out_Main FOR SelectQuery USING optional_usingThanks for reply,
In my procedure, i suppose to frame the where clause with bind dynamically according to the input parameters. so that i am framing the values of the bind variables also dynamically like this,
Please advise...
IF in_assignedAppFlag IS NOT NULL THEN
IF in_assignedAppFlag = 'Y' THEN
optional_where := optional_where || ' AND b.ASSIGNED_TO = :b' ;
optional_using := ' in_appFuncGroup'||',in_currentUserID';
ELSe
IF in_isSupervisor = 0 THEN
optional_where := optional_where || ' AND (b.ASSIGNED_TO = :b'||' OR b.ASSIGNED_TO = ''-1'' OR b.ASSIGNED_TO IS NULL)';
optional_using := ' in_appFuncGroup'||',in_currentUserID';
END IF;
END IF;
ELSE
IF in_isSupervisor = 0 THEN
optional_where := optional_where || ' AND (b.ASSIGNED_TO = :b'||' OR b.ASSIGNED_TO = ''-1'' OR b.ASSIGNED_TO IS NULL)';
optional_using := ' in_appFuncGroup'||',in_currentUserID';
END IF;
END IF;
IF in_appFuncGroup IS NOT NULL THEN
optional_where := optional_where || ' AND e.APP_FUNC_GROUP= :c';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup';
END IF;
IF in_queue_id IS NOT NULL THEN
optional_where := optional_where || ' AND b.QUEUE_ID = :d';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id';
END IF;
IF in_applicationId IS NOT NULL THEN
optional_where := optional_where || ' AND a.APPLICATION_ID like '||':e%';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'||',in_queue_id'||',in_applicationId';
END IF;
IF in_sourceCode IS NOT NULL THEN
optional_where := optional_where || ' AND e.APP_SOURCE_CODE like '||':f%';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
||',in_queue_id'||',in_applicationId'||',in_sourceCode';
END IF;
IF in_logo IS NOT NULL THEN
optional_where := optional_where || ' AND appProds.PRODUCT_TYPE like '||':g%';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo';
END IF;
IF in_firstName IS NOT NULL THEN
optional_where := optional_where || ' AND upper(a.FIRST_NAME) like upper(:h%)';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName';
END IF;
IF in_surName IS NOT NULL THEN
optional_where := optional_where || ' AND upper(a.SURNAME) like upper(:i%)';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName'||',in_surName';
END IF;
IF in_retreival_id IS NOT NULL THEN
optional_where := optional_where || ' AND e.RETREIVAL_ID like :j%';
optional_using := ' in_appFuncGroup'||',in_currentUserID'||',in_appFuncGroup'
||',in_queue_id'||',in_applicationId'||',in_sourceCode'||',in_logo'||',in_firstName'||',in_surName'||',in_retreival_id';
END IF; -
I have the privilege of performing a very tedious task.
We have some home grown regular expressions in our company. I now need to expand these regular expressions.
Samples:
a = 0-3
b = Null, 0, 1
Expression: Meaning
1:5: 1,2,3,4,5
1a: 10, 11, 12, 13
1b: 1, 10, 11
1[2,3]ab: 120, 1200, 1201, ....
It get's even more inetersting because there is a possibility of 1[2,3]a.ab
I have created two base queries to aid me in my quest. I am using the SQL MODEL clause to solve this problem. I pretty confident that I should be able to convert evrything into a range and the use one of the MODEL clause listed below.
My only confusion is how do I INCREMENT dynamically. The INCREMENT seems to be a constant in both a FOR and ITERATE statement. I need to figure a way to increment with .01, .1, etc.
Any help will be greatly appreciated.
CODE:
Reference: http://www.sqlsnippets.com/en/topic-11663.html
Objective: Expand a range with ITERATE
WITH t AS
(SELECT '2:4' pt
FROM DUAL
UNION ALL
SELECT '6:9' pt
FROM DUAL)
SELECT pt AS code_expression
-- , KEY
-- , min_key
-- , max_key
, m_1 AS code
FROM t
MODEL
PARTITION BY (pt)
DIMENSION BY ( 0 AS KEY )
MEASURES (
0 AS m_1,
TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key,
TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key
RULES
-- UPSERT
ITERATE (100000) UNTIL ( ITERATION_NUMBER = max_key[0] - min_key[0] )
m_1[ITERATION_NUMBER] = min_key[0] + ITERATION_NUMBER
ORDER BY pt, m_1
Explanation:
Line numbers are based on the assupmtion that "WITH t AS" starts at line 5.
If you need detailed information regarding the MODEL clause please refer to
the Refrence site stated above or read some documentation.
Partition-
Line 18: PARTITION BY (pt)
This will make sure that each "KEY" will start at 0 for each value of pt.
Dimension-
Line 19: DIMENSION BY ( 0 AS KEY )
This is necessary for the refrences max_key[0], and min_key[0] to work.
Measures-
Line 21: 0 AS m_1
A space holder for new values.
Line 22: TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key
The result is '1' for '1:5'.
Line 23: TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key
The result is '5' for '1:5'.
Rules-
Line 26: UPSERT
This makes it possible for new rows to be created.
Line 27: ITERATE (100000) UNTIL ( ITERATION_NUMBER = max_key[0] - min_key[0] )
This reads ITERATE 100000 times or UNTIL the ITERATION_NUMBER = max_key[0] - min_key[0]
which would be 4 for '1:5', but since the ITERATION_NUMBER starts at 0, whatever follows
is repaeted 5 times.
Line 29: m_1[ITERATION_NUMBER] = min_key[0] + ITERATION_NUMBER
m_1[ITERATION_NUMBER] means m_1[Value of Dimension KEY].
Thus for each row of KEY the m_1 is min_key[0] + ITERATION_NUMBER.
Reference: http://www.sqlsnippets.com/en/topic-11663.html
Objective: Expand a range using FOR
WITH t AS
(SELECT '2:4' pt
FROM DUAL
UNION ALL
SELECT '6:9' pt
FROM DUAL)
, base AS
SELECT pt AS code_expression
, KEY AS code
, min_key
, max_key
, my_increment
, m_1
FROM t
MODEL
PARTITION BY (pt)
DIMENSION BY ( CAST(0 AS NUMBER) AS KEY )
MEASURES (
CAST(NULL AS CHAR) AS m_1,
TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key,
TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key,
.1 AS my_increment
RULES
-- UPSERT
m_1[FOR KEY FROM min_key[0] TO max_key[0] INCREMENT 1] = 'Y'
ORDER BY pt, KEY, m_1
SELECT code_expression, code
FROM base
WHERE m_1 = 'Y'
Explanation:
Line numbers are based on the assupmtion that "WITH t AS" starts at line 5.
If you need detailed information regarding the MODEL clause please refer to
the Refrence site stated above or read some documentation.
Partition-
Line 21: PARTITION BY (pt)
This will make sure that each "KEY" will start at 0 for each value of pt.
Dimension-
Line 22: DIMENSION BY ( 0 AS KEY )
This is necessary for the refrences max_key[0], and min_key[0] to work.
Measures-
Line 24: CAST(NULL AS CHAR) AS m_1
A space holder for results.
Line 25: TO_NUMBER(SUBSTR(pt, 1, INSTR(pt, ':') - 1)) AS min_key
The result is '1' for '1:5'.
Line 26: TO_NUMBER(SUBSTR(pt, INSTR(pt, ':') + 1)) AS max_key
The result is '5' for '1:5'.
Line 27: .1 AS my_increment
The INCREMENT I would like to use.
Rules-
Line 30: UPSERT
This makes it possible for new rows to be created.
However seems like it is not necessary.
Line 32: m_1[FOR KEY FROM min_key[0] TO max_key[0] INCREMENT 1] = 'Y'
Where the KE value is between min_key[0] and max_key[0] set the value of m_1 to 'Y'
*/Of course, you can accomplish the same thing without MODEL using an Integer Series Generator like this.
create table t ( min_val number, max_val number, increment_size number );
insert into t values ( 2, 3, 0.1 );
insert into t values ( 1.02, 1.08, 0.02 );
commit;
create table integer_table as
select rownum - 1 as n from all_objects where rownum <= 100 ;
select
min_val ,
increment_size ,
min_val + (increment_size * n) as val
from t, integer_table
where
n between 0 and ((max_val - min_val)/increment_size)
order by 3
MIN_VAL INCREMENT_SIZE VAL
1.02 .02 1.02
1.02 .02 1.04
1.02 .02 1.06
1.02 .02 1.08
2 .1 2
2 .1 2.1
2 .1 2.2
2 .1 2.3
2 .1 2.4
2 .1 2.5
2 .1 2.6
2 .1 2.7
2 .1 2.8
2 .1 2.9
2 .1 3
15 rows selected.--
Joe Fuda
http://www.sqlsnippets.com/ -
More binding params in ViewLink assoc clause in 10g (10.1.2)
I'm using a ViewLink with assoc. clause which uses more times 1 binding parameter. The expression :1 ... is taken as a question mark (?) and when is used more times, the next attribute is required. Also, it doesn't care the number used behind the colon (:).
The numbers behind the colon were resolved in 9i and ViewLinks with clauses like:
key in (select fk1 from rel1 where fk1=:1 union select fk2 from rel2 where fk2=:1)worked properly.
Is there any way to use this feature as before?
Thanks for any suggestions.My first thought is that you suggest the app server to database connection is timing out - I'm assuming you're not using the load balancer to balance sqlnet connections so are we actually talking about a firewall in between and not the Big IP?
If it is the load balancer then, looking at this another way... on Cisco CSS 11500 series you can definitely set the timeout on the load balancer to a specific value (or to never timeout), so you can probably do the same on the Big IP.
Note: I wouldn't recommend setting the connections to never timeout as this can potentially waste memory on your load balancers which might look like a memory leak after, say, 6 months in a production environment without a reboot.
Hope this helps. -
More binding params in ViewLink assoc clause in 10g
I'm using a ViewLink with assoc. clause which uses more times 1 binding parameter. The expression :1 ... is taken as a question mark ? and when is used more times, the next attribute is required. Also, it doesn't care the number used behind the colon (:).
The numbers behind the colon were resolved in 9i and ViewLinks with clauses like:key in (select fk1 from rel1 where fk1=:1 union select fk2 from rel2 where fk2=:1)worked properly.
Is there any way to use this feature as before?
Thanks for any suggestions.I'm using a ViewLink with assoc. clause which uses more times 1 binding parameter. The expression :1 ... is taken as a question mark ? and when is used more times, the next attribute is required. Also, it doesn't care the number used behind the colon (:).
The numbers behind the colon were resolved in 9i and ViewLinks with clauses like:key in (select fk1 from rel1 where fk1=:1 union select fk2 from rel2 where fk2=:1)worked properly.
Is there any way to use this feature as before?
Thanks for any suggestions. -
Using Interactive Report with SQL query accessing tables via db link
Is there a known issue with using the interactive report in version 3.1.2.00.02 with SQL that is accessing tables via a database link? I get the error 'not all variables bound', I do not get this error when using the standard report for the same SQL?
Thanks,
Edited by: [email protected] on May 26, 2009 2:59 PMVarad,
Good question, failed to check that. In fact there are errors. Dump file c:\oraclexe\app\oracle\admin\xe\bdump\xe_s002_3640.trc
Mon Jun 15 08:48:11 2009
ORACLE V10.2.0.1.0 - Production vsnsta=0
vsnsql=14 vsnxtr=3
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Windows XP Version V5.1 Service Pack 3
CPU : 2 - type 586, 1 Physical Cores
Process Affinity : 0x00000000
Memory (Avail/Total): Ph:1051M/2038M, Ph+PgF:2273M/3934M, VA:1302M/2047M
Instance name: xe
Redo thread mounted by this instance: 1
Oracle process number: 16
Windows thread id: 3640, image: ORACLE.EXE (S002)
*** ACTION NAME:(PAGE 2) 2009-06-15 08:48:11.743
*** MODULE NAME:(APEX:APPLICATION 112) 2009-06-15 08:48:11.743
*** SERVICE NAME:(SYS$USERS) 2009-06-15 08:48:11.743
*** CLIENT ID:(ADMIN:232384011651572) 2009-06-15 08:48:11.743
*** SESSION ID:(24.931) 2009-06-15 08:48:11.743
*** 2009-06-15 08:48:11.743
ksedmp: internal or fatal error
ORA-07445: exception encountered: core dump [ACCESS_VIOLATION] [_LdiDateFromArray+55] [PC:0x608B04F3] [ADDR:0x0] [UNABLE_TO_WRITE] []
Current SQL statement for this session:
select Stage,Procedure,Stp,FW,Reslt,MSG,date_run
from bi_msg_VW@dwitnm
order by 1
----- PL/SQL Call Stack -----
object line object
handle number name
2FE1EA14 1207 package body SYS.DBMS_SYS_SQL
2FE1F064 328 package body SYS.DBMS_SQL
2ABDC520 5097 package body APEX_030200.WWV_RENDER_REPORT3
2BD5E55C 1538 package body APEX_030200.WWV_FLOW_DISP_PAGE_PLUGS
2BD5E55C 366 package body APEX_030200.WWV_FLOW_DISP_PAGE_PLUGS
335BDA88 11190 package body APEX_030200.WWV_FLOW
2BDBD1C8 255 procedure APEX_030200.F
2AB58D10 30 anonymous block
----- Call Stack Trace -----
I didn't include the call stack, it is too large. Now I'm even more puzzled that the IR would work while a sql report would fail.
Bob -
How to use lexical parameters with Sql Server Stored Procedure?
Hi,
I'm developing a BI Publisher report on a sql server database. I need to execute a stored procedure to dynamically build the query by replacing the lexical parameters with the values of varaibles of the stored procedure. With Oracle stored procedures, I have used data template and had reference the varaiable in SP by prefixing it with '&'.
It doesn't work if I try to do the same thing with SQL server. Is there anyone who has come across the similar situation? Please let me know if anyone has got any ideas...
Thanks in Advance
RagTopLink currently doesn't support multiple ResultSets. Multiple ResultSets support is considered for a future release.
-
Use of PVKConverter with SQL Server 2012 SP2
I am trying to convert a certificate that was exported from our database server to be used by SQL Server for database encryption. When I run the PVKConverter, not Private Key File (PVK) is generated.
The certificate has Server and Client Authentication as the purposes of the certificate.
What purpose or purposes does the certificate need in order to be able to be used by SQL Server 2012 SP2?
Why doesn't the PVKConverter generate a private key file?
I can use the command makecerts to generate a self signed certificate and have it work with SQL Server database encryption.
Thanks.
DJHi DJ,
Based on my research, SQL Server supports the importing of existing security certificates, specified as a pair of files that are encoded in PVK/DER format. Below Transact-SQL script displays the basic key file format for SQL Server database encryption.
CREATE CERTIFICATE <Certificate name>
FROM FILE = '<PVK/DER format file>.cer'
WITH PRIVATE KEY (FILE = '<PVK/DER format file>.pvk',
DECRYPTION BY PASSWORD = '<Encryption password>');
According to your description, PVKConverter doesn’t generate a private key file. PVKConverter is used to generate PVK/DER encoded security certificates from existing PFX encoded security certificates. Thus, please ensure that your certificate is encoded in
PFX format and make sure you perform all the steps properly as described in the
KB article.
There is also a related blog for your reference.
http://blogs.msdn.com/b/sql_pfe_blog/archive/2014/02/04/generating-a-trusted-tde-certificate-in-the-proper-format-from-a-certificate-authority.aspx
Thanks,
Lydia Zhang
Lydia Zhang
TechNet Community Support
Maybe you are looking for
-
Schedule background job without broadcasting
Hi Can anyone share with me how to achieve to schedule the query in background without broadcasting? Thus, the output result from background has to be in Excel format just like BEX report. Regards KR
-
Dear Community, During the "engineer to relational model" from the logical model I got a long time the correct behaviour. Now I get the following error in the log file: "ERROR FWDEngineering - FWDEngineering.execute()" NullpointerException The model
-
Can I delete an album in iPhoto?
Can I delte an album from iPhoto?
-
How can I change the mouse pad scrolling option?
I am sure before my recent upgrade it was the opposite way round for scrolling I have OS X 10.9.4
-
Will FCP X export to Flash?
I've been an Adobe Premiere user all this time and am finally ready to throw in the towel and losing about 6 hrs worth of work due to a corruption with my project file. With the new release of FCP X, I need to verify whether it (or Compressor) can ex