SQL & PL/SQL :: Assigning Numbers To The List?

Apr 10, 2012

acheive the below result.

Select * from result;

res
===
3
3
3
3
3
0
3
3
3
0
3
0

output:

I would like to get res1 using SQL query.

resres1

31
32
33
34
35
00
31
32
00
31
32
33
34
00
.. ....

View 9 Replies


ADVERTISEMENT

Application Express :: Assigning Value To Select List Only First Time Page Loads

Jan 3, 2013

I am trying to set the intial value of "Select List" to APP_USER the only first time when the page loads and use it to filter the report, any other time once the page is loaded the user should select another value from the Select List then click the submit button to display the details in the report, i tried to achieve this by setting "select List" creating LOV for Select List then set default=APP_USER but now the problem any time you click the submit button it reset the "Select List" from selected value back to default so how can you achieve this to set the value of Select List only the first time the page loads?

View 1 Replies View Related

SQL & PL/SQL :: Extracting Numbers And Few Portion Of Text From A String Containing Dates / Characters And Numbers

Jul 13, 2011

I have a table test with column containing dates, characters and numbers. I have to extract the number part and the three characters before the number . My data looks like :

TEST
ID DATA
1 3/12/2007
2 0
3 3/8/2010 ABC 217
4 NONE
5 COLM XYZ 469 6/8/2011
6 LMN 209

My expected results should look like :

ID DATA
1
2
3 ABC 217
4
5 XYZ 469
6 LMN 209

View 7 Replies View Related

SQL & PL/SQL :: Assigning Value To A Variable?

Jun 14, 2011

Can I assign the outcome of a select query to a defined variable

like

var=select emp id from emp where empname='ddf'

View 5 Replies View Related

SQL & PL/SQL :: Assigning ID (Fill SID Column)

Feb 4, 2013

I have a table with 200k entries, which has ~12k unique combination of columns that I wish to assign an ID to. My real world problem is with addresses and street components (of which nulls are allowed); but this should be a reasonable example.

DROP TABLE tt;

CREATE TABLE tt AS
SELECT ROWNUM id,
CASE
WHEN MOD(ROWNUM, 107) = 0 THEN NULL
ELSE MOD(ROWNUM, 101)
END
c1,
CASE

[Code]...

Now I have 3 ways to assigned an ID (fill the SID column).

The first is congruent with the method most commonly used, but seems especially slow in this case. I think this is due to the COALESCE/TO_CHAR usage. Can this be optimized?

DECLARE
CURSOR c1 IS
SELECT a.*, sid_seq.NEXTVAL sid
FROM (SELECT DISTINCT c1, c2 FROM tt) a;
BEGIN
FOR s IN c1 LOOP
UPDATE tt d

[Code]...

The second I've made relies on the usage of a temp table, which I really don't like, but it is faster; so that is something at least.

CREATE TABLE ttt AS
SELECT a.*, sid_seq.NEXTVAL sid
FROM (SELECT DISTINCT c1, c2 FROM tt) a;

[Code]...

The third discards the sequence, and uses dense_rank. This allows us to use the ID (which might have an index, whereas c1 and c2 will not).

MERGE INTO tt d
USING (SELECT id, (SELECT COALESCE(MAX(sid), 317) FROM tt) + DENSE_RANK() OVER (ORDER BY c1, c2) sid FROM tt) s
ON (d.id = s.id)
WHEN MATCHED THEN
UPDATE SET d.sid = s.sid

The ideal solution would use the SEQUENCE, not use a temporary table and match/merge/update based on ID, and be 'fast'; but I cannot conceive of such a solution; does one exist? What would you do?

View 2 Replies View Related

PL/SQL :: Assigning Varchar2 Index On Bulk Collect

Dec 14, 2012

if it is possible to assign a varchar2(14) index to a pl/sql table while fetching bulk data with bulk collect.my requirement is to assign varchar2(14) index to a pl/sql table so that i can directly reach to my record by index and process the record further.

further i need to run a loo on this ( for processing each record)my database version is 11.2.01.0.

View 4 Replies View Related

PL/SQL :: Assigning Dynamically Created Sequence Value To Variable

Jan 23, 2013

in my procedure i am creating a sequence on the fly, i am preparing the name with some passed parameters like below

v_seq_name := 'seq_'||loadid||v_table_name;
execute immediate 'CREATE SEQUENCE '||v_seq_name||' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment by 1 cache 20';

