Prepared statement problem using a field name that contains a "?"
I am attempting to execute the following query via use of a PreparedStatement:
select [Spread_By_Cost_Center?], Debit_Category, Credit_Category, Start_Date, End_Date, Allocation_Type From ALLOCATION_FORMULA Where FormulaID = ?
The query fails with the following message:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]COUNT
field incorrect
However, I can run this query directly in MS-ACCESS, using a value for the substitution parameter (i.e., FormulaID = 1)
If I remove the "Spread_By_Cost_Center? field from the query within the PreparedStatement, the PreparedStatement query executes successfully.
So, it would appear that the "?" in the field name is possibly being treated as a substitution parameter. Is this a bug within PreparedStatement? I do not want to use a Statement object, as the PreparedStatement provides a much more elegant solution (when it works).
Any suggestions?
That may be so, but as I see it there are two alternatives:
1. Wait for the "bug" to be fixed.
2. Change the database to use less problematic column names.
I know which alternative I would choose.
Similar Messages
-
Problem using alias field names in a sql query
Hello,
I have a question regarding a simple Oracle database SQL query writeup:
In the following (badly written but properly working) SQL query:
Query 1:
select
soe.field1,
(soe.field2 + soe.field3) as field4,
(soe.field5 - (soe.field2 + soe.field3)) as field6,
(select comp.parValue*soe.field7
from
CompTable comp) as parValue,
(select soe.field8 - (comp.parValue*soe.field7+ soe.field9)
from
CompTable comp) as field10
from
SomeTable soe
PROBLEM 1:
I am re writing the code (soe.field2 + soe.field3) to get the alias field4 or column name field4 that I have created on the fly in the previously for use with the following fields. Can't I rewrite the query as follows. There is something simple missing!
Query 2:
select
soe.field1,
(soe.field2 + soe.field3) as field4,
soe.field5 - field4 as field6, <<< field4 does not work here
(select
comp.parValue*soe.field7
from
CompTable comp) as parValue,
(select
soe.field8 - (comp.parValue*soe.field7+ soe.field9)
from
CompTable comp) as field10
from
SomeTable soe
PROBLEM 2:
Similar to the above problem, I was thinking to get a field parValue out of the CompTable table and re-use many times rather than the code shown in Query 1:
Query 3:
select
soe.field1,
(soe.field2 + soe.field3) as field4,
soe.field5 - field4 as field6,
soe.field7* (select comp.parValue from CompTable comp) as parValue1,
soe.field8 - (parValue1*soe.field7+ soe.field9) as field10 <<<< parvalue1 does not work here
parValue1*soe.field9 as TaxCondition <<<< parvalue1 does not work here
from
SomeTable soe
See that the query becomes so simple, but the above query does not work. There is something fundamentally wrong in my usage of the alias field names in creating other fields. The Query1 seems to be the only working option but its very slow as I am redoing and re-writing the whole code again and again to get the parValue field out of the CompTable table for use to create many other fields.
I will appreciate if you can guide me in the right direction on this issue.
Thanks and Regards
RamaSELECT tmp.contract_no, tmp.Actual, tmp.Actual - tmp.NbHours
FROM ( SELECT t.contract_no, sum(l.hrs) AS Actual, (c.labour_hours * c.labour_progress_per) / 100 AS NbHours
FROM TASK_DELEGATION t
INNER JOIN COST_CODE c
ON t.cost_code = c.cost_code AND t.contract_no = c.contract_no AND t.is_inactive=0
INNER JOIN Labour.dbo.LABOURALLOT l
ON l.contractNo = c.contract_no AND l.costcode = c.cost_code AND l.pm = 'N'
GROUP BY t.contract_no, c.labour_hours, c.labour_progress_per
) tmp -
i already reserved app name as Ma_Test. But only one error showing "This package is using an app name that hasn't been reserved for this app: "Matest". how to solve?
Hello,
You need to make sure both names match exactly -
Error - The deployment cannot use the ReservedIP Name that belongs to a region.
hi experts,
I created a ReservedIP in North Central US. IF i deploy a project containing below config on anexisting Cloud
Service in North Central US it gives error.
<NetworkConfiguration>
<AddressAssignments>
<ReservedIPs>
<ReservedIP name="name"/>
</ReservedIPs>
</AddressAssignments>
</NetworkConfiguration>
it is throwing this error after uploading to the portal
"The deployment cannot use the ReservedIP name that belongs to a region."
But then if i try creating a new cloud service from scratch and deploying it works fine. Can you let us know what might be the issue with the old cloud service. The old Cloud service also shows North Central US
With Regards,
Amit
With Regards, AmitHi,
As far as I know, the reserved IP is belong to azure IP space, You can enable all azure services to access your database (which whitelists the whole azure IP space, essentially), if you set azure service to true, I think it is unnecessary to set allow IP
address.
Best Regards,
Jambor
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
when i open an irc link with a channel name that contains "~" at the end firefox (14.0.1) opens the same channel name but with "%7E" instead of "~" at the end
http://img835.imageshack.us/img835/2856/clipboard05nq.jpgI can not open the image, but I can say something in general about the tilde.<br>
The tilde "~" is an unreserved character and therefore it can be replaced by its percent-encoded form "%7E" inside a URI without changing meaning. See<br>
http://en.wikipedia.org/wiki/Percent-encoding<br>
According to section 2.3 of RFC3986 we should prefer the unencoded form so this behavior seems to be a bit out-dated.<br> -
To know the table names that contains changed and old PO values.
Dear All,
Please let me on the table names that contains changed PO value and old PO value details for which I'll be grateful.
Regards,
S.SureshHello,
Check the table CDHDR and CDPOS.
Cheers,
Vasanth
Edited by: Vasanth M on Feb 18, 2008 12:08 PM -
Oracle Prepared Statement and spaces in field
I have a field that is defined as char(10). It has characters like '39' in it. When I select against it using standard SQL (where clause) I get results. When I use it in the where clause of a prepared statement it does not return any rows.
If I have the field defined as char(2) the prepared statement works.
If I have the field defined as varchar2(10) and loaded with '39' the prepared statement works.
If I have the field defined as varchar2(10) and loaded with '39 ' the prepared statement returns no results.
I really do not think this is a JDBC problem. However, since Oracle's site basically <expletive deleted>, I am hoping someone here has a solution.
Thanks in advance if you can help.Let me clarify.
I cannot remove the whitespace from the data in the database. I do not need the whitespace to do the query if I am not using a Prepared Statement. This seems to be a problem with the way Oracle is handling the prepared statement. (hence.. my thinking that this is really not a JDBC problem at all.. but I could be wrong.) -
I am pulling information based on the following "If" statement;
If({JCT_CURRENT__TRANSACTION.Category} = "L"
and "cost" in {JCT_CURRENT__TRANSACTION.Transaction_Type}
and {JCT_CURRENT__TRANSACTION.Transaction_Date} > {@Prev Week}
and {JCT_CURRENT__TRANSACTION.Transaction_Date} <= {@Week 1})
then
{JCT_CURRENT__TRANSACTION.Units}
This works fine and I can print it on the report with other associated fields. One of those fields is a "Cost Code" field associated with the above conditions and date set (I am pulling for one pay period week). Of these transactions, each week different "cost codes" could be available.
One item I need to figure out another formula is associated with the cost codes that are pulled, but, I need to compare them to a different date range.
Here is how I get the cost codes that were used in a specific time frame;
If({JCT_CURRENT__TRANSACTION.Category} = "L"
and "cost" in {JCT_CURRENT__TRANSACTION.Transaction_Type}
and {JCT_CURRENT__TRANSACTION.Transaction_Date} > {@Prev Week}
and {JCT_CURRENT__TRANSACTION.Transaction_Date} <= {@Week 1})
then
left({JCM_MASTER__COST_CODE.Cost_Code},6) & "001"
This gives me the cost codes used in that period but changes the last three digits to be "001" (xx-xx-001).
Now, I need to take that cost code, the xx-xx-001 and compare it to a completely different date range to get an "estimate" number.
My problem is that, because I need to use a date range in the original conditions, even after I truncate the cost code, for some reason, it stays associated with that date range.
How can I use a field from a group of records based on date, but, associate it with a competely different date range.
I hope this is clear, I am having a real hard time with this, I am fairly new, but have pretty normal working knowledge of basic formulas, etc...
Thanks, MikePlease re-post if this is still an issue
-
I am trying, for some time now, to implement some sort of bank application that uses DBs to store customers.
I have been trying to improve my code, the results are interesting since while studing more I saw that the previous code was.....not so good. I am using Prepared statement now as some of you suggested but I cannot surpass this final glich.
try
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection=DriverManager.getConnection("jdbc:odbc:customersTable");
Statement stat = connection.createStatement();
ResultSet set = stat.executeQuery("SELECT * FROM CUSTOMERSTABLE");
boolean check = true;
while(set.next())
String ssnChecked = ssn.getText();
String SSN = set.getString("ssn");
if(ssnChecked.equals(SSN))
JOptionPane.showMessageDialog(null, "SSN already excists");
check = false;
if(check == true)
String ssnToDB = ssn.getText();
String nameToDB = name.getText();
String surnameToDB = surname.getText();
String addressToDB = address.getText();
String phoneToDB = phone.getText();
String phone2ToDB = phone2.getText();
String balanceToDB = balance.getText();
System.out.println(ssnToDB+nameToDB);
PreparedStatement prstat = connection.prepareStatement("INSERT INTO CUSTOMERSTABLE VALUES ( ????????)");
prstat.setString(1,ssnToDB);
prstat.setString(2,nameToDB);
prstat.setString(3,surnameToDB);
prstat.setString(4,addressToDB);
prstat.setString(5,phoneToDB);
prstat.setString(6,phone2ToDB);
prstat.setString(7,balanceToDB);
prstat.executeUpdate();
prstat.close();
//String command = "INSERT INTO CUSTOMERSTABLE VALUES ("+ssnToDB+nameToDB+surnameToDB+addressToDB+addressToDB+phoneToDB+phone2ToDB+balanceToDB+")";
connection.close();
catch(ClassNotFoundException exception)
JOptionPane.showMessageDialog(null, "ERROR1");
catch(SQLException exception)
JOptionPane.showMessageDialog(null, "ERROR2");
}This code throws a SQLException that probably has to do with the use of PreparedStatement. Can you help?java.sql.SQLException: [Microsoft][╨?ⁿή?άΉΉά Ύϊ▐ήύ≤ύ≥ ODBC Microsoft Access]┼≤?ά
ΈΉ▌ΊΎ Ώίϊ▀Ύ COUNT
???????????? -
Kerberos error when using a DNS name that doesn't match the Active Directory domain name
I am running into a weird issue with a new SQL Reporting Services server I built. I installed SQL Reporting 2014 on Windows Server 2012 R2 and configured Kerberos, but the site is extremely slow. After some reconfiguration and log captures I have determined
the issue has to do with the Kerberos setup but it is an exact replica of a Windows Server 2008 R2 server we currently have and it does not have these issues.
The error I see while using Wireshark is KRB Error: KRB5KDC_ERR_BADOPTION NT Status: STATUS_NO_MATCH.
When I drill down the into the error I can see the kerberos string is testprjmnmtreports14.company.com, which is the URL we are using to access the site. I made sure to add that name as an SPN for the service account that is running SQL Reporting Services,
however I still receive the error.
Then I tried configuring the site to run without a hostheader, so I accessed the site with the server name ECTSTSQLRS5 and the site works perfectly fine, no errors are reported either. So it seems I have isolated the issue down to Kerberos but I am not sure
how to resolve it. Here is some more information about my environment:
DNS/URL used: testprjmnmtreports14.company.com
Server Name (FQDN): ECTSTSQLRS5.company.int
AD Domain Name: company.int
Server Version: Windows Server 2012 R2
AD Functional Level: 2008 R2
I also have the following SPNs set for my SQL service account:
http/testprjmngmtreports14.company.com
http/testprjmngmtreports14
http/ECTSTSQLRS5.COMPANY.INT
http/ECTSTSQLRS5
As you can see I am trying to use a .com address but my AD domain is .int which I think is the issue, but I do not have the same problem on my other server that is running Windows Server 2008 R2.
Has anyone see this issue before? What do I need to do to allow my new site on 2012 R2 to work with this DNS Alias?
Thanks,
BrandonHi
Quote from there; Kerberos errors in network captures
The most common scenario is a request for a delegated ticket (unconstrained or constrained delegation). You will typically see this on the middle-tier server trying to access a back-end server. There are several reasons for rejection:
1. The service account is not trusted for delegation
2. The service account is not trusted for delegation to the SPN requested
3. The user’s account is marked as sensitive
4. The request was for a constrained delegation ticket to itself (constrained delegation is designed to allow a middle tier service to request a ticket to a back end service on behalf on another user,
not on behalf of itself).
Regards, Philippe
Don't forget to mark as answer or vote as helpful to help identify good information. ( linkedin endorsement never hurt too :o) )
Answer an interesting question ? Create a
wiki article about it! -
Problem with column/field names in Oracle resultset being UPPERCASE
Hi everyone,
I understand that Oracle DBMS returns all the field names in UPPERCASE in the result set. However this is undesired for my application and I was wondering if there is any workaround for getting the field names in the application in exactly the same format as your select query. Is there any set method which can be called before to control this behavior.
E.g. select ename as employeename from table_name;
ORACLE RETURNS --> EMPLOYEENAME
Required --> employeename
Please help me
..VinitVinit,
You can use column aliases in your query -- see Oracle SQL Reference for more details.
Then you can set some connection property in Oracle JDBC that allows you to obtain the column alias (I think). Check the Oracle JDBC User's Guide and Reference for more details.
Good Luck,
Avi. -
Can I use a field name in text module
Hi,
I get a object name of the standard text in a field. Can I use that field in Text module.
Thanks,
Srinivas.Go to t-code SMARTFORMS->Text Module->Create or Edit-> choose add icon and type your field name (used in your smartform) like this &fieldname&, then use this Text module in your smartform.
-
Php select using column Field names ?
Hello,
I need some advice using this select
usually I do this
$query = "SELECT * FROM table WHERE title LIKE 'body'";
it works, is fast and no problems.
But now I've a big table [id, ..., ...] and need to select just the row starting with body, so I use body%
question is
How can I select records using the Field property of the MySql table? (Field, Type, Collation, Attributes,...)
I want something like
$query = "SELECT * FROM table WHERE FIELD LIKE 'body_%'";
Thanks
PludaExPluda wrote:
ok, I know the name of my table, but don´t know the name of the fields, or I know them, but need this to be dinamic, so what i´m trying is to select all content from table 'body' where FIELD name like ´body%'
I understand what you're trying to do (or at least I think I do). The answer is simple. You can't do it.
Why not? Because it's nonsense. If you know the name of the table, you know the names of the fields (columns). Moreover, the WHERE clause is used for checking values in fields, not for checking field (column) names.
What you're actually trying to do is probably this:
SELECT [field_name] FROM body.
By the way, this sort of question should really be posted in the Application Development forum. -
Hide form field based on name that contains certain characters
I think this is an easy one.
We're looking for help with a script that will hide all instances of text fields that contain a certain value. We have a function running that applies to the same text fields, however, each text field had to be tagged with a number at the end. Also running with this is a custom save button that flattens the page and hides certain elements before saving out. The hide function works pretty straightforward with "this.getField… = display.hidden;". The issue is that we don't want to repeat this for every single instance of the text fields that share the same name.
We need it look for every text box that has a similar title so for instance if we had multiple fields like this… "my-text-field-01", "my-text-field-02" and "my-text-field-03" we want the script to look for the name "my-text-field" and hide all instances of that.
Hope this makes sense, sorry, our programming skills are still amateur. Thanks in advance for any help.You can do that if you use a heirarchical naming convention. So instead use something like: my-text-field.1, my-text-field.2, etc.
You can then hide them all like:
// Hide all of the "my-text-field" fields
getField("my-text-field").display = display.hidden; -
I'm trying to migrate my music and pictures over to my new iMac. When I use the migration assistant it connects to my PC fine but it won't let me use the account name and username that I have created as the admin. It requires me to create a new user account - so then I have two separate accounts to log in to which i don't want. How do I get it to let me use the current account that I have to move my files to?
Thanks!Migration Assistant creates a new account and migrates all the information you have requested to that new account. There is no way around that. However once migrated you can move the data to the account you want to. Here are some instructions for doing so:
Transferring files from one User Account to another.
Maybe you are looking for
-
Help. I need to change my apple account and don't have access to my old email, how can i change this - how do i verify that it is me.
-
SAP R/3 : System Functions
Hi , I was just curios to know abt the Systems C functions available in SAP R/3. DO any one of you have any idea , plz share that in the forum. I did heard from some one that filename is sapactab.h , but could not trace it .... Thanks Rajiv
-
Playlists vs. tracks in folders
I just made a new folder in ITunes 10 (Mac) and dragged several related playlists into it. I then dragged the folder into my iPod Classic. On iTunes, the opened folder shows the playlists. On the iPod, going to the folder shows the individual tracks
-
Standard Text doesnt contain correct format of Text in Recruitment
Hi Experts, Please throw some light on this While performing Recruitment Activities : Prepare to Hire or Rejection I can see Standard Text doesnt contain correct format of Script But record can be created. what would be the cause I googled it and se
-
Iphone 5 slider freeze during charging.
iphone 5 slider freeze during charging. This happened after upgrading to iOS 6.1. The "slide to unlock" stuck. I could receive phone, sms, and other notification but can not answer nor reply. It stuck. This only happened during charging, when I pull