How do I use a variable within a sql statement
I am trying to use a local variable within an open SQL step but I keep getting an error.
My sql command looks like this "SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " + locals.CurrentSerialNo
If I replace the locals.CurrentSerialNo with an actual value such as below the statement works fine.
"SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " + " 'ABC001' "
Can someone tell me how to correctly format the statement to use a variable?
Hi,
Thanks for the reply. I have changed the required variable to a string, but with no success. I have reattached my updated sequence file and an image of the error.
When looking at the Data operation step I see that the sql statement is missing everything after the last quotation mark.
Thanks again,
Stuart
Attachments:
Database Test Sequence.seq 10 KB
TestStand error.JPG 37 KB
Similar Messages
-
How do I use bind variables for the SQL statements having IN clause
SELECT id, name FROM t
WHERE id in (10,20,30)
As the IN list will have 'n' number of values, I am not able to specify fixed number of bind
variables like
SELECT id, name FROM t
WHERE id in (?,?,?....)452051 wrote:
I am not able to specify fixed number of bind variablesYou could use collection:
SQL> create or replace force
2 type NumList
3 as
4 table of number
5 /
SQL> select ename from emp where deptno member of NumList(10)
2 /
ENAME
CLARK
KING
MILLER
SQL> select ename from emp where deptno member of NumList(10,20,30)
2 /
ENAME
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
ENAME
JAMES
FORD
MILLER
14 rows selected.
SQL> This way you have one bind variable - collection.
SY. -
How to use presentaion variable in the SQL statement
Is there any special syntax to use a presentation variable in the SQL Statement?
I am setting a presentation variable (Fscl_Qtr_Var)in the dashboard prompt.
If i set the filter as ADD->VARIABLE->PRESENTATION, it shows the statement as 'Contract Request Fiscal Quarter is equal to / is in @{Fscl_Qtr_Var} '.
And this works fine but when i convert this to SQL, it returns
"Contract Request Date"."Contract Request Fiscal Quarter" = 'Fscl_Qtr_Var'
And this does not work.It is not being set to the value in the prompt.
I need to combine this condition with other conditions in the SQL Statement. Any help is appreciated. ThanksTry this: '@{Fscl_Qtr_Var}'
-
Using 'NOT IN' Within a SQL Statement
Does anyone know why the following SQL statement does not return any values? The problem is with the SELECT statement within the 'NOT IN' clause. When explicitly typing in the part_ids returned from the select statement, everything works as expected.
Thanks for any help.
SELECT Distinct Part_Id, Trans_Date
FROM Invctrl
WHERE Trans_Type = 0
AND Trans_Date BETWEEN To_Date( '1-Mar-2006 00:00:00', 'dd-mon-yyyy hh24:mi:ss' )
AND To_Date( '31-Jan-2007 23:59:59', 'dd-mon-yyyy hh24:mi:ss' )
AND Part_Id NOT IN (SELECT part_Id From InvCtrl WHERE Trans_Date < To_Date( '1-Mar-2006 00:00:00', 'dd-mon-yyyy hh24:mi:ss'))'NOT IN' should be avoided where ever we can.
Change your query to 'IN' clause as below and it should work.
SELECT DISTINCT part_id, trans_date
FROM invctrl
WHERE trans_type = 0
AND trans_date BETWEEN TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
AND TO_DATE ('31-Jan-2007 23:59:59',
'dd-mon-yyyy hh24:mi:ss'
AND part_id IN (
SELECT part_id
FROM invctrl
WHERE trans_date BETWEEN TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
AND TO_DATE ('31-Jan-2007 23:59:59',
'dd-mon-yyyy hh24:mi:ss'
MINUS
SELECT part_id
FROM invctrl
WHERE trans_date <
TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
[pre] -
How do I use a variable within paragraphFormat?
I would like to insert the firstname of a client within paragrapgFormat(). ie: paragraphFormat(Hi #firstname#, your info......) When I output this the firstname just shows as #firstname#. Is there a way to get his to work?
The first instance of 'FirstName' is a variable name. Whereas the last instance is a substring within the string defined by getInfo.message. I am assuming that the message you have saved in the database is:
"Hi" & FirstName & ",
We are writing to you to inform you that we received your request to schedule the...
You could modify the code as follows. Give the queries separate names, say, getUser and getMessage. Omit the columns userID and messID from the respective queries. This is because the where-clauses already specify the values.
What you could then do is replace the substring " & FirstName & " in getMessage.message with the variable getUser.FName. The result would be something like
<!--- grabbing firstname --->
<CFQUERY Name="getUser" datasource="#application.dsn#">
SELECT fNname, lName, email, company, phone
FROM users
where userID = 1
</CFQUERY>
<cfset firstNameString = " " & trim(getUser.fName) & " ">
<!--- grabbing message --->
<cfquery name="getMessage" datasource="#application.dsn#">
select name, message
from messages
where messID = 1
</cfquery>
<table width="300" cellpadding="0" cellspacing="0" border="1">
<tr><td>
<cfoutput query="getMessage">
<cfset msg = replaceNoCase(message, '" & FirstName & "', firstNameString)>
#paragraphFormat(msg)#
</cfoutput>
</td></tr>
</table>
Having said that, there are still 2 things I fail to understand. Firstly, why loop across the query when there is just one row? Secondly, why do you save a static message in the database when you could just save it in the CFML code as a string variable? -
How to query using CGI path for 'IN' sql statement
Some problems that requires help:
I have a report that requires a query which has 'IN' statement in SQL query. For example: SELECT EMP_ADDRESS1 FROM EMPLOYEE WHERE EMP_NO IN (:EMP_NO).
I am going to query the result of this query using CGI. My peoblem starts here - I can't be passing a list of parameter for ':EMP_NO' because the path does not accept escape characters. I can't be put a query path below:
<HTML>http://172.188.2.7/dev60cgi/rwcgi60.exe?server=9iAS&mode=default&destype=localfile&desformat=\\pri_wnt\generic&report=gcgd1.rdf&userid=comm/comm@employee<B>&emp_no='A','B','C'<B></HTML>
What I am doing is that I will have a front end written in JAVA and display a listing of Employee available in the company. The user will be able to choose whatever employee on the front end. Then, I will call the CGI path to display the result to the user.
Pls help. Kindly email personally([email protected]) or reply here.
Thank youYou'll need to escape your single quotes using %XX where XX is the hex code corresponding to the special character you want to use. I'm not sure what the escape code is for quotes. I know that if you wanted to have a space, this:
....../rwcgi60.exe?key+P_city='San Francisco'+....
would need to look like:
.../rwcgi60.exe?key+p_city=San%20Francisco+...
You'll need to find out what the number for quote is. HOpe that helps a bit.
Toby -
Using a number variable in an SQL statement
Hi,
I am trying to use a variable in an sql statement and I have run into problems when the variable is a number. The following line of code works if the variable is a string but not if it is a number.
"SELECT TOP 1 UUT_STATUS FROM UNIT_UUT_RESULT WHERE UnitID = '" + Locals.LocalUnitID + "' ORDER BY START_DATE_TIME DESC"
Is there a difference in the use of the single and double quotes and the + sign for number variables?
Thanks
Stuart
Solved!
Go to Solution.Hi Stuart,
I am assuming that the UnitID is stored as a numeric in the database? If so, the proper SQL syntax for comparing with numerics should not use a single quote (or any quotes for that matter). The quotes are used only for strings.
So you would want to use:
"SELECT TOP 1 UUT_STATUS FROM UNIT_UUT_RESULT WHERE UnitID = " + Locals.LocalUnitID + " ORDER BY START_DATE_TIME DESC"
This is really more of an SQL question universal to all languages, not just TestStand.
Here is an excellent resource that you can consult:
http://www.w3schools.com/sql/sql_where.asp
Jervin Justin
NI TestStand Product Manager -
How can I use environment variables in a controller?
Hi all,
How can I use environment variables in a controller?
I want to pass a fully qualified directory and file name to FileInputStream and would like to do it by resolving an env variable, such as $APPLTMP.
Is there a method somewhere that would resolve this??
By the way,Did anyone used the class of "oracle.apps.fnd.cp.request.RemoteFile"?
The following is the code.
My EBS server is installed with 2 nodes(one for current,and other is for application and DB).I want to copy the current server's file to the application server's $APPLTMP directory. But the result of "mCtx.getEnvStore().getEnv("APPLTMP")" is current server's $APPLTMP directory.
Can anyone help me on this?
private String getURL()
throws IOException
File locC = null;
File remC = new File(mPath);
String lurl = null;
CpUtil lUtil = new CpUtil();
String exten;
Connection lConn = mCtx.getJDBCConnection();
ErrorStack lES = mCtx.getErrorStack();
LogFile lLF = mCtx.getLogFile();
String gwyuid = mCtx.getEnvStore().getEnv("GWYUID");
String tmpDir = mCtx.getEnvStore().getEnv("APPLTMP");
String twoTask = mCtx.getEnvStore().getEnv("TWO_TASK");
// create temp file
mLPath = lUtil.createTempFile("OF", exten, tmpDir);
lUtil.logTempFile(mLPath, mLNode, mCtx);
Thanks,
binghaoHowever within OAF on the application it doesn't.
what doesnt work, do you get errors or nothing ?XX_TOP is defined in adovars.env only. Anywhere else this has to go?
No, it is read from the adovars.env file only.Thanks
Tapash -
Using jsp variables within JSP tag
I have a variable defined within a JSP:
<%
String cust_id = request.getParameter("cust_id");
%>
I want to use this variable as a parameter to a custom tag:
<%@ taglib uri="/tlds/DBTags.tld" prefix="db" %>
<db:MultiColumnSelect columns="c.id, c.po" name="ccar_id" table_name="ccar_headers c, ccar_rmas r" selectString="r.ccar_id = c.id AND c.cust_id = <%= cust_id %>"/>
The selectString value that is passed to my tag is:
r.ccar_id = c.id AND c.cust_id = <%= cust_id %>
The <%= cust_id %> is not replaced by the actual variable value.
How would I accomplish using this variable within my JSP tag?Your definition of the selectString attribute must indicate that it can accept runtime expressions.
<%
String cust_id = request.getParameter("cust_id");
String selectString = new String("r.ccar_id = c.id AND c.cust_id = " + cust_id);
%>
<%@ taglib uri="/tlds/DBTags.tld" prefix="db" %>
<db:MultiColumnSelect columns="c.id, c.po" name="ccar_id" table_name="ccar_headers c, ccar_rmas r"
selectString="<%= selectString %>"/> -
How can we use Session Variable in Answers or Analysis?
How can we use Session Variable in Answers or Analysis?
Again, duplicate cross-posting!
See rukbat 's post here: Re: BI Apps 7.9.6.3(Agent Issue) -
How can we use java variable in javascript code on JSP page?
How can we use java variable in javascript code on JSP page?
Pls helpThink about it:
JSP/Java is executed on the Server and produces HTML+JavaScript.
Then that HTML+JavaScript is transfered to the client. The client now interpretes the HTML+JavaScript.
Obviously there's no way to access a Java variable directly from JavaScript.
What you can do, however, is write out some JavaScript that creates a JavaScript variable containing the value of your Java variable. -
Dears,
I dont Understand How Can I Use the Variable Delay to Deploy Variable Delay on a Speedy-33 KitHello,
Thank you for posting to the NI Forums!! You should be able to incorporate the Variable Delay.vi into your vi and then build as normal and the functionality of the vi should translate to the build. What type of build are you doing? Are you receiving any specific errors? Thanks!
Regards,
Margaret Barrett
National Instruments
Applications Engineer
Digital Multimeters and LCR Meters -
How can i use substitution variable
Hai All
This is my sql statement
SELECT (TO_DATE(TO_CHAR(Intime,'DD-MON-YYYY')||' '||
TO_CHAR(0815,'0000'),'DD-MON-YYYY HH24:MI')-intime) * 24*60
from dail_att where to_char(intime,'hh24mi') between 0700 and 0815 ;
Here my table name called Dailyattendance
Intime field is declared as Date Type
So now i have hardcoded 0815 and now my intime is subtracted from this time so i can calculate the employee
coming late so how can i use substitution variable here to give the value at run time
Ie i need to give 0815 instead or any other time at runtime
Thanks In advance
Srikkanth.MWhere exactly are you planing to use it? Is sqlplus or at any other front end?
One way is to use below given SQL
SELECT ( TO_DATE ( TO_CHAR (intime, 'DD-MON-YYYY')
|| ' '
|| TO_CHAR (:TIME_VAR, '0000'),
'DD-MON-YYYY HH24:MI'
- intime
* 24
* 60
FROM dail_att
WHERE TO_CHAR (intime, 'hh24mi') BETWEEN 0700 AND 0815;*009*
Edited by: 009 on Apr 6, 2010 2:15 AM -
How can i put the value of a variable in an SQL statement?
Hi,
Can someone please tell me how i can use a variable as part of an sql statement.
So instead of "SELECT * FROM tablename WHERE username='john'"
I can put in "SELECT * FROM tablename WHERE username.text"What would happen if someone entered "(delete *
from tablename)" into the username field?The SELECT would fail and the DELETE
would never run.
Or am I missing something?Ok, that wasn't valid SQL, so lets change it into valid SQL. What would this do
"SELECT * FROM tablename WHERE username=" + user
where user is "blah;DROP TABLE tablename;"
The SQL would become
SELECT * FROM tablename WHERE username=blah;DROP TABLE tablename;
And that would select, and then drop the table
Kaj
Message was edited by:
kajbj -
Using a var within an Include statement
What syntax do I use in order to put a variable within an Include statement...
<%@ include file="<%= varhere %>.htm" %>
Thanks for any help!use
<include>
<param name=" something " value="34"/>
</include>
Maybe you are looking for
-
Changed Trackpad and still no joy
Hi, I'm hoping someone can help I have a Curve 8520 and have had the usual trackpad problems the first time I changed it and it worked well for about 6 months then started to go again so I changed it again. Tis was about 3 months ago and now it has
-
"CREATE ACCOUNTING"프로그램이 INVOICE나 PAYMENT등을 SELECT하지 못할때
제품 : FIN_AP 작성날짜 : 2003-04-07 "CREATE ACCOUNTING"프로그램이 INVOICE나 PAYMENT등을 SELECT하지 못할때 ======================================================== PURPOSE Invoice나 Payment정보에 대해 Account정보를 생성한 다음 GL로 그 정보를 transfer해야 한다. 그렇게 Account정보를 생성하기 위해 "Create A
-
JMS to ECC messages in different Queues ...
Hi All, We have a requirement , sender is JMS and target is ECC. The QOS is EOIO , the messages are for three different company codes. When the messages received from JMS , they have to sent in three different queues based on their company
-
A way to transform a template chart/map into an editable template?
Hello! I've been curious about this for a while now, so I was hoping that perhaps some of you knowledgeable people in here could shed some light on this for me. I often use Adobe Illustrator to create charts, maps and diagrams that contains texts for
-
I have made an applet that runs under the applet viewer. In netscape the button, labels, and textfields show, but the button doesn't produce the remainder of the run, as evidenced by no painting, like it does in the other situations. It also runs as