and now after doing some operations i need to assign the current value of sequence to a number variable i tried following but not working

1) v_curr_value : = v_seq_name.currval ;
2) select v_seq_name||'.nextval' into v_curr_value from dual;

how i can get the value in plsql block.

View 4 Replies View Related

Precompilers, OCI & OCCI :: (ORA-01480) Error While Assigning Value To A Variable?

Sep 23, 2008

I am writing a code in Proc as

<code>
#define SMSDUN_LANGID_LEN 10

-- other statements

EXEC SQL BEGIN DECLARE SECTION
char dbLanguageId[SMSDUN_LANGID_LEN + 1];
EXEC SQL END DECLARE SECTION

-- other statements

EXEC SQL EXECUTE
BEGIN
SELECT LANGUAGE_ID -- Length of this column is 10
INTO :dbLanguageId
FROM CUSTOMERATTRIBUTES

[code]...

While executing the above command, it is giving error as "ORA-01480: trailing null missing from STR bind value". Its working in some oracle versions but not in other. where exactly the problem is.

View 1 Replies View Related

Forms :: How To Avoid (no List Elements Defined For List Item) Error

Sep 27, 2011

I am creating the Dynamic list but when i am compiling the form it gives the compilation error "No list elements defined for the list item".

I can eliminate it by entering the dummy list element but this dummy value will be displayed at form run time.

View 1 Replies View Related

List Products List Of Client Grouped By Type Of Product?

Dec 14, 2011

Im trying to list the products list of a client grouped by type of the product. Ex:

product type

prod.A acid
prod.B flavour
prod.C acid
prod.D cleaner
prod.E flavour

I want to list something as:

Acid

Prod.A
Prod.C

Cleaner

prod.D

Flavour

prod.B
prod.E

View 1 Replies View Related

Forms :: FRM-30351 / No List Elements Defined For List Item

Oct 30, 2011

DECLARE
CURSOR GRP IS
SELECT RowNum rn, Letter_Group_ID||'-'||A_Desc AName,Letter_Group_ID
FROM Hrs_Group;
BEGIN
Clear_list('Letter_Group_ID');
FOR I IN GRP LOOP
Add_List_Element('Letter_Group_ID',I.rn,I.AName,I.Letter_Group_ID);
end loop;
END;

FRM-30351: No list elements defined for list item.

List LETTER_GROUP_ID

View 4 Replies View Related

SQL & PL/SQL :: List All Tables Connected To Each Other With Constraints And List All Together

Apr 22, 2013

I just want to list and group all my tables that are linked together by constraints. I just want my tables to be able to be listed together as one particular database. my tables are , CUSTOMER, ORDER_INFO, ORDER_LINE, PRODUCT. They're all linked together by way of constraint and I want to list and print them all together as one DB. HOW DO I put them all in one schema and then also list them all together and print/illustrate them as one. also, I tried to import them into their own scheme but i ran into a series of probs regaurding the .dmp file being read.

View 2 Replies View Related

String Of Numbers

Oct 12, 2007

I have the following set of numbers that i am passing in as one input into a stored procedure.

234,456,234,456,567

Now i want to take this list of numbers and use it in an IN statement:

select * from table where column_a in (P_INPUT);

however, when i try this, it give me an invalid error. I have tried inserting single quote around each value and get the same invalid error. I tried a To_char around my column, which solved the error, but it never finds a match!

View 6 Replies View Related

SQL & PL/SQL :: How To Get Random Numbers

Jul 1, 2010

I want to get 10 random numbers from existing 100 numbers. How can we get/generate random numbers ?

for example I have a table with customer ID, customer Name, having 100 record. We want 10 customers ID randomly from that 100 record not repeated any number. Have any command or procedure for that ?

View 3 Replies View Related

SQL & PL/SQL :: How To Get Column Containing Numbers Only

Jul 25, 2010

I have a column of datatype varchar2

this column may contain char or may contain number or may contain both

some values in this column are only number is there any function or any other way to get those column that are only number

View 3 Replies View Related

SQL & PL/SQL :: Combinations Of Numbers

Nov 1, 2010

Earlier, we had a discussion how to generate the permutations. generating the code for combinations

For eg: if I have input as [1,2,3,4,5] then 5c2 = 20 combinations should be generated as pairs

