Creating pl/sql procedure problems

Dear all,
I have problems with creating a procedure which select returns more then one row.
CREATE OR REPLACE PROCEDURE ECM_DATA.check_padrones_datos
IS
  v_padron_check   VARCHAR2(50);
  v_padron_number   VARCHAR2(50);
BEGIN
   SELECT count(pd.estado)
   INTO v_padron_check
   FROM par6.padrones_datos pd, par6.padrones p, par6.FECHAS f
     where pd.estado not in ('2000','8000')
     AND PD.ARCHIVO = P.ARCHIVO
     AND P.FECHA = F.datum_s;
    DBMS_OUTPUT.PUT_LINE('Št. neuspešnih zapisov :  ' || v_padron_check);
    SELECT distinct pd.archivo
   INTO v_padron_number
   FROM par6.padrones_datos pd, par6.padrones p, par6.FECHAS f
     where pd.estado not in ('2000','8000')
     AND PD.ARCHIVO = P.ARCHIVO
     AND P.FECHA = F.datum_s;
    DBMS_OUTPUT.PUT_LINE('Padron št. :  ' || v_padron_number);
  EXCEPTION
    WHEN NO_DATA_FOUND THEN
     v_padron_number := 'Vsi padroni so OK';
     DBMS_OUTPUT.PUT_LINE('Padron št. :  ' || v_padron_number);
END;
Error ->  -01422: exact fetch returns more than requested number of rows
Select returns 2 or more rows.
SELECT distinct pd.archivo
    FROM par6.padrones_datos pd, par6.padrones p, par6.FECHAS f
     where pd.estado not in ('2000','8000')
     AND PD.ARCHIVO = P.ARCHIVO
     AND P.FECHA = F.datum_s;
How to write correct syntax in pl/sql. I apologize in advance for rookie questions. Any help would be appreciated.
Regards,
Robert

