Pl/sql anonymous block and procedure ??

Hi I want to ask a question about my sql query and procedure.
I wrote a like this.. it's şanguage is my native language but my question is not related language. I wrote this query like procedure. So procedure's code same this. But this query retrieve right result but procedure is not retrieve right result. What is cause of this situation. is fault definiton of procedure or what ?
quey is this
-- d?sardan girilen y?l birim ve sn?f baz al?narak basar?l? ö?rencilerin getirilmesi     
SELECT  da.acilan_ders_no, da.ders_kodu,oa.ogrenci_no, da.ders_adi,dk.harf_kodu
FROM ders_aktif da,ders_tanim dt,ogrenci_akademik oa,ders_kayit dk
WHERE da.acildigi_yil='2009' and
      oa.ders_baslama_yil='2009'and
      oa.birim like '1521%'and
      (da.acildigi_donem='1'or
      da.acildigi_donem='2')and
      da.ders_kodu like '1521%'and
      (dt.normal_yariyili='1' or
      dt.normal_yariyili='2')and
      dt.ders_kodu=da.ders_kodu and
      da.acilan_ders_no=dk.acilan_ders_no and
      (dk.harf_kodu!='FF' and
      dk.harf_kodu!='DZ' and
      dk.harf_kodu!='YZ') and
      oa.ogrenci_no=dk.ogrenci_no
      order by oa.ogrenci_no desc
      ;procedure is this
create or replace
PROCEDURE SINIF_BAZINDA_BASARI(yil in number, birimno in number)IS
acilan_ders_no number;
ders_kodu  VARCHAR2(12);
ogrenci_no  VARCHAR2(12);
ders_adi   VARCHAR2(50);
harf_kodu  VARCHAR2(4);
CURSOR c_basari IS
SELECT  da.acilan_ders_no, da.ders_kodu,oa.ogrenci_no, da.ders_adi,dk.harf_kodu
into acilan_ders_no,ders_kodu,ogrenci_no,ders_adi,harf_kodu
FROM ders_aktif da,ders_tanim dt,ogrenci_akademik oa,ders_kayit dk
WHERE da.acildigi_yil=yil and
      oa.ders_baslama_yil=yil and
      oa.birim like birimno ||'%' and
      (da.acildigi_donem='1'or
      da.acildigi_donem='2')and
      da.ders_kodu like birimno ||'%' and
      (dt.normal_yariyili='1' or
      dt.normal_yariyili='2')and
      dt.ders_kodu=da.ders_kodu and
      da.acilan_ders_no=dk.acilan_ders_no and
      (dk.harf_kodu!='FF' and
      dk.harf_kodu!='DZ' and
      dk.harf_kodu!='YZ') and
      oa.ogrenci_no=dk.ogrenci_no
      order by oa.ogrenci_no ASC
      BEGIN
FOR I IN c_basari LOOP
dbms_output.put_line('ACILAN DERS NO'||I.acilan_ders_no||'  DERS KODU  '|| I.DERS_KODU||'OGRENCI NO '||I.OGRENCI_NO||' DERS ADI  '||I.DERS_ADI||' HARF KODU '||I.HARF_KODU);
end loop;
END ;

