How to auto assign a number to some data using PL/SQL

Hi,
Assume that i have a few lines of data...
How do i auto assign number to the data without hardcoding it?
In this instance, i want p_id to be auto-generate...
create or replace procedure insert_file
p_id number,
p_file_type varchar2,
p_file_name varchar2
)as
geor MDSYS.SDO_GEORASTER;
begin
insert into nyp_images values( p_id, p_file_type, sdo_geor.init('NYP_IMAGES_RDT') );
select image into geor from nyp_images where image_id = p_id for update;
sdo_geor.importFrom(geor, NULL, p_file_type, 'file', p_file_name);
update nyp_images set image = geor Where image_id = p_id;
end insert_file;
Thanks and regards,
Esther

In this case you could slightly change your procedure to
create or replace procedure insert_file (
  p_file_type     varchar2,
  p_file_name     varchar2,
  p_id        out number
  )as
  geor MDSYS.SDO_GEORASTER;
begin
  insert into nyp_images values( your_seq.nextval, p_file_type, sdo_geor.init('NYP_IMAGES_RDT') )
     returning image_id into p_id;
  select image into geor from nyp_images where image_id = p_id for update;
  sdo_geor.importFrom(geor, NULL, p_file_type, 'file', p_file_name);
  update nyp_images set image = geor Where image_id = p_id;
end insert_file;I highly reccommend you to take classes in this SQL and PL/SQL stuff or look for some external ressources that can guide you.

