Searching for numeric values in a text field / SQL Server
Hi all,
here's a problem that I've been trying to solve for several days: I try to select rows from an MS SQL Server via JDBC that contain a certain numeric value at a certain position in a long varchar field.
I'm using queries like
select * from table where substring(field_1, 37, 7) like '1011234';Those queries always return an empty ResultSet. If I use the same queries in WinSQL, I get correct results (several rows).
The application code is working in principle; if I search for a text instead of a numeric value, for example select * from table where substring(field_1, 4, 5) like 'Paper'; , I get a complete ResultSet.
I've tried many variations (= instead of like, search in the entire field (without substring but with like '%1011234%'), with or without ', and more), but that didn't change anything.
It's also most probably not caused by the JDBC driver; I have tried JTDS first, and then the MS driver (newest versions) - no difference.
One idea was that the sort order is not correct, tried some COLLATE settings, but that didn't help so far. In this context I'd like to know how to determine the collation sequence of a certain column.
Another thing I tried was using CAST, for example SELECT * FROM table WHERE CAST(SUBSTRING(field_1, 37, 7) as bigint) = CAST('1011234' as bigint); or SELECT * FROM table WHERE CAST(SUBSTRING(field_1, 37, 7) as bigint) = CAST(1011234 as bigint);, but that didn't help either.
Some facts:
Server: Microsoft SQL Server, version 09.00.2047
Driver in WinSQL: SQLSRV32.DLL, version 03.85.1117
JDBC-Driver:
- JTDS, version 1.2
- Microsoft SQL Server 2005 JDBC Driver, Version 1.2
JVM: jre1.5.0_11
I didn't find anything on Google, or in this forum, or other forums. I really hope someone here can help me. Thanks in advance!
Best regards,
Uica
Your note suggests to me that this is a coding problem, not a JDBC or SQL problem unless you are hitting a bug in the SQL Server JDBC driver. Others may have ideas from what you have written, but I think it would be helpful to see the actual code that you are executing that does not bring back the results that you are expecting (don't forgot to use code tags to format your code correctly).
It might also be helpful to execute a query (from within your Java code) to ensure that you are connecting to the right database, accessing the correct table and that your substring is using the correct offset. The query would look something like this (and then of course display the list of results):
SELECT substring(field_1, 37, 7) from table
Similar Messages
-
Search for a space within a text field
Hi All
I am trying to search for a sapce within a text field but sofar not being very successful. I have used:
FIND search_str
IN text_str
MATCH COUNT lv_mcnt
MATCH OFFSET lv_moff.
where search_str = TYPE c VALUE ' '.
I am looking a way of searching a character within the string using ABAP (like INSTRING in other languages). If you have similiar codes - Could you please post me a copy - ThanksHI
Check this..
DATA string7(30) TYPE c VALUE 'This is a little sentence.'.
WRITE: / 'Searched', 'SY-SUBRC', 'SY-FDPOS'.
ULINE /1(26).
SEARCH string7 FOR 'X'.
WRITE: / 'X', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR 'itt '.
WRITE: / 'itt ', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR '.e .'.
WRITE: / '.e .', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR '*e'.
WRITE: / '*e ', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR 's*'.
WRITE: / 's* ', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
Thanks ,
Praveen -
Wildcard search for numeric values using select ?
Hi,
I want do wildcard search for numeric fields of the table.
For charcter/string i have used - select * from XX_TABLE where param1 like 'SS%'. But this query doesnt work when para1 is numeric. Please let me know first whether this is possible ? if yes how to achieve it ?
Thanks in advance,
ShrinivasHi Jack,
The numeric field is of 8 digits, so when i give search critera as '66', it should return values 66000000, 660000, 6600 etc. so i was not able to give between some range. I also tried storing all these values in internal table and the segregate the values it contains '66*'. This worked well but requires lot of coding effort.Please suggest if you guys have any better method ?
Thanks,
Shrinivas -
How can I validate numeric values in a text field?
Hi
Once more I have a problem.
I have a field in which the user should enter 10 digits in the pattern 999999-9999. The field must only contain numeric data and must be exactly 10 characters. I have a validation script on the print button, that prevent printing if required fields are empty or not properly filled out.
I have tried two ways to work this out, and I'm not satisfied with any of them, as I can still print despite of validation scripts and warning messages.
1.
I set the field to numeric, limited to 11 characters.
Display pattern num{999999-9999}, edit pattern num{999999-9999} and validation pattern num{999999-9999}
Problems using this solution: When I type 11 digits in the field (ex.12345612345) I get a warning message and 12.345.612.
But when I type 9 digts (ex. 123456-123 or 123456123) I get no warning message and 000000-0000 or 012345-6123
If I type alphabetical characters (ex. 123456-abcd) I get no warning message and 000000-0000.
2.
I set the field to text field, limited to 11 characters.
Display pattern text{999999-9999}, edit pattern text{999999-9999} and validation pattern text{999999-9999}
Now when I type 11 digits in the field (ex.12345612345) I get no warning message and 12345612345.
When I type 9 digts (ex. 123456-123) I get no warning message and 123456-123
When I type 9 digts (ex. 123456123) I get a warning message and 123456123
If I type alphabetical characters (ex. 123456-abcd) I get a warning message and 123456-abcd.
It works slightly better as a text field, but I am not satisfied at all.
Has anyone a solution to this?
Additional I would also like the hyphen to emerge automatically when typing.
KI just want to summarize my experience.
I found a related discussion here: http://forums.adobe.com/message/2513720#2513720.
Putting the pieces together I came up with this solution.
form1.subform.TextField1::exit - (JavaScript, client)
var
myRegex = /\d{6}\-\d{4}/;
var
singleDigits = [0,1,2,3,4,5,6,7,8,9]; // array for single digit check
if
(this.rawValue != null || this.rawValue != ''){ // only if the field has a value...
if (!this.rawValue.match(myRegex)){ // and it doesnt match the pattern (i.e. 2 digits)
this.rawValue
= ''; // clear the field
xfa.host.setFocus(
this); // set focus back to the field
xfa.host.messageBox('Error: Pattern Conflict. Please use the pattern 999999-9999.');
// enter any message you wish here
Kirstine -
Search for multiple items in one text field
Hi all,
I am new to ApEx, I have a request from one of our users to ask if there is a way we can allow them to enter more than one search items delimited by a comma. For instance, we have a text item field for user to enter some values as emp names, when he key in like PETER,SMITH,ALLEN,WARD, once he submit the page he will see the result as:
select t.empno, t.ename, t.job, t.mgr, t.hiredate, t.sal
from scott.emp t
where t.ename in('PETER','SMITH','ALLEN','WARD')
Many thanks.
Message was edited by:
lcpxYou can create a multiselect list named P1_REPORT_SEARCH based on a List of Values (LOV) with those employee names and use this code.
select t.empno, t.ename, t.job, t.mgr, t.hiredate, t.sal
from emp t
where
(instr(':'||:P1_REPORT_SEARCH ||':',':'||ENAME||':') > 0 or :P1_REPORT_SEARCH is null) /**for multiselect**/
) -
Search and Replace values in the text field before values are stored to DB
Hi,
In my application there is a question - text area and answer - text field. Problem is, some answers are stored with the single quotes to the DB and I have a problem while retrieving it from the DB. I need to replace the 1 single quotes with 2 single quotes. The values are stored to the DB when the submit button is clicked.
So I am using the following javascript code:
italics
<script type="text/javascript">
function test()
var str="&P2_S1.";
document.write(escape(str));
</script>
italics
I need to call this javascript function, when the submit button is clicked but BEFORE the values are stored to the DB. How can i get this done?
Please let me know.Hi,
Thanks for the reply.
Yeah I planned to drop the Javascript idea.
Now, I am using the PL/SQL code. This is what I am planning to do.
When the user enters any word like this, Test's, this single quote should be replaced by some special character, #@@#, - what is the PL/SQL code for this?
Right now my PL/SQL code is:
begin
update test set S1=:P2_S1 where name=:APP_USER;
end;
so the replacing part should come somewhere before the update statement.... how can I do it?
from the DB when the values are retrieved, I use the following code:
select REPLACE(s1,'''','') from test where NAME=:APP_USER; // this works fine.
Please help me with the replace of the single quote before the update process... -
I need to get the value of a text field that is located in another page JSP
I need to get the value of a text field that is located in another page JSP. How do I do that?
Well you see, I have a page at angelfire.com, which
does not support JSP. I want to call a script located
at mycgisever and then, when pressing a link on the
former page, the JSP page is loaded, and the script
get the value from the text field on the OTHER page.
Is this possible?I know nothing about cgi. But that should not prevent me from understanding what can and cannot be done, assuming cgi is sort of comparable with jsps.
I'm unable to understand your description clearly. Try to explain it better. Give precise steps that you intend to follow and I should be able to help you further.
So you have a page1.
You hit submit from page1.
That goes to the cgiserver.
From the cgiserver, programmatically load up the jsp.
search this for the text field.
Display it on your page2.
Is that what you are trying to do?
BTW, won't be able to help you with cgi scripting at all. Can help with Java and Jsp. -
How can I limit numeric codes in a text field?
How can I limit numeric codes in a text field? For example I want to list Industry SIC codes and I want to block someone from inputting an exlcuded industry code.
We don't offer that type of input restriction for a text field.
Can you create a list of all allowed codes and use a Drop Down menu or Single/multiple Choice field?
Thanks,
Josh -
How to restrict the user to enter only numeric values in a input field
How to restrict the user to enter only numeric values in a input field.
For example,
i have an input field in that i would like to enter
only numeric values. no special characters,alphabets .
reply ASAPHi Venuthurupalli,
As valery has said once you select the value to be of type integer,once you perform an action it will be validated and error message that non numeric characters are there will be shown. If you want to set additional constraints like max value, min value etc you can use simple types for it.
On the project structure on left hand side under local dictionary ->datatypes->simple types create a simple type of type integer
The attribute which you are binding to value property ;make its type as simple type which you made
Hope this helps you
Regards
Rohit -
Display comma for numeric values
Hi,
I want to display comma for numeric values.I know we can use strlen and concatenate, but any one can give me an example.
Ex: 1,234 and 12,234 , 1,22,500 ( iam expecting)
Thanks,
Veeruit depends on ur data...
if it is currency then u can use
WRITE.... CURRENCY...
if it is qty then u can use
WRITE....UNIT....
or u simply pass it to a packed field and it will take the default decimal settings of the user profile...
Reward points if helpful -
How to search for a value in an iterator in Jdev 10.1.2?
Hi!
I need to search an iterator named "PermitYrIterator1" for a year value (e.g. 2009) that is stored in bindings.Yr in my jsp. How do I do this in my jsp's DataForwardAction Code) in Jdev 10.1.2?
I need this in my "Create page." I need to search for this value because I want to check if I should re-execute the "PermitYrIterator1" so that it shows the newly added year in bindings.Yr or not. If bindings.Yr is found in the iterator then I do not need to re-execute the iterator. But if the newly entered year cannot be found then I need to re-execute the iterator.
I hope you can help me immediately! Thanks!Hi,
Anyone can help me on this please? -
How to search for multiple values with Bex Prompts
Hi,
I would like to know if it is possible to search for multiple values at the same time with Bex Prompts instead of searching one value at a time (please see the screen shot below). I searched the forum couldn't find any relevant answers. please let me know how to achieve?
Thanks,
Charvi.Hi Charvi,
You can use wild card search to ensure you get multiple similar values listed as search output.use * for multiple characters and ? for single character.
For Example, Ravi * would result you all employees with first name as Ravi
You can use various search formats such as * Ravi * and * Ravi and Ra?? etc.
Thanks
Mallik -
I can't enter any value in the Text field, after loading flash files
Hi to all,
In my Java application, I'm using a text field and a panel to load flash files. I'm using JDIC 0.9.1 to load the flash files in the panel. The flash files are created by Flash CS4.
While running the application, I can't enter any value in the Text field, after minimize and maximize the application I can enter the values.
This problem happens after change the jre version from 1.6 to 1.7.
I'm getting the following exception while running the application.
org.jdesktop.jdic.init.JdicInitException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at org.jdesktop.jdic.init.JdicManager.initBrowserNati ve(Unknown Source)
at org.jdesktop.jdic.browser.WebBrowser.<clinit>(Unkn own Source)
pls give me a solution.
Thanks in advance...:)I can't enter any values in JTextField after loading the flash files., locking.
-
Invalid text value. A text field contains invalid data. Check the value and try again
Hello,
I am having a problem with the error mentioned in the title. I see alot of others have experienced the same problem, but I have quite a twist to it.
I see the problem when I try to edit a list item, and then try to save the changes.
Here what I see in the ULS log:
System.Runtime.InteropServices.COMException: Invalid text value. A text field contains invalid data. Check the value and try again
at Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId,
Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter
pListDataValidationCallback, ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)
at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean
bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish, String bstrFileName, ISP2DSafeArrayWriter pListDataValidationCallback,
ISP2DSafeArrayWriter pRestrictInsertCallback, ISP2DSafeArrayWriter pUniqueFieldCallback)
I have 3 front end servers(fx wfe1, wfe2, wfe3). And here is the twist.
If I access the library directly through wfe1 and wfe2, I get the error. If I access the library via wfe3 if works just fine.
So because of this, I think it is safe to assume that is has nothing to do with the character limit of 255. Nor does it have anything to do with the field type, since it is already set to mulitible lines of text.
So. Any ideas?
Regards,
Michael
micCheck if there is any change in web.config of these servers
http://support.microsoft.com/kb/2880758
To work around this issue, limit the length of the personal message in the invitation to 256 characters or less.
This is a known issue. Microsoft is working to resolve this issue.
http://social.msdn.microsoft.com/Forums/en-US/7bb16e51-e7cc-439e-a8b3-755683ccac1a/max-length-on-custom-field-types
To solve the problem you may have to change the field's parent type to "note". To do that you have to open your fldtypes... file under Templates/xml and change the line to:
"<Field Name="ParentType">Note</Field>" from "<Field Name="ParentType">Text</Field>"
You might also have to add a sql type if your text needs to be longer than 255 characters
<Field Name=”SQLType”>ntext</Field>
and inherit from SPFieldMultiLineText instead of SPFieldText
If this helped you resolve your issue, please mark it Answered -
SAP Best Practices for Data Migration :repositories only on MS SQL Server ?
Hi,
I'm implementing the "SAP Best Practices for Data Migration" (see https://websmp109.sap-ag.de/bp-datamigration).
As part of the installation you have to install MS SQL Server Express Edition. The installation guide contains detailed steps to do this. All repositories for Data Services should be running on SQL Server, according to the installation guide.
The customer I'm working for now does not want to use SQL Server, but DB2, as company standard.
So I use DB2 for the local and profiler repositories.
I notice however that the web application http://localhost:8080/MigrationServices does not support DB2.The only database type you can select in the configuration area is MS SQL Server.
Is this a limitation, a by design ?Hans,
The current release of SAP Best Practices for Data Migration, v1.32, supports only MS SQL Server. The intent when developing the DM content was to quickly set up a temporary, standardized data migration environment, using tools that are available to everyone. SQL Server Express was chosen to host the repositories, because it is easy to set up and can be downloaded for free. Sone users have successfully deployed the content on Oracle XE, but as you have found, the MigrationServices web application works only with SQL Server.
The next release, including the web app, will support SQL Server and Oracle, but not DB2.
Paul
Maybe you are looking for
-
IPhone 5s isn't recognized by iTunes and shows a 'timed out' error
My iPhone 5s won't sync with iTunes, I get a 'timed out' error. Anyone know how to fix this?
-
Error when connecting to form builder
When I try to connect to form builder ,I get this error message , ORA-12154:TNS: could not resolve service name What is it?
-
BJ Printer Utility needs Classic stopped
I have a Canon i450 printer connected to my iBook G4 via USB. When I use the BJ Printer Utility to perform maintenance tasks like checking/resetting the ink level, cleaning heads, or changing printer settings, it usually doesn't work when Classic is
-
How to apply a css style to vbox.
I'd like to apply below style to vbox. But It's not changed. When I use ID property, it's changed, But I want to use class property. .v-box{ -fx-spacing:10; -fx-alignment:center; Edited by: shakddoo on 2012. 4. 20 오후 9:08 Edited by: shakddo
-
I Have office for mac home and business 2011, can you install on both users on one iMac?
I Have office for mac home and business 2011, can you install on both users on one iMac?