on integer column SELECT statement returns no data
After the export and import of database of 32-bit database 10 g 2 64 bits, 10gR 1, I get strange resultsSelect * from test
returns 5 rows
but
Select * from test
where col3 = 1
returns no rows
where col3 is an integer column and has a value of 1 for all lines.
K1 is varchar2, col2 is varchar2 and col3 and col4 are columns of integers
/ Rajkum
You could start a ticket with the Support of Oracle for confirmation bug and see if there is a patch attached to your release.
Alternatively, if you have access to Metalink, search for 'erroneous results check constraint' and you will see a number of bugs confirmed around this area.
The solution recommended - other than to install a patch available - tends to set 10195 event to disable the use of predicates as check constraints.
For example
alter session/system set events '10195 trace name context forever, level 1';
If you go to the bottom of the event route, you may need to empty the pool shared before the definition of this event and execute the sql, otherwise you might find yourself just reuse the existing plan.
Tags: Database
Similar Questions
-
How to create a select statement to the data in two tables?
Hi allTable 1
ID YEAR
758 2013
Table 2
ID YEAR
758 2014
I want to create some that translates into two lines: function that does this?
ID YEAR
758 2014
758 2013
Thank you, best regards.
Hello
Perhaps a select * from table1 UNION ALL select * from table2 will help you.
concerning
Kay -
normalize the schema of the table in a select statement (without view)
Hello
I have a table storing a physical value, mean temperature for different locations every minute. The table schema is as following: timestamp (datetime), rental (string), value (number).
Do you know a way to have a select statement, return of lines with the following data: timestamp, the value at location1, value of place.2 guests, etc.
This will help me to create time series in he same diagram in my reporting tool.
This may be possible with a view, but I don't have access to the database, the best I can do is set my a data source such as a select statement.
Thank you!
Brahim
PS. We use Oracle 10 g R2
Hello
8e07ad81-CDAE-4c23-b0fb-b6cd117cf5bc wrote:
Hello
I have a table storing a physical value, mean temperature for different locations every minute. The table schema is as following: timestamp (datetime), rental (string), value (number).
Do you know a way to have a select statement, return of lines with the following data: timestamp, the value at location1, value of place.2 guests, etc.
This will help me to create time series in he same diagram in my reporting tool.
This may be possible with a view, but I don't have access to the database, the best I can do is set my a data source such as a select statement.
Thank you!
Brahim
PS. We use Oracle 10 g R2
What you're asking about is called pivoting. The ahs Forum FAQ page devoted to this topic: Re: 4. How can I convert rows to columns?
Since you're using Oracle 10, you cannot use the SELECT... Function PIVOT; You can use GROUP BY and CASE instead.
Do ' t worry not about creating views. What you can do with views, you can also do it using a WITH clause in your query.
If you get stuck, please post some sample data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also to publish the results you want from this data, as well as your best attempt to query a specific question.
Explain, using specific examples, how you get the results desired from data provided.
See the FAQ forum: Re: 2. How can I ask a question on the forums?
-
Details by e-mail to the people found in the select statement
Hello
I managed to send me an e-mail to test base for the first time.
However, I now require a method to be found via a SQL select with their information only email people.
for example, select statement returns the details below: -.
NAME OF APPLICATION DETAILS
Fred.Bloggs request2 details
Fred.Bloggs request4 details
Jim.Blair request3 details
I should concatenate the field IE @company.com
so
[email protected] receiving an email
"request2 details" completed
"request4 details" completed
and
[email protected] receiving an email
"Details of the request3" completed
I need help for the loop enter the full e-mail address of each person, and then send them only their data.
Thanks in advance for your help.
Wire UPDATE with news (previously the report erroneously) select sql statement
your Reported
Published by: user11962502 on December 1st, 2009 01:56
Published by: user11962502 on December 1st, 2009 02:02Hello
I don't have easy access to an Oracle instance to check it works and get the syntax right right right now but my first reaction would be to use a combination of rpad() and width as the column to be constant. This can be a you hard-code (IE, if you know what type of query will always say less than 8 characters) or ideally, first select the maximum length of the table:SELECT MAX(LENGTH(request)) + 3 INTO l_max_length FROM my_table WHERE clauses; /*Added the three to give a bit of extra space - modify to suit your needs*/
Then when you are out of the field, do something like:
message:=message || rpad(i.request,l_max_length - LENGTH(i.request));
This will ensure that everything is aligned. Of course, it only works if the email is sent in plain text and that the user is using a font to width fixed to read emails in plain text. Most people do, but do not count on it.
As before, the other option is to use an HTML table, however HTML emails are not very nice - try to stick with the plaintext if possible! :) -
selective elimination lines in a select statement
Hi friends,
I'm pretty new to SQL and need help to format the data in the table. I have a table where I get the data, and then group data in the weeks following the syntax below.
Select from the table
........
........
To_char Group (next_day (to_date(created_dt,''yyyy-mm-dd''), "WEDNESDAY"), "IW")
order of to_char (next_day (to_date(created_dt,''yyyy-mm-dd''), "WEDNESDAY"), "IW") desc))
where rownum < = 26 order by Etiquettemois ASC ';
Basically, group Wednesday as the day of the beginning of the week in the last 26 weeks.
Here is the data that I get after the execution of the query
Col1 Col2
06/07/2011 34
14/06/2011 20
21/06/2011 0
28/06/2011 30
.....
......
and so on up to 26 weeks. Note that the col1 contains the start date of the week.
Now, I need to remove all the lines that contain 0 select statement so that the select statement returns me the lines as below. How can I do it.
Col1 Col2
06/07/2011 34
14/06/2011 20
28/06/2011 30
.....
......
Kind regards
PradeepWell, the easiest way would be something like...
select * from (... your select statement ...) where col2 != 0
-
SELECT which returns a minimum of time
Hello
I don't know how to do a select. I'm goig to explain what I want to see wheter can someone help.
I have a select statement returns the columns following (table t):
handle_id, logon_id, object_name
....
....
I have another table with the following columns (table t0):
time0, handle_id, logon_id, object_name, source, eventid
....
....
If I make this selection:
Select t0.time0, t0.source, t0.eventid
t, t0
where t.handle_id = t0.handle_id and t.logon_id = t0.logon_id and t.object_name = t0.object_name
It returns me several records with the same State (handle_id, logon_id, object_name) because, of course, I said almost with the same conditions but with diferent time0.
I want to have only one record for each condtion with the shortest time0.
How can I do?
I tried with separate, but it is not what I want.
Thanks in advance.
Kind regards.select * from ( select t0.time0, t0.source, t0.eventid........ , t0.accesses, row_number() over(partition by t0.handle_id,t0.logon_id,t0.object_name order by t0.time0) rn from t, t0 where t.handle_id = t0.handle_id and t.logon_id = t0.logon_id and t.object_name = t0.object_name ) where rn = 1 /
If there may be several lines with 'shorter time0' for the same handle, logon_id, object_name, the above query returns olny one of these lines. If you want to get all these lines:
select * from ( select t0.time0, t0.source, t0.eventid........ , t0.accesses, dense_rank() over(partition by t0.handle_id,t0.logon_id,t0.object_name order by t0.time0) rn from t, t0 where t.handle_id = t0.handle_id and t.logon_id = t0.logon_id and t.object_name = t0.object_name ) where rn = 1 /
SY.
-
Formatting for a select statement
I am trying to include formatting in a select statement.
The data, I'm pulling compared to the SSN for a unique value. The problem is that the SSN is formatted with dashes in a table and not in the other.
Example:
Table 1
Name SSN
John 400-30-8745
Mary 348-00-4093
Table 2
Name SSN
John 400308745
Mary 348004093
What I would do is:
Select * into Table1, Table2 where table1.ssn = table2.ssn
However, I am unable to do so due to the formatting.
Thxs!It will not replace the data in the database because it is a SELECT statement and not a DML (INSERT, UPDATE, DELETE) statement. You can also consider putting a function based on this column in table1 index to facilitate this request. However, it depends on many factors and because we do not know the versions, estimated use, how many times the table is updated, etc., we can say with certainty whether this can help or not. An example would be:
CREATE INDEX TABLE1_SSN_FBIDX ON TABLE1(REPLACE(SSN,'-'))
-
validation for each 1,000 records to be inserted in the select statement
Hi, I have the following INSERTION in the SELECT statement.
The SELECT statement (who joined) data fo about 6 crores. I need to insert this data into another table.
Please suggest me the best way to do it.
I use the INSERT in the SELECT statement, but I want to use the statement commit for each 1,000 records.
How can I do this...
Thank youinsert into emp_dept_master select e.ename ,d.dname ,e.empno ,e.empno ,e.sal from emp e , dept d where e.deptno = d.deptno ------ how to use commit for every 1000 records .
Method 4 is the best
You could combine method 3 and 1 (without dynamic SQL)
Method 2 is the less optimal solution from the list.
-
Exception No_data_found to insert into... select statement
Hai,
I have a doubt in plsql exceptions. In the sub program mentioned plsql.
Start
insert into select abc * xyz a, b of cdf where a.c1 = b.c2;
exception
When no_data_found then
do some operations
end;
In the pl/sql block above, if the select statement returns no rows, whether or not the exception is triggered? If not, how do the same. Any available alternative.
Thanks in advance.
Concerning
SridharYou would get an error no_data_found triggered at that time there, because it's perfectly valid to insert rows 0.
You will need to check SQL ROWCOUNT % and raise the no_data_found if it is equal to 0.
-
SELECT statement to return a type in Oracle objects
Hi all, I have created a small system for Uni using oracle objects and types. I have a table person with type of seller under the person table and the type of claimant to the title of the person table. I need the select statement to return data of the person, table, but only the type of applicant data. for example, SELECT * FROM person_tab, WHERE the type is applicant_t. I know it's probably simple, but just can't get the syntax right. The code all series just may not get the right to choose. Thanks for your time.
create type appointment_t; create type property_t; create type telephone_t as object ( weekdayDaytime varchar2(15), weekdayEveningAndWeekend varchar2(15)); create type person_t as object ( person char(6)) not final; create type appointment_list_t as table of ref appointment_t; create type property_list_t as table of ref property_t; create type salesperson_t under person_t ( sSurname varchar2(20), sForename varchar2(20), dateOfBirth varchar2(12), makes appointment_list_t, member function appointments_made return number ); create type applicant_t under person_t ( aSurname varchar2(20), aForename varchar2(20), dateOfBirth varchar2(12), aAddressLine1 varchar2(25), aAddressLine2 varchar2(25), aTown varchar2(20), telephoneNums telephone_t, maxPrice number(10), desiredArea varchar2(20), attends appointment_list_t, member function appointments_attended return number ); create or replace type body salesperson_t as member function appointments_made return number is total number; begin total := self.makes.count; return total; end; end; create or replace type body applicant_t as member function appointments_attended return number is total number; begin total := self.attends.count; return total; end; end; create or replace type appointment_t as object ( appointment char(10), appdate date, apptime varchar2(15), appointmentType varchar2(15), levelOfInterest integer(3), offerMade number(10), is_made_by ref salesperson_t, is_attended_by ref applicant_t, is_related_to ref property_t); create or replace type property_t as object ( property char(10), dateOfRegistration date, propertyType varchar2(15), bedrooms integer(2), receptionRooms integer(2), bathrooms integer(2), garage varchar2(5), garden varchar2(6), regionArea varchar2(20), pAddressLine1 varchar2(20), pAddressLine2 varchar2(20), pTown varchar2(20), askingPrice varchar2(20), relatesTo appointment_list_t); create table person_tab of person_t ( person primary key ); create table property_tab of property_t ( primary key(property)) nested table relatesTo store as relates_to_table; create table appointment_tab of appointment_t ( primary key (appointment), scope for (is_made_by) is person_tab, scope for (is_attended_by) is person_tab, scope for (is_related_to) is property_tab); insert into person_tab values (salesperson_t('s001', 'Fontigue', 'Farquar', '22-feb-1980', appointment_list_t())); insert into person_tab values (salesperson_t('s002', 'Richmond', 'Neil', '30-feb-1983', appointment_list_t())); insert into person_tab values (salesperson_t('s003', 'Devere', 'Jeremy', '03-mar-1977', appointment_list_t())); insert into person_tab values (salesperson_t('s004', 'Schofield', 'Paul', '07-dec-1969', appointment_list_t())); insert into person_tab values (salesperson_t('s005', 'Johnson', 'Richard', '04-jul-1992', appointment_list_t())); insert into person_tab values (salesperson_t('s006', 'Stevens', 'Rupert', '22-may-1989', appointment_list_t())); insert into person_tab values (applicant_t('ap007', 'Hadfield', 'Linda', '22-nov-1981', '3 Duckdoo Avenue', 'Rosemont', 'Neath Port Talbot', telephone_t('01639877103', '07756338175'), '110000', 'Mumbles', appointment_list_t())); insert into person_tab values (applicant_t('ap008', 'Walsh', 'Riley', '18-sep-1974', '12 George Street', 'Taibach', 'Neath Port Talbot', '01639890337', '075982228741', '125000', 'Ten Acre Wood', appointment_list_t())); insert into person_tab values (applicant_t('ap009', 'Kennedy', 'Shaun', '11-dec-1972', '101 Granada Close', 'Waun Wen', 'Swansea', '01792558447', '07894558123', '150000', 'Central Swansea', appointment_list_t())); insert into person_tab values (applicant_t('ap010', 'Redgrave', 'Steven', '30-jun-1988', '47 Victoria Gardens', 'City Apartments', 'Neath', '01639770183', '07774273391', '95000', 'Neath', appointment_list_t())); insert into person_tab values (applicant_t('ap011', 'Hopkins', 'John', '07-feb-1979', '130 Flanders Court', 'Richfield', 'Bridgend', '01656889227', '05589337123', '137500', 'Brechfa', appointment_list_t())); insert into person_tab values (applicant_t('ap012', 'Glover', 'Germaine', '14-aug-1983', '32 Regent Crescent', 'Cranforth', 'Cardiff', '01210887336', '07975625195', '170000', 'Cardiff West', appointment_list_t()));
The one I am running made the telephone_t in all households.
Happy that you have your code working but that was not my point
It comes to you providing us with the correct instructions to actually run the test case and help you efficiently.
Regarding your last question, use the function of REGAL to caster level being superior in one of its subtype.
for example
SQL> select person 2 , treat(object_value as applicant_t).aSurname as surname 3 , treat(object_value as applicant_t).aForename as forename 4 from person_tab 5 where object_value is of (applicant_t) ; PERSON SURNAME FORENAME ------ -------------------- -------------------- ap007 Hadfield Linda ap008 Walsh Riley ap009 Kennedy Shaun ap010 Redgrave Steven ap011 Hopkins John ap012 Glover Germaine 6 rows selected.
-
mixture of column type in the select statement
Oracle 11g r2.
tab_test (name varchar2, blob... photo)
(1) select general use *.
Stored procedure: open ref_cursor to some * of table_test...
Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR); Call.Execute ();
It works very well.
(2) enter the name of the column in the select such as
Stored procedure: open ref_cursor to select name, photo table_test...
Coast of java: call.registerOutParameter (1, OracleTypes.CURSOR); Call.Execute ();
ERROR: java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent data types: expected - got BLOB
My question, if I specify the column names in the select statement, including the varchar2 and blob, how can I registerOutParameter (1, OracleTypes.CURSOR);?
Thank you
Scott
PS The number of returned columns, in real case schenario, is a little, so I prefer to specify column names.
Wrong forum. This forum is for questions of sql and pl/sql.
Enter the question ANSWER and the repost in the JDBC forum
When repost you provide the necessary information to help you:
1. information on the full version for Oracle DB
2 version of the JDK
3. the name and version of the JDBC jar file
4. real code that demonstrates the problem
You should also review the info re REF CURSOR in the JDBC Developer's Guide
http://docs.Oracle.com/CD/E16655_01/Java.121/e17657/oraint.htm#i1058743
-
Get the types of columns in a select statement
Hello
Is there a way to get the types of columns that results in a select statement?
For example to force an analysis on this topic and then look for the types of columns resulting in the view v$?
Best regards
Klaus Mogensen
declare c number; d number; col_cnt integer; rec_tab dbms_sql.desc_tab; col_num number; begin c := dbms_sql.open_cursor; dbms_sql.parse(c, 'select dummy, 33 x, sysdate now from dual', dbms_sql.native); dbms_sql.describe_columns(c, col_cnt, rec_tab); col_num := rec_tab.first; while col_num is not null loop dbms_output.put_line( rec_tab(col_num).col_name || ' ' || case rec_tab(col_num).col_type when 1 then 'varchar2' when 2 then 'number' when 12 then 'date' else '???? ' || rec_tab(col_num).col_type end ); col_num := rec_tab.next(col_num); end loop; dbms_sql.close_cursor(c); end; / DUMMY varchar2 X number NOW date
-
Return multiple values from a function in a SELECT statement
I hope I've provided enough information here. If not, let me know what I'm missing.
I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).
Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.
For example, right now, I have:
Table 1:
sequence_number NUMBER (10),
name varchar (30),
...
Table2:
Table1_seq NUMBER (10),
action_seq NUMBER (10),
action_date DATE,
action_office VARCHAR (3),
action_value VARCHAR (60),
...
I can't just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.
The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in the SELECT statement.
CREATE VIEW all_this_stuff AS
SELECT sequence_number, name,
RP.action_date (sequence_number) action_date,
RP.action_office (sequence_number) action_office,
RP.action_value (sequence_number) action_value
FROM table1
Is there a way to return multiple values in my SELECT statement or I'm going about this all wrong?
Any suggestions?
Thank you very much!Hello
What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, like this:
WITH got_rnum AS ( SELECT action_seq, action_dt, action_office, action_type, action_value , ROW_NUMBER () OVER ( ORDER BY action_date , action_seq , action_serial ) AS rnum FROM table2 WHERE action_code = 'AB' AND action_office LIKE 'E' -- Is this right? ) SELECT action_seq, action_dt, action_office, action_type, action_value FROM got_rnum WHERE rnum = 1 ;
As written, this returns a single line (at most).
I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
In this case, add a PARTITION BY clause to the ROW_NUMBER function.
If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
As I don't have your tables, I'll show you the use of the tables in the scott schema.
This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.CREATE OR REPLACE VIEW senior_emp AS WITH got_rnum AS ( SELECT d.deptno , d.dname , e.empno , e.ename , e.hiredate , ROW_NUMBER () OVER ( PARTITION BY d.deptno ORDER BY e.hiredate , e.empno ) AS rnum FROM scott.dept d JOIN scott.emp e ON d.deptno = e.deptno ) SELECT deptno , dname , empno , ename , hiredate FROM got_rnum WHERE rnum = 1 ; SELECT * FROM senior_emp ;
Output:
. DEPTNO DNAME EMPNO ENAME HIREDATE ---------- -------------- ---------- ---------- --------- 10 ACCOUNTING 7782 CLARK 09-JUN-81 20 RESEARCH 7369 SMITH 17-DEC-80 30 SALES 7499 ALLEN 20-FEB-81
Moreover, one of the conditions to the query you posted has been
action_office LIKE 'E'
which equals
action_office = 'E'
(AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
Did you mean say that or did you mean something like this:action_office LIKE 'E%'
Instead?
-
SELECT statement: no data found
I have the following select statement:
However, I got this error when he tried to enter this if statement when l_customerID = 0DECALRE l_customerID INTEGER :=0; BEGIN SELECT DISTINCT customer_id into l_customerID FROM customer where status = 'd'; If l_customerID = 0 then DBMS_OUTPUT.PUT_LINE('Not deactivated') else DBMS_OUTPUT.PUT_LINE('deactivated') end if; END /
How to do in the stated case when l_customerID = 0 or should I change my select statement or what?ORA-01403: no data found
Hi try this
l_customerID INTEGER :=0; BEGIN select nvl((SELECT DISTINCT customer_id into l_customerID FROM customer where status = 'd'),'-1') from dual If l_customerID = 0 then DBMS_OUTPUT.PUT_LINE('Not deactivated') else DBMS_OUTPUT.PUT_LINE('deactivated') end if; END /
It only works if the inner query will return a single line... If a return that one line will return the exception of other lines.
Concerning
Singh -
There are two select statement, which are as follows: 1) select project id, the name of ppm.pm_projects project_name and request_id 2) select id, name from request_type_name to kcrt_request_details. There is a column called entity that can store a value i.e. project or request. I want to write a select statement containing a condition that is if the entity name is project and then run the select statement 1 otherwise, if the name of the entity's request, then run the select statement 2. All this must be written in a select statement. Can someone help me how to write this select statement type.
Hello
Hello
2726057 wrote:
... There is a column called entity that can store a value i.e. project or request. ...
In which table is this column? Assuming that it is in a table called entity_table, you can do something like this:
SELECT project AS id
project name AS the name
OF ppm.pm_projects
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = "Project".
)
UNION ALL
SELECT request_id ID
request_type_name AS name
OF kcrt_request_details
WHEN THERE IS)
SELECT 1
Of entity_table
Entity WHERE = 'ask '.
)
;
This does not have anything on the number of lines is entity_table, or what are the values in the column of the entity. In other words, the query works in all cases. If any line in entity_table entity = 'Project', then the pm_projects data will be included in the result set. If any line in entity_table entity = 'Request', kcrt_request_details data will be included.
I hope that answers your question.
If this isn't the case, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
Maybe you are looking for
-
Photos app frustrates me. I can't do simple things such as importing a photo in an email without having to open the Photos app and drag and drop a picture in an open email. Cannot even name a file. It only adds a tag. I want something like the ph
-
Tap simple trackpad issue integrated
You just bought Macbook Air MMGF2HN/A. There the last OS X El Capitan 10.11.5. Having some problems with the only tap water in the built-in trackpad. Sometimes (not often) the single tap doesn't work. For example, I tap on a tab in an application, bu
-
HP Pavilion a1v33ua #ABC g6: need drivers for HP Pavilion g6 a1v33ua #abc
Specifically, the network drivers. Thank you.
-
Unable to access the Dell Inspiron n5110 webcam
can't access webcam and it does not appear in devices but youtube Manager how to fix that can access? I have a dell insperion notebook n5110.
-
Cannot install HP Photosmart C310 on Win 7 Pro
I tried to install it in a single device, but the installation will stop. I managed to install as a printer Basic, but since having a new attempt to get the scanner to work, I now can not install at all! I get an error that the driver is not found -