SQL LIKE statement to text field fomr CF MX 6.1
Hi.
Here's my scenario. I am running SQL Server 2000 SP4 on a
Windows 2003 Server running IIS 6. Using ColdFusion MX 6.1 Updater
version.
I am storing HTML page code (some complete, some just clips)
in a text type field.
I need to check to see if someone has already saved that
exact code already before. So I do the following query:
<cfquery name="checkforexisting"
datasource="mydatasource">
SELECT smallfieldtogetareturn
FROM MyTable
WHERE MyTextField LIKE '%#mystringoflongdata#%'
</cfquery>
Then to see if it posted:
<cfif checkforexisting.RecordCount GT 0>
do the don't clip optional processing
</cfif>
What is killing me is that it finds the match SOMETIMES. Just
not ALL the time. I have tried no percent signs when passing the
ColdFusion variable, only one on the right (which has solved these
types of problems before).
If I pull the record back OUT of the database in a page by
itself (retrieving it by key field), it finds every other copy of
the code EVERY time.
I have put this into a stored procedure, which seemed to help
I even have resorted to creating a temp table first with the
clip, then running a query to retrieve the record that was just put
in, and comparing THAT to my primary table (both have text type
fields). The reason for this, is that if I write a single page that
has just the retrieval of the temp record, and that compare is run,
it finds EVERY copy of it in the primary table. I also thought that
maybe there was a strong problem (I had tried HTMLEditFormat,
HTMLCodeFormat, JavaCast since it was coming from a java program on
the browser end).
I am not terribly familiar with using large text fields, or
dealing with these large pieces of HTML code as something to
compare!
- Mike
MichaelSJudd wrote:
As Dan indicated your most likely issue is slight differences
in
capitalization and|or white space or other 'invisible'
difference
between your strings. One can have nearly infinite variety in
HTML code
that will display identically in a browser, the standard is
very
forgiving of formatting differences.
Something I have done in the past to compare HTML content is
to use the
hash() function. It will not help you eliminate the
differences but it
would show when something is different then it appears to be.
#hash(mystringoflongdata)# will return a hexadecimal number
representing
the string. Two *exactly* the same strings will produce the
same
number. Then it is very easy to compare these numbers to see
if two
long strings are the same.
To use this with your database data, you would probably have
to store
the hash value of the string in a field when you store the
HTML data.
HTH
Ian
Similar Messages
-
PL/SQL Function source of text field
I have the following code as a PL/SQL function body as the source of a text item. There is a group_options table that specifies if the user group selected has fixed pricing or
can key in a price. For the fixed price groups, I was wanting to have the text field auto-populate and for the nonfixed price groups, I just wanted an empty text field for them to key in the price. The check boxes on the page for purchasing an item or leasing an item determine which table the pricing comes from. I don't get an error message, but there is something APEX doesn't like about the code below because I get the 'page cannot be found' message. Do you see a problem with the code below? Last week, it would not work and then mysteriously started to work. Today, it started out not working, so there has to be something flakey about it.
Thank you in advance.
Kelly
DECLARE
vfixed NUMBER;
vpurprice NUMBER;
vleasprice NUMBER;
BEGIN
SELECT FIXED_PRICE INTO vfixed FROM UPSL_DEV.GROUP_OPTIONS WHERE USER_GROUP =
:P7_GROUP ;
IF vfixed = 1 and :P9_PURCHASE = 1 THEN
SELECT PURCHASE_PRICE INTO vpurprice FROM UPSL_DEV.PRICE_GRID g WHERE g.user_GROUP = :P7_GROUP and g.equip_code =:P9_ITEMCODE ;
return vpurprice;
ELSIF vfixed = 0 and :P9_PURCHASE = 1 THEN
return NULL;
END if;
IF vfixed = 1 and :P9_LEASE = 1 THEN
SELECT MIN into vleasprice from UPSL_DEV.PRICE_GRID_LEASE l WHERE l.equip_code = :P9_ITEMCODE AND l.user_group = :P7_GROUP and l.term = :P9_LEASETERM;
RETURN vleasprice;
ELSIF vfixed = 0 and :P9_LEASE = 1 then
RETURN NULL;
END if;
END;Put a "return null;" statement at the end of the block to allow for your logic not covering all cases. It may presently be getting a "function returned without value" error that is inconveniently suppressed in the page output.
Just a guess.
Scott -
Complex query using 'sql like' statement.
Given the following basic class structure.
public class Project {
private String name;
private Architecture architecture;
private Resources resources;
public Architecture getArchitecture();
public void setArchitecture(Architecture architecture);
public Resources getResources();
public void setResources();
public String getName();
public void setName(String name);
public Architecture {
private String name;
public String getName();
public void setName(String name);
public Resources {
private String name;
public String getName();
public void setName(String name);
we want to be able to do a query like:
find all Projects where (Project.name.indexOf("a") > 0) &&
(Project.architecture.name.indexof("b") > 0)
In essence a "like" comparison across String properties of the JDO objects.
Is it supported in KODO?? Anyone tried it out? Also, is it possible to
generate SQL type query in KODO?
rgds
NKNote that this relies on a current bug in Kodo -- we should escape out the
'%' character, but we don't.
Some day, we'll fix that bug. But, before then, we will introduce a proper,
supported mechanism for finding records that have a string field that
contains some substring.
-Patrick
On 5/30/02 6:12 PM, "Andrew" <[email protected]> wrote:
Hi,
I wanted to perform a LIKE statement to get records where the partial string
existed in a field -> eg. select a where a.field LIKE "SPRING" - 2 records,
SpringSteen & MindSprings
I did it like this:
setFieldName("Spring");
String sFilter = "field.startsWith(%\" + getFieldName() + \"%)"; -
Extent anExtent = pm.getExtent(this.getClass(), true);
Query aQuery = pm.newQuery(this.getClass(), anExtent, sFilter);
return (Collection) aQuery.execute();
Hope it helps. oh, don't know about the generating sql query.
Nitin Kanani wrote:
Given the following basic class structure.
public class Project {
private String name;
private Architecture architecture;
private Resources resources;
public Architecture getArchitecture();
public void setArchitecture(Architecture architecture);
public Resources getResources();
public void setResources();
public String getName();
public void setName(String name);
public Architecture {
private String name;
public String getName();
public void setName(String name);
public Resources {
private String name;
public String getName();
public void setName(String name);
we want to be able to do a query like:
find all Projects where (Project.name.indexOf("a") > 0) &&
(Project.architecture.name.indexof("b") > 0)
In essence a "like" comparison across String properties of the JDO
objects.
Is it supported in KODO?? Anyone tried it out? Also, is it possible to
generate SQL type query in KODO?
rgds
NK
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com -
I tried to write a query in jsp page using LIKE statement. However, Apache Tomcat report back an error in the query string. I tried to run the same query style in MS Access and it works. Can someone please tell me where is the error in jsp code:
JSP Code:
sql = "SELECT tblStudent.firstName, tblStudent.lastName, tblStudent.studentID FROM tblStudent WHERE (((tblStudent.firstName) LIKE '%" + g_firstNameInput + "%')) ORDER BY tblStudent.firstName";
MS Acccess:
SELECT tblStudent.firstName, tblStudent.lastName, *
FROM tblStudent
WHERE (((tblStudent.firstName) Like '*e*'))
ORDER BY tblStudent.firstName;
PS: I tried changing from '%' to '*' already, but still does not work
ThanksDon't use JSP for SQL querries... to complicated.
1) Write a Java application that does what you want (as far as interacting with the database
2) Isolate the database access code into its own class/classes
3) Double check that you can then use those isolated classes inside a command line application
4) Adapt the code you used in 3) to use those same classes from a JSP - preferrably using Java Beans and DTOs -
SQL "LIKE" statement isn't working right -- help please!
Good day everyone,
I thought about putting this in the "SQL on Oracle" forum, but it looked like those messages were geared more toward the Oracle platform itself, so here I am. I apologize if this isn't the best forum.
I have the following SQL statement:
SELECT zzreporting_ut1
zzreporting_ut2
zzreporting_ut3
zzreporting_ut4
zzreporting_ut5
UP TO 1000 ROWS
INTO TABLE it_gmia_gmgrresp_data
FROM gmspprogram
WHERE ( ( zzreporting_ut1 LIKE '4011%' OR
zzreporting_ut1 LIKE '4012%' OR
zzreporting_ut1 LIKE '4013%' ) OR
( zzreporting_ut2 LIKE '4011%' OR
zzreporting_ut2 LIKE '4012%' OR
zzreporting_ut2 LIKE '4013%' ) OR
( zzreporting_ut3 LIKE '4011%' OR
zzreporting_ut3 LIKE '4012%' OR
zzreporting_ut3 LIKE '4013%' ) OR
( zzreporting_ut4 LIKE '4011%' OR
zzreporting_ut4 LIKE '4012%' OR
zzreporting_ut4 LIKE '4013%' ) OR
( zzreporting_ut5 LIKE '4011%' OR
zzreporting_ut5 LIKE '4012%' OR
zzreporting_ut5 LIKE '4013%' ) ).
All I want to do is bring back the rows where one of those 5 "ut" fields begins with 4011, 4012, or 4013. However, when I run it, it brings back anything: rows where all 5 "ut" fields are empty, where the ut1 field begins with 4014, etc.
Does anyone know what I'm doing wrong in my SQL statement?
Thank you! And as always, points awarded for ALL HELPFUL answers!
Dave
Edited by: Dave Packard on Jul 1, 2008 2:18 PMHi Dave,
because I don't know such a table named gmspprogram I'm not sure what to say.
According to boolean expression syntax you do not need any of the brackets because the only operator used is OR.
I'd suggest.
data: lt_pattern_range type range of gmspprogram-zzreporting_ut2.
perform insert_range using 'ICP':
'4011*' '' changing lt_pattern_range,
'4012*' '' changing lt_pattern_range,
'4013*' '' changing lt_pattern_range.
SELECT
zzreporting_ut1
zzreporting_ut2
zzreporting_ut3
zzreporting_ut4
zzreporting_ut5
UP TO 1000 ROWS
INTO CORRESPONDING FIELDS OF TABLE it_gmia_gmgrresp_data
FROM gmspprogram
WHERE zzreporting_ut1 in lt_pattern_range
OR zzreporting_ut2 in lt_pattern_range
OR zzreporting_ut3 in lt_pattern_range
OR zzreporting_ut4 in lt_pattern_range.
* need form
*& Form insert_range
* insert selection range - handles any range type "CLI20061218
FORM insert_range USING p_signopt TYPE c "#EC CALLED
p_low TYPE any
p_high TYPE any
CHANGING pt_range TYPE table.
FIELD-SYMBOLS:
<range> TYPE ANY,
<sign> TYPE ANY,
<option> TYPE ANY,
<low> TYPE ANY,
<high> TYPE ANY.
DATA:
lv_ref TYPE REF TO data.
CHECK NOT (
p_low IS INITIAL AND
p_high IS INITIAL ).
CREATE DATA lv_ref LIKE LINE OF pt_range.
ASSIGN lv_ref->* TO <range>.
CHECK sy-subrc = 0.
ASSIGN COMPONENT 'SIGN' OF STRUCTURE <range> TO <sign>.
CHECK sy-subrc = 0.
ASSIGN COMPONENT 'OPTION' OF STRUCTURE <range> TO <option>.
CHECK sy-subrc = 0.
ASSIGN COMPONENT 'LOW' OF STRUCTURE <range> TO <low>.
CHECK sy-subrc = 0.
ASSIGN COMPONENT 'HIGH' OF STRUCTURE <range> TO <high>.
CHECK sy-subrc = 0.
<sign> = p_signopt(1).
<option> = p_signopt+1(2).
<low> = p_low.
<high> = p_high.
READ TABLE pt_range WITH KEY table_line = <range> BINARY SEARCH
TRANSPORTING NO FIELDS.
CHECK sy-subrc <> 0.
INSERT <range> INTO pt_range INDEX sy-tabix.
ENDFORM. " insert_range
At least - I think - this looks better. And you may reuse the FORM insert_range whereever you want.
Regards,
Clemens -
how can i get all records starting with % ?
Something that I found here (
SQL Tutorial) might
help:
The optional ESCAPE sub-clause specifies an escape character for
the pattern, allowing the pattern to use '%' and '_' (and the
escape character) for matching. The ESCAPE value must be a single
character string. In the pattern, the ESCAPE character precedes any
character to be escaped.
For example, to match a string ending with '%', use:
x LIKE '%/%' ESCAPE '/'
..or here
Using
SQL Escape Sequences
... or here
How
to escape a wildcard in an SQL order with ORACLE.
Phil -
Hi all,
I want to select all values from prps-usr00 where the field contains XXX-XXXX...where X is any letter or number. How in the world do I do that?
Thanks,
MatHi,
SELECT SOMETHING INTO VARIABLE FROM TABLE
WHERE PARAM1 LIKE '%-%'.
Or
If you know that there will be exactly 2 char in front of '-' and 2 char after. then use.
SELECT SOMETHING INTO VARIABLE FROM TABLE
WHERE PARAM1 LIKE '__-__'.
Regards
madhu
Edited by: madhu tatikonda on Jun 27, 2008 9:08 PM -
SQL Server 7 (n)text field
Hi there,
I was wondering what resultset method you use when you wish to retrieve information from the data type text (and ntext) datatype fields.
Because this is a pointer, I can not use .getString()...unless there is something I am missing.
In case it matters, this is using NetBeans and Java Server Pages.
Cheers,
JohnWhy you can't use getString()? This should be work.
Which driver do you use?
Volker -
Error converting SQL Server text field to Oracle CLOB
I am trying to convert an SQL Server DB to Oracle DB using DB link. The issue I am facing is one of the SQL Server table contains text field and we are trying to convert the text field to CLOB.
The error I am getting is "SQL Error: ORA-00997: illegal use of LONG datatype"
The statement is something like this.
Insert into oracle_table
Select col_1,col_2,col_3,col_4,col_5 from sql_table@sqldblink;
Please help.Hi,
This is a known restriction involving long columns -
(1) LONG datatype not supported with use of DBLINK when insert or update involves a select statement
(2) LONG datatype cannot be used in a WHERE clause, in INSERT into ... SELECT ... FROM
constructs, and in snapshots.
The workround is to use a PL/SQL procedure or try the SQLPLUS COPY command.
If you have access to My Oracle Support then review these notes -
Cannot Move A Long From non Oracle database Ora-00997: Illegal Use Of Long Datatype (Doc ID 1246594.1)
How To Workaround Error: Ora-00997: Illegal Use Of Long Datatype (Doc ID 361716.1)
Regards,
Mike -
Adding additional text field to infotype in SQ02
Hi ,
I am trying to create an additional text filed to the infotype 0034 in a customized infoset, in Tx SQ02 as shown in the link below:
http://help.sap.com/saphelp_nw04/helpdata/en/d2/cb4468455611d189710000e8322d00/content.htm
Here the question is :
The check box "Detemine LIKE reference using text field" is grayed out and I couldn't able to check the box.
Can any one help me to resolve this and let me know what is the significance of that check box?Hi Suresh,
I tried running the query after deleting the newly added text fields to the infoset, the query is running properly with out any short dump, where as with the additional fields added it is going to short dump and the shot dump states as shown:
An exception occurred. This exception is dealt with in more detail below
. The exception, which is assigned to the class 'CX_SY_DYN_CALL_ILLEGAL_FUNC',
was neither
caught nor passed along using a RAISING clause, in the procedure "%_GET_PERNR"
"(FORM)"
Since the caller of the procedure could not have expected this exception
to occur, the running program was terminated.
The reason for the exception is:
The program "!QZZ/SAPQUERY/H2AAVULA27174228" contains a CALL FUNCTION
statement. The name
of the function module to be called is "RPAQ_GET_AF_0034".
No function module exists with the name "RPAQ_GET_AF_0034".
All function modules are stored in the Function Library (SE37).
Possible reasons:
a) Wrong name specified. Particular attention should be paid
to upper/lower case and underscores ("_")
b) Transport error
c) If an enqueue/dequeue module has been used, the lock object
may not have been activated (ABAP Dictionary)
Any help?
Best regards
Vamsi -
Cursor Comes Into Text Field then open a window with Values.
hi,
i have to create a form with some items.there are two text field item :p1_item_group and :p1_item_name.
i want to design these form like telly Form .eg in a telly form like if we want to enter state in text field and cursor come on State text field then open a window with all state name in right side and user select state from these window and state come in to text field.
So i want to this type of action on p1_item_group when cursor come in to this item p1_item_group then quickly open a window with all item group name.
MY table is
CREATE TABLE "ITEM_GROUP_DETAILS"
( "S_NO" NUMBER,
"ITEM_GROUP" VARCHAR2(500),
CONSTRAINT "ITEM_GROUP_DETAILS_CON" PRIMARY KEY ("S_NO") ENABLE
insert into ITEM_GROUP_DETAILS values(1,'A');
insert into ITEM_GROUP_DETAILS values(2,'B');
insert into ITEM_GROUP_DETAILS values(3,'C');
insert into ITEM_GROUP_DETAILS values(4,'D');
I want When Cursor Comes in to p1_item_group text Field Then Open a window with
A
B
C
D
Item Group List.
How can i do this.
Thanks
MANOJ KAUSHIKhi manoj,
you can write onFocus event on your textbox from which you want to call a pop up window
write a javascript function and call it onFocus event of textbox. In that function call a new popup page using window.open function.
on that page you will have a values as you mentioned eg A,B,D etc.
then user will select value from there and textbox will get that value.
regards,
Chetan -
Hi there,
I have a (probably) easy question to answer for a programming newbie.
I have a radio button - it says are you left or right handed - so two options: left and right - I have also changed their values from 0 and 1 to left and right. I've called the object name: 'handed' and set it to global data
On another part of the form I would like an uneditable text field that says: this person is ... handed
...so in other words there's a gap where I want the text to say 'left' or 'right' - I've also given this field the name 'handed'.
It almost works, but instead of showing the name I get the value (ie. 0 or 1) - can anyone help me to change the value into the text?
Many thanks,
Sunil
I'm using ES4 by the way.Hi again,
well, I don't know what I did wrong before, but this time round I changed the values from 0 and 1 to right and left and lo and behold it worked - so didn't need to resort to coding for this one.
However, before doing that I tried what you said above but couldn't get it to work - am I missing syntax here - not sure. Also, wasn't sure when the calculate event would happen. Ie. is it instantaneous with when the user clicks on the radio button to make the selection, or does the event need to be triggered somehow - eg. using a button on click etc.?
Thanks for your help though - much appreciated.
Sunil -
How to give for a text field 'max+1' value instead of sequence .
HI All,
I have a requirement like ,
For my text field i applied sequence by using groovy expression.Now i need to change that to 'max+' value of table Grid and display in the text field. Can please suggest me how can i implement .(JDev 11.1.1.3 v)
Regards,
Sindhu.hi user,
if you want perform some increment operation . in auto means. donot prefer these thread given below..
there is lot thread of for creating sequence. based on the sequence it works perfect.
if i understud correctly means follow this
Increment operation // it perfoms some increment operation. not using sequennce.
button press
compliation problem // have a look at this
if cumes under cirumstance for multiple user on that scree or ui . probabaly this idea(max)or (some increment) will fails.
i i will prefer sequqnecs._
IN ADDITION INFO TO USER
JOHN SAYIGN EXACTLY
Edited by: Erp on Sep 25, 2011 9:46 PM -
Ad hoc query text field reference
Hi all,
Faily new to all this and wonder if you have any insight on the following:
In ad hoc query I'm adding additional fields to a functional area. They subsequently show up in SQ02 in the left hand pane tree structure for that functional area.
Now, if I double click on one of the additional fields the most central pane shows the details of this field. One of the boxes in there called 'References' contains a field 'Text field' that associates a long text with the code that the field contains.
As a made-up example: the add. field could be Personnel Area, value "XY01", and it is associated with a field Personnel Area Long Text that contains "Xeta Yoyo Regional Office". This is the association shown in 'References' -> 'Text Field'.
My problem is that this 'Text field' field seems to be populated automatically, that is there is some kind of automatic link between the field and the foreign field that contains its associated long text. Also it's greyed out so un-editable.
Does anyone know where this relationship comes from? Does anyone know how to be able to edit this 'Text field' field?
Grateful for help,
RichieOk, I'll try to be a bit clearer.
For infosets in Ad Hoc Query, a field has an option to be related to another, different field that provides the long text version of this. Example: field P1000-OTYPE 'object type' is related to T7770-OTEXT 'object type text'.
This relationship is displayed for each infoset additional field: right click on the add. field -> display/change definition, text identification -> 'Determine LIKE reference using text field' in the pop up window.
Problem is this text field is <b>always</b> greyed out and uneditable. So the question was, how do you set this yourself?
Hope this clarifies stuff, thanks for any help,
Richie -
I am working on an iBooks Author Widget and want to allow the user to switch between drawing-pad functions and a text field on screen. I'd like to create an action that will automatically re-order the layers so that the text field is accessible when typing but covered when writing by hand. Then, I'd like the opposite to be available, so that the text field is accessible when typing, but the drawing pad is left alone.
Have you tried using the selections in the Encore menu viewer that show you selected and activated states?
Maybe you are looking for
-
This makes no sense - Can't switch phone?
There's a bit of history behind this so to get proper context here's what has happened so far 1) After 14 months, my original moto droid died so VZW sent me a replacement pre-owned....that didn't work. They then sent another one.....that also didn't
-
Hi all, I have developed a webdynpro application. Now my requirement is that i would like to send the URL of this application through an email to the user and then the user can run the application from there when he clicks on the URL/Link. Any soluti
-
Update the software but not configration
Dear sir/madam i am using i phone 3gs,i will do this software update i.s.o. 6.1.6 finish it but mobile not configuration what reason please tell me
-
Nik Color Effex Pro 4 will not work iin Photoshopcc after being sent from Lightroom . Help
When I transfer Nik Color Effex Pro 4 from Lightroom into PScc, I ran work the program but cannot save it back into Lightroom. The Nik people have given me 4 updates which they thought will correct it but no luck. All the other software from Nik wor
-
Do you have to be root to run dhcpcd?
By reading the wiki, I found out that I can connect to my school's wireless as follows: ifconfig wlan0 up iwconfig wlan0 essid GTwireless key (...) dhcpcd wlan0 I then wrote a script containing #!/bin/bash and those three commands. It may not be the