SQL & PL/SQL :: How To Use Row Generator

Apr 16, 2013

I have a specific problem like below of allocating proper pallets to received quantity. row generator query feature.

CREATE TABLE PALLETMASTER
(
PALLETTYPE VARCHAR2(1 BYTE),
CAPACITY NUMBER(2)
);

Insert into PALLETMASTER (PALLETTYPE, CAPACITY) Values ('A', 18);
Insert into PALLETMASTER (PALLETTYPE, CAPACITY) Values ('B', 16);
Insert into PALLETMASTER (PALLETTYPE, CAPACITY) Values ('C', 15);
Insert into PALLETMASTER (PALLETTYPE, CAPACITY) Values ('D', 14);
[code]...

View 12 Replies


ADVERTISEMENT

SQL & PL/SQL :: A Row Generator?

Oct 25, 2011

In my table two colums are there say Col1 and Col2. Data is:

Col1 Col2
----- -----
15 20

So i want to get the result in some Column as:
ROWNUM Col
------- -----
1 15
2 16
3 17
4 18
5 19
6 20

View 1 Replies View Related

SQL & PL/SQL :: Alphanumeric Sequence Generator

Apr 12, 2010

Is there a function or a process to generate and maintain an alphanumeric sequence?

I need to be able to sequentially generate both a 3 and 5 byte case sensitive alphanumeric primary key that uses A-Za-z0-9 characters intermittently of which the 5 byte MAY be a subset of the 3 byte. e.g. the key can be 00000 or a3BD7.

so I need to be able to generate a new 5 char using 3 char base and if that value is not available, generate a unique 5 char value and allocate the substr(1,3) of that value backwards.

Ex1: unique customer location comes in - not a preexisting customer name (same name,different location address doesn't exist) --> select nextval.[5char] into v_long_c to insert into customer_loc table, and substr (v_long_c, 1, 3) for customer name table.

EX 2: unique customer location comes in. customer name exists in customer table with 3char val A39, but that location doesn't exist in customer_location table (5chars are location specific).

I need to take the A39 and generate new 5char for that unique location using that prefix (A39) if possible.

However, a number of a39-- already exist, though not all assigned to the same customer name (we're trying to keep them grouped together but that might not be logically feasible)

How do I select next a39||[2char] for that unique location - and if that value is not available (all 62*62 possibilities have been used for A39--), select nextval.[5charseq] into long_key.

I suspect someone out there knows the functions I can use to create this or has written a package to do just this; I suspect with enough time I could do it, but I don't currently have the time or knowledge to develop it within these deadlines. I thought it would be easier.

My short-sighted solution was to create a static table of all iterations of A-z0-9 5 char values, select one, mark it used and move on. Unfortunately 62^5 is a substantial number (913+million records) and that table took a LOT of space, causing my development server to groan and crack miserably. indexing on it takes a lot of space too (and trying to build multiple indexes exceeded database size). But without an index on the 3char field, selecting an available 5 code from it based on the customer_3char prefix took five minutes - much longer than the fraction of a second I need.

View 5 Replies View Related

SQL & PL/SQL :: Oracle Primary Key Error On Sequence Number Generator

Mar 11, 2011

I have a table called table 1 and I am trying to insert a few values in this table and i am constantly getting bogged down by a primary key error. Strange thing is this primary key called "ID" on the table is a system generated sequence value number. The error is

"ORA-00001: unique constraint (Schema1.LICN_PK) violated"

Table structure:
*****************************************
CREATE TABLE schema1.table1
(
ID NUMBER(12),
LITM_ID NUMBER(12),
PROG_PROGRAM_CD VARCHAR2(2 BYTE),
SCHED_NBR VARCHAR2(3 BYTE),
SCHD_VERSION_YR NUMBER(4),
SCHD_VERSION_NBR NUMBER(3),
[code]........

****************Insert statement*************
insert into table1
(id,
litm_id,
prog_program_cd,
sched_nbr,
schd_version_yr,
[code].......

why the error is coming up and any way to resolve it. I checked the max sequence number value and kept running it for a while and then tried to run my insert statement but no luck yet.

View 5 Replies View Related







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