oracle10g

Oracle stored procedure an INTO clause is expected in this SELECT statement

不问归期 提交于 2020-01-14 09:22:29
问题 I am having a stored procedure mentioned below. create or replace PROCEDURE example( in_start_date IN VARCHAR2, in_svc_provider IN a_message.msg_service_provider%type,sell OUT number) IS BEGIN SELECT COUNT(*) as sell FROM a_message b1 WHERE TO_CHAR(b1.msg_when_created,'YYYY-MM-DD') = in_start_date AND b1.msg_trans_type = 'SELL' AND b1.msg_service_provider = in_svc_provider; end; While executing the stored procedure I am getting following error. Error(11,1): PLS-00428: an INTO clause is

Oracle SQL: Counting in 4h?

人走茶凉 提交于 2020-01-14 04:44:05
问题 I have oracle 10g database with table of many records. Table has data for employees receiving some kind of orders. Most usable columns are employee, dt and orderId (I've attached example). I want to construct select that will select records of an employee that had 6 or more orders in any 4h. I used regular join, various functions but I still didn't made usable select. I couldn't make select that will for each record search in past(4h) and see if there are 6 orders for same employee. Any help

handling HTML data in Oracle query

纵饮孤独 提交于 2020-01-14 03:25:53
问题 I have a table with ID,TEXT,etc columns Here TEXT is clob column which contains data in HTML FORMAT SELECT ID,TEXT FROM TABLE WHERE ID=1000 I'm getting output for text column as below <p>NAME:  XXX<br />Company Name:  YYYYY<br />Location: ZZZ, 22 Z1Z1Z1, Z2Z2Z2,Z3Z3Z3, 0000024, IND<br />Type: PrePA<br /> Team: Team1, Dues tamble <br />Date: January 25 – 26, 2016<br />Rating:  Tr 2<br />Number: 8554342</p> <p><u>Observ: <br /></u>There were (6) major and (2) minor .<br /> <br />MAJOR</p><ul>

Select all from table Oracle

只愿长相守 提交于 2020-01-14 03:12:13
问题 I wrote a stored procedure to select all records from a table. Since I'm new to Oracle I have few questions. Is this Correct? Is this the best way to select all records from a table? How can I view result in SP in DB level? alter PROCEDURE employee_getall ( cv_results in out sys_refcursor ) IS BEGIN open cv_results for select * from employee_master EXCEPTION WHEN OTHERS THEN NULL ; END; 来源: https://stackoverflow.com/questions/30442927/select-all-from-table-oracle

Why does Oracle SQL mysteriously resolve ambiguity in one joins and does not in others

99封情书 提交于 2020-01-13 14:56:32
问题 I'm an Oracle 10g user. I had to write some SQL queries, and spotted a mysterious (as I see it) behaviour. Let's pretend we have a table, which is able to join itself in some kind of simple two-level tree structure. The next query gives me "ambiguity error", which is expected: select title from table1 left join table1 on condition BUT if I would add one more table to the join, the ambiguity problem will simply go away: select title from table1 join table2 on other_condition left join table1

sequence creation in oracle

夙愿已清 提交于 2020-01-13 10:23:06
问题 I want to create a sequence in oracle where the max value of the column field (Empid) must be the min value of the sequence. The below was the one i found in our same stackexchange create sequence mytemp_seq start with &v_Startval; This command prompts me to enter the max value of teh column name which i have to enter. How can I fix the value of &v_startval with out it prompting ,but directly setting the values from the below statement select max(empid) from mytemp.. I am trying like this

Dynamically select the columns to be used in a SELECT statement

可紊 提交于 2020-01-13 09:01:53
问题 I would love to be able to use the system tables (Oracle in this case) to drive which fields are used in a SELECT statement. Something like: SELECT ( select column_name from all_tab_cols where table_Name='CLARITY_SER' AND OWNER='CLARITY' AND data_type='DATE' ) FROM CLARITY_SER This syntax doesn't work, as the subquery returns multiple rows, instead of one row with multiple columns. Is it possible to generate a SQL statement dynamically by querying the table schema information in order to

Get the top row after order by in Oracle Subquery

ⅰ亾dé卋堺 提交于 2020-01-12 07:42:11
问题 I have a table student(id, name, department, age, score). I want to find the youngest student who has the highest(among the youngest students) score of each department. In SQL Server, I can use following SQL. select * from student s1 where s1.id in (select s2.id from student s2 where s2.department = s1.department order by age asc, score desc top 1). However, in Oracle, you cannot use the order by clause in subquery and there is no limit/top like keyword. I have to join the student table with

How to get datetime in 24hour format from oracle database?

随声附和 提交于 2020-01-12 02:50:33
问题 Is there any other way to get datetime field from oracle database in 24hour format???like -> "select getxsddate(col_name) from tab_name" will get you datetime format as "2012-04-04T12:31:00"...I wanted to know if there are any other ways as i`m not satisfied with this format. 回答1: select to_char(col_name, 'yyyy-mm-dd hh24:mi:ss') from tab_name You can read more about to_char function here 回答2: Another very simple way is to set, in the database nls parameters, the parameter date_format='DD-MM

Query correction needed

喜夏-厌秋 提交于 2020-01-11 14:43:30
问题 select stdcode,name,degree_code,phone,startsemester,endsemester from ( select distinct stdcode as stdcode,name as name,degree_code as degree_code,phone as phone, ( SELECT sem_code FROM V_ALLSTUDATA b WHERE a.name = b.name and a.stdcode= b.stdcode and a.degree_code=b.degree_code and a.phone=b.phone AND startsem=(select min(startsem) from V_ALLSTUDATA b) ) as startsemester, ( SELECT sem_code FROM V_ALLSTUDATA b WHERE a.name = b.name and a.stdcode= b.stdcode and a.degree_code=b.degree_code and a