The exact implementation depends on the use case.
You can loop through the results
FOR r IN (
    SELECT  DISTINCT pd.archivo
    FROM    par6.padrones_datos pd
           ,par6.padrones p
           ,par6.fechas f
    WHERE   pd.estado not in ('2000','8000')
    AND     pd.archivo = p.archivo
    AND     p.fecha = F.datum_s
LOOP
    dbms_output.put_line('Padron št. :  ' || r.archivo);
END LOOP;
Or maybe you can process all results in one step, e.g. if you want to update a table based on the select.
Regards
Marcus

Similar Messages

  • PL SQL Procedure Problem

    I have a procedure that resides in a package and which is called by another application(Adobe Flex app).
    I would like to strip out and run/test individually one of the procedures with the package.
    I dont know how to create the procedure as a standalone procedure first. The reason for the test is that I have an application that has data (by month) for a range of dates in the tbl_dashb_data table. The procedure should return 14 records for data in the table for a date range of Jan07-Feb08.
    What I would like to do is run the procedure or the package and test to see how many records are returned.
    Do I need to put in a DBMS_OUTPUT.PUT_LINE statement into the procedure to view results in an SQL Plus session?
    Do I need to hardcode some of the variables in the procedure to get results.
    Im new to PL-SQL and trying to debug an application, any help would be great
    thanks
    [email protected]
    The package that it resides in is defined as;
    create or replace PACKAGE "PKG_DASHB_DATA" IS
    TYPE crsr_Data is REF CURSOR;
    PROCEDURE sp_getDateRange(p_TargetComp_ID IN NUMBER,p_Data OUT crsr_Data);
    END pkg_Dashb_Data;
    PROCEDURE sp_getDateRange(p_TargetComp_ID IN NUMBER,p_Data OUT crsr_Data) IS
    start_Date DATE;
    end_Date DATE;
    start_Year NUMBER;
    end_Year NUMBER;
    start_Month NUMBER;
    end_Month NUMBER := 24;
    lbl_TmpDate DATE;
    lbl_Month VARCHAR(30);
    lbl_Year VARCHAR(30);
    BEGIN
    SELECT MIN(Publication_Date),MAX(Publication_Date) INTO start_Date,end_Date FROM tbl_Dashb_Data WHERE
    Target_Cmpny_ID = p_TargetComp_ID ;
    start_Year := TO_CHAR(start_Date,'YYYY');
    end_Year := TO_CHAR(end_Date,'YYYY');
    start_Month := TO_CHAR(start_Date,'MM');
    end_Month := TO_CHAR(end_Date,'MM');
    FOR vYear IN start_Year..end_Year
    LOOP
    FOR vMonth IN start_Month..end_Month
    LOOP
    lbl_TmpDate := TO_DATE('01-' || vMonth || '-' || vYear,'DD-MM-YYYY');
    lbl_Month := TO_CHAR( lbl_TmpDate ,'MONTH');
    lbl_Year := vYear ;
    INSERT INTO TMPTBL_DATERANGES VALUES( lbl_Month ,lbl_Year);
    END LOOP;
    END LOOP;
    COMMIT;
    OPEN p_Data FOR
    SELECT * FROM TMPTBL_DATERANGES;
    END;

    Hi,
    If you really need to make a stand-alone procedure from a package procedure, it's basically just a matter of adding "CREATE OR REPLACE " in front ot "PROCEDURE". See the SQL Reference manual (under "CREATE PROCEDURE") for details.
    Like Warren said, you can run the package procedure from SQL*Plus, so there's no need to make a stand-alone version. One thing you can't do from SQL*Plus is have OUT-parameters. Put the call in an anonymous block, which you can run from SQL*Plus:
    DECLARE
         c     pkg_dashb_data.crsr_data;
    BEGIN
         pkg_dashb_data.sp_getDateRange(10, c);
    END;
    /There's no reason to hard-code any variables. Is there a reason why you think that would help?
    That's all I have to say about the questions you asked.
    Below is a suggestion that you didn't request, but I hope it helps you.
    SQL has a DATE type, with lots of convenient features. TO_CHAR (DT) is useful for displaying a DATE, but think very carefully before using it for any other purpose. Converting DATES to strings or numbers to manipulate them, and then convert them back is cumbersome, inefficient, error-prone and only rarely necessary.
    For example, you could write the procedure like this:
    CREATE OR REPLACE PROCEDURE sp_getDateRange2
    (     p_TargetComp_ID     IN     NUMBER
    ,     p_Data          OUT     pkg_dashb_data.crsr_Data
    ) IS
         start_Date DATE;
         end_Date DATE;
         lbl_TmpDate DATE;
         lbl_Month VARCHAR(30);
         lbl_Year VARCHAR(30);
    BEGIN
         SELECT     MIN (Publication_Date),     MAX (Publication_Date)
         INTO     start_Date,          end_Date
         FROM     tbl_Dashb_Data
         WHERE     Target_Cmpny_ID = p_TargetComp_ID ;
         lbl_TmpDate := TRUNC (start_date, 'MM');
         WHILE  lbl_TmpDate <= end_date
         LOOP
              lbl_Month := TO_CHAR( lbl_TmpDate ,'MONTH');
              lbl_Year := TO_CHAR( lbl_TmpDate ,'YYYY');
              INSERT INTO TMPTBL_DATERANGES VALUES( lbl_Month ,lbl_Year);
              lbl_TmpDate := ADD_MONTHS (lbl_TmpDate, 1);
         END LOOP;
         OPEN p_Data FOR
              SELECT * FROM TMPTBL_DATERANGES;
    END;
    /

  • Creating page items from pl/sql procedure and using them on a page

    I have a page containing 2 select lists (P21_DEPARTMENTS and P21_DATE). Originally I added them as items that were "select list with submits". The problem is that based on the clearance level of the currently logged on user I only wanted the P21_DEPARTMENTS to be a select list if the user was an administrator. If however the user is not an admin then I want the page to have a hidden form field called P21_DEPARTMENTS that stores the user's department and has a label item that has the department name.
    There is also a report region that generates a table based on the department selected from the select list (if the user is an admin) or the value stored in the hidden form field if the user is not.
    My problem is that I cannot have both those items on the same page and use the HTML built-in authentication to determine which item should be rendered because I need to use the same ID for both items so that the stored procedure in my report region doesn't break. HTML does not permit items to share the same ID.
    I tried to circumvent the problem by creating a stored procedure that performs all of the item rendering in the procedure and uses "htp.p()" to output all of my HTML code. This solution would allow me to pass a parameter into the procedure informing me as to whether or not the user is an administrator. If the user is an administrator the procedure would use a conditional statement and render a select list. If not, the hidden form field and label option would be used instead.
    I finally got the stored procedure working perfectly. Now I am encountering the most bizarre thing. Since the "select list with submit" was not working (I used the same code that gets generated when I created other items using htmlDB's GUI) I decided to use a JavaScript function instead that gets triggered by the onChange event. I send along the value that is currently selected in the select list and in the function I set:
    location.href='http://www.myoraclesite.com/pls/htmldb/f?p=111:21:729740000000000000::NO::P21_DEPARTMENTS:1';
    In theory this should work. The problem is that it doesn't. The page reloads and the P21_DEPARTMENTS select list is not pre-selected.
    The only thing I can think of is that when htmlDB generates page items that you've created with it's own admin tool it assigns some internal guid or something as opposed to when someone tries to generate dynamic page items of their own from a pl/sql procedure it's like the application doesn't even know they exist.
    Any help would be GREATLY appreciated.
    My only other solution would be to create a totally separate page (one for admin and another for non-admin). I would really like to avoid this.
    Thanks in advance.

    I would love to be able to generate my menus and
    various other items in my htmlDB applications in much
    the same way I can using ASP, PHP and Cold Fusion.
    Users should have the ability to write server-side
    code wherever they feel like it. The way htmlDB works
    right now I spend more time trying to figure out how
    to create simple effects and generate simple
    interfaces when I need to be building a portal. Ami - it's important to understand that HTML DB is not like other languages. Thus, trying to force concepts which are common in other languages into HTML DB will often result in more work.
    It's definitely worth the time to go over the HTML DB 2-day Developer, which can be found here: http://www.oracle.com/technology/products/database/htmldb/pdf/B14377_01.pdf
    I can build a portal using Classic ASP, C#, PHP or Cold
    Fusion in like 1/10 of the time that it takes me to
    build one using htmlDB. I understand that this is not
    meant for the hard-core programmer but no web
    programming application in today's day and age should
    prevent experts from getting under the hood.And I can build a Portal in HTML DB in 1/10 the time it will take me to do it in any other language. It's like anything else - proficiency comes with practice and work.
    As for getting under the hood, there is plenty of places you can do that with HTML DB. Keep in mind that HTML DB itself is an HTML DB application, so the limits on what you can build with HTML DB are virtually limitless.
    Sorry for the vent there. After spending the last 2
    days trying to figure out how to implement such a
    straightforward thing and now being informed that it
    can't be done kind of bugged me.I understand your frustration, as I've been there before. My rule for beginners is that if you are writing more than a line or two of code in the first week, you're doing something wrong. Stop, take a break, and then use the ample resources (including searching this forum) to help solve your problem. There are plenty of resources available for you to learn about HTML DB on the HTML DB home page: http://otn.oracle.com/htmldb
    Good luck,
    - Scott -

  • PL/SQL Procedure Calling Java Host Command Problem

    This is my first post to this forum so I hope I have chosen the correct one for my problem. I have copied a java procedure to call Unix OS commands from within a PL/SQL procedure. This java works well for some OS commands (Eg ls -la) however it fails when I call others (eg env). Can anyone please give me some help or pointers?
    The java is owned by sys and it looks like this
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "ExecCmd" AS
    //ExecCmd.java
    import java.io.*;
    import java.util.*;
    //import java.util.ArrayList;
    public class ExecCmd {
    static public String[] runCommand(String cmd)
    throws IOException {
    // set up list to capture command output lines
    ArrayList list = new ArrayList();
    // start command running
    System.out.println("OS Command is: "+cmd);
    Process proc = Runtime.getRuntime().exec(cmd);
    // get command's output stream and
    // put a buffered reader input stream on it
    InputStream istr = proc.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(istr));
    // read output lines from command
    String str;
    while ((str = br.readLine()) != null)
    list.add(str);
    // wait for command to terminate
    try {
    proc.waitFor();
    catch (InterruptedException e) {
    System.err.println("process was interrupted");
    // check its exit value
    if (proc.exitValue() != 0)
    System.err.println("exit value was non-zero: "+proc.exitValue());
    // close stream
    br.close();
    // return list of strings to caller
    return (String[])list.toArray(new String[0]);
    public static void main(String args[]) throws IOException {
    try {
    // run a command
    String outlist[] = runCommand(args[0]);
    for (int i = 0; i < outlist.length; i++)
    System.out.println(outlist);
    catch (IOException e) {
    System.err.println(e);
    The PL/SQL looks like so:
    CREATE or REPLACE PROCEDURE RunExecCmd(Command IN STRING) AS
    LANGUAGE JAVA NAME 'ExecCmd.main(java.lang.String[])';
    I have granted the following permissions to a user who wishes to run the code:
    drop public synonym RunExecCmd
    create public synonym RunExecCmd for RunExecCmd
    grant execute on RunExecCmd to FRED
    grant javasyspriv to FRED;
    Execute dbms_java.grant_permission('FRED','java.io.FilePermission','/bin/env','execute');
    commit
    Execute dbms_java.grant_permission('FRED','java.io.FilePermission','/opt/oracle/live/9.0.1/dbs/*','read, write, execute');
    commit
    The following test harness has been used:
    Set Serverout On size 1000000;
    call dbms_java.set_output(1000000);
    execute RunExecCmd('/bin/ls -la');
    execute RunExecCmd('/bin/env');
    The output is as follows:
    SQL> Set Serverout On size 1000000;
    SQL> call dbms_java.set_output(1000000);
    Call completed.
    SQL> execute RunExecCmd('/bin/ls -la');
    OS Command is: /bin/ls -la
    total 16522
    drwxrwxr-x 2 ora9sys dba 1024 Oct 18 09:46 .
    drwxrwxr-x 53 ora9sys dba 1024 Aug 13 09:09 ..
    -rw-r--r-- 1 ora9sys dba 40 Sep 3 11:35 afiedt.buf
    -rw-r--r-- 1 ora9sys dba 51 Sep 3 09:52 bern1.sql
    PL/SQL procedure successfully completed.
    SQL> execute RunExecCmd('/bin/env');
    OS Command is: /bin/env
    exit value was non-zero: 127
    PL/SQL procedure successfully completed.
    Both commands do work when called from the OS command line.
    Any help or assistance would be really appreciated.
    Regards,
    Bernard.

    Kamal,
    Thanks for that. I have tried to use getErrorStream and it does give me more info. It appears that some of the commands cannot be found. I suspected that this was the case but I am not sure about how this can be as they all appear to reside in the same directory with the same permissions.
    What is more confusing is output like so:
    SQL> Set Serverout On size 1000000;
    SQL> call dbms_java.set_output(1000000);
    Call completed.
    SQL> execute RunExecCmd('/usr/bin/id');
    OS Command is: /usr/bin/id
    exit value was non-zero: 1
    id: invalid user name: ""
    PL/SQL procedure successfully completed.
    SQL> execute RunExecCmd('/usr/bin/which id');
    OS Command is: /usr/bin/which id
    /usr/bin/id
    PL/SQL procedure successfully completed.
    Regards,
    Bernard

  • Create table statement in a pl/sql procedure

    Hi all.
    I have a problem in Oracle 10g.
    First of all I must say that I'm new in oracle 10.
    I have a stored procedure in which I have the instruction "create table name_table as
    select col1,col2,col3,..ecc
    from table1, table2
    where table1.col1 = table2.col2"
    When I compile this procedure it gives me an error.
    Is it changed the sintax????
    Is there anyone that can help me???
    Thanks all for the collaboration,
    Fabrizio

    A little mistake -- see it --
    SQL> ed
    Wrote file afiedt.buf
      1  Create or replace procedure My_procedure as
      2  begin
      3  EXECUTE IMMEDIATE 'create table my_table(fld number(5));'
      4* end;
    SQL> /
    Warning: Procedure created with compilation errors.
    SQL>
    SQL>
    SQL> ed
    Wrote file afiedt.buf
      1  Create or replace procedure My_procedure as
      2    str varchar2(200);
      3  begin
      4   str := 'create table my_table(fld number(5))';
      5  EXECUTE IMMEDIATE(str);
      6* end;
    SQL> /
    Procedure created.
    SQL>
    SQL>
    SQL> Create or replace procedure My_procedure as
      2  begin
      3  EXECUTE IMMEDIATE 'create table my_table(fld number(5));'
      4  end;
      5  /
    Warning: Procedure created with compilation errors.
    SQL> ed
    Wrote file afiedt.buf
      1  Create or replace procedure My_procedure as
      2  begin
      3  EXECUTE IMMEDIATE 'create table my_table(fld number(5))';
      4* end;
    SQL> /
    Procedure created.Regards.
    Satyaki De.
    N.B.: Please check the bolded line. You didn't write the ; outside the quotation. Otherwise, it will compile successfully.

  • Creating a CSV file from a pl/sql procedure

    Hi Everyone,
    I would like to know how to write a procedure in pl/sql where i need to check if they are any records in a table say "Table A".
    If they are any records in the "Table A" then we need to write those records in the "Table A" to the CSV file.
    If they are no records then we need to insert a record into the CSV file that "No records are found in "Table A".
    Could anybody please help ?
    Thanks in advance

    see this
    ops$tkyte@8i> create or replace procedure dump_table_to_csv( p_tname in varchar2,
    2 p_dir in varchar2,
    3 p_filename in varchar2 )
    4 is
    5 l_output utl_file.file_type;
    6 l_theCursor integer default dbms_sql.open_cursor;
    7 l_columnValue varchar2(4000);
    8 l_status integer;
    9 l_query varchar2(1000)
    10 default 'select * from ' || p_tname;
    11 l_colCnt number := 0;
    12 l_separator varchar2(1);
    13 l_descTbl dbms_sql.desc_tab;
    14 begin
    15 l_output := utl_file.fopen( p_dir, p_filename, 'w' );
    16 execute immediate 'alter session set nls_date_format=''dd-mon-yyyy hh24:mi:ss''
    17
    18 dbms_sql.parse( l_theCursor, l_query, dbms_sql.native );
    19 dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );
    20
    21 for i in 1 .. l_colCnt loop
    22 utl_file.put( l_output, l_separator || '"' || l_descTbl(i).col_name || '"'
    23 dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );
    24 l_separator := ',';
    25 end loop;
    26 utl_file.new_line( l_output );
    27
    28 l_status := dbms_sql.execute(l_theCursor);
    29
    30 while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop
    31 l_separator := '';
    32 for i in 1 .. l_colCnt loop
    33 dbms_sql.column_value( l_theCursor, i, l_columnValue );
    34 utl_file.put( l_output, l_separator || l_columnValue );
    35 l_separator := ',';
    36 end loop;
    37 utl_file.new_line( l_output );
    38 end loop;
    39 dbms_sql.close_cursor(l_theCursor);
    40 utl_file.fclose( l_output );
    41
    42 execute immediate 'alter session set nls_date_format=''dd-MON-yy'' ';
    43 exception
    44 when others then
    45 execute immediate 'alter session set nls_date_format=''dd-MON-yy'' ';
    46 raise;
    47 end;
    48 /
    Procedure created.
    ops$tkyte@8i> exec dump_table_to_csv( 'emp', '/tmp', 'tkyte.emp' );
    PL/SQL procedure successfully completed.

  • Creating web service from pl/sql procedure

    Hello.
    I need to create a web service from pl/sql procedure and i chose JDeveloper for this implementation. I have wsdl, but I never created web services. So, I created web service with document/literal message format.
    But I have several troubles:
    1. All element names have lower case letters.
    2. The SOAP envelope must begin from words soapenv:Envelope but i have soap:Envelope.
    3. And operation name has tail like "Element".
    I know bad way for implement 1 and 3 points. It's a modification of java_wsdl_mapping.xml and wsdl files. But if I want to add new method to my service all changes will be cleaned. It's not critical but inconvenient to support.
    But for point 3 i have no ideas.
    This task is very important for me. Can somebody help me?
    JDeveloper 10.1.3.3
    Regards,
    Aleksey

    http://www.oracle.com/technology/obe/obe1013jdev/10131/wsfromplsqlpackage/devwsfrom%20plsql.htm
    Frank

  • Problems in creating RLANG stored procedure in HANA studio

    Hi,
    While I am creating a stored procedure (using .hdbprocedure file) in HANA studio with language as RLANG, I am getting an error message like this: "It is not supported to use another language than sqlscript".
    I have the following setting configured.
    HANA System -> Administration -> Configuration ->indexserver.ini -> repository -> sqlscript_mode = UNSECURE
    Any clues will be appreciated.
    Best Regards
    Surya

    HI Raj,
    This happens even for the empty procedure as following
    PROCEDURE "IDMANALYTICS_OPER"."idmanalytics.hana.db.hdbprocedures::MC_ROLEMINING_CLUSTERING_R" ( )
      LANGUAGE RLANG
      SQL SECURITY INVOKER
      READS SQL DATA AS
    BEGIN
      Write your procedure logic
    END;
    The procedure that I wanted to write is following.
    PROCEDURE MC_ROLEMINING_CLUSTERING_R(IN rolemining_input "_SYS_BIC"."idmanalytics.hana.db.views/MC_ROLEMINING_VINPUT",
      IN params "IDMANALYTICS_DB"."idmanalytics.hana.db.hdbtables::MC_ROLEMINING_PARAMETER",
      OUT result MC_ROLEMINING_CLUSTERS_TYPE,
      OUT result_hierarchy MC_ROLEMINING_HIERARCHY_TYPE,
      OUT result_userorder MC_ROLEMINING_USERORDER_TYPE
    LANGUAGE RLANG AS
    BEGIN
      noofclusters <- params$INT_VALUE[1];
      simindex <- params$DOUBLE_VALUE[2];
      distancemethod="jaccard"
      clusteringmethod="complete"
      usercol <- rolemining_input$USER_ID
      privcol <- rolemining_input$PRIV_ID
      #--generate user-permission matrix from user-permission table
      uptable <- data.frame(users = usercol, privileges = privcol)
      uniqueusers <- sort(unique(uptable$users))
      uniqueprivileges <- sort(unique(uptable$privileges))
      upmatrixdata <- vector()
      index <- 0
      for(i in uniqueusers )
      for(j in uniqueprivileges) {
      row_to_find <- data.frame(users=i, privileges = j)
      if(duplicated(rbind(uptable, row_to_find))[nrow(uptable)+1]){
      upmatrixdata <- append(upmatrixdata, 1, after = index)
      else {
      upmatrixdata <- append(upmatrixdata, 0, after = index)
      index <- index +1
      upmatrix <- matrix(
      upmatrixdata ,
      nrow = length(uniqueusers),
      ncol = length(uniqueprivileges),
      byrow = TRUE,
              dimnames = list(
              uniqueusers,
                  uniqueprivileges
      #--apply hierarchical clustersing
      require(vegan)
      distance<-vegdist(upmatrix,method=distancemethod)
      clusters<-hclust(distance,method=clusteringmethod)
      #--fill clusters for given h and k
      if(noofclusters > 0){
      userclusters<-cutree(clusters,k=noofclusters)
      tempresult <- as.data.frame(userclusters)
      result <- data.frame(USER_ID=row.names(tempresult), CLUSTER_ID=tempresult$userclusters)
      if(noofclusters <= 0 & simindex >= 0){
      userclusters<-cutree(clusters,h=simindex)
      tempresult <- as.data.frame(userclusters)
      result <- data.frame(USER_ID=row.names(tempresult), CLUSTER_ID=tempresult$userclusters)
      #--fill role hierarchy
      clusters_merge <- as.data.frame(clusters$merge)
      clusters_height <- clusters$height
      clusters_order <- clusters$order
      result_hierarchy <- data.frame(HEIGHT=clusters_height, V1=clusters_merge$V1, V2=clusters_merge$V2)
      #--fill user order
      clusters_order <- clusters$order
      result_userorder <- data.frame(USERORDER=clusters_order)
    END;

  • Pl/sql Procedure is Not Creating With the CLOB data Type

    Hi,
    I am Using Oracle 10g Express Edition Release2.... My Doubt is While creating a table With CLOB Data Type the table is created successfully,but while Creating a Procedure With the CLOB Data type i am getting an Error Message
    2667/5 PL/SQL: Statement ignored
    2667/24 PLS-00382: expression is of wrong type
    then i tried With the Varchar2(30000) the Procedure is Created Successfully note i have not changed any thing in my code except the data type.
    I am Just Confused ......Why the Procedure is not Created with CLOB Data type?
    Please advice ...
    Thank U
    SHAN

    hi,
    Thanks for reply....Another Example
    CREATE TABLE USER_MAS (USER_ID     VARCHAR2 (20 Byte),MAIL_ID     VARCHAR2 (255 Byte));
    set serveroutput on
    declare
    atable varchar2(64) := 'USER_MAS';
    acolumn varchar2(64) := 'MAIL_ID';
    avalue varchar2(64) := 'NEWYORK' ;
    dyn_sql clob;
    begin
    dyn_sql := 'update '||atable||' set '||acolumn||' = '''||avalue|| '''' ;
    dbms_output.put_line(dyn_sql);
    execute immediate dyn_sql;
    end;
    commit ;
    Error at line 2
    ORA-06550: line 9, column 23:
    PLS-00382: expression is of wrong type
    ORA-06550: line 9, column 5:
    PL/SQL: Statement ignored
    When i Changed the Data type to varchar2(64)
    update USER_MAS set MAIL_ID = 'NEWYORK'
    PL/SQL procedure successfully completed.
    Commit complete.
    I like to Know the Reason Why the Procedure is Not Created in Oracle 10g XE DB
    Note :the Same Script i used in 11g DB the Procedure is Created Successfully....
    Why you need use CLOB or VARCHAR2 in your temp_num variable as you sending parameters as number?
    In the Procedure we are create some run time queries while executing the procedure. There are around 10 run time queries created.
    The size of each query is more than 4000 characters . We then add all the queries using union all after each query  to the clob variable as the normal varchar will not support.
    Please Advice
    Thank U
    SHAN

  • Creating Web service for PL/SQL Procedure with Complex Data Types

    I need to created web service for PL/SQL Procedure with Complex Data types like table of records as parameters, how do we map the pl/sql table type parameters with web service, how to go about these?

    Hello,
    When you are creating a service from a Stored Procedure, the OracleAS WS tools will create necessary Java and PL wrapper code to handle the complex types (table of record) properly and make them compatible with XML format for SOAP messages.
    So what you should do is to use JDeveloper or WSA command line, to create a service from your store procedure and you will see that most of the work will be done for you.
    You can find more information in the:
    - Developing Web Services that Expose Database Resources
    chapter of the Web Service Developer's guide.
    Regards
    Tugdual Grall

  • Create an ASCII file from pl/sql procedure

    hello
    I need to create a file starting from a pl/sql procedure launched by command line
    I'll have my .sql file containing my procedure; I'll launch it via command line and it will create the ASCII file
    In the procedure I'd like to use some stored procedures or functions
    is all of this possible?

    itmick wrote:
    I need to create a file starting from a pl/sql procedure launched by command line
    I'll have my .sql file containing my procedure; I'll launch it via command line and it will create the ASCII file
    In the procedure I'd like to use some stored procedures or functions
    is all of this possible?You could have the procedure code as well as invocation in your .sql file. In that case, launching the .sql file will
    (a) compile your procedure and
    (b) invoke it as well
    Yes, the compiled procedure can invoke other stored procedures or functions.
    To create the ASCII file, you could:
    (a) use UTL_FILE supplied package in your procedure; this will create the ASCII file on the Oracle server, or
    (b) have DBMS_OUTPUT.PUT_LINE calls in your procedure. When invoked from SQL*Plus, this will print out the lines on the SQL*Plus interface and you could spool it to a file on your client filesystem.
    HTH,
    isotope

  • Creating Excel Workbook from PL/SQL Procedure

    I am trying to create Excel Workbook with two worksheets from PL/SQL procedure. I created one worksheet. Can I create a separate sheet from same procedure. I used OWA_UTIL.MIME_HEADER ('application/vnd.ms-excel', FALSE)
    command to create the spreadsheet.
    Any help would be helpful.
    Thanks
    Yagna Shah

    Further to my previous post here is how I will develop a typical master details excel report.
    by using the package,
    It will also show sum of salary at each department.
    Note : When I paste the code here I loose the indentation. So the code below is not indented properly.
    DECLARE
    r NUMBER := 0 ; --- r IS the ROW NUMBER IN this excel file
    l_sum NUMBER ;
    BEGIN
    --- Generate the styles that we need
    gen_xl_xml.create_excel( 'UTL_DIR','master_Detail.xls') ;
    gen_xl_xml.create_style( 'dept_title' , 'Arial', 'Red',14, p_backcolor => 'LightGray' );
    gen_xl_xml.create_style( 'sgs2' , 'Arial', NULL ,10, p_bold => TRUE );
    gen_xl_xml.create_style( 'sgs3' , 'Arial', 'blue',14 );
    gen_xl_xml.create_style( 'sgs4' , 'Arial', 'green',14 );
    gen_xl_xml.create_style( 'emp_title' , 'Arial', 'Black',9, p_backcolor => 'LightBlue' );
    gen_xl_xml.create_style( 'sal_tot' , 'Arial', 'Brown',13, p_backcolor => 'Yellow' );
    -- SET ANY COLUMN AND ROW changes
    gen_xl_xml.set_column_width( 3, 145 );
    gen_xl_xml.set_column_width( 4, 145 );
    l_sum := 0 ;
    FOR recd IN ( SELECT department_id, department_name FROM departments ) LOOP
    IF l_sum <> 0 THEN
    r := r +1 ;
    gen_xl_xml.write_cell_char( r, 4, 'Department Total ->' , 'sal_tot' );
    gen_xl_xml.write_cell_num( r, 5, l_sum , 'sal_tot' );
    l_sum := 0;
    END if ;
    r := r+1 ;
    gen_xl_xml.write_cell_CHAR( r,1, 'Department : '|| recd.department_name , 'dept_title' );
    -- As we need same style applied till the above data flows use write_cell_null
    gen_xl_xml.write_cell_NULL( r,2 , null );
    gen_xl_xml.write_cell_NULL( r,3, 'dept_title' );
    gen_xl_xml.write_cell_NULL( r,4, 'dept_title' );
    gen_xl_xml.write_cell_NULL( r,5, 'dept_title' );
    --- Add employee heading
    r := r+1 ;
    gen_xl_xml.write_cell_CHAR( r,2, 'EmployeeID' , 'emp_title' );
    gen_xl_xml.write_cell_CHAR( r,3, 'First Name' , 'emp_title' );
    gen_xl_xml.write_cell_CHAR( r,4, 'Last Name' , 'emp_title' );
    gen_xl_xml.write_cell_CHAR( r,5, 'Salary' , 'emp_title' );
    FOR rec IN (SELECT employee_id , first_name , last_name, salary FROM employees WHERE department_id = recd.department_id ) LOOP
    r := r+1 ;
    gen_xl_xml.write_cell_num( r,2, rec.employee_id, 'sgs2' );
    gen_xl_xml.write_cell_char( r,3, rec.first_name, 'sgs3' );
    gen_xl_xml.write_cell_char( r,4, rec.last_name , 'sgs4' );
    gen_xl_xml.write_cell_num( r,5, rec.salary );
    l_sum := l_sum + rec.salary ;
    END LOOP ;
    END LOOP ;
    gen_xl_xml.close_file ;
    END ;
    -----------------------------------------------------------------------------------------------------------------

  • Problem with PL/SQL Procedure

    Hi,
    the following procedure doesn't work:
    PROCEDURE "DATEDIMENSION" (start_date in date, end_date in date) is
    current_date date;
    days_offset number;
    days_between number := end_date - start_date;
    BEGIN
    execute immediate
    'create or replace table dwh_dim_date
    ( FULL_DATE date NOT NULL,
    DAY_OF_WEEK number(1) NOT NULL,
    DAY_NUMBER_IN_CALENDAR_MONTH number(2) NOT NULL
    for days_offset IN 0..days_between
    loop
    current_date := start_date + days_offset;
    execute immediate
    insert into dwh_dim_date
    ( "FULL_DATE",
    "DAY_OF_WEEK",
    "DAY_NUMBER_IN_CALENDAR_MONTH"
    values
    select
    to_date(current_date, "DD.MM.YYYY"),
    to_number(to_char(current_date, "D")),
    to_number(to_char(current_date, "DD")),
    from
    dual
    END LOOP;
    END;
    Can anybody help?
    Thanks,
    Walter

    What version of oracle are you running?
    This works fine 9.2.0.6
      1  create or replace PROCEDURE DATEDIMENSION
      2   (start_date in date, end_date in date) is
      3  curr_date date;
      4  days_offset number;
      5  days_between number := end_date - start_date;
      6  BEGIN
      7    for days_offset IN 0..days_between
      8    loop
      9       curr_date := start_date + days_offset;
    10       insert into dwh_dim_date
    11            ( "FULL_DATE",
    12              "DAY_OF_WEEK",
    13              "DAY_NUMBER_IN_CALENDAR_MONTH")
    14      values(curr_date,
    15             to_number(to_char(curr_date, 'D')),
    16             to_number(to_char(curr_date, 'DD')) );
    17  END LOOP;
    18* END;
    SQL> /
    Procedure created.
    SQL> execute DATEDIMENSION (to_date('01.01.1901', 'DD.MM.YYYY'), to_date('31.12.2099', 'DD.MM.YYYY'))
    PL/SQL procedure successfully completed.
    SQL>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Simple PL/SQL Question - Creating/using a procedure in PL/SQL

    So far, I have been making simple PL/SQL scripts with no procedures. The structure looks like the following:
    DECLARE
    BEGIN
    END
    I have found documentation for Procedures, however I don't see how to insert them into that structure. Apparently one way is Packages, however I don't want to store the PL/SQL on the database. Can someone give me a highlevel structure of a PL/SQL that defines and uses a procedure?

    SQL> declare
      2    procedure stage1 as
      3    begin
      4      dbms_output.put_line('stage 1');
      5    end;
      6    procedure stage2 as
      7    begin
      8      dbms_output.put_line('stage 2');
      9    end;
    10  begin
    11    stage1;
    12    stage2;
    13  end;
    14  /
    stage 1
    stage 2
    PL/SQL procedure successfully completed.
    SQL>

  • Problem calling PL/SQL procedure from Workflow function activity.

    Hi,
    I am trying to call a PL/SQL procedure from within my workflow activity.
    While I am able to execute the procedure through SQLDeveloper, the workflow function does not seem to call it.
    It seems that custom PL/SQL procedures have to conform to certain standards to be called within workflow applications. I have written my procedure to conform to those standards (referred to the example workflows).
    Could someone please help me with it?
    Thanks and regards.

    Hi,
    When I've received enough alpha reviews of the first few chapters of my book, I'll make chapter five available, which deals with writing functions for Workflows.
    Matt
    Alpha review chapters from my book "Developing With Oracle Workflow" are available on my website:
    http://www.workflowfaq.com
    http://forum.workflowfaq.com

Maybe you are looking for

  • Questions on Lob-Columns

    Hi, i´m working still along time with Oracle, but not very often with Lob-Types. The docs and metalink didn´t helped me very much with the following questions: 1. What is the maximum length of a CLOB Datatype in PL/SQL (long ago it was 32767 Bytes, b

  • Setting the charset in dynamic invocation

    I'm on WLS 8.1 SP1. The doc (http://e-docs.bea.com/wls/docs81/webserv/i18n.html) shows how to set the charset attribute of the Content-Type HTTP header via the client stub. But I am not using client stubs, I'm using dynamic invocation. So how do I ac

  • Dead line block is not getting executed

    Hi, I configured BPM scenario to collect messages from one interface and create IDOCs in ECC.i configured with following steps Start Block(start of Block) Loop(While 1=1) receive container step(to create multiline container) endloop Exception branch

  • Satellite L500 - Lost wireless connection

    My Satellite L500 recently lost wireless connection. I looked up the Realtek wireless device in Device Manager, and it says the device is working properly. I have tried using "ping 192.168.1.1" to reach the router, and I get "Transmit error - general

  • Table Name Substitution with a variable

    I have the following procedure.... LOOP FETCH table_cur INTO table_rec; EXIT WHEN NOT table_cur%FOUND; TableID := table_rec.TableName; Office := table_rec.OfficeNum; Client := table_rec.CliNum; IF Office = 'Y' AND Client = 'Y' Then UPDATE TableID SET