Using WHERE command in property loader SQL query
Hello All,
Hopefully this will be a fairly straight forward question.
I am attempting to use Property Loader to read in test limits from a SQL database. There are many types of models that need to be tested, each having a unique set of limits. I want to be able to retrieve the appropriate limits for the model of product under test.
To do this I have the product model number available in a FileGlobal. The database contains a table with the test limit information with an identifying 'ModelNumber_Number' column.
I have written the following SQL query achieve this:
"SELECT * FROM TESTLIMITS WHERE ModelNumber_Number=+ FileGlobals.ModelNumber"
However, this is where I am confused. I'm not sure on the syntax for accessing a variable in the SQL command. I receive the following error:
The multi-part identifier "FileGlobals.ModelNumber" could not be bound.
Can someone please provide guidence on how to do this?
Many thanks,
Cam.
Solved!
Go to Solution.
Thank you very much for your reply.
Upon changing the query to as you suggest, I am presented with the following:
Error In SQL Statement Expression. "SELECT * FROM TESTLIMITS WHERE ModelNumber_Number = " + FileGlobals.ModelNumber
Specified value does not have the expected type.
The type of FileGlobals.ModelNumber is a numeric represented as a double precision 64 bit signed integer.
The database column is also of type int 64.
Can you suggest a solution?
Many thanks.
Similar Messages
-
How to use property file - sql query define in property file
Hi All,
Anybody please tell me how to use property file.
I have placed sql query in propery file and I have to access this in my file.
well so far this is my code but don't know how to implement in the following ...
pstmt = con.prepareStatement("select * from registration where username=?");
instead of writting the query I want to use the property file.
so far I have developed the following code...
FileInputStream fis = new FileInputStream("querysql.property");
Properties dbProp = new Properties();
dbProp.load(fis);is the code correct... or is there another way to access property file
Please help.
please reply soon....
ThanksBefore answering, check if it's already been done here http://www.jguru.com/forums/view.jsp?EID=1304182
-
How Can I Change the Where Condition In the First SQL Query?
SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT,
TRUNC(MONTHS_BETWEEN((TO_DATE('19'||END_SVC_DT,'YYYYMMDD')),BEG_SVC_DT)/12),
mod(trunc(months_between((to_date('19'||end_svc_dt,'YYYYMMDD')),BEG_SVC_DT)),12),
DECODE((SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1),-1,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-2,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-3,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-4,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-5,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-6,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-7,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-8,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-9,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-10,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-11,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-12,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-13,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-14,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-15,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-16,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-17,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-18,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-19,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-20,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-21,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-22,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-23,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-24,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-25,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-26,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-27,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-28,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-29,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-30,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
-31,((SUBSTR(END_SVC_DT,5,2)+ 31) - SUBSTR(BEG_SVC_DT,1,2)),
30,0,
(SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1))
FROM SVC_OCCURRENCES
WHERE end_svc_dt not in ('PRESENT')
AND SUBSTR(END_SVC_DT,1,1) IN '9'
AND SUBSTR(END_SVC_DT,5,2) NOT IN ('31')
and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
UNION
SELECT IND_SSN, BEG_SVC_DT, END_SVC_DT, NULL, NULL, NULL
FROM SVC_OCCURRENCES
WHERE SUBSTR(END_SVC_DT,1,1) IN 'P'
The above code works fine and I get the correct numeric values from the SQL
query when the varchar2 end_svc_dt field is numeric however if I have encoded
the word 'PRESENT' in the varchar2 end_svc dt field the SQL query aborts at
the last statement in the WHERE condition. The beg_svc_dt field is a Date field.
and (SUBSTR(END_SVC_DT,5,2) - SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')
I get the following error message
ERROR ORA-0722 INVALID NUMBER
I encode the word 'PRESENT' in a varchar2 end_svc_dt field on an Oracle form. This is the only word that can be encoded.
Is there some way that I can bypass the last statement in the where condition and
compute the values from the SQL query without having the SQL query abort?
Eventually I want to do this in a report. I know that this sounds strange but can it be done?The above code works fine and I get the correct
numeric values from the SQL
query when the varchar2 end_svc_dt field is numeric
however if I have encoded
the word 'PRESENT' in the varchar2 end_svc dt field
the SQL query aborts at
the last statement in the WHERE condition.Ouch!
Storting dates in VARCHAR2 columns is bad practice, poor design and makes for horrible code.
The beg_svc_dt field is a Date field.
and (SUBSTR(END_SVC_DT,5,2) -
SUBSTR(BEG_SVC_DT,1,2)+1) not in ('30')If it's a date field then why on earth are you trying to SUBSTR it. SUBSTR = sub-string i.e. take a sub section of a string not sub-date.
I get the following error message
ERROR ORA-0722 INVALID NUMBERAnd you're surprised by this?
Is there some way that I can bypass the last
statement in the where condition and
compute the values from the SQL query without having
the SQL query abort?Store your dates properly, use additional flag columns for non-date information and code your SQL properly.
Eventually I want to do this in a report. I know
that this sounds strange but can it be done?Yes, most things are possible. -
Using/calling a parameter in the SQL Query!
Hi
How do I use or call a parameter from the parameterform in my SQL query in Reports ??
Thanks in advange *S
/Stig :-)If you have user parameters of P_BEGINDATE and P_ENDDATE, in your query you would reference them by the following:
FROM auditlog
WHERE (eventtimestamp between :P_BEGINDATE and :P_ENDDATE
or :P_BEGINDATE IS NULL)
If you are using the report through Oracle Applications Concurrent Manager make sure the Token (when setting up parameters for the concurrent program)matches the user parameter exactly.
- Rob -
Where rownum=2 in my sql query is not working . Why ??
Hello,
i am using Oracle 11g .Referring scott schema's emp table.
I just issued this sql query with the intention to get second highest salary of a employee. But i am unable to understand why my query fails ?
select rownum,empno,ename,sal from (select empno,ename,sal from emp order by sal desc) where rownum=2;This query is returning no rows . Can you tell why this query is returning no rows ?888953 wrote:
Because you can use ROWNUM only to limit the number of returned records, not to return a specific record.
So only this has sense (n any number):
ROWNUM <= n
or
ROWNUM = 1 (which is equal to ROWNUM <= 1)
Anything else will not return a row.As i said ,
select * from (select rownum rn,empno,ename,sal from (select empno,ename,sal from emp order by sal desc)) where rn=2;this query is working fine.So rownm can be used to return a specific record . Please rectify me if i am wrong . -
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 -
Where is the oracle.xml.sql.query package?
Hi,
I have downloaded the xmlparser_v2_0_2_9.zip. I hoped I have everything to compile the example for retrieving XML document with an sql query. However, the jar file is missing the entire package oracle.xml.sql.query which contains for instance the crucial class OracleXMLQuery. Does anyone know where I could get this package - is it part of another download that I have to do, or can I buy it anywhere? Thanks for your help.
KarelIt's part of the XML SQL Utility for Java, avialable for download from http://technet.oracle.com/tech/xml
-
Uses for the Action Property with SQL and Oracle DB Adapters
This thread is a complement to the Wiki Article
BizTalk: Streamlining WCF SQL and Oracle Messaging-Only and Other Patterns
The question. In what circumstances is explicitly setting the Action value with the WCF SQL and Oracle DB bindings useful or beneficial.
A complimentary question. Is it even possible to set the Action value to anything other than exactly what is required by the Message.
I ask because of three very specific behaviors of the bindings themselves:
The binding enforces a match between the Action and the Message, therefore...
There is a one-to-one relationship between the Message and Action, but...
The binding is able to correctly derive and perform the requested operation with the unspecific CompositeOperation.
For clarity, I understand how to set the Action. I. understand what the Action represents in the SOAP scheme. I understand how Action can be used as an abstraction for SOAP operations.
Thoughts?Do you have any good suggestion to learn how to use action property with SQL and Oracle DB adapters? I learn a lot from your replies for years in BizTalk forum. :)
-
Using a Variable to create the SQL Query
I need to create a "dynamic" Update query. I want to store
the meet of the command in a variable and then reference the
variable in in query.
Example:
<cfquery name="fred" datasource="mydb">
update db_table_name set
pbname = 'Fred Flintstone',
pbnumber = '555-555-1234'
pbage = 25
where recnum = 24
</cfquery>
I would like use code this:
<cfset upst = "pbname = 'Fred Flintstone', pbnumber =
'555-555-1234', pbage = 25">
<cfquery name="fred" datasource="mydb">
update db_table_name set
#upst#
where recnum = 24
</cfquery>
When I run this, I get the following error message:
Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error
(missing operator) in query expression ''Fred Flintstone''.
The SQL line is:
update db_table_name set pbname = ''Fred Flintstone'',
pbnumber = ''555-555-1234'', pbage = 25 where recnum = 24
I know its hard to see, but the '' are 2 ' not 1 " . I have
no idea why Coldfusion (or maybe the ODBC driver??) is placing the
2nd ' in the command which causes the errors.
Can anyone shed some light on this topic?
While this is a simple example, my application is far more
complex. I have over 50 fields in the udpate and depending on
changes to the form values, I may need to update all the fields,
some of the fields or NONE of the fields.
I can use <cfif> to test if any fields have changed and
if so, include them in the update command, but if NONE of the
fields have changed, I would have an empty update command and
therefore get an error. I want to avoid having to test for changes
twice (once to determine if I am doing the update and twice to
perform the update).
Thanks,
Mike.cf automatically escapes the single quotes, so you need to
preserve them
<cfquery name="fred" datasource="mydb">
update db_table_name set
#PreserveSingleQuotes(upst)#
where recnum = 24
</cfquery>
Ken -
Using the LIKE keyword in a SQL query
Does anyone have an example using the Database Connectivity Execute Query vi and the LIKE keyword? I would like to do something like:
SELECT TestNum, TestType FROM tests WHERE DeviceType ='Paul_AF125_Ver1' AND DeviceID = 'Test1' AND (TestType LIKE "Cyclic Voltammetry*")
It works fine if I say LIKE "Cyclic Voltammetry" (without the *) but if I put the * in there, I get no records.
I'm using Microsofts SQL Server Desktop Engine (comes with Access).
Thanks,
PaulPaul-
Thank you for contacting National Instruments. I don't have an example program, but I did find some information for you.
LIKE - similar to.
Using the LIKE command, you can use the wildcard symbol %. To find names starting with J : names LIKE 'J%'; Ending in s ? name LIKE '%S'; You can use more than one % charactor too : names LIKE '%sam%'; Also, LIKE is not case sensitive.
What you have written, may work if you change the wildcard syntax from * to %.
-Erik -
Using multiple 'and' conditions in a SQL query
Is it possible to reduce the SQL required to query using multiple 'and' conditions, e.g. I have a query like the following:
select stat.personal_id, appt.username, appt.password, apps.rgn_apt_id, apps.apy_apn_id
from apy_ast_application_status stat, rgn_usr_user appt, rgn_aps_applications apps
where stat.apy_apn_id = apps.rgn_apt_id
and apps.rgn_apt_id = appt.rgn_apt_id
and stat.application_completed is null
and stat.application_started_date > '01-MAY-11'
and stat.amount_paid is null
and stat.personal_details = 'C'
and stat.further_details = 'C'
and stat.education = 'C'
and stat.employment = 'C'
and stat.personal_statement = 'C'
and stat.choices = 'C'
and stat.reference = 'C'
and stat.student_finance = 'C'
Is there a way, to reduce all the multiple 'and' queries, to be read from say one line? If you know what I mean.......Ah, Ok this looks nice, thanks very much. It doesn't quite run as is because the stat.amount_paid query value is 'is null', while the others are 'C'. I tried amending the relevant line to various versions of the following:-
in (select 'is null' 'C','C','C','C','C','C','C','C' from dual)
which doesn't work.
I can get the following to work so I am assuming that the it is not possible to use different query values within the brackets of the 'in (select....' statement?
select stat.personal_id, appt.username, appt.password, apps.rgn_apt_id, apps.apy_apn_id
from apy_ast_application_status stat, rgn_usr_user appt, rgn_aps_applications apps
where stat.apy_apn_id = apps.rgn_apt_id
and apps.rgn_apt_id = appt.rgn_apt_id
and stat.application_completed is null
and stat.application_started_date > '01-MAY-11'
and stat.amount_paid is null
and (stat.personal_details, stat.further_details, stat.education,
stat.employment, stat.personal_statement, stat.choices, stat.reference, stat.student_finance)
in (select 'C','C','C','C','C','C','C','C' from dual)
Thanks for everybodys help - the suggested alternatives seem so much more elegant -
Hi, I created all of my tables and constraints into a notepad document, and then when I was finished I named it proj4.sql so it could be loaded into oracle and automatically create my tables and constraints all at once. The problem is, I forgot the command used to do this, can anyone help? I though it was: @(filelocation)proj4.sql
ThanksHi,
Am afraid but it is @(filelocation)proj4.sql, but from sql prompt. I mean you have to connect to the database through sql plus and then run this file.
else
sqlplus username/password@tnsnames @(filelocation)proj4.sql
Regards -
Using extract and existnodes in a SQL query
I have created a table having one column of datatype xmltype in oracle 9i and inserted 2 rows. When I try to execute the select query having extract and existsnode it is giving me ORA-00904: invalid column name.
CREATE TABLE xml_tab ( xmlval sys.xmltype);
INSERT INTO xml_tab VALUES (
sys.xmltype.createxml('<?xml version="1.0"?>
<EMP>
<EMPNO>221</EMPNO>
<ENAME>John</ENAME>
</EMP>'));
INSERT INTO xml_tab VALUES (
sys.xmltype.createxml('<?xml version="1.0"?>
<PO>
<PONO>331</PONO>
<PONAME>PO_1</PONAME>
</PO>'));
SELECT e.xmlval.extract('//EMPNO/text()').getNumVal() AS empno
FROM xml_tab
WHERE e.xmlval.existsnode('/EMP/EMPNO') = 1;Correct forum for extract() and existsnode() SQL functions is /Products/Database/XML DB.. Please post there
-
Using textField input as parameter to SQL Query
Hi,
Only a newbie can ask a quetion like this. I need my user to input a value in a text box, click a button and see the results of the Query displayed. I can do that if I bind a Dropdown box to a table, but since the table is huge, my page will slow down.Hi,
Exactly,
The below peice of code may give u an idea.
this.getSessionBean1().setid(textField1.getValue().toString());
where id would be bean property.
Cheers:) -
Using Forumlas in (Command) SQL Query
We're trying to optimize the record returns on some reports and recently discovered the ability to apply a Command to specify the SQL Query.
One of the things we do with our reports is actually pass in some values so the user doesn't have to enter so many parameters. So we define a couple of formula tags and then pass values into those during the oninitialization portion of the crystal subclass in our program.
In our case these formula tags would be Jobcode and Division
Prior to our discovering the Command option, we were using those formulas in the Record and Group selections in this manner:
We would define two other formulas as thus:
sMyJobCode
ToText({@Jobcode})
sMyDivision
ToText({@Division})
and then we would call those in the Record and Group selection
example:
SELECT * from TableA where TableA.date between {?StartDate} and {?EndDate} and TableA.job = {@sMyJobCode} and TableA.division = {@sMyDivision}
My problem is that I can't figure out a way to include those formulas in the Command. It lets me use parameters (the date ranges in this case). But I need to get those two formula values (sMyJobCode and sMyDivision) pulled in as part of that initial SQL query because those values filter the record returns substantially.
Is there a way to do this? Any help on this would be greatly appreciated.An SQL Command can not use formula fields directly. I would think that using parameters - with default values set - would be just as easy for the user, and they could be used in the SQL.
Barring that, you could put the report into a subreport (if it is not already using subreports). Calculate the formula in the main report, and use the formula to link to the subreport's parameters, which are added as parameters to the subreport's SQL Command.
HTH,
Carl
Maybe you are looking for
-
My apple pay is not working. Period. When I have tried using it at a McDonald's, and Walgreen, nothing has popped up at all. I live about 3.5 hours from the closest apple store. So I am at a loss on what I need to do.
-
Photoshop CS6 Layer via Copy Question
Hi, I've noticed that when a selection is Layer via Copyed in Photoshop CS6, it appears brighter and slightly more saturated in color than the original selection it came from. Currently I manually make lighting and color adjustments to match it back
-
Trouble importing from content copier
Upgraded my firmware on my n95 8gb to newest version (31.0.015 / 31.0.017). Used newest pc suite to make a copy of the content (7.1). When i try to import the backed up data, only "user files from phony memory" is listed as data from the .nbu file. I
-
My project using Oracle9i Jdeveloper
http://www.weizhiyun.com/prj/lss/lss.htm I use Jdeveloper and Oracle database to finish the project. It is easy and happy. Welcome to share my happiness.
-
It's pretty much what I have seen others write about, only I have not gotten any of their solutions to work. Last thing I tried was a new firewire cable. The mb can't see my ibook wirelessly either. Now I have a new computer and no way to really u