Bind variable for date type
Hello
I have a question about bind variable.
I have a simple query which is a stand alone SQL.
Its simple select
select a, b , c from table1, table 2
where table1.g1 = table 2.p1
and table1.pnumber like :var1 || '%'
and table2.check_date between :var2 and :var3
This SQL is embedded in another piece of code.
I have table1.pnumber like :var1 || '%'
So even when I do not pass any value for var1, it will run fine because I concatenate a % with it.
But my question is how can I do the same for "table2.check_date like :var2 "
I can not append % with it because then it throws an error.
How can I modify my SQL so that I can run it without giving any value for var2 and var3.
I do not want to use an or condition in which I give a default value of date.
Is there any way to modify the SQL so that I can run it without giving a value for var2 and var3
Thanks
var var2 varchar2(11)
var var3 varchar2(11)
EXEC :VAR2 := '01-JUN-1981'
PL/SQL procedure successfully completed.
EXEC :VAR3 := '30-JUN-1981'
PL/SQL procedure successfully completed.
select * from emp
where nvl2(:var2,hiredate,to_date('01-JAN-2000','DD-MON-YYYY')) between
nvl(to_date(:var2,'DD-MON-YYYY'),to_date('01-JAN-2000','DD-MON-YYYY'))
AND
nvl(to_date(:var3,'DD-MON-YYYY'),to_date('01-JAN-2000','DD-MON-YYYY'))
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09-JUN-81 2450 100 10
EXEC :VAR2 := NULL
PL/SQL procedure successfully completed.
EXEC :VAR3 := NULL
PL/SQL procedure successfully completed.
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09-JUN-81 2450 100 10
7839 KING PRESIDENT 17-NOV-81 5000 100 10
7934 MILLER CLERK 7782 23-JAN-82 1300 100 10
7566 JONES MANAGER 7839 02-APR-81 20
7902 FORD ANALYST 7566 03-DEC-81 20
7876 ADAMS CLERK 7788 12-JAN-83 20
7369 SMITH CLERK 7902 17-DEC-80 20
7788 SCOTT ANALYST 7566 09-DEC-82 20
7521 WARD SALESMAN 7698 22-FEB-81 30
7844 TURNER SALESMAN 7698 08-SEP-81 30
7499 ALLEN SALESMAN 7698 20-FEB-81 30
7900 JAMES CLERK 7698 03-DEC-81 30
7698 BLAKE SALESMAN 7839 01-MAY-81 30
7654 MARTIN SALESMAN 7698 28-SEP-81 30
Message was edited by: Priyasagi
Similar Messages
-
How to declare a bind variable with 'date' data type in command prompt?
how to declare a bind variable with 'date' data type in command prompt?
sql>variable q date;
when i execute it show list of datatypesHi,
As Lokanath said, there are no DATE bind variables.
You can use a VARCHAR2 bind variable, and convert it to a DATE in your SQL statment.
If you're using SQL*Plus, consider a substitution variable. It won't be as efficient as a bind variable, but it will be as convenient.
For example:
DEFINE first_entrry_date = "DATE '2010-06-20''
SELECT ...
WHERE entry_date >= &first_entry_date
{code} -
How to set bind variable for a VO ,
Hi,
i got a requirement in which i have to set bind variable for VO , But the Bind variable is coming from payload attribute,
For example my query in VO is select * from Employee where emp_id="payload attribute"
How to set this attribute value is from the payload
Thanks Regard
RajendarHi i am getting this exception " Cannot create an object of type:java.lang.Number from type:oracle.bpel.services.datacontrol.data.DataObject with value:21159"
Actually i am getting Decimal Value from Payload of BPEl process and i am trying to set this to The bind variable
is that a type cast exception where can i typeCast Those values You should this in a new thread.Dont ask questions out of the scope of this thread.
Please mark this thread as answered or helpful if you got solution for this thread.
Thanks!!! -
Bind variable for view accessor
I am using a Gantt chart where I need to pass in a date field for the schedule as a bind variable.
Since this is a Gantt chart, there is no iterator binding for the child VO (the tasks) in my page definition.
<gantt IterBinding="ParentVO1Iterator" id="ParentsVO1" xmlns="http://xmlns.oracle.com/adfm/dvt">
<ganttDataMap>
<nodeDefinition DefName="com.pat.model.view.ParentsVO" type="Resources">
<AttrNames>
<Item Value="ParentId" type="resourceId"/>
</AttrNames>
<Accessors>
<Item Value="MainGantt" type="tasks"/>
</Accessors>
</nodeDefinition>
<nodeDefinition type="Tasks" DefName="com.pat.model.view.MainGantt">
<AttrNames>
<Item Value="PatId" type="taskId"/>
<Item Value="StartTimeDate" type="startTime"/>
<Item Value="EndTimeDate" type="endTime"/>
<Item Value="Patname" type="label"/>
</AttrNames>
</nodeDefinition>
I have tried retrieving the accessor through the parent VO, and setting the bind variable.
But I get an error if I fire executeQuery() on the child VO that says that the bind variable for the view link is missing.
DCIteratorBinding iter = dcBindings.findIteratorBinding("ParentVO1Iterator"); // get parent iterator binding
ViewObject vo = iter.getViewObject();
MainGanttImpl childVO = (MainGanttImpl)vo.findAttributeDef("MainGantt").getAccessorVO(vo); //get the child VO through the accessor link
childVO.setpViewDate(new Timestamp(((Date)getGanttDate().getValue()).getTime())); // get the date entered by the user and set to the child VO
childVO.executeQuery(); //execute the child VO
Exposing the child VO impl through the Application module and setting the bind variable to that instance alone has no impact on the Gantt data returned.We researched a bit more and hit upon the solution here.
Decompiling ADF Binaries: Search by child attributes on a tree table
I added the same bind variable to my parent VO (and added some SQL 'and : pViewDate = : pViewDate' to the query to just get it to work )
In the parent VO Impl class, I overrode the createViewLinkAccessorRS method:
protected ViewRowSetImpl createViewLinkAccessorRS(AssociationDefImpl assocDef,
ViewObjectImpl accessorVO,
Row masterRow,
Object[] values) {
ViewRowSetImpl v =
super.createViewLinkAccessorRS(assocDef, accessorVO, masterRow,
values);
// Timestamp viewDate = (Timestamp )accessorVO.getNamedWhereClauseParam("pViewDate");
v.setNamedWhereClauseParam("pViewDate", getpViewDate());
return v;
public Timestamp getpViewDate() {
return (Timestamp) getNamedWhereClauseParam("pViewDate");
This sets the child VO with the value of the bind variable that I have set to my parent VO. This got the Gantt working! -
How to set bind variables for child VO in hierarchy component?
Hi,
Recently I created a application with Hierarchy Component with Parent VO (Query based VO with Bind variables in it) and its Child VO along with Child-Child VO(Query based VO with bind variable in it)
I am able to set bind variable of parent VO but unable to set bind variable for Child-Child VO. Can any one help me regarding this issue?Hi i am getting this exception " Cannot create an object of type:java.lang.Number from type:oracle.bpel.services.datacontrol.data.DataObject with value:21159"
Actually i am getting Decimal Value from Payload of BPEl process and i am trying to set this to The bind variable
is that a type cast exception where can i typeCast Those values You should this in a new thread.Dont ask questions out of the scope of this thread.
Please mark this thread as answered or helpful if you got solution for this thread.
Thanks!!! -
How to substitute a bind variable for a IN condition?
Dynamically I am setting the WHERE condition for one of my blocks using SET_BLOCK_PROPERTY Built in. The condition that I am attaching has two IN conditons..
For Eg.,
contracts_tbl.status_col IN ('NEW', 'OLD', 'EXPIRED', 'OPEN')
AND contracts_tbl.id_col IN (1, 2, 3, 4)
The number of choices in the IN condition will vary depending upon the user choice in my screen. Because of this the parsed SQL state is could not be shared and multiple of these are getting created in shared pool. To avoid this I would like to use bind variables.
There are two ways I am trying to do this..
1. Generating one bind variable for each value. i.e.,
contracts_tbl.status_cod IN (:global.var1, :global.var2,
:global.var3)
Now this could result it memory error if no. of choices exceeds the avilable memory. Also its a tedious task to purge the variables after querying the block. Also because of multiple IN conditions, the chances of different set of selections are possible and then again sharing will be minimal.
2. The second method is to set the one bind variable for each IN condition. i.e.,
:GLOBAL.Var1 := '( 'NEW', 'OLD', 'EXPIRED', 'OPEN' )';
:GLOBAL.Var2 := '(1, 2, 3)';
contracts_tbl.status_col IN :GLOBAL.Var1
AND contracts_tbl.id_col IN :GLOBAL.Var2
In this case, forms is not querying as the IN condition takes the global variable value as one string and the query returns no rows though there are plenty available for each status. Also any NUMBER type condtions erroring out as the , and ( are invalid numerals.
Q: Is there anyway you can make this work? or Is there any other better method to substitute bind variables in place to avoid creating new set of statements for each query in the shared pool?
Your suggestions and pointers are higly appreciated. Please respond immediately as this is a P1.
Thanks,
-- Raam.2. The second method is to set the one bind variable for each >>IN condition. i.e.,
:GLOBAL.Var1 := '( 'NEW', 'OLD', 'EXPIRED', 'OPEN' )';
:GLOBAL.Var2 := '(1, 2, 3)';
contracts_tbl.status_col IN :GLOBAL.Var1
AND contracts_tbl.id_col IN :GLOBAL.Var2 This method should work - not sure if you put exact syntax in or not but your first assignment would cause a problem as everywhere you want one ' mark you would have to put two so that it does not close your quoted string
Try the following syntax:
:GLOBAL.Var1 := '( ''NEW'', ''OLD'', ''EXPIRED'', ''OPEN'' )';
:GLOBAL.Var2 := '(1, 2, 3)';
SET_BLOCK_PROPERTY('blk name',
default_where,
'contracts_tbl.status_col IN ' || :GLOBAL.Var1
|| ' AND contracts_tbl.id_col IN ' ||
:GLOBAL.Var2);
Hope this helps,
Candace Stover
Forms Product Management -
How to pass pageFlowScope variable value as bind variable for VO
Hi,
I have one fixed lov (not based on datasource), if i select any value in that lov i want to pass this value to a pageFlowScope variable.
After this i want to use this value as bind variable for VO. whenever the vo executes thereafter this bind variable should filter that vo results.
My jdev version: 11.1.0.0
Thanks in advance,
SANsan-717,
can you elaborate on the use case instead of the implementation you don't get done? I understand you have data displayed in a tree: so lets assume the tree structure is Locations, Departments and Employees according to the Oracle HR sample schema.
1. What is the LOV supposed to do ?
2. Where is the LOV located ?
3. What values does the LOV show ?
4. Is the LOV a select choice component or a real LOV (with search dialog)
5. Where is the bind variable used ?
To me it sounds like you want to filter the tree data based on the select choice value. However, you wont do this by passing the bind parameter to all View Objects involved as they may not have the attribute in their query. So your use case is important to answer the question
Frank -
[Q] Using viewCriteria for Date type
To Query data, I used ViewCriteria.
But it works well for Varchar2, Number type.
But it does not work for Date type.
for example
If I set variables like the below, it works,
attrName = "OrdName";
attrValue = "Nick";
But, If I set variables like the below, it does not work
attrName = "AppDate";
attrValue = "04.5.12";
ViewCriteria vc = order.createViewCriteria();
ViewCriteriaRow vcr = vc.createViewCriteriaRow();
vcr.setAttribute(attrName, attrValue);
vc.addElement(vcr);
order.applyViewCriteria(vc);
order.executeQuery();
Can I solve this problem ?using a custom expression in the view criteria, ex.
vcr.setAttribute("DateField", "LIKE TO_DATE('" + dateField.toString() + "', 'yyyy-mm-dd')");
similarly, you can use other expressions to remove the default BC4J problems w/ dates (>, <, between) - At least I know you can't use = to get it to work right.
The default handling of BC4J is to say = TO_DATE(whatever you put in the value portion) where it needs to be LIKE to work properly - for some reason - probably a patch is available for it. -
Extract the "bind" variables for a given query running in 10g.
how can we extract the "bind" variables for a given query running in 10g? The performance of a query may vary based on the parameters supplied to it. For example, a query like the following
SELECT * FROM CUSTOMER_ORDERS WHERE CUSTOMER = :CUST_ID
.might run differently when the :CUST_ID is "123" who may have very few orders versus "456" who may have tens of thousands of orders.
So, if we see a spike in the system due to a query, we need visibility into what the exact query syntax and values are for any database session. We're aware of an Oracle view called V$SQL_BIND_CAPTURE, but what we're finding with this view is that it's only a snapshot of variables that are refreshed on an interval. That view does not give us a live view into what values are being used in the various sessions in realtime.
If someone ould provide us with some SQL (or other means) to do get a realtime view into the SQL and variables currently running in the database, it would be greatly appreciated.In addition to what's been said in the other thread, you could add a layer of logging either in the database or out.
v$sql_bind_capture and the associated ash view dba_hist_sqlbind contain sample data.
You could up the sample rate but it's not advisable - it's still just a sample.
If you're on 11g, this is where adaptive cursor sharing might help.
Not help in finding the values of your binds, but help in using different plans where there is such a skew for different bind values and the plan is perhaps wrong for customer 456.
The problem when you're got such a skew and you're using bind variables is that the two don't really go together.
When the query is next parsed and you've got bind variable peeking enabled, you might get the 123 plan is that is the bind value at parse time and then run into problems for 456 or even vice versa.
See http://jonathanlewis.wordpress.com/2009/05/06/philosophy-1/ for a discussion on binds and histograms which reflects the reasons for using either. -
Domain for data type in Oracle 8i database
Hi Sir,
Does Oracle database supports domain creation for data type.
for example, can I create a domain called shorttext which is VARCHAR2(50). Then when I specify a data type for a column in table, then I just declare the column as domain.
eg. address SHORTTEXT;
--where SHORTTEXT is a domain.
How is this implemented in Oracle database and supported by front end tools like Oracle Developer 6.0.
Hope someone can provide some clear explanation on this.
Thanks.The ordimagesignature is not something you can see or hear. It is strictly binary metadata about the image, used only to compare images to each other.
What are you trying to do?
Larry -
Date type-specific Customizing missing for date type ACTActPln
Hi all.
I'm using a Web Service obtained by copying the CRM 7.0 built-in WS APPTACTCRTRC.
I'm using it to create Appointments using an Adobe Interactive Form.
It goes everything fine (a Date is created in the system, with all the input data properly set) excepted the dates...
The WS uses two TIMESTAMPS, TIMESTAMP_FROM for StartDateTime and TIMESTAMP_TO for EndDateTime, whereas the GUI transaction to create Dates accepts dates and times in separated fields.
Going in Debug I can see that the execution ends with the following error, referred to the involved entity (CRM_APPOINTMENT):
Date type-specific Customizing missing for date type ACTActPln
CRM_APPOINTMENT uses date profile 0000000001 with three possible date types: ORDERACTUAL, ORDERPLANNED and ORDERPROPOSED and I cannot find anywhere date type ACTActPln (just to add it in customizing).
Is anyone able to enlight me?
Thank you in advance!
Alessandro
PS I've years of experience in Java programming but I'm quite new to the SAP world. Maybe the problem is not a problem at all, but it seems to me as such. Even if it has a trivial solution, please let me know. Thx!Hi,
Well I was about to write that you should enter date in decimal format. but you already did that as mentioned in How to set a date in a Form where the bound date format is a decimal?
In response to following from above thread (copied for others to understand my response)
Hi all.
I'm successfully using the LiveCycle Designer and I've managed to remotely create Appointments using a CRM Web Service (a mere copy of APPTACTCRTRC).
The only problem I'm encountering is that I'm not able to set the dates/times (start and end of the appointment).
Dragging each of the two fields from the WSDL based Data Connection I obtain a Decimal Field limited to 15 digits.
How can I write a date and time in such a field?
I've tried with a retroverse date as YYYYMMDDHHmmss (for example, 20100301124500) but it does not work
(the appointment is indeed created, but with the start date and time fields filled with
the current date/time and the end date and time fields filled with the current date and time plus 10 minutes).
The retroverse date above is only 14 digit long, so, maybe, this is the problem.
But, given the field definition, I'm not able to fill a blank space between the date and the time.
I'm not able to put a dot either.
What should I do?
Any suggestions?
Thank you in advance.
Alessandro
15 digit in UTC time format here is fraction of second so you should enter 201003011245000 (add one more zero).
14th Oct 2010 16:00 should be written as 201010141600000, so just try it and and see if it works, I guess if you do not supply end time then by default it will be starttime + 10 min but this is just guess.
Regards,
Gourav -
How to set a date string in a textbox which bind to a Date type datasource
Hi,
I found i can't set a default date value in a textbox which bind to a Date type datasource. Even i tried copying a date string which is picked by the calendar date picker and copy the exactly same string into my source code. It just doesn't work and gives me error said "Invalid date value".
My source code is like this:
oEditText = (SAPbouiCOM.EditText)oItem.Specific;
oEditText.DataBind.SetBound(true, "", "dtFrom");
oEditText.Value = "09/08/2010"; //DateTime.Now.ToString("dd/MM/yyyy");
Any suggestion?
Thanks!
LanHi,
oItem = oForm.Items.Item("10")
oEdit = oItem.Specific
oEdit.String = Format(Today.Date, "dd/MM/yyyy")
or
datestring = oForm.Items.Item("10").Specific.value
datepass = Left(datestring, 4) & "/" & Mid(datestring, 5, 2) & "/" & Mid(datestring, 7, 2)
dtDocDate = Date.Parse(datepass)
Thanks,
Mahesh -
Conversion Exit for data type FLTP
Can someone suggest me a conversion Exit for data type FLTP?
Hi,
CHAR_FLTP_CONVERSION
FLTP_CHAR_CONVERSION
Have a look at the function module documentation.
Regards,
Reema.
PS. pl. award points to useful answers. -
[Access 2010] Change default formats for data types
Whenever I import data, the default format for Boolean data types is "-1,0." I know how to subsequently change this format to "Yes/No," but I'd like to change the default
setting to "Yes/No." Is this possible?
Thanks in advance.Hi,
I found you post the same question in other place and got the advice. I agree with Mr. Kees suggestion. The data type is a build-in default setting with Access, we can't change it. We may try the workaround via VBA to test.
http://forums.cnet.com/7723-6129_102-627633/access-2010-change-default-formats-for-data-types/#message5617496
Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
Have a good time.
Regards,
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs. -
Variable binding for Date type over ODBC
Hi I'm trying to parameterize a DATE variable over ODBC. Over JDBC I have no problem doing so in Java but on the ODBC (C-code) I had problem figuring out how to deal with the expression, *{ts '2009-02-23 09:02:10'}.* But eventually based on SQL tracing on the DB side, I found that it gets translated to to_date('2009-02-23 09:02:10', 'YYYY-MM-DD HH24:MI:SS'). So now I can attempt to parameterize. But that's the side story.
My question is, do I gain any performance by doing the following (cut and paste from SQL trace)
SELECT ROWID, reservation_id, job_type, job_start
FROM reservation_job_queue
WHERE job_start <= to_date(:1, 'YYYY-MM-DD HH24:MI:SS')
ORDER BY job_start
as compared to the original
SELECT ROWID, reservation_id, job_type, job_start
FROM reservation_job_queue
WHERE job_start <= to_date('2009-02-23 09:02:10', 'YYYY-MM-DD HH24:MI:SS')
ORDER BY job_start
Thanks!
Edited by: pidge66 on Feb 23, 2009 6:27 AM
Edited by: pidge66 on Feb 23, 2009 6:30 AMIf I understand you correctly, you want to be able to enter some arbitrary dates in the where-clause of your application.
Thus, to use the first form with a bind variable is key for performance of your application.
And yes, you will gain a lot of performance when using to_date(:1, 'YYYY-MM-DD HH24:MI:SS') instead of to_date('2009-02-23 09:02:10', 'YYYY-MM-DD HH24:MI:SS').
Why not using bind variables is evil you can read best over at AskTom
Maybe you are looking for
-
2011 Macbook Pro External Monitor Problems
Hi all, Looking through some of the threads, it appears that getting macbook pros to work with an external monitors is a big issue. I've just bought a phillips 27" monitor and I'm having no luck whatsoever getting my MBP to see it. I've tried both H
-
I have an ipod previously linked someone else's account. We used to share the library and they used to update my iPod for me. Now I have my own ID and laptop with iTunes. How to I extract my music from the iPod and add it to the library ? At present
-
Indbound Interface not visible in Receiver business service
Hello Experts- II have created a business service. After creating the business service, when try to enter receiver inbound interfaces. The message interface which I declared in IR is not visible . I am not able to select it as its not visible. When I
-
FCPX(10.1.1) quits when I load library
Every time I try to load a library FCPX quits. It's just this one. I have it on an external drive. Have tried moving the library do another drive, but same problem there. It quits when it's loading curves(Natress). Have downloaded Event Manager X, bu
-
Most Difficult to Migrate from JDEV 10.1.2 to 10.1.3
Hi Oracle Team, I have developed new application from scratch containing 700 pages from struts based to Jdeve 10.1.2 with UIX , Struts Controller , BC4J ( ViewController ,Model) based architecture of Jdeveloper 10.1.2. Now oracle annouced that UIX wi