Pls convert this piece of SQL code to oracle

Following is the SQL code----
Update reg_dim
set reg_dim.Region_Description = st_reg.Region_Desc ,
reg_dim.Process_Date = sysdate
from st_glt_region st_reg
left join
Dim_Region reg_dim
on st_reg.Region_Abbreviation = reg_dim.Region
where reg_dim.Region is not null
I have tried this in oracle -----
update Dim_region_test set Dim_region_test.REGION_DESCRIPTION = (select st_glt_region.Region_Desc
from st_glt_region left join Dim_region_test
on Dim_region_test.Region=st_glt_region.Region_Abbreviation where Dim_region_test.Region not in null)
group by st_glt_region.Region_Desc;
This is executing but in Dim_region_test, REGION_DESCRIPTION column is empty
Pls help me..................

Something like this?
UPDATE reg_dim
   SET reg_dim.region_description = st_reg.region_desc,
       reg_dim.process_date = (SELECT SYSDATE
                                 FROM st_glt_region st_reg LEFT JOIN dim_region reg_dim
                                         ON st_reg.region_abbreviation = reg_dim.region
                                WHERE reg_dim.region IS NOT NULL);*009*

Similar Messages

  • Please suggest correction in this pl and sql code

    Hi,
    Please find the error in following PL/Sql code and suggest the corrections.
    I want to use this code on form-trigger level to display error messages in middle of the screen.
    When I compile this code in ONERROR trigger, it is showing compiling errors.
    Code:
    ERR_VAL NUMBER(5):= NVL(ERR_IN,ERROR_CODE);
    MSG VARCHAR2(150) := NVL(MSG_IN,SUBSTR(' '||ERROR_TYPE||'-'
    ||TO_CHAR(ERR_VAL)||': '||ERROR_TEXT,1,150));
    Compilation time errors:
    Error 103 at line 1,column9
    Encountered the symbol “NUMBER” when expecting one of the following:
    := [ @ %
    the symbol “=” was substituted for “NUMBER” to continue
    Error 103 at line 1, column 27
    Encountered the symbol”=” when expecting one of the following:
    .[=%=.+</> in mod not rem an exponent(**)
    <> or !=~=>=<=<> and or like between is null is not ||
    is dangling
    the symbol “ was inserted before”=” to continue.
    Error 103 at line2, column5
    Encountered the symbol “VARCHAR3” to continue.
    Error 103 at line2,column 20
    Encountered the symbol”=” when expecting one of the following:
    .[=%=.+</> in mod not rem an exponent(**)
    <> or !=~=>=<=<> and or like between is null is not ||
    is dangling
    the symbol “ was inserted before”=” to continue.
    thanks in advance
    prasanth

    Is this the whole content of your trigger? In PL/SQL you have to declare variables under the declare section and then to make the program under begin:
    declare
    VAR1 xxxxxx;
    VAR2 xxxxxx;
    begin
    /* assignments */
    end;
    I am not sure if it is possible to make your assignments with error_code etc. in the declaration. Where you are calling the message-box?
    Can you give us the complete content of your form-trigger?

  • How this piece of html code is encoded from commandLink?Help!

    Hi, this is the jsf code:
    <h:panelGrid columns="1">
                         <h:dataTable value="#{temp.nameFile}" var="myL"
                             rendered="#{temp.show1}">
                             <h:column>
                                  <h:commandLink actionListener="#{temp.create}" value="#{myL.name}"
                                       immediate="true">
                                       <f:param name="name" value="#{myL.name}" />
                                       <f:param name="path" value="#{myL.path}" />
                                  </h:commandLink>
                             </h:column>
                        </h:dataTable>
                   </h:panelGrid>And this is the html code it generates:
    <table>
         <tbody>
              <tr>
                   <td>
                   <table>
                        <tbody>
                             <tr>
                                  <td><a href="#"
                                       onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id2:0:_id4';
                                                             document.forms['_id0']['name'].value='ISO-3166';
                                                             document.forms['_id0']['path'].value='D:/Tomcat5.0/webapps/test/WEB-INF/iso3166.xml';
                                                             document.forms['_id0'].submit(); return false;">ISO-3166</a></td>
                             </tr>
                             <tr>
                                  <td><a href="#"
                                       onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id2:1:_id4';
                                                              document.forms['_id0']['name'].value='NAICS';
                                                              document.forms['_id0']['path'].value='D:/Tomcat5.0/webapps/test/WEB-INF/naics.xml';
                                                              document.forms['_id0'].submit(); return false;">NAICS</a></td>
                             </tr>
                             <tr>
                                  <td><a href="#"
                                       onclick="document.forms['_id0']['_id0:_idcl'].value='_id0:_id2:2:_id4';
                                                             document.forms['_id0']['name'].value='UNSPSC';
                                                             document.forms['_id0']['path'].value='D:/Tomcat5.0/webapps/test/WEB-INF/unspsc.xml';
                                                             document.forms['_id0'].submit(); return false;">UNSPSC</a></td>
                             </tr>
                        </tbody>
                   </table>
                   </td>
              </tr>
         </tbody>
    </table>there is a line of html code like this:
    document.forms['_id0']['_id0:_idcl'].value='_id0:_id2:1:_id4';I know that "_id0" is the form ID, and "_id0:_idcl" is the clientID,but what is the value part "_id0:_id2:1:_id4" and what is the meaning of each part?I am writing my custom renderer, so i need to know how it is encoded,please help:)
    Best Regards:)
    Robin

    _id0 - id of the form
    _id2 - id of the datatable
    1 - row index
    _id4 - id of the commandlink                                                                                                                                                                                       

  • Convert substring function from SQL Server to Oracle

    I am converting a large application written for SQL Server to Oracle and have encountered a difference in how the substring function is called between the two database systems.
    In SQL Server:
    select substring('xyz'1,2)
    In Oracle:
    select substr('xyz',1,2)
    Is there a way to establish a user-defined operator to map the substring call to a substr call so I don't have to change the application code?
    Is the user-defined function a way to do this?
    Which is better?

    If you want to be able to use the code that has substring in it, without modifying it, and have it do the same thing as substr, then try running the script below. It will create a user-defined function named substring that will cause substring to act like substr.
    CREATE OR REPLACE FUNCTION substring
    (p_string IN VARCHAR2,
    p_start IN VARCHAR2,
    p_end IN VARCHAR2 DEFAULT NULL)
    RETURN VARCHAR2
    IS
    v_string VARCHAR2 (100);
    BEGIN
    IF p_end IS NULL
    THEN
    SELECT SUBSTR (p_string, p_start)
    INTO v_string
    FROM DUAL;
    ELSE
    SELECT SUBSTR (p_string, p_start, p_end)
    INTO v_string
    FROM DUAL;
    END IF;
    RETURN v_string;
    END substring;
    null

  • Converter program for MS SQL Server to Oracle

    My problem with converting MS SQL Server queries in a SQL Pass-thru is becoming critical at my job.
    I am hoping there is an easy converter tool that will let a user take SQL Server statements and feed them into a converter that outputs Oracle SQL.
    Does such a program conversion tool exist?
    I bet not, right?

    Your bet is right as SQL-Server's SQL implementation is not the same as Oracle's SQL implementation. There are numerous differences. Translating one to the other is not a 1:1 keyword swap.
    And when these SQL statements involve locking and concurrency, there are also significant differences in core database functionality between SQL-Server and Oracle.
    What exactly is the problem you are facing? SQL-Passthru is specifically designed as a SQL interface that does not touch and change (and muck up) a SQL being passed to a remote database - so the actual raw SQL text being send is what arrives at the server end. Allowing you to, for example, use Oracle's SQL dialect inside SQL-Server to talk to a remote Oracle database - without SQL-Server throwing errors about Oracle dialect being used. Oracle has a similar passthru option.
    Why is this not working? Or is the issue something else?

  • Hi all Plz convert this SQL code to ORACLE

    -- Insert Not Available Record
    set identity_insert Dim_Region on
    if not exists ( select 'x' from Dim_Region where Region_Id = 99999 and Region = '#NA#' )
    Begin
    insert into Dim_Region (Region_Id , Region , Region_Description , Process_Date ) values
    (99999 , '#NA#' , 'Not Available' , getdate())
    End
    set identity_insert Dim_Region off

    Hi,
    I am not sure what is getdate() I have assumed it to be a function which returns date.
    Hopefully this is what you want a Procedure called "identity_insert Dim_Region"
    create procedure identity_insert Dim_Region is
         cursor c_exists is
              select 'x' from Dim_Region where Region_Id = 99999 and Region = '#NA#';
        v_var char (1);
        v_date date;
    begin
         open c_exists;
         fetch c_exists into v_var;
         if c_exists%notfound then
             v_date := getdate ();
             insert into Dim_Region
                (Region_Id , Region , Region_Description , Process_Date )
             values
                (99999 , '#NA#' , 'Not Available' , v_date);
        end if;   
        close c_exists;
    end;Best Regards
    Arif Khadas

  • How can I convert this small pl/sql block in a single query?

    Hello,
    I need to have a single SQL query which gives the same output as the following piece of code, which uses a cursor to iterate on the rows in order to get the informations I need:
    declare
    cursor c(p varchar2) is
    select context_id, id, parent_id
    from CONTEXT_CONTEXT
    start with parent_id is null
    and context_id = p
    connect by prior id = parent_id
    and context_id = p;
    begin
    for r in (select context_id from ALL_CONTEXTS where context_type in ('MYTYPE'))
    loop
    for j in c(r.context_id)
    loop
    -- I want to obtain the values of the following colums from a query:
    dbms_output.put_line(j.context_id || ' ' || j.id || ' ' || j.parent_id);
    end loop;
    end loop;
    end;
    Additional informations:
    CONTEXT_CONTEXT.context_id references ALL_CONTEXTS.id
    CONTEXT_CONTEXT.id references ALL_CONTEXTS.id as well
    CONTEXT_CONTEXT.parent_id references ALL_CONTEXTS.id as well
    id is primary key of ALL_CONTEXTS
    (context_id, id) is primary key of CONTEXT_CONTEXT
    */

    user10047839 wrote:
    Unfortunately, the CONNECT_BY_ROOT is not supported by my version of the DB 9i.
    SELECT  context_id,
            SUBSTR(
                   SYS_CONNECT_BY_PATH(context_id,'/'),
                   2,
                   INSTR(
                         SYS_CONNECT_BY_PATH(context_id,'/') || '/',
                         1,
                         2
                        ) - 2
                  ) AS parent_context_id
      FROM  CONTEXT_CONTEXT
      START WITH parent_id IS NULL
        AND context_id IN (
                           SELECT  context_id
                             FROM  all_contexts
                             WHERE context_type IN ('MYTYPE')
      CONNECT BY PRIOR ID = parent_id
             AND context_id = PRIOR context_id;SY.

  • Convert this MS Access SQL to do it in Oracle?

    I converted an MS Access database to make it into Oracle. Everything is going well until i came to this update SQL. How do I do this in Oracle?
    UPDATE (((tblkapplan
    INNER JOIN tblTotalStock ON tblkapplan.MATERIAL = tblTotalStock.MATERIAL)
    LEFT JOIN tblSafetyStock ON tblkapplan.MATERIAL = tblSafetyStock.MATERIAL)
    LEFT JOIN tblOrders ON tblkapplan.MATERIAL = tblOrders.Material
    SET tblkapplan.QUANTITY =
    (IIf(IIf(IsNull([tblSafetyStock]![QUANTITY]),'0',[tblSafetyStock]![QUANTITY])-(IIf([tblTotalStock]![TOTAL_STOCK]-
    IIf([tblOrders]![Quantity]>0,([tblOrders]![Quantity]),'0')>0,[tblTotalStock]![TOTAL_STOCK]-
    IIf([tblOrders]![Quantity]>0,([tblOrders]![Quantity]),'0'),'0'))>0,([tblkapplan]![QUANTITY]*12)+
    IIf(IsNull([tblSafetyStock]![QUANTITY]),'0',[tblSafetyStock]![QUANTITY]-(IIf([tblTotalStock]![TOTAL_STOCK]-
    IIf([tblOrders]![Quantity]>0,([tblOrders]![Quantity]),'0')>0,[tblTotalStock]![TOTAL_STOCK]-
    IIf([tblOrders]![Quantity]>0,([tblOrders]![Quantity]),'0'),'0'))),([tblkapplan]![QUANTITY]*12)))/12I know this can be done like this:
    IIf(IsNull([tblSafetyStock]![QUANTITY]),'0',[tblSafetyStock]![QUANTITY])
    nvl(tblSafetyStock.QUANTITY,0)But how do I do with the rest?

    Hi,
    Maybe you could explain (To yourself) in words, what the update is supposed to do.
    If you can't, then your question is basically what this means
    (IIf(IIf(IsNull([tblSafetyStock]![QUANTITY]),'0',[tblSafetyStock]![QUANTITY])-(IIf([tblTotalStock]![TOTAL_STOCK]-
    IIf([tblOrders]![Quantity]>0,([tblOrders]![Quantity]),'0')>0,[tblTotalStock]![TOTAL_STOCK]-
    IIf([tblOrders]![Quantity]>0,([tblOrders]![Quantity]),'0'),'0'))>0,([tblkapplan]![QUANTITY]*12)+
    IIf(IsNull([tblSafetyStock]![QUANTITY]),'0',[tblSafetyStock]![QUANTITY]-(IIf([tblTotalStock]![TOTAL_STOCK]-
    IIf([tblOrders]![Quantity]>0,([tblOrders]![Quantity]),'0')>0,[tblTotalStock]![TOTAL_STOCK]-
    IIf([tblOrders]![Quantity]>0,([tblOrders]![Quantity]),'0'),'0'))),([tblkapplan]![QUANTITY]*12)))/12A question which is probably better asked somewhere else. (Unless of course, someone here is familar with that syntax)
    Regards
    Peter

  • How to convert this random pos AS2 code to AS3?

    Hi! I'm doing a sort of screensaver and need to random the logo all over the screen. In ActionScript 2 it was easy, just paste some code to the object and it works. The things to do this is total different in ActionScript 3 and I can't figure out how to solve this. It would be nice if someone could take a look at my very simple example and point me in the right direction. Maybe there is some example out there done in AS3?
    I can't figure out how to post fla so I renamed it to jpg. Just change the extension to fla again...
    Regards / Jimmy

    SORRY FOR THE LATE RESPONSE I WAS NOT ONLINE FOR THREE DAYS....
    I am still not able to download the file.
    What you can do is enclose the code which is called directly on the timeline in a function and call that function whenever required.
    You can also send the file on my mail ID at [email protected] [Make sure you zip it and the version is saved in CS3]

  • ORA-00972 from generated piece of SQL code

    Hi - I stepped over this problem while testing a new procedure:
    7 WHENEVER SQLERROR exit
    8 SELECT 'STOP! Missing refresh group!' " ' FROM DUAL
    9 WHERE NOT EXISTS (SELECT refg_name FROM SYS.DBA_REFRESH WHERE rname='Thingy')
    10 SELECT 1/(sign(count(*)) FROM (SELECT refg_name FROM SYS.DBA_REFRESH WHERE rname ='Thingy')
    I always get an ORA-00972: identifier is too long when I try to run these lines.
    But WHERE is there a too long identifier? "STOP! Missing refresh group!" is only 28 characters long.
    Somebody got a clue?
    Thanks in advance,
    Thomas

    The suspection is what you are using something like
    SQL> SELECT "'STOP! Missing refresh group!' " FROM DUAL
      2  /
    SELECT "'STOP! Missing refresh group!' " FROM DUAL
    ERROR at line 1:
    ORA-00972: identifier is too long, isn't it ?
    Double-quoted strings are identifiers - and can't have more than 30 symbols.
    Use single quotation in strings.
    Rgds.

  • Converting OLE Object in Sql Server to Oracle

    SQL Server contains datatype OLE Object. This is basically an array of binary floating point data where each value of the array is 4 byte long. How can I store these values in Oracle database.
    null

    You cannot specify the precision/scale or length of input paramters to a stored procedure in Oracle, or at least the pl/sql engine does not respect the sizing. Assuming that you want to do something with variable1 in the procedure, and not just return it, the Oracle equivalent would be something along the lines of:
    SQL> CREATE FUNCTION f (p_param1 IN VARCHAR2,
      2                     p_param2 IN NUMBER,
      3                     p_param3 IN NUMBER) RETURN NUMBER IS
      4     l_var1 NUMBER(20) := SUBSTR(p_param1, p_param2, p_param3);
      5  BEGIN
      6     RETURN l_var1 * 10;
      7  END;
      8  /
    Function created.
    SQL> SELECT f('ABC10DEF', 4, 2) FROM dual;
    F('ABC10DEF',4,2)
                  100You may need to adjust the return type to match what you are actually returning.
    You can also use this iin a direct assignment in pl/sql without doig a select, something like:
    SQL> DECLARE
      2     l_num NUMBER(20);
      3  BEGIN
      4     l_num := f('ABC10DEF', 4, 2);
      5     DBMS_OUTPUT.Put_Line('The number is: '||l_num);
      6  END;
      7  /
    The number is: 100John

  • Convert this query from Ms Access to Oracle?

    How in the hole world can do this query in oracle?
    TRANSFORM Sum(NET_SALES) AS SALES
    SELECT YEAR_MONTH
    FROM TBLCUSTOMER
    WHERE (CUSTOMER=2083 Or CUSTOMER=1035 Or CUSTOMER=2097)
    AND YEAR_MONTH Between 200709 And 200801
    GROUP BY YEAR_MONTH
    ORDER BY YEAR_MONTH
    PIVOT CUSTOMER;

    Like this perhaps:
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t AS (SELECT TO_DATE('01/01/2008','dd.mm.yyyy') AS dt, 1 AS emplid, 100 as sales FROM dual UNION ALL
      2             SELECT TO_DATE('01/01/2008','dd.mm.yyyy'), 1, 200 FROM dual UNION ALL
      3             SELECT TO_DATE('01/02/2008','dd.mm.yyyy'), 2, 300 FROM dual UNION ALL
      4             SELECT TO_DATE('01/06/2008','dd.mm.yyyy'), 2, 400 FROM dual UNION ALL
      5             SELECT TO_DATE('01/03/2007','dd.mm.yyyy'), 2, 500 FROM dual UNION ALL
      6             SELECT TO_DATE('01/05/2007','dd.mm.yyyy'), 3, 600 FROM dual UNION ALL
      7             SELECT TO_DATE('01/02/2008','dd.mm.yyyy'), 3, 700 FROM dual UNION ALL
      8             SELECT TO_DATE('01/12/2008','dd.mm.yyyy'), 3, 800 FROM dual)
      9  -- END OF TEST DATA
    10  select year, month, emp_1_sales, emp_2_sales, emp_3_sales
    11  from (
    12        select extract(year from dt) as year, extract(month from dt) as month,
    13               sum(decode(emplid, 1, sales, 0)) as emp_1_sales,
    14               sum(decode(emplid, 2, sales, 0)) as emp_2_sales,
    15               sum(decode(emplid, 3, sales, 0)) as emp_3_sales
    16        from t
    17        group by extract(year from dt), extract(month from dt)
    18       )
    19* order by emp_3_sales desc, emp_2_sales desc, emp_1_sales desc
    SQL> /
          YEAR      MONTH EMP_1_SALES EMP_2_SALES EMP_3_SALES
          2008         12           0           0         800
          2008          2           0         300         700
          2007          5           0           0         600
          2007          3           0         500           0
          2008          6           0         400           0
          2008          1         300           0           0
    6 rows selected.
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t AS (SELECT TO_DATE('01/01/2008','dd.mm.yyyy') AS dt, 1 AS emplid, 100 as sales FROM dual UNION ALL
      2             SELECT TO_DATE('01/01/2008','dd.mm.yyyy'), 1, 200 FROM dual UNION ALL
      3             SELECT TO_DATE('01/02/2008','dd.mm.yyyy'), 2, 300 FROM dual UNION ALL
      4             SELECT TO_DATE('01/06/2008','dd.mm.yyyy'), 2, 400 FROM dual UNION ALL
      5             SELECT TO_DATE('01/03/2007','dd.mm.yyyy'), 2, 500 FROM dual UNION ALL
      6             SELECT TO_DATE('01/05/2007','dd.mm.yyyy'), 3, 600 FROM dual UNION ALL
      7             SELECT TO_DATE('01/02/2008','dd.mm.yyyy'), 3, 700 FROM dual UNION ALL
      8             SELECT TO_DATE('01/12/2008','dd.mm.yyyy'), 3, 800 FROM dual)
      9  -- END OF TEST DATA
    10  select extract(year from dt) as year, extract(month from dt) as month,
    11         sum(decode(emplid, 1, sales, 0)) as emp_1_sales,
    12         sum(decode(emplid, 2, sales, 0)) as emp_2_sales,
    13         sum(decode(emplid, 3, sales, 0)) as emp_3_sales
    14  from t
    15  group by extract(year from dt), extract(month from dt)
    16* order by 5 desc, 4 desc, 3 desc
    SQL> /
          YEAR      MONTH EMP_1_SALES EMP_2_SALES EMP_3_SALES
          2008         12           0           0         800
          2008          2           0         300         700
          2007          5           0           0         600
          2007          3           0         500           0
          2008          6           0         400           0
          2008          1         300           0           0
    6 rows selected.
    SQL>If you meant something different, you'd better give an example of how you expect the output to be.

  • How to 100% Protect PL/SQL Code By Wrapped in Oracle Database 10g R2

    Hello,
    Is Possible to 100% Protect PL/SQL Code By Wrapped in Oracle 10g R2 ?
    If it is not possible by wrap in oracle 10g R2,
    Please, let me suggest, how i will be able to 100% protect PL/SQL code in Oracle Database 10g R2.
    Because, I have lot of functions, procedures & package's in my project.
    Which is running in field filed.
    So, i have needed to protect 100%.
    Also, will i convert to al functions, procedures & package's to .pll file ?
    And .pll file to .plx file?
    Is it possible to convert .plx file to .pll file ?
    Please, let know any better solutions in this case....
    Regards
    Mehedi

    Hello,
    No, wrapping is not a 100% secure method. It could prevent your code from amateurs, but not from professional hackers. Look at the article http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/wrap.htm#BEHGBJAA
    It says: "•Wrapping is not a secure method for hiding passwords or table names.
    Wrapping a PL/SQL unit prevents most users from examining the source code, but might not stop all of them."
    Edited by: apiminov on 03.12.2012 3:23
    Edited by: apiminov on 03.12.2012 3:24

  • Including an Expression in SQL Code with Columns from a Table

    The code under MY CODE will not work. Getting error saying 00922-from keyword not found where expected..
    In the examples I looked up, the months_between function was written as a select statement like:
    Select
    months_between (sysdate,me607.mbr_dob) / 12 as date
    from mbr_exp me607
    Can anyone help me with the syntax I need to include this with my SQL code as below?
    Thanks..
    MY CODE:
    Select
    me607.mbr_dob,
    months_between (sysdate,me607.mbr_dob) / 12 as date
    from mbr_exp me607

    -date- is an oracle keyword and cannot be used as a column name
    SQL> select sysdate as date from dual
    select sysdate as date from dual
    Error at line 1
    ORA-00923: FROM keyword not found where expectedeither do
    select sysdate as "date" from dualor use a diffent colum name.

  • Compare SQL Server and Oracle syntax

    Hello, I am very new to the Oracle DB as I have been working with MS SQL Server for many years. I have a SQL statement that works fine in MSSQL but seems to not work in Oracle. Is this a syntax problem or do I need to look elsewhere?
    DECLARE @as_master_key varchar(26)
    EXEC [dbo].[GET_UNIQUE_MASTER_KEY]
         @as_project_name = N'CMDEMO',
         @as_database_site = N'CMPL',
         @as_user_initials = N'SK',
         @as_table = N'SUBMITTAL_CATEGORY',
         @as_master_key =
         @as_master_key
    OUTPUT SELECT @as_master_key as N'master_key'
    This is what I use in MSSQL and it works fine - but I am porting this application to an Oracle backend and it fails. Any suggestions?
    Thanks in advance to this newbie. :)

    SQL Server and Oracle are two completely different RDBMS'.
    You'd be best not to try and port SQL Server code to Oracle SQL or PL/SQL directly as it will not favour the power of Oracle's features correctly.
    I'm not sure what your code is supposed to be doing (I find SQL Server code awful to read, and never understand the need for "@" before variable names, that just seems to show a lazy parser (or lazy coder who designed the parser)).
    From what I can guess it's going to be something like...
    SQL code...
    create or replace sequence my_master_key;PL/SQL code...
    DECLARE
      as_master_key number;
      as_project_name varchar2(20) := 'CMDEMO';
      as_database_site varchar2(20) := 'CMPL';
      as_user_initials varckar2(5) := 'SK';
      as_table varchar2(30) := 'SUBMITTAL_CATEGORY';
    BEGIN
      select my_master_key.nextval
      into as_master_key
      from dual;
      -- In 11g you could replace this select with just:
      -- as_master_key = my_master_key.nextval;
    END;This get's a unique sequence value into a variable and declares all the other variables. What you want to do with them after that I don't know.

Maybe you are looking for