Similar Messages

  • How to get a week number  for the year using oracle sql query?

    hi everyone,
    i have the requirement to find the week number for the calender..
    so that week number should start with 01 when the year starts and it should end with week end date(that is first saturday of the january month).. so next week number starts with sunday and ends with saturday ,continously.. in the end date of the year it should not be 'saturday' but week number should end with last date of the year.. again in the next year it should start with '01'.
    for example:
    01-JAN-13 tuesday 01
    02-JAN-13 wednesday 01
    03-JAN-13 thursday 01
    04-JAN-13 friday 01
    05-JAN-13 saturday 01
    06-JAN-13 sunday 02
    07-JAN-13 monday 02
    26-DEC-13 thursday 52
    27-DEC-13 friday 52
    28-DEC-13 saturday 52
    29-DEC-13 sunday 53
    30-DEC-13 monday 53
    31-DEC-13 tuesday 53
    01-JAN-14 wednesday 01
    02-JAN-14 thursday 01
    how can i achieve this, can anyone please help me out on this..
    i have a query that starts with 01 when year starts but it gives problem in the end of the year .. described below with a query..
    select mydate,
    to_char(mydate,'day') as weekday,
    to_char(next_day(mydate,'sunday'),'iw') as week_num
    FROM ( SELECT TRUNC (SYSDATE, 'yy') - 1 + LEVEL AS mydate
    FROM dual
    CONNECT BY LEVEL <= (SELECT TRUNC (ADD_MONTHS (SYSDATE, 24), 'yy')
    - TRUNC (SYSDATE, 'yy')
    FROM DUAL))
    this query gives date, weekday and week_num for 2 years 2013 and 2014,
    when i run this query ,at the end of the 2013 it gives the result as,
    26-DEC-13     thursday      52
    27-DEC-13     friday      52
    28-DEC-13     saturday      52
    29-DEC-13     sunday      01
    30-DEC-13     monday      01
    31-DEC-13     tuesday      01
    01-JAN-14     wednesday     01
    02-JAN-14     thursday      01
    for dates 29 ,30,31st it should give 53 .. how can i achieve that using this this query .. can any one help me out on this please...
    thanks,
    pradeep

    I tried with the IW ...
    it is giving week_id for the year.
    select
    mydate,
    to_char(mydate,'day'),
    case when mydate between trunc(mydate,'yyyy') and next_day(trunc(mydate,'yyyy'),'saturday')
    then to_number(to_char(mydate,'yyyy')||to_char(trunc(mydate,'yyyy'),'iw'))
    when mydate between next_day(trunc(mydate,'yyyy'),'saturday') and trunc(add_months(trunc(mydate,'yyyy'),12)-1,'d')-1
    then to_number(to_char(mydate,'yyyy')||to_char(next_day(mydate,'sunday'),'iw'))
    when mydate between trunc(add_months(trunc(mydate,'yyyy'),12)-1,'d') and add_months(trunc(mydate,'yyyy'),12)-1
    then to_number(to_char(mydate,'yyyy')||to_char(trunc(add_months(trunc(mydate,'yyyy'),12)-1,'d')-1,'iw')+1) end as WEEK_ID
    FROM ( SELECT TRUNC (SYSDATE, 'yy') - 1 + LEVEL AS mydate
    FROM dual
    CONNECT BY LEVEL <= (SELECT TRUNC (ADD_MONTHS (SYSDATE, 24), 'yy')
    - TRUNC (SYSDATE, 'yy')
    FROM DUAL
    ))

  • Portal Master-detail form how to auto assign detail record sequence number

    Portal Master-detail form how to auto assign detail record sequence number.Please help me?

    You can just read the following section
    Can I specify a sequence number generator as the default value for a form column?
    Yes. Enter the following in the "default value" field for the column:
    #<schema name>.<sequence name>.nextval
    where <schema name> is the name of the schema containing the sequence, and <sequence name> is the name of the sequence. The entry is preceded by a "#".
    For example, if the schema name is "SCOTT", and the sequence name is "CUSTOMER_SEQ", the default value entry is:
    #SCOTT.CUSTOMER_SEQ.NEXTVAL
    same way you can do for master - detail form.
    for more information on forms please refer the following URL.
    http://otn.oracle.com/products/iportal/htdocs/portal_faq.htm#BuildingApplications
    hope it helps.

  • How to auto increment a NUMBER(10) datatype

    Anyone know the syntax on how to auto increment a number field every time a new row comes in?
    TIA
    CREATE TABLE loc_color_group_values(
         ID number(10) NOT NULL auto_increment, <----------------
         COLOR_CODE_ID number(10) default 0,
         PROD_LOC_ID number(10) default 0,
         COLOR_GROUP_CODE_ID number(10) default 0,
         PRIMARY KEY(ID)
    );

    Here is an example:
    CREATE OR REPLACE TRIGGER "EXAMPLE_TRIG" BEFORE
    INSERT ON "loc_color_group_values" FOR EACH ROW BEGIN
      IF :NEW.id IS NULL THEN
        SELECT loc_color_group_values_seq.nextval INTO :NEW.id FROM dual ;
      END IF;
    END ;This allows you to overide the sequence without having to disable the trigger.

  • How to auto insert a number array with size of 20 into a named excel file with the positon is from A1 TO A20?i use lv6.1

    can you give me a example vi for it ?thanks a lot!
    how to auto insert a number array with size of 20 into a named excel file  with the positon is from A1 TO A20?i use lv6.1

    You don't need us to give you an example, as the example already comes with LV. Go to Help>>Find Examples and search for "excel". You will find an example called "write table to XL". You should note that the example doesn't do that exactly, because it writes a 2D array from 2 to N.
    You can modify the example by using only one for loop (instead of nested loops) with a 1D array or by going into the Set Cell Value and modifying it to accept a second cell value for the Cell2 terminal and wiring in a 1D array instead of the single string. If you do modify it, be sure to save it under a different name, so you don't overwrite the original.
    To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
    Try to take over the world!

  • How can i assign an identifier to a movieclip using AS2 ???

    Hey guys, i'm using the scrolling pane component in my
    project. i used to enter in the content path, the identifier of the
    movieclip which i set through the library. But now i wanna give it
    a movie clip that i've created in my code...so how can i assign an
    identifier to a movieclip using AS2 so that i can use it with my
    componenets ???? THANX

    I'm trying to make a script that goes through a folder recursively, checks for every folder if it's name is "template", and if so it changes the icon of that folder to an icon
    I chose.
    I searched for an answer here, and I've only managed to find a way to assign an icon to a shortcut, but not to an existing file.
    Thanks in advance (:

  • How can I assign an icon to a folder using Powershell?

    How can I assign an icon to a folder using Powershell?

    I'm trying to make a script that goes through a folder recursively, checks for every folder if it's name is "template", and if so it changes the icon of that folder to an icon
    I chose.
    I searched for an answer here, and I've only managed to find a way to assign an icon to a shortcut, but not to an existing file.
    Thanks in advance (:

  • How to send message to a multi-consumer queue using pl/sql

    How to send message to a multi-consumer queue using pl/sql ? Thanks.
    I tried following, but got an message: no receipient specified.
    DBMS_AQ.ENQUEUE(
    queue_name => 'aqadm.multi_queue',
    enqueue_options => queue_options,
    message_properties => message_properties,
    payload => my_message,
    msgid => message_id);
    COMMIT;
    END;
    /

    Here's two way to enqueue/publish new message into multi-consumer queue.
    (1) Use explicitly declared recipient list
    - Specify "Recipients" by setting recipient_list to messge_properties, before ENQUEUE().
    DECLARE
    recipients DBMS_AQ.aq$_recipient_list_t;
    BEGIN
    recipients(1) := sys.aq$_agent('RECIPIENTNAME',NULL,NULL);
    message_properties.recipient_list := recipients ;
    (2)Or, declare subscriber list permanently. Then you need not to specify recipient list each time you call ENQUEUE().
    begin
    dbms_aqadm.add_subscriber(
    queue_name=>'YOURQUEUE',
    subscriber=> sys.aq$_agent('RECIPIENTNAME', null, null)
    end;
    You can add 1024 local subscriber include maximum 32 remote-queue-consumer to one queue.

  • How to Create an Input Schedule Comparison with Data Using EVDRE

    Hello,
    I try implement the scenario described in "How to Create an Input Schedule Comparison with Data Using EVDRE".
    Once I am using the "Insert Function" from the panel and selecting the EVTIM function Excel crashes (see page 8 How to paper).
    Systems:
    BPC 7.0 NW SP02
    Office 2007
    BPCADminClient and BPCOfficeClient up to date
    Have anyone a solution?
    Thanks
    Oktay

    Hi Oktay -
    This function works in my BPC70NW SP02 system. Your issue might be that you are trying to access a TIME member that does not exist. Please make sure the offset value is a valid dimension member.
    I can confirm that EVTIM does allow the offset for base members (such as 2009.MAY) as well as parent nodes (such as 2009.Q1 or 2008.TOTAL)... BUT...the offset result of the EVTIM function needs to be a valid dimension member!
    Regards,
    Sheldon

  • How to make External Reference number and Ref Date Mandatory in Complaints

    Dear Experts,
    Greetings!!!.
    How to make External Reference number (EXT_REF_NUMBER ) and Ref Date ( EXT_REF_DATE ) Mandatory in Complaints.
    Regards,
    Sany

    HI,
    You can use Incompleteness Procedure to make those fields mandatory in complaint transaction.
    Regards,
    PP

  • How to upload different views of customer master data using LSMW-IDOC

    I need to upload customer master data  using LSMW Idoc method for my client. Now customer will have different views like main view, Sales data, Company code data, Partner function data etc. And except main data all other data can be multiple for each customer. We are going to upload data from tab delimited .TXT file. Should I propose different LSMW for upload different views for the customer from different .TXT files? or we can upload all the customer related data (like main view data and partner function data )from a single .TXT file. Kindly suggest which one in convenient and how we can prepare the data file in both cases.

    convinient is the method that you can handle.
    but as the guy who loads the data you have to load the data like they are available, like it is convinient for others to prepare the data.
    In general there is no problem to use an IDOC method to load a customer master with multiple comany codes and several sales orgs in one shot.
    the data can be in one source file, but need then to be maintained in a certain way
    Example1: all data in 1 structure
    GD1 - CC1 - SO1
    GD1 - CC2 - SO2
    GD1 - CC2 - SO3
    in this case the GD (general data) is redundand in each line which has different Company code data or different Sales Org data
    Example2: all data in 3 sturcures but one file
    GD1
    .CC1
    .CC2
    ..SO1
    ..SO2
    ..SO3
    Example3: data delivered in 3 files - you join the files in LSMW, they must have a common identifier like the old customer number in the beginning of each file
    FILE General data:
    GD1
    GD2
    GD3
    file Compamy code data:
    CC1
    CC2
    CC3
    file Sales org data:
    SO1
    SO2
    SO3
    LSMW is flexible and can handle each of this scenarios, are you flexible too?

  • How can you SELECT via Database Link CLOB data using Application Express?

    Customer Issue:
    Developer using Oracle's Application Express 3.1. The Developer is trying to SELECT a CLOB datatype column from a remote (10.2.0.3) database, via a database link on her 10.2.0.4 based client Application. The Developer wants to be able to select CLOB data from the remote database which has limitation that she can't make any changes to the remote database.
    Developer's Comments:
    I do a select and get the error. Getting error ORA-22992: cannot use LOB locators selected from remote tables. So she feels she can't use dbms_lob.substr in this configuration I can do a "select into" but that is for one value. I am trying to run a select statement for a report that brings back more than one row. I do not have permission to change anything on the remote database. I want to access the remote database and multiple tables.
    This is not something I work with, would greatly appreciate help or ideas. Is this a limitation of the 3.1; or does she just not have this set up correctly; or should she be using a Collection (if yes, please share example)
    Thanks very much,
    Pam
    Edited by: pmoutrie on Jun 4, 2009 12:01 PM
    Hello???
    Would really appreciate an answer.
    Thanks,
    Pam

    This may not be a perfect solution for you but it worked for my situation.
    I wanted to grab some data from Grid Control's MGMT$JOB_STEP_HISTORY table but I couldnt' create an Interactive Report due to the existance of a CLOB column. I cheated this by creating a view on the GC DB, grabbing the first 4000 characters and turning it into a varchar2 column:
    create view test_job_step_history as
    select job_Name, target_name, status, start_time, end_time, to_char(substr(output,1,4000)) output
    from MGMT$JOB_STEP_HISTORY where trunc(end_time) > trunc(sysdate)-90
    In an APEX Interactive Report:
    select * from test_job_step_history@GCDB
    Granted, the output looks aweful right now but I am only looking for a very particular output (failed, denied, ORA-, RMAN-, etc) so the formatting isn't the most important thing to me right now.
    If anyone can improve -- and I'm sure you can -- on this I'd love to hear about it.
    Thanks,
    Rich

  • How to get the home page for a user using  Pl/sql code ?

    Hi,
    I have a pl/sql procedure which runs after a form submission on a dynamic page. At end of completion of the procedure I want to send user to his/her home page. I am trying to write at the end of procedure to redirect the user to the home page. How do I do that ? What is way to redirect to a page using pl/sql and how do I know the user home page url ?
    thanks,
    Mainak

    Hi,
    Try <portalschema>.wwv_redirect.url('<portalschema>.home');
    Please replace portalschema with the name of your portal schema.
    Thanks,
    Sharmila

  • How to filter complex data using pl/sql

    Hello,
    i have to filter some data from the table with 1millions rows in it.
    here the requirement
    for example table is TEST
    id type
    1 a
    1 a
    1 b
    2 c
    33 b
    33 b
    33 c
    33 d
    5 c
    5 c
    now i just want to display the results which contains type c only if id is with also connected other than c than i dont want to dislplay that results
    so my result will look like .here i dont want to disply id 33 because some the id with 33 are connected with type other than c.
    id type
    2 c
    5 c
    so can please give me idea to make a query on that table
    thanks in advance

    with t as (
               select  1 id,'a' type_cd from dual union all
               select  1 id,'a' type_cd from dual union all
               select  1 id,'b' type_cd from dual union all
               select  2 id,'c' type_cd from dual union all
               select 33 id,'b' type_cd from dual union all
               select 33 id,'b' type_cd from dual union all
               select 33 id,'c' type_cd from dual union all
               select 33 id,'d' type_cd from dual union all
               select  5 id,'c' type_cd from dual union all
               select  5 id,'c' type_cd from dual
    select  id,
            type_cd
      from  (
             select  id,
                     type_cd,
                     count(distinct type_cd) over(partition by id) cnt,
                     row_number() over(partition by id,type_cd order by 1) rn
               from  t
      where type_cd = 'c'
        and cnt     = 1
        and rn      = 1
            ID T
             2 c
             5 c
    SQL>SY.

  • How to auto save and pre-fill some textfields

    first time i open a pdf, there are some textfields. they are all empty.
    i click on a button to call a web service. this returns some text and fill in those textfields.
    if one of these textfields, "message", has got an auto-filled text "success", then the pdf needs to remember the text in some of the rest of the fields. next time when the user open it, those fields should be with the text generated last time.
    notice that the "Do you want to save the file" auto-popup window won't meet my requirement. even if the user clicks on "no" for this popup window, now that i get a "success" transaction from the web service, the fields should be saved.
    i read through this, but may not be able to use it. i only have LiveCycle Designer ES3. I don't know how those adminui or process work.
    http://livecycleapps.wordpress.com/2009/10/21/livecycle-es2-using-action-profiles-to-pre-f ill-a-form-for-display-in-workspace/

    Hi,
    in Designer ES3 there is an Auto Save option in the form properties you can activate.
    Remember, the form needs Usage Rights to be savable through Reader, so you need Acrobat to apply those rights to your form first.

Maybe you are looking for