1,2
1,3
1,4
1,5
2,3
2,4
2,5
3,4
3,5
4,5

Total of 10 combinations

View 8 Replies View Related

SQL & PL/SQL :: Function To Sum Five Numbers

Apr 13, 2013

I am creating a function to sum five numbers (less 1). Is it possible to have an array of numbers in an SQL function, and how would this be implemented?

Here is the screenshot of my output (I cannot embed links until 5 posts!): flic.kr/p/eaSHBP

CREATE OR REPLACE FUNCTION sumfivenumbers ( n1 NUMBER, n2 NUMBER, n3 NUMBER, n4 NUMBER, n5 NUMBER)
RETURN NUMBER
IS
Sumnums NUMBER;
BEGIN
SELECT SUM(n1+n2+n3+n4+n5-1) INTO Sumnums FROM DUAL;
DBMS_OUTPUT.PUT_LINE(Sumnums);
RETURN 1;
END sumfivenumbers;
/
SELECT sumfivenumbers(5,5,5,5,5) AS "Five Numbers less 1" FROM DUAL;

View 7 Replies View Related

SQL & PL/SQL :: Selecting 1st And 2nd TOP Numbers (from Same Row)

Jul 6, 2012

I need to find the top two values value for each ID Number:

CREATE TABLE TABLE_1
(ID number (8),
NUMBER_1 number (2),
NUMBER_2 number (2),
NUMBER_3 number (2),
NUMBER_4 number (2));

INSERT INTO TABLE_1
VALUES
('12345679','30','25','30','05');
INSERT INTO TABLE_1
VALUES
('99999999','30','25','15','05');

Desired Result:

ID Number 1st 2nd
12345679 30 30
99999999 30 25

View 7 Replies View Related

SQL & PL/SQL :: Numbers To Alphabets

Jul 6, 2013

I have a requirement to display numbers as equivalent alphabets , like if the stored value is 1 then it should display as 'A' ,2 means 'B' ,is there a way to find out.

CREATE TABLE APS ( ITEM_NO NUMBER, ITEM_NAME VARCHAR2(12))
INSERT INTO APS (ITEM_NO,ITEM_NAME) VALUES (1,'TEST1');
INSERT INTO APS (ITEM_NO,ITEM_NAME) VALUES (2,'TEST2');
INSERT INTO APS (ITEM_NO,ITEM_NAME) VALUES (3,'TEST3');
INSERT INTO APS (ITEM_NO,ITEM_NAME) VALUES (4,'TEST4');

-- The output to be is.

item_no , item_name
A TEST1
B TEST2
C TEST3
D TEST4

View 23 Replies View Related

SQL & PL/SQL :: Numbers To Words

Jul 6, 2012

I tried to convert numbers to words, it shows the below error.

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jul 6 11:00:29 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SELECT TO_CHAR (TO_DATE (2447834, 'j'), 'jsp') FROM DUAL;

TO_CHAR(TO_DATE(2447834,'J'),'JSP')
---------------------------------------------------------------------------
two million four hundred forty-seven thousand eight hundred thirty-four

SQL> SELECT TO_CHAR (TO_DATE (244783400, 'j'), 'jsp') FROM DUAL;
SELECT TO_CHAR (TO_DATE (244783400, 'j'), 'jsp') FROM DUAL
*
ERROR at line 1: ORA-01830: date format picture ends before converting entire input string

SQL>

View 4 Replies View Related

PL/SQL :: Extract Numbers Only

Sep 18, 2012

Here i face probelm that he numbers must be follw by DOT "." , this is not correct if the statment only conatines numbers without DOT that not extract. As the

SELECT REGEXP_SUBSTR ( 'hello to 8898989898989 jkjk nnnm mnj'
, '([0-9]+.[0-9]*)' || -- Starts with digit(s) (may or may not have digits after .)
'|' || -- or
'(.[0-9]+)' -- starts with decimal point
) AS result
FROM dual
;

but mean i have to add . after numbers . as follow

SELECT REGEXP_SUBSTR ( 'hello to 8898989898989 jkjk nnnm mnj'
, '([0-9]+.[0-9]*)' || -- Starts with digit(s) (may or may not have digits after .)
'|' || -- or
'(.[0-9]+)' -- starts with decimal point
) AS result
FROM dual
;

but this is not right

i want to extract numbers without DOT also.

View 6 Replies View Related