78091                  152111003    152120091063 INTRODUCTION TO COMPUTER ENGINEERING I             YT       
78831                  152111006    152120091063 PHYSICS I LAB                                      BA       
78090                  152111002    152120091063 INTRODUCTION TO COMPUTERS                          DD       
79000                  152111009    152120091062 EXPOSITORY WRITING                                 CC       
78091                  152111003    152120091062 INTRODUCTION TO COMPUTER ENGINEERING I             YT       
78090                  152111002    152120091062 INTRODUCTION TO COMPUTERS                          DC       
78831                  152111006    152120091062 PHYSICS I LAB                                      BA       
81888                  152111008    152120091062 CHEMISTRY LAB.                                     CB       
78089                  152111001    152120091062 CALCULUS I                                         CB    procedure retrieve
78091                  152111003    152120091063 INTRODUCTION TO COMPUTER ENGINEERING I             YT       
78831                  152111006    152120091063 PHYSICS I LAB                                      BA       
78090                  152111002    152120091063 INTRODUCTION TO COMPUTERS                          DD       
79000                  152111009    152120091062 EXPOSITORY WRITING                                 CC       
78091                  152111003    152120091062 INTRODUCTION TO COMPUTER ENGINEERING I             YT       
78090                  152111002    152120091062 INTRODUCTION TO COMPUTERS                          DC       
78831                  152111006    152120091062 PHYSICS I LAB                                      BA       
81888                  152111008    152120091062 CHEMISTRY LAB.                                     CB       
78089                  152111001    152120091062 CALCULUS I                                         CB   
78089                  152111001    152120091062 CALCULUS I                                         CB       
78830                  152111005    152120091062 PHYSICS I                                          DC       
78832                  152111007    152120091062 CHEMISTRY                                          CC       
78830                  152111005    152120091050 PHYSICS I                                          BA       
78091                  152111003    152120091050 INTRODUCTION TO COMPUTER ENGINEERING I             YT       
78090                  152111002    152120091050 INTRODUCTION TO COMPUTERS                          AA       
78089                  152111001    152120091050 CALCULUS I                                         BB       
78094                  152111010    152120091050 INTRODUCTION TO PROGRAMMING                        BA       
79000                  152111009    152120091050 EXPOSITORY WRITING                                 CC       
81888                  152111008    152120091050 CHEMISTRY LAB.                                     CB       
78832                  152111007    152120081050 CHEMISTRY                                          CB       
78831                  152111006    152120081050 PHYSICS I LAB                                      BB       
78090                  152111002    152120081043 INTRODUCTION TO COMPUTERS                          CC       
81888                  152111008    152120081043 CHEMISTRY LAB.                                     CB       
78091                  152111003    152120081043 INTRODUCTION TO COMPUTER ENGINEERING I             YT       
79000                  152111009    152120081043 EXPOSITORY WRITING                                 BB       
78831                  152111006    152120081043 PHYSICS I LAB                                      BB       
78832                  152111007    152120081043 CHEMISTRY                                          DD       
78090                  152111002    152120071038 INTRODUCTION TO COMPUTERS                          BA       
79000                  152111009    152120071038 EXPOSITORY WRITING                                 CC       
78094                  152111010    152120071038 INTRODUCTION TO PROGRAMMING                        DC       
78089           Edited by: esra aktas on 17.May.2011 10:34

