oracle9i

Convert columns to rows in SQL [duplicate]

左心房为你撑大大i 提交于 2019-12-10 02:49:12
问题 This question already has answers here : Oracle SQL pivot query (2 answers) Closed last year . I need to write a query which takes rows and converts it into columns - here's my table: Count fname lname id ----------------------------- 1 abc def 20 2 pqr 20 3 abc xyz 20 4 xyz xyz 20 1 abc def 21 1 pqr xyz 22 2 abc abc 22 This is the output I'm trying to produce: id fname lname fname lname fname lname fname lname ------------------------------------------------------------- 20 abc def pqr NULL

Why does a connect by expression in a FOR loop, execute only once?

断了今生、忘了曾经 提交于 2019-12-09 07:51:28
问题 I just found what I think is somewhat unexpected behavior in PLSQL vs SQL in Oracle. If I run this query on SQLDeveloper I get 5 results: select level lvl from dual connect by level <=5; But if i run this statement in SQLDeveloper: declare w_counter number :=0; begin for REC in (select level lvl from dual connect by level <=5) loop w_counter := w_counter+1; end loop; dbms_output.put_line('W_COUNTER: '|| w_counter); end; The variable w_counter finishes with value 1 (weird) but the weirdest

Defining a Character Set for a column For oracle database tables

ε祈祈猫儿з 提交于 2019-12-09 04:42:39
问题 I am running following query in SQL*Plus CREATE TABLE tbl_audit_trail ( id NUMBER(11) NOT NULL, old_value varchar2(255) NOT NULL, new_value varchar2(255) NOT NULL, action varchar2(20) CHARACTER SET latin1 NOT NULL, model varchar2(255) CHARACTER SET latin1 NOT NULL, field varchar2(64) CHARACTER SET latin1 NOT NULL, stamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, user_id NUMBER(11) NOT NULL, model_id varchar2(65) CHARACTER SET latin1 NOT NULL, PRIMARY KEY (id), KEY idx_action (action) ); I

Error while inserting data having single quotes between it

随声附和 提交于 2019-12-08 11:19:16
问题 I have an application that is saving clob data into database. Suppose when I put some text into textbox and then click save. It will call a procedure that will insert this text (clob) into database table. Suppose I have the following text: Hi i am gaurav's soni's Now my procedure take this clob data as: insert into rtf_clob(1,'Hi i am gaurav's soni's'); This however throws an error. How to handle this single quote in dynamic data coming from front end? I'm using oracle as RDBMS. 回答1: You

retrieving long raw data into clob variable

六月ゝ 毕业季﹏ 提交于 2019-12-08 07:16:41
问题 I want to retrieve long raw data from a column having data type long raw into a clob variable. If I directly write insert statement , I am not able to insert into long raw column. I have to use utl_raw.cast_to_raw(..) function for inserting text into long raw column. Can someone explain this issue? Let me explain you the workflow for this User enters formatted text in a rich editor control in Delphi and saves. Data is saved in a long raw column. User clicks on a button in Delphi and data

Converting integer value from a db column to text in oracle

那年仲夏 提交于 2019-12-07 19:01:14
问题 I have a requirement in db. 1).Table ABC, column: check_amount number number(18,4) . This basically contains check amount for eg. 3000.50 to be paid to an employee. Now a cheque is issued and that check contains this check_amount in number as well as in text form.for eg.check will have: pay to <emplyee_name> ****$3000.50**** ****THREE THOUSAND DOLLARS AND FIFTY CENTS**** I have to generate this text using DB column value and display that on check. Can anybody help me out, how can i achieve

Specify IBatis query timeout

你。 提交于 2019-12-07 16:48:53
问题 There is a way to specify IBatis query timeout using oracle jdbc and Java? Thanks 回答1: From the iBatis manual : in the <settings> element : defaultStatementTimeout (iBATIS versions 2.2.0 and later) This setting is an integer value that will be applied as the JDBC query timeout for all statements. This value can be overridden with the “statement” attribute of any mapped statement. If not specified, no query timeout will be set unless specified on the “statement” attribute of a mapped statement

retrieving long raw data into clob variable

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 00:33:26
I want to retrieve long raw data from a column having data type long raw into a clob variable. If I directly write insert statement , I am not able to insert into long raw column. I have to use utl_raw.cast_to_raw(..) function for inserting text into long raw column. Can someone explain this issue? Let me explain you the workflow for this User enters formatted text in a rich editor control in Delphi and saves. Data is saved in a long raw column. User clicks on a button in Delphi and data should retrieve from the long raw column and display in the rich editor control. So all we need is a SQL

Is there another command for wm_concat in oracle 9i?

≯℡__Kan透↙ 提交于 2019-12-06 11:18:34
问题 I have a table containing dept id, employee names and date of joining. I want to get a list of all the employees who joined on a given day in a given dept. wm_concat is not working. 回答1: According to this, WM_CONCAT is not supported. WM_CONCAT is an undocumented function and as such is not supported by Oracle for user applications You can use a user defined aggregate function described in that link. 回答2: Try wmsys.wm_concat (10g+) or listagg (11g+) 回答3: See the String Aggregation Techniques

count number of rows that occur for each date in column date range

蓝咒 提交于 2019-12-06 11:07:29
问题 I have a table with data such as below Group Start Date End Date A 01/01/01 01/03/01 A 01/01/01 01/02/01 A 01/03/01 01/04/01 B 01/01/01 01/01/01 ETC I am looking to produce a view that gives a count for each day, like this Group Date Count A 01/01/01 2 A 01/02/01 2 A 01/03/01 2 A 01/04/01 1 B 01/01/01 1 I am using Oracle 9 and am at a total loss on what how to handle this and am looking for any idea to get me started. Note: Generating a table to hold the dates is not practical because I final