SQL & PL/SQL :: How To Print Even Numbers Without Using MOD Function

Mar 1, 2012

How to print even numbers 1 to 10.without using the MOD Function

View 17 Replies View Related

Insert All Client Numbers

May 12, 2010

I am trying to run this script:

Update ACT.CUSTOMER_CLIENT_REFERENCE
Set ORIGINAL_SOURCE_FG = 'N',
CANADIAN_ULTIMATE_REFERENCE_FG = 'N',
LUDT = SYSDATE,
CLT_NO = (Select clt_no from client.client where clt_no between 701885 and 705287)
Where Exists (Select 1 from client.client where clt_ofc_no = 19 and clt_no between 701885 and 705287)

But the CLT_NO = .... line is giving me this error: ORA-01427: single-row subquery returns more than one row

what i am trying to do is insert all the client numbers between 701885 and 705287 into ACT.CUSTOMER_CLIENT_REFERENCE

View 6 Replies View Related

SQL & PL/SQL :: Checking Consecutive Numbers

May 11, 2012

I have a table with three columns: terminal, place and batch. How can I check for missing batches?

select * from transactions;

terminal place batch
84812
84813
84814
84816
84821
84823
84824
84825

View 5 Replies View Related

SQL & PL/SQL :: Spell Out Numbers To Words

Mar 14, 2002

I found a message which explain how to spell out numbers to words. I'm french and the purpose of my question is how to convert numbers to word (to print cheque) but in french the function found in the newsgroup was :

select decode( sign( &num ), -1, 'Negative ', 0, 'Zero', NULL ) ||
decode( sign( abs(&num) ), +1, to_char( to_date( abs(&num),'J'),'Jsp') )
from dual
/

I'm afraid but i don't undaunted how pass my number to this function (&num ???)

View 12 Replies View Related

SQL & PL/SQL :: Missing Numbers In A Sequence

Feb 16, 2010

create table t (
number_from number,
number_to number);
insert into t values(1,3);
insert into t values(5,9);
insert into t values(10,15);
commit;

I need to create a stored function that could find/return missing numbers between number_from and number_to for each record in table t.

For example:

Number_fromNumber_to missing

13
594 from previous record, this record is supposed to start from 4

View 24 Replies View Related

Forms :: Calculation When Add Numbers

Feb 5, 2011

I am developing a form where I need to add Numbers.In fact we have a bag of Cones that contain 24 cones.In normal calculation when I add numbers for example

5.24 Plus 5.24 it will give the result 10.48

I Need the appropriate method to calculate if I add these two numbers it should give the result 5.24 Plus 5.24 the result should be 12

View 7 Replies View Related

SQL & PL/SQL :: Find Numbers Between More Than 1 Condition

Sep 21, 2011

I have a table A with 10000 records with values as 1 to 10000. Table B has columns as range,number1,number2. Totally there are three rows as

ROW1=range1,1,100 & ROW2=range2,300,500 & ROW3=range3,800,900

I need to select all records from table A when it is between any one of the three rows from table B.

View 13 Replies View Related

SQL & PL/SQL :: No Rounded Decimal Numbers

Aug 5, 2011

how can show this query in this picture

select round(15.555,2) from dual appear final result 15.55 only

and this query don't be this result 15.56

because i have filed and always Decimal numbers be (15.555,2)

i want only result appear after two numbers and no rounded the numbers

View 2 Replies View Related

PL/SQL :: Compare 2 Numbers With Different Precision

Jan 30, 2013

Using DB 10.2.0.5, I've encountered a strange behavior today while trying to compare ORA_ROWSCN with a previous SCN stored in a column.

SELECT
h.id HID,
h.ora_rowscn HSCN,
o.id OID,
o.scn OSCN,
[code]......

1157 rows While casting o.scn to a number gives me another resultset (this one is correct):

SELECT
h.id HID,
h.ora_rowscn HSCN,
o.id OID,
o.scn OSCN,
h.ora_rowscn-o.scn DIFF
[code]......     

2114 rows I got the same result if I use NVL(o.scn,0) rather than TO_NUMBER(o.scn). I can't find out why this happens. Obviously, the ">" condition doesn't match when the difference is too small.

AFAIK, ora_rowscn is a NUMBER while my "scn" column is a NUMBER(12) (which should be sufficient to store my DB or remote DB's SCN).

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved