oci_bind_by_name and null values
Hi, I'm developing a PHP application that allows users to execute SQL statements on an Oracle database. The idea behind the app does the administrator pass a query with some bind variables, for example:SELECT NAME, SALARY, DEPTNO of EMPLOYEES WHERE SALARY >: salary AND DEPTNO =: deptno
After this, users are presented with a series of screens that allow them to select columns that they want to see (in our case they could choose between NAME, SALARY and/or DEPTNO) and enter values for the bind variables (in our case it would be salary and deptno). So far, everything works as expected.
The problem I have is that if a value null is entered (say for example in deptno, we know the employees that are part of any Ministry), the oci_bind_by_name() function function that I use php to make the bindings of variables does not match all records. I understand that if you put something like "AND DEPTNO = NULL" the query should return no results. But, is it possible to do with oci_bind_by_name() behave similarly as if the query would have been "AND DEPTNO IS NULL" when it receives a null value?
Modify the query using PHP is an option that I would avoid because I can't make all the assumptions on the query as it is entered by an administrator.
Thank you for your time.
Because this behavior is not specific to PHP OCI8 or the use of bind variables, you'll need to arrive at a SQL solution.
Your comment about not being able to make assumptions on the motion seem strange: If the administrator wants the semantics you describe, they will need to write the SQL statement that is appropriate for their desired output.
Other types of solutions include put (s) in a PL/SQL procedure that returns a ref cursor You can hide the complexity of PHP by linking only to the PL/SQL procedure parameters. But this seems to deviate away from your goals.
Tags: Database
Similar Questions
-
number and date of type storage and null values
Hi, I read that the date type consumes 7 bytes on the disc when it is preserved.
It is also true for the value null in date type or the space for a null value in the column of type date is then reduced and equal to 1 byte?
What about nulls (x) number?
How can I check to make sure?
Thank you
Columns of NULL values using either no space (if they are physically at the end of the line), or 1 byte if not.
-
Question about mySQL Date and NULL value
I am using phpMyAdmin for a simple mySQL database. Am a little confused here, as I have two date fields that, as far as I can tell, are the same - ticked i.e. Date, with a default of null with the NULL value.
If I update a record, but let both of these fields is empty, it remains empty, and the other is filled with the 0000-00-00 (and displays 30 November - 0001 Web site.)
Pointers on why two supposedly identical fields are different?
Thank you.
It must be in the script.
Is it possible to copy and paste the script here. The script that causes the problem is the script Insert or Update script. A list of the fields in the table will be also useful.
-
select_list_from_lov_xl and null values
I'm creating a column on a report that will have a lov by using the code below: -.
apex_item.select_list_from_lov_xl (p_idx,
p_value,
"ARL LOV."
l_attributes,
'' YES. ''
"% null %."
"Please select."
NVL (p_item_id, item_id (p_idx, p_rownum)));
The problem I have is that exisiting records where the value of the column (i.e. the lov for) is null, it is not translating null values in the text "Please select. The text is displayed in the lov when you click on the list, but it should appear as a default value, as for page elements that use the same lov.
We saw what happens and you know how I can get around it?
Andy.Try using the NULL value instead of null %. See this example:
http://Apex.Oracle.com/pls/OTN/f?p=31517:209
Add lines to the form of tables and see the selection list.
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Opal-consulting.de/training
http://Apex.Oracle.com/pls/OTN/f?p=31517:1
------------------------------------------------------------------- -
The code works until the db is the evTimeEnd field when there is a NULL value instead of a time value. It throws an error "parameter 1 of the IsNumericDate function which is now" "must be a number of stk_real".
How to spend it?
Thank you.Well Yes
Phil
-
Separate s processed NULL values in indexes
http://docs.Oracle.com/CD/B19306_01/server.102/b14220/schema.htm#i20690
Indices and null values
NULL
the index values are considered as distinct except when all non -NULL
in two or several lines of an index, the values are the same, in which case the lines are regarded as the same. Therefore,UNIQUE i
index prevents the lines containingNULL
values to be treated as identical. This does not apply if there is not a no -NULL
values - in other words, if the lines are fullyNULL
.The bold part: who's trying to tell me that the lines for the NULL indexed lines, that if these indexed 2 NULL values maintain the same values for the rest of the line that oracle treats as unique to them?
That being said, the bold part is qualified with this statement:
Therefore,
UNIQUE i
index prevents the lines containingNULL
values to be treated as the same.In fact all this 2 average values in a single column being zero, with the rest of the line being exactly the same, is not treated as identical.
I'm sure that's what the DOC tries to explain.
Consider that you have a composit index SINGLE a two columns COL1 and COL2. And you want to insert some values like this
ROWNUM COL1, COL2
------- -------- --------
1 1 NULL
2 2 NULL
3 3 NULL
4 3 NULLNULL values in the index are considered to be separate
This statement indicates that NULL in COL2 values are considered to be UNIQUE values. If the NULL in COL2 ROWNUM 1, 2 are considered to be two different values.
But the following statement
except in the case of all values not NULL in two or more rows of an index are the same, in this case, the lines are considered to be identical
This statement says ROWNUM 3, 4 for COL1, where they have identical values, where the NULL in COL2 value are not considered as UNIQUE values but as identical. That's why the 4 ROWNUM insert will fail with UNIQUE constraint violation.
-
Remove the NULL values and update the value according to the logic
Hello
The problem data
CREATE TABLE VOLA (SRNO, NUMBER, zero NUMBER, A NUMBER); INSERTION of REM in VOLA
TOGETHER TO DEFINE
Insert in VOLA (SRNO, ONE) values (1,237.94);
Insert in VOLA (SRNO, ONE) values (2, null);
Insert in VOLA (SRNO, ONE) values (3,203.565);
Insert in VOLA (SRNO, ONE) values (4,170.69);
Insert in VOLA (SRNO, ONE) values (5,113.67);
Insert in VOLA (SRNO, ONE) values (6,93.6);
Insert in VOLA (SRNO, ONE) values (7,82.03);
Insert in VOLA (SRNO, ONE) values (8,66.675);
Insert in VOLA (SRNO, ONE) values (9,63.59);
Insert in VOLA (SRNO, ONE) values (10,61.415);
Insert in VOLA (SRNO, ONE) values (11,60.015);
Insert in VOLA (SRNO, ONE) values (12,58.235);
Insert in VOLA (SRNO, ONE) values (13,57.805);
Insert in VOLA (SRNO, ONE) values (14,56.965);
Insert in VOLA (SRNO, ONE) values (15, null);
Insert in VOLA (SRNO, ONE) values (16, null);
I have to remove the NULL values in column 1, the problem is that the position of the NULL values are not fixed, and it can be any position. If all the lines of the columns are null, then throw it away.
If multiple NULL values are here so I have to do the math as follows to update null with the eigenvalues
1. If the first line is null then take the 2nd value in row and update it.
2. If the lines between both is null then take avg of prev and next value not null and refresh it.
3. If the last value in the column is null, then then take prev and update, in this case last two are null, so I have to take value of prev 14 value line update in
15th and 16th ranks.
I want to put this pl/sql logic, somehow, that I thought have loop and counter aapproach and loops through the elements and check and update.
But always looking for something better before looking to write code. No idea or help will be useful for me.
I * think * you are looking for something like:
WITH VOLA (SRNO, ONE)
AS (select 1,237.94 from all the double union)
Select 2, union null value double all the
Select 3,203.565 from all the double union
Select 4,170.69 from all the double union
Select 5,113.67 from all the double union
Select 6,93.6 from all the double union
Select 7,82.03 from all the double union
Select 8,66.675 from all the double union
Select 9,63.59 from all the double union
Select 10,61.415 from all the double union
Select 11,60.015 from all the double union
Select 12,58.235 from all the double union
Select 13,57.805 from all the double union
Select 14,56.965 from all the double union
Choose 15, null of union double all the
SELECT 16, NULL FROM dual)
GET_VALUES (SELECT SRNO, ONE ACE,
, LAST_VALUE (WE IGNORE NULLS) (ORDER BY SRNO CSA ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS PREVIOUS_VALUE
, first_VALUE (ONE IGNORE NULLS) over (ORDER OF SRNO CSA ROWS BETWEEN 1 SUITE AND FOLLOWS without TERMINALS) AS NEXT_VALUE
FROM VOLA)
SELECT SRNO, ONE, CASE
WHEN IT IS NOT NULL, THEN WE
OTHER CASES
WHEN PREVIOUS_VALUE IS NOT NULL AND IS NOT NULL THEN (PREVIOUS_VALUE + NEXT_VALUE) NEXT_VALUE / 2
WHEN THE PREVIOUS_VALUE IS NOT NULL, THEN PREVIOUS_VALUE
WHEN THE NEXT_VALUE IS NOT NULL, THEN NEXT_VALUE
END
END AS NEW_VALUE
OF GET_VALUES
/
HTH
-
Hello Experts,
I read a slide (five things you probably don't know about SQL) on the values NULL and the cardinality of Tom Kyte. He has demonstrated this indexed column with estimate cardinality evil cause NULL values. However, I do not understand why it causes the estimation of cardinality wrond? You have an idea?
Party suite comes from the slide. Here's the proof, but is not written why.
OPS$ % ORA11GR2 tkyte > create table t2 20 PCTFREE
3 as
4. Select a.*,
5 case when mod(rownum,100) < = 50
6 then last_ddl_time
7 end end_date
8 object;
Table created.
OPS$ % ORA11GR2 tkyte > create indexes t_idx2 on t (end_date);
The index is created.
OPS$ % ORA11GR2 tkyte > select count (*)2 t
3 where end_date
4 between to_date ('01 - sep - 2010 "," dd-mon-yyyy "")
5 and to_date ('30-Oct-2010, ' mon-dd-yyyy "");
COUNT (*)
----------
36267
OPS$ % ORA11GR2 tkyte > startDBMS_STATS.gather_table_stats 2 (user, 't');
3 end;
4.
PL/SQL procedure successfully completed.
OPS$ % ORA11GR2 tkyte > select count (*),2. count (distinct end_date)
count (end_date) 3,.
min (end_date) 4,
5 max (end_date)
6 t;
CNT CNTD CNT2 MIN MAX
---------- ---------- ---------- --------- ---------
72228 703 36850 1 OCTOBER 02 SEP 30.-11
OPS$ % ORA11GR2 tkyte > set autotrace traceonly explainOPS$ % ORA11GR2 tkyte > select *.
2 t
3 where end_date
4 between to_date (' 01-sep-2010', 'dd-mon-yyyy')
5 and to_date ('30-Oct-2010, 'dd-mon-yyyy');
Execution plan
----------------------------------------------------------
Hash value of plan: 1601196873
--------------------------------------------------------------------------| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 36024 | 3588K | 339 (1) | 00:00:05 |
|* 1 | TABLE ACCESS FULL | T | 36024 | 3588K | 339 (1) | 00:00:05 |
--------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
1 Filter ("End_date" < = TO_DATE (' 2010-09-30 00:00:00 ',' syyyy-mm-dd '))
HH24:MI:SS') AND 'End_date' > = TO_DATE (' 2010-09-01 00:00:00 ', ')
'syyyy-mm-dd hh24:mi:ss"))
OPS$ % ORA11GR2 tkyte > update tEnd_date set 2 =.
3 to_date ('01 - jan - 9999',' mon-dd-yyyy "")
4 where End_date is null;
35378 lines to date.
OPS$ % ORA11GR2 tkyte > commit;
Validation complete.
OPS$ % ORA11GR2 tkyte > startDBMS_STATS.gather_table_stats 2 (user, 't');
3 end;
4.
PL/SQL procedure successfully completed.
OPS$ % ORA11GR2 tkyte > select *.2 t
3 where end_date
4 between to_date ('01 - sep - 2010 "," dd-mon-yyyy "")
5 and to_date ('30-Oct-2010, ' mon-dd-yyyy "");
Execution plan
-------------------------------------------------
Hash value of plan: 470836197
---------------------------------------------------------------------------| ID | Operation | Name | Lines | Bytes | Cost (% CPU).
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 175. 18375 | 10 (0) |
| 1. TABLE ACCESS BY INDEX ROWID | T | 175. 18375 | 10 (0) |
|* 2 | INDEX RANGE SCAN | T_IDX | 175 | | 2 (0) |
---------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
1 Filter ("End_date" < = TO_DATE (' 2010-09-30 00:00:00 ',' syyyy-mm-dd '))
HH24:MI:SS') AND 'End_date' > = TO_DATE (' 2010-09-01 00:00:00 ', ')
'syyyy-mm-dd hh24:mi:ss"))
Thanks in advance.
Charlie
Jonathan has hit it on the head.
the index has nothing really to do with anything.
See ask Tom: on queries to external tables, the consistency of data and nothing
" NULL values and cardinality.
-
Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?
Guessing
Select nvl (x.col_a, y.col_b) the_column
from table_1 x,.
table_2 y
where x.pk = y.pk
Concerning
Etbin
-
Hi all
I write that I'm a little apprehensive with embaresment as I know it's an easy question and one that I should be able to work from google. It remains however after 30 minutes of searching I'm not the wisest.
The problem is simply NOT IN does not return NULL values and I need a function to do this. I think that NOT EXISTS is the solution, but when I run the present I get a message from the invalid relational operator.
Wanted output {{orange, Adam}, {banana, NULL}}WITH tblFRUIT AS ( SELECT 'kiwi' AS fruit, 'John' AS cust_name FROM DUAL UNION ALL SELECT 'apple', 'Mike' FROM DUAL UNION ALL SELECT 'orange', 'Adam' FROM DUAL UNION ALL SELECT 'banana', NULL FROM DUAL ) SELECT * FROM tblFRUIT WHERE cust_name NOT IN ( 'John', 'Mike') ;
Return output {orange, Adam}
My attempt with NOT EXISTS
Wanted output {{orange, Adam}, {banana, NULL}}WITH tblFRUIT AS ( SELECT 'kiwi' AS fruit, 'John' AS cust_name FROM DUAL UNION ALL SELECT 'apple', 'Mike' FROM DUAL UNION ALL SELECT 'orange', 'Adam' FROM DUAL UNION ALL SELECT 'banana', NULL FROM DUAL ) SELECT * FROM tblFRUIT WHERE cust_name NOT EXISTS ( SELECT cust_name FROM tblFRUIT WHERE cust_name IN ('John', 'Mike'))
Return output ORA-00920: invalid relational operator
I really hope you can help
Edited by: DaveyB June 28, 2011 08:17Keep things simple!
SQL>WITH tblFRUIT AS ( 2 SELECT 'kiwi' AS fruit, 'John' AS cust_name FROM DUAL UNION ALL 3 SELECT 'apple', 'Mike' FROM DUAL UNION ALL 4 SELECT 'orange', 'Adam' FROM DUAL UNION ALL 5 SELECT 'banana', NULL FROM DUAL 6 ) 7 SELECT * 8 FROM tblFRUIT 9 WHERE (cust_name IS NULL OR cust_name NOT IN ( 'John', 'Mike')) 10 ; FRUIT CUST ------ ---- orange Adam banana
URS
-
Keeping the description of the table on the evolution and not displaying only not NULL values
I have the table grouped by MPV and then showing by Fund. I can't get the description section appears for the first Fund and then when he changes nothing only shows funds. When the year changes once again it appears so.
ex.
MPV: 2005: 0100AXXXXD
but when changes in Fund 0100AXXXXD... nothing appears.
Also, I wanted to not include any funds/years that have the value null. I had the following code in, but it does not prevent null values.
<? If: SEC_ZERO_INDICATOR! = 0 ? >
Thanks for any help.Need to see your xml data structure. Can you send me the xml and the RTF file to [email protected]? I'll take a look.
Thank you
Bipuser -
Sorting and null for currency values in a report
All,
I think this should be easy, and I just missed something obvious.
I have an APEX 3.2.1 standard report that includes a column with a monetary value in it. I want the column to display the UK pound sign to be able to sort and display NULL values, as appropriate.
The question I have is that I can't find a way to reach all 3 in a medium satisfctory. As I see the options would be:
(1) in the SQL for the report, concat the pound sign in the required column, for example SELECT "£". amount OF the...
The problem is that it makes this field a CHAR field, so sorting is not sort of the same way as for a numeric field.
(2) use the format FML999 number... etc in the column attribute.
The problem with this is that it is a multi-country database, and the default currency unit is the value of the U.S. dollar.
(3) expression box to use HTML code in the column attribute to display £#COL #.
It fills the pound sign and keep the number format, but unfortunately a null value is displayed as a sign of pounds with no number. I do not see how so he can leave this value in the report as completely empty.
As I said, I'm sure I missed obvious soemthing. If someone can identify how to achieve this it would be much appreciated.
Kind regards
Jon.>
(2) use the format FML999 number... etc in the column attribute.
The problem with this is that it is a multi-country database, and the default currency unit is the value of the U.S. dollar.
>The NLS currency symbol can be changed on the fly if you have a few ways to identify the location/preference of the user: {: identifier of the thread = 990848} (ignore the last post)
However, it probably doesn't make sense to do - ≠ £100 $100 (at least I hope not!) - unless there is some sort of conversion occurring in the report? Is there a currency stored and the amount?
>
(3) expression box to use HTML code in the column attribute to display £#COL #.
It fills the pound sign and keep the number format, but unfortunately a null value is displayed as a sign of pounds with no number. I do not see how so he can leave this value in the report as completely empty.
>
Use 2 columns, one for the amount and one for the money, with a switch to include or exclude it if necessary:select ename , comm amount , nvl2(comm, '£', null) currency from emp where job in ('SALESMAN', 'MANAGER') ENAME AMOUNT CURRENCY ---------- ---------------------- -------------------------------- ALLEN 300 £ WARD 500 £ JONES MARTIN 1400 £ BLAKE CLARK TURNER 0 £
Then use the two columns in the Expression of the amount of HTML:
#CURRENCY##AMOUNT#
-
How to return a NULL value in LOV and insert into a field of allowingNULL number 4?
Hello
I have the following LOV and the return_value is PeopleId which is number 4, allowing NULL. And the LOV options are as follows:
LOV named--> select named LOV-
Show Extra values-> no
Dynamic translation-> - untranslated-
The number of columns - > 1
Display Null-> Yes
Null-> - Select value-
Return NULL,-> NULL value
^^^^^^^^^^^^^^^
----------------
List of values definition:
Select Lname | ', ' || Fname | ' ' || Mname as display_value, PeopleId as return_value
of PEOPLETB
where PEOPLETYPE ('i', 'HERE', 'IF')
order by 1
--------------
Given that PoepleId is a number 4, allowing NULL. I want a NULL value will be inserted, if the user does not select anything in the drop-down list. It seems that I would get "ORA-01722: invalid number" error when the PeopleId msg is null (ie: user doesn't have a selection). What is the good 'return Null value' I need to put it in? I tried "NULL" (see above) or nothing, it still does not work.
Any suggestions?
Thank you very much
HelenHello Helen,.
You have found one of the many sources of my frustration with APEX. Here's what I do:
In the definition of the element in your page, go to the LOV part and implemented like this:
Display Extra values: Yes a dynamic conversion (I ignore this)
Number of columns: 1 display Null: No.
Display null value: (leave blank) return Null value: (leave blank)An empty row is displayed when the user comes first to the screen. If they do NOT select the drop-down list, the value is left empty (null).
If anyone has a better way, I will definitely experiment with it.
Don.
-
Data in table, overwritten by the null value
I work on writing a VI that simulttaneously reading speed and pressure, then record them on separate tables. Hit a wall at about 90% of the way through.
The data (represented by random numbers for testing sake) comes in this central loop case then a VI "add to the table." Here is where it gets Sticky: when I use a null at the beginning of this table (top of the page highlighted) my data continually gets crushed in the row of the '0' table of each loop. But when I leave aside the value zero (low highlighted) my data are added to the table very well, but when I stop the VI together and restart, the new data values are just added at the bottom of the table. Any help would be appreciated.
Forgive my drawings Caveman to a VI, learning of the system on mine and just happened to a point of optimization. Thank you!
-Blaster
Hello Blaster,
What you did (perhaps accidentally) is created a uninitialized shift register, which will retain its value until the VI leaves memory. This can be an extremely powerful tool and can be used to create things like Motors of the Action, but if you need to erase the data between tracks, you will need to do additional work.
Looks like what you want to do is to maintain the value of your table, while the application is running, but clear is when restarting the application - which is correct?
If this is the case, then you have a few options. My recommendation would be to leave the uninitialized loop and use the primitive 'first call?"to check whether or not it is the first time your processing loop reiterated and replace the table 'used' with an empty array and null.
You might also consider using initialized worldwide feedback nodes, or half a dozen other methods that have benefits and different disadvantages. Congratulations on the job through the application, by the way!
-
How meter and analog value FIFO synchorize
I use a card NI 6123.
Anyone knows how to put 6 analog values and the value of the counter in FIFO with the same rate: 4 k.
Thus, every second, there should be 6 * 4 k analog values and 4 k in FIFO counter value.
The problem is:
1. the counter is a numeric value, so I can't put a sampling on it. So how can I put the value of the counter in the FIFO every second of 1/4000
2. how to sync analog channels and channel meter.
-------------------------
DAQmxErrChk (DAQmxCreateTask("",&datHandler));
DAQmxErrChk (DAQmxCreateAIVoltageChan(datHandler,"Dev1/ai0:5","",DAQmx_Val_Cfg_Default,-5.0,5.0,DAQmx_Val_Volts,NULL));)
DAQmxErrChk (DAQmxCfgSampClkTiming(datHandler,"",4000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,4000));
DAQmxErrChk (DAQmxCreateTask("",&ctrHandler));
DAQmxErrChk (DAQmxCreateCICountEdgesChan(ctrHandler,"Dev1/ctr0","",DAQmx_Val_Rising,0,DAQmx_Val_ExtControlled));
DAQmxErrChk (DAQmxStartTask (datHandler));
DAQmxErrChk (DAQmxStartTask (ctrHandler));
-----------------------------------
Thank you
It is possible to apply for a meter in the buffer. (this is actually preferred). Simply specify a sampling and source clock. Given that you want the meter to "lock" data from the meter to the same rate as the sample analog clock to simply specify this sample clock as the sample for the meter clock.
An example of event in the buffer (life-long) count can be found here by using an external clock (your HAVE sample digital Instruments\NI-DAQ\Examples\MStudioVC2005\Counter\Count Events\CountDigEventsBuffContinuous_ExtClk clock):...\National)
Check out this example and I think he should get you operational.
Maybe you are looking for
-
Time Machine, delete the old files from MacAir?
We had a MacAir and a MacPro at home and both were using backups time machine on our 2 TB Time Capsule. I sold the MacAir and replaced by a new MacBook. Can I delete the backups Time Machine of old MacAir and make room on my time Machine 2 TB for Mac
-
How to add to my HP Pavilion Elite HPE-590uk Usb 3.0
Hi does anyone know if I can improve my HP Pavilion Elite HPE-590uk for usb 3.0 and if so could you recommend a product that I could buy to do this. Thanks in advance.
-
Satellite M40x-105: Mini PCI Wifi card available?
Hello I recently bought a M40x-105. Does anyone know if she has a mini-pci card to install a wireless card? I know that I can use a pcmcia wireless card. Electron
-
Wireless driver not working not not win8-64
Hello I just bought a HP Pavilion 17-e073ed and an own win8 64-bit is installed. Now I got everything works except for internet wireless. I tried a lot of pilots 'just to see if one works' but nothing works. Some drivers just stop when installing...
-
Unable to send or receive e-mails. I get the server error: 0x800CCC90
Unable to send or receive e-mails. I get the server error: 0x800CCC90