Similar Messages

  • PL/SQL anonymous block delete procedure

    Dear All,
    the below procedure works only if I use the value inside :P29_FAMILY_CALL_OUT, seems that the procedure doesn't get the value of :P29_FAMILY_CALL_OUT variables, why?
    many thanks in advance
    regards
    Carmelo Pace
    declare
    l_season_markup_id number;
    begin
    select season_markup_id into l_season_markup_id from season_markup where CALL_OUT = :P29_FAMILY_CALL_OUT;
    DELETE FROM season_markup where season_markup_id = l_season_markup_id;
    end;

    Eric:
    Do you know if it is a named exception in PL/SQL? If so I could replace a lot of my code that does:
    PROCEDURE P
       doesnt_work EXCEPTION
    BEGIN
       do_something;
       IF <condition> THEN
          RAISE doesnt_work
       ELSE
          do_more_stuff;
       END IF;
    EXCEPTION
       WHEN doesnt_work THEN
          RAISE_APPLICATION_ERROR (20001, 'Doesn''t Work encountered');
    END;with
    PROCEDURE P
    BEGIN
       do_something;
       do_more_stuff;
    EXCEPTION
       WHEN doesnt_work THEN
          RAISE_APPLICATION_ERROR (20001, 'Doesn''t Work encountered');
    END;John

  • How come the item value does not come thru via PL/SQL anonymous block?

    Hi,
    It's a Form with 3 tables -
    1) ClinicianProfileTb (with about 40 columns, insert/update via DML),
    2) PeopleTb (with about 7 columns, insert/update via PL/SQL anonymous block) and
    3) ClinicianPracticeTb (with about 10 columns, insert/update via PL/SQL anonymous block) for after-submit-processes.
    So I have several After-Submit-Processes. For some reason, it appears that PeopleId which is supposed to come thru via the 2nd After-Submit-Process (ie: Insert/Update PeopleTb) does not do the way it's supposed to. And when I press "Create" button at the bottom, I got the following error msg:
    ORA-01400: cannot insert NULL into ("TEST_0712"."CLINICIANPRACTICETB"."PEOPLEID")
    I tried the "debug" mode (via edit page link), but to no avail. (I'm newbie, trying to learn and deliver at the same time :)).
    I uploaded the app to apex.oracle.com, if someone could kindly take a look and let me know what goes wrong, it'd be greatly appreciated.
    workspace: test_0712
    app: 43408 - TEST
    user: demo
    pswd: demoPswd
    Page#21 -> look at the After-Submit-Processes -> in "Insert/Update PeopleTb" it appears that PeopeId does not come thru; thus it cannot be updated to ClinicianProfileTb.PeopleId (allows null) -> and thus cannot be inserted into ClincianPracticeTb.PeopleId (which does NOT allow null). Basically my logic is that in order to create ANY row in ClinicianPracticeTb, BOTH PracticeId AND PeopleId must be present.
    Acutally I should have used the PeopeTb as DML (as the driving table) to enforce that PeopleId must be present in order to insert ClinicianProfileTb and ClinicianPracticeTb, but it'd be lots of codes to write to insert/update in ClinicianProfileTb (40 columns).
    In addition, does ApEx consider EVERY SINGLE after-submit-process are in ONE transaction for commit/rollback? It appears that it treats all PL/SQL anonymous blocks are in ONE transaction, while Automatic Row Processing (DML) is commited/rolled back on its own?
    Thanks much,
    Helen

    All blocks that do not commit in one of the ways I detailed (and which do not explicitly commit using a commit statement) are part of the transaction started with > the first DML statement issued in any of the page processes and continuing until a commit is issued.Say, there are the following processes in the After-Submit-Processes:
    1. Process1 -> Automatic Row Processing (DML)
    2. Process2 -> PL/SQL anonymous block
    3. Process3 -> PL/SQL anonymous block
    Based on what you describe, in the event that if there is no explicit "commit" issued in any of these processes, then an implicit "commit" will be issued at the end of Process3?
    Thanks, Scott.
    Doreen

  • Need help displaying item based on pl/sql anonymous block

    This is probably something really simple but I'm stuck.....
    On purchase order, I want to show related parent project name and ID. What is the best way to do it? I have created a region based on pl/sql anonymous block, and that works, but the data is above where I want it. I want the project name and ID to show up in the region w/ all the other fields.
    I have created an item in the region that has other form fields, item is based on pl/sql anonymous block, w/ same code as above region, and the item doesn't find the data. What's the difference? Is it because the item doesn't save state? In order to choose for the item to be based on pl/sql anon block, APEX made me choose Display as Text (based on PLSQL, does not save state).
    Please see this picture:
    http://farm3.static.flickr.com/2391/2658673285_04f157a3fa_o.png
    thanks!
    ~Darby

    this is weird.. Now it is working. I didn't change anything! What the heck?
    http://farm3.static.flickr.com/2010/2659557520_73e54b67ea_o.png

  • Autonomous Transactions usage in PL/SQL anonymous block coding

    Hi,
    I am trying to incorporate Autonomous Transaction for our work. I am using the tables provided below,
    CREATE TABLE T1
    F1 INTEGER,
    F2 INTEGER
    CREATE TABLE T2
    F1 INTEGER,
    F2 INTEGER
    insert into t1(f1, f2)
    values(20, 0)
    insert into t2(f1, f2)
    values(10, 0)
    Now, when I use the code snippet given below, it is working as expected.
    create or replace procedure p1 as
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
         update t2
         set f2 = 25
         where f1 = 10;
         commit;
    end;
    declare
    PRAGMA AUTONOMOUS_TRANSACTION;
    a integer;
    begin
         update t1
         set f2 = 15
         where f1 = 20;
         p1();
         rollback;
    end;
    Here, updation in t2 table is commited and t1 is rolled back, it is working as
    expected. I would like to achieve the same functionality through PL/SQL
    anonymous block coding, to do this, I use the following code snippet,
    declare
    PRAGMA AUTONOMOUS_TRANSACTION;
    a integer;
    begin
         update t1
         set f2 = 15
         where f1 = 20;
         begin
              update t2
              set f2 = 35
              where f1 = 10;
              commit;
         end;
         rollback;
    end;
    Here, data in both the tables are commited, how do I change it to work as I
    mentioned above like committing t2 alone, please help, thank you.
    Regards,
    Deva

    Can you explain what you're trying to accomplish from a business perspective? This doesn't look like a particularly appropriate way to use autonomous transactions, so you may be causing yourself problems down the line.
    That said, padders's solution does appear to work for me
    SCOTT @ nx102 Local> CREATE TABLE T1
      2  (
      3  F1 INTEGER,
      4  F2 INTEGER
      5  )
      6  /
    Table created.
    Elapsed: 00:00:01.03
    SCOTT @ nx102 Local>
    SCOTT @ nx102 Local>
    SCOTT @ nx102 Local> CREATE TABLE T2
      2  (
      3  F1 INTEGER,
      4  F2 INTEGER
      5  )
      6  /
    Table created.
    Elapsed: 00:00:00.00
    SCOTT @ nx102 Local>
    SCOTT @ nx102 Local> insert into t1(f1, f2)
      2  values(20, 0)
      3  /
    1 row created.
    Elapsed: 00:00:00.01
    SCOTT @ nx102 Local>
    SCOTT @ nx102 Local> insert into t2(f1, f2)
      2  values(10, 0)
      3  /
    1 row created.
    Elapsed: 00:00:00.01
    SCOTT @ nx102 Local> commit;
    Commit complete.
    Elapsed: 00:00:00.01
    SCOTT @ nx102 Local> DECLARE
      2     a INTEGER;
      3 
      4     PROCEDURE update_t2
      5     IS
      6        PRAGMA AUTONOMOUS_TRANSACTION;
      7     BEGIN
      8        UPDATE t2
      9           SET f2 = 35
    10         WHERE f1 = 10;
    11 
    12        COMMIT;
    13     END update_t2;
    14  BEGIN
    15     UPDATE t1
    16        SET f2 = 15
    17      WHERE f1 = 20;
    18    
    19     update_t2;
    20 
    21     ROLLBACK;
    22  END;
    23  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.04Have you done something else that would cause a deadlock?
    Justin

  • Reference value of an SQLPLUS variable in a PL/SQL anonymous block

    All,
    Is there a way of referencing an SQLPLUS variable within a PL/SQL anonymous block. See my example below........
    sqlplus -s /@${L_DB_SID} <<-ENDOFSQL >> ${L_LOGFILE}
    SET FEEDBACK OFF
    SET PAGES 0
    SET SERVEROUTPUT ON
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    WHENEVER OSERROR EXIT 2
    VARIABLE l_ret_sts NUMBER;
    VARIABLE l_ret_msg VARCHAR2(300);
    exec sh_plsql_owner.sh\$secure_batch.p\$set_role(p_ret_sts => :l_ret_sts);
    begin
    if :l_ret_sts > 0 then
    dbms_output.put_line('l_ret_sts:'||:l_ret_sts||':SECURITY');
    else
    ${L_PLSQL_PROG}(p_ret_type => 0, p_ret_sts => :l_ret_sts, p_ret_msg => :l_ret_msg);
    dbms_output.put_line('l_ret_sts:'||NVL(:l_ret_sts,0));
    dbms_output.put_line('l_ret_msg:'||:l_ret_msg);
    end if;
    end;
    exit
    ENDOFSQL
    I need to be able to reference :l_ret_sts in the begin block using the if statement "if :l_ret_sts > 0 then"
    :l_ret_sts is populated in a procedure call beforehand.
    However it seems as though the begin block cannot reference the value returned to :l_ret_sts.
    Any ideas.
    Ian.

    Managed to solve this. I put my call to the package that the role enables via dynamic sql....
    sqlplus -s /@${L_DB_SID} <<-ENDOFSQL >> ${L_LOGFILE}
    SET FEEDBACK OFF
    SET PAGES 0
    SET SERVEROUTPUT ON
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    WHENEVER OSERROR EXIT 2
    VARIABLE l_ret_sts NUMBER;
    VARIABLE l_ret_msg VARCHAR2(300);
    exec dbms_application_info.set_client_info('CONTROL-M');
    exec sh_plsql_owner.sh\$secure_batch.p\$set_role(p_ret_sts => :l_ret_sts);
    declare
    v_text varchar2(500);
    begin
    if :l_ret_sts > 0 then
    dbms_output.put_line('l_ret_sts:'||:l_ret_sts||':SECURITY');
    else
    v_text := 'begin ${L_PLSQL_PROG}(p_ret_type => 0, p_ret_sts => :1, p_ret_msg => :2);end;';
    execute immediate v_text using in out :l_ret_sts, in out :l_ret_msg;
    dbms_output.put_line('l_ret_sts:'||NVL(:l_ret_sts,0));
    dbms_output.put_line('l_ret_msg:'||:l_ret_msg);
    end if;
    end;
    exit
    ENDOFSQL
    Cheers
    Ian.

  • Calling PL/SQL anonymous block from href in tabular report

    apex 2.2.
    I've got a tabular report where I've added some img columns with a href to call diff processes
    for example
    "<a href="f?p=&APP_ID.:22:&APP_SESSION.:BRANCH_TO_PAGE_ACCEPT|NEW_PROXY:NO:::22,ABCDEF ><img src="/i/asyl.gif" border="0" alt="Runprocess"></a>"
    When clicking on an image column in row x then I would like to run the process - no page submit.
    The pl/sql anonymous block process source calls package.storedproc(p1,p2) - two in parameters
    I'm struggling with the syntax and is wondering if there's a smarter way to achieve the same function
    Any ideas most welcome
    Thanks
    Peter

    &lta href="f?p=&APP_ID.:22:&APP_SESSION.:BRANCH_TO_PAGE_ACCEPT|NEW_PROXY:NO:::22,ABCDEFG" &gt&ltimg src="/i/asylogin.gif" border="0" alt="Process"&gt&lt/a&gtQuestion is how can you pass values from a row in a tabular report to the application process ?

  • Using Create table command in a Pl/Sql Anonymous Block

    Hi,
    I need to create a table dynamically based on the table_name and column_names that a user wants. When I use a Pl/sql Anonymous block to do this, it complains. Any suggestions ?
    Thanks,
    Marisa

    Personally this sounds like a bad design to me. I would say under most "normal" circumstances, you should not be creating tables on the fly. Especially one where a user has control over what columns,datatypes to use. Let a developer or dba take care of that.

  • Help!! how to call pl/sql anonymous block from java?

    I know that jdbc can call a pl/sql package or procedure,but if i
    want to call a pl/sql anonymous block, how can i do it? no procedure
    name or package name will be offered.
    Can u give me a sample code? thanks very much

    thanks ,but do u make sure that it can work? i have tried to do like this ,but i can not get it. Or please give me a detail code, thanks very much

  • Refresh pl/sql anonymous block via dynamic action?

    Greetings again to the community!
    Something I must be misunderstanding.
    I want to dynamically (ajax) update a select list depending on a page item. Now when you research for operations like this, you get some examples - but which mostly are older and... contain a lot of coding. So I am wondering if this is to be achieved in a simple way using dynamic action.
    I have created a testcase here where the html for a select list ist created in a pl/sql anonymous block like that:
    begin
    for i in (select EMPNO, ENAME from EMP
            where DEPTNO = :P50_DEP_NO or
                     :P50_DEP_NO is null)
          loop
      htp.p('<option value="' || i.EMPNO || '">' || i.ENAME || '</option>');
      end loop;
    end;Region header and footer contain the tags for <select id="selEmps"> ... </select>.
    When you press [Btn Update Sel], a dynamic action is triggered, that submits :P50_DEP_NO, then refreshes the region with the pl/sql code, so that, after you have enteres another value in :P50_DEP_NO, the select list then shows the employees of that department. Thats the plan, but
    Its not working! Can anyone tell me, what I have overlooked here, please?
    Thank you and good night for now,
    tobi

    Hi Marko,
    thanks for your hint. I have already tought about that, but im not sure if this is the solution of this particular situation, because the list really should be generated html-code for formating reasons with jQuery UI and further processing. But I have not worked so much with cascading LOVs, so I really should look into it further.
    If I dont find a solution there, I'll get back here.
    Thanks and so long,
    tobi

  • Multi Row update using pl/sql anonymous block process

    Does anyone have an example of multi row update using a pl/sql anonymous block process?
    The reason I can not use the apex mru process is that the table in questions has a five field key.
    My attempts have failed with a bad number.
    Thanks,
    Gary

    Hi Gary,
    can y<ou pls send the definition of thet table and the UPDATE sql.
    It is a littel difficult like this.
    We need more info.
    BR,
    Lutz
    =;-)

  • SQL Developer Blocked and is not allowed to connect to database ORA-200001

    SQL Developer Blocked and is not allowed to connect to database gives ORA-200001.
    i found on net that DBA can write triggers which can deny connection to database from certain appplication.
    so i want a way to change application name so that when it connects to database
    the V$SESSION will have different value (other than SQL Developer) in column PROGRAM and/or MODULE (which i think is used by dba to restrict the connection).
    one more way is
    i am using jdbc url to connect to database
    in java we can change properties of connection to change the PROGRAM in V$SESSION.
    but i am not java expert so dont know how and where to make the changes
    either way my aim is to connect to database such that V$SESSION will have different value (other than "SQL Developer") in column PROGRAM and/or MODULE

    This is not system configration or credential issue.
    This is a check which is put DBA using logon trigger
    to check certain user loging in using certain application.
    only some users using particular username are getting this error when they try to logon using oracle sql developer
    the same users when uses different username(some generic user names created to access database) to access the same database then they are able to login.
    similarly if they login using SQL navigator they are able to login with both their own and the generic user name
    more over of all the database instances this is only happening on some of the instances and all of them are development instances.
    following will help you understand
    USER | DBUSERNAME | DATABASE | APPLICATION | ACTION
    X | X | DB1 | Oracle Sql Developer | Blocked
    X | G(Genric) | DB1 | Oracle Sql Developer | Login Success
    X | X | DB1 | Sql Navigator/SqlPLus | Login Success
    X | G(Genric) | DB1 | Sql Navigator/SqlPLus | Login Success
    X | X | DB2 | Oracle Sql Developer | Login Success
    X | G(Genric) | DB2 | Oracle Sql Developer | Login Success
    X | X | DB2 | Sql Navigator/SqlPLus | Login Success
    X | G(Genric) | DB2 | Sql Navigator/SqlPLus | Login Success
    I just want to bypass this check which i think uses V$SESSION and columns PROGRAM and/or MODULE to check the application used by particular user.
    if i can override these values some where in oracle sql developer before loging in the DB then i can clearly pass this check and login to database.
    Edited by: user13430736 on Jun 21, 2011 4:05 AM
    Edited by: user13430736 on Jun 21, 2011 4:12 AM

  • PL/SQL declaration blocks within procedure

    Greetings,
    I have a few PL/SQL scripts that I would like to deploy to the database as stored procedures, but I am having a bit of trouble. The scripts themselves are all over 400 lines and contain multiple declaration blocks, some with multiple cursors in each block. I believe the problems I am encountering revolve directly around these declarations blocks and cursors, which are mandatory for these scripts. Here is a sample of the errors I am receiving:
    SQL> SHOW ERRORS
    Errors for PROCEDURE *:
    LINE/COL ERROR
    56/20 PL/SQL: SQL Statement ignored
    57/25 PL/SQL: ORA-00942: table or view does not exist
    66/20 PL/SQL: SQL Statement ignored
    71/70 PL/SQL: ORA-00942: table or view does not exist
    127/11 PL/SQL: SQL Statement ignored
    128/16 PL/SQL: ORA-00942: table or view does not exist
    144/16 PL/SQL: Statement ignored
    144/21 PLS-00364: loop index variable * use is invalid
    156/16 PL/SQL: Statement ignored
    157/36 PLS-00364: loop index variable * use is invalid
    189/16 PL/SQL: Statement ignored
    189/20 PLS-00364: loop index variable * use is invalid
    211/16 PL/SQL: Statement ignored
    231/24 PLS-00364: loop index variable * use is invalid
    268/25 PL/SQL: SQL Statement ignored
    272/48 PLS-00364: loop index variable * use is invalid
    272/48 PL/SQL: ORA-00904: *.*: invalid identifier
    292/21 PL/SQL: Statement ignored
    292/26 PLS-00201: identifier *.* must be declared
    345/46 PLS-00201: identifier * must be declared
    SQL>
    Unfortunately, I cannot paste any of the script itself, nor can I be more descriptive with the error log. That being said, it would be extremely helpful to me to receive any input whatsoever from the community, as even something only vaguely related may push me in the right direction. Mainly, I need to figure out if these errors are generated due to the reasons I suspect.
    I must note that these scripts execute correctly and perform their necessary tasks when either pasted into the editor or when executed directly from their respective .sql files.
    Thank you for the help.
    -JNT

    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2  v_variable1 varchar2(10);
      3  v_variable2 varchar2(10);
      4  v_variable3 varchar2(10);
      5  begin
      6  select alpha into v_variable1 from x;
      7  For i in 1..i+2 loop
      8  null;
      9  end loop;
    10  v_variable4 := v_variable3;
    11* end;
    SQL> /
    select alpha into v_variable1 from x;
    ERROR at line 6:
    ORA-06550: line 6, column 36:
    PL/SQL: ORA-00942: table or view does not exist
    ORA-06550: line 6, column 1:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 7, column 13:
    PLS-00364: loop index variable 'I' use is invalid
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored
    ORA-06550: line 10, column 1:
    PLS-00201: identifier 'V_VARIABLE4' must be declared
    ORA-06550: line 10, column 1:
    PL/SQL: Statement ignored
    The table 'x' does not exist or I do not have access to it.
    I cannot specify the loop interval as indicated.
    I cannot assign a value to a variable that does not exist.
      1  declare
      2  v_variable1 varchar2(10);
      3  v_variable2 varchar2(10);
      4  v_variable3 varchar2(10);
      5  v_variable4 varchar2(10);
      6  begin
      7  select alpha into v_variable1 from dual;
      8  For i in 1..2 loop
      9  null;
    10  end loop;
    11  v_variable4 := v_variable3;
    12* end;
    SQL> /
    select alpha into v_variable1 from dual;
    ERROR at line 7:
    ORA-06550: line 7, column 8:
    PL/SQL: ORA-00904: "ALPHA": invalid identifier
    ORA-06550: line 7, column 1:
    PL/SQL: SQL Statement ignored
    There is no column by name 'alpha' in table 'dual'.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2  v_variable1 varchar2(10);
      3  v_variable2 varchar2(10);
      4  v_variable3 varchar2(10);
      5  v_variable4 varchar2(10);
      6  begin
      7  select dummy into v_variable1 from dual;
      8  For i in 1..2 loop
      9  null;
    10  end loop;
    11  v_variable4 := v_variable3;
    12* end;
    SQL> /
    PL/SQL procedure successfully completed.
    Here is the corrected script.  I hope it helps.

  • PL/SQL Anonymous Block - Trying to Call Function within Cursor

    Hello -
    I need to create an anonymous block that contains a cursor and a function. I want to call the function from within the cursor, and the function will basically take an ID as its IN parameter, and will return a comma separated list of values.
    However, when I try to do this I get the error " function 'GET_PAYMENT_DATES' may not be used in SQL".
    Does anyone know of a workaround? I'm trying to avoid having to store this function.
    Thanks,
    Christine

    Exploring Keith's suggestion of using the function code inline in your SQL:
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> drop table t;
    Table dropped.
    test@ORA10G> drop table monetary_trans;
    Table dropped.
    test@ORA10G>
    test@ORA10G> create table monetary_trans as
      2  select 1 household_id, trunc(sysdate)-10 received_date from dual union all
      3  select 1, trunc(sysdate)-9 from dual union all
      4  select 1, trunc(sysdate)-8 from dual union all
      5  select 2, trunc(sysdate)-7 from dual union all
      6  select 2, trunc(sysdate)-6 from dual;
    Table created.
    test@ORA10G>
    test@ORA10G> create table t as
      2  select rownum x, rownum*10 y from dual connect by level <= 4;
    Table created.
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> select * from monetary_trans;
    HOUSEHOLD_ID RECEIVED_
               1 28-DEC-08
               1 29-DEC-08
               1 30-DEC-08
               2 31-DEC-08
               2 01-JAN-09
    test@ORA10G> select * from t;
             X          Y
             1         10
             2         20
             3         30
             4         40
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> -- the function code could be rewritten as follows
    test@ORA10G> --
    test@ORA10G> select household_id,
      2         ltrim(sys_connect_by_path(rd,','),',') payment_dates
      3    from
      4  (
      5  select household_id,
      6         to_char(received_date,'mm/dd/yy') as rd,
      7         row_number() over (partition by household_id order by 1) rn,
      8         count(*) over (partition by household_id) cnt
      9    from monetary_trans
    10    -- and the constraints here in the where clause
    11  )
    12  where level = cnt
    13  start with rn = 1
    14  connect by prior household_id = household_id
    15  and prior rn = rn - 1
    16  and household_id = 1 -- <== this is the input parameter value
    17  ;
    HOUSEHOLD_ID PAYMENT_DATES
               1 12/28/08,12/29/08,12/30/08
    test@ORA10G>
    test@ORA10G> --
    test@ORA10G> -- and can be used as an inline view when joined with other tables
    test@ORA10G> --
    test@ORA10G> select t.y,
      2         fn.payment_dates
      3    from t,
      4         (select household_id,
      5                 ltrim(sys_connect_by_path(rd,','),',') payment_dates
      6          from (select household_id,
      7                       to_char(received_date,'mm/dd/yy') as rd,
      8                       row_number() over (partition by household_id order by 1) rn,
      9                       count(*) over (partition by household_id) cnt
    10                  from monetary_trans)
    11          where level = cnt
    12          start with rn = 1
    13          connect by prior household_id = household_id
    14          and prior rn = rn - 1
    15         ) fn
    16   where t.x = fn.household_id
    17  ;
             Y PAYMENT_DATES
            10 12/28/08,12/29/08,12/30/08
            20 12/31/08,01/01/09
    test@ORA10G>
    test@ORA10G>HTH
    isotope

  • Running SQL Server Function and Procedures from Oracle

    I am trying to run SQL Server 2005 functions and/or procedures from a SQL statement in Oracle. I have gone throught the hetergeneous services and have connected to the SQL Server database successfully. I can also do a query to a table in SQL Server successfully; but I have not been able to execute a procedure or a function.

    Have you tried Oracle syntax? It seems to me that you have only tried T-SQL syntax, e.g. execute proc.
    Wrap it in a begin..end tag like you would a normal PL/SQL function or proc call. Assumption is that as Oracle makes the remote database (via the dblink) look like an Oracle database, you should also play along and pretend it is one and treat it as such.
    E.g.declare
      r integer;
    begin
      -- execute remote proc
      procFoo@dblink( 'ABC' );
      -- call a remote function
      r := funcFoo@dblink( 123 );
    end;

Maybe you are looking for