SOS PL/SQL

Hi all
I have some hard work to improve if someone could help.
looking for procedures to:
Mechanism to calculate purchase total based on seats =>like in Theatre system.
To locate seats with restricted views
VAT calculations.
Overtime calculations(I may need an attendence table for staff?)
To calculate Salaries with or without Overtime?
automatic generation of overtime records?
the last one
Procedures to create new staff records with appropriate values when staff are appointed.
For info ---------------------------------For info
tables created with relationship:
Customer
Purchase-->Purchase_Seat--> Seat-->Event--> Venue
Staff--> Overtime_session-->Payment.
TABLE STAFF
create table staff(
s_id number(15) primary key,
fname varchar2(30),
lname varchar2(30),
street varchar2(40),
city varchar2(20),
postcode varchar2(15),
phone varchar2(15),
dob date,
position varchar2(12),
grade char(1),
salary number(6,2),
otime_rate number(4,2),
status varchar2(15));
TABLE OVERTIME_SESSION
create table overtime_session(
s_id number(15) references staff (s_id),
hours number(2),
o_date date,
payment_made varchar2(3));
I am getting pb with my table Attendance
Create table attendance (
s_id number(15) primary key,
CONSTRAINT s_id,
absent_late varchar2(7),
CONSTRAINT absent_late_chk
check ( absent_late in ('Absent','Late','Present')),
constraint s_id number(15) primary key (s_id));
all comments are welcome, Please feel free

Hi Rolmau,
What have you tried so far? what problems have you encountered? where are you stuck?
We're not going to write your code from scratch, but we can point you in the right direction if you ask more specific questions.
because as the old saying goes: "We're not going to write your code from scratch, but we can point you in the right direction if you ask more specific questions."

Similar Messages

  • SOS!! HBC's pointing ORACLE and MS-SQL server DB simultaneously  Help!!!!!

    Dear Partners:
    Switching the Model.jpr->Business Components->Connections between
    2 different DB connections (1) Ms-Sql server and (2) Oracle, I was able
    to create Entity-and-View BC's from both databases. Also, I was able
    to drag and drop datacontrols (tables) from both databases over
    the same JSP/UIX page.
    However, the application runs working only with either the MS-sql-BC's or
    the Oracle-BC's, but not both simultaneously.
    I beg your help to solve this issue.

    I think you'll need 2 AMs for this to work. Each AM will have it's own DB connection. Unless one DB knows how to access the other DB's tables (using something like the Oracle Transparent Gateway).

  • SQL 2008 R2 small business server OS edition check fails on SBS 2011 premium install on SBS member server.

    I am having trouble installing SQL 2008 Small Business Edition on top of MS 2008 std from the SBS premium suite. I recieve the SQL Server 2008 R2 setup log error stateing "Operating system supported for edition "Failed". The specific error is "EditionRequirementCheck
    Failed" This SQL server edition is not supported on this operating system.
    The SQL 2008 server is a valid SBS domain member server and sees the SBS domain just fine. I have tried re-installing the OS. Not selecting any options except the SQL engine, verbose logging as per How to diagnose "Operating system supported for edition"
    pre-requisite errors while installing SQL 2008 Standard Edition for Small Business with no success. (no log.txt generated), enabled browsing, and other items with no luck.
    I got the software from MVLS under the specific SBS 2011 premium section. It doesnt seem right or sees something to keep it from installing. The SBS AD box is clean with all FSMO and root functions assigned to it. There are no trust relationships or
    child domains. I have licenses for 75 users. Of course there is no tool, log or utility to find what the actual issue the SQL installation is seeing. SOS! Help!!!

    I meet all prerequisites that can be verified.
    I am installing it on the SBS Premium Server 2008 R2 OS from MVLS with the ISO file ending in 29732.
    I am on a valid SBS 2011 domain.
    The new SQL box is joined to the domain as a member server.
    THe SBS server contains alll FSMO roles and is the root of the AD.
    There are no trust relationships or child domains.
    There is NO way that I can find to determine the number of user and device licenses that it "senses" on the domain. I dont know which ones to count. I am licensed for 75 users and have less than that useing the network. There is no licensing monitor or meathod
    I can find to actually verify what the SQL install sees.
    I am doing all this logged in as the domain admin.
    The troubleshooting steps at the bottom of the post refrenced do not work or I am doing them wrong. I cannot find an output file when I enable verbose logging for the SQL install. I believe if I figure out how it may point the way to the block. Thanks

  • ORA 01722 & NFE.....SOS!

    im constantly getting 2 errors on console (Solaris XManager)
    **java.sql.SQLException: ORA-01722: invalid number**
    **java.lang.NumberFormatException: For input string: "abc"**
    In my bean file theres a method calld 'FLoc()' in which
    im passing 5 parameteres (all strings) plus sessionID.
    in that method a method is called which is in another file
    called 'gsms()': there are SAME six parameters; all Strings
    also in that method, JDBC connectivity is done with
    procedure calls.
    That procedure contains 11 'IN' parameters & 2 'OUT'
    p pi_session_id                    IN      1          VARCHAR2,
                                  2          pi_B_p_M                    IN                VARCHAR2,
                                  3          pi_log_id                    IN                NUMBER,
                                  4          pi_B_p_loc                    IN                VARCHAR2,
                                  5          pi_ms_st                    IN                VARCHAR2,
                                  6          pi_s_re_time                    IN               VARCHAR,
                                  7          pi_s_re_flag                    IN               VARCHAR2,
                                  8          pi_s_re_text                    IN                VARCHAR2,
                                  9          pi_ap_st_id                    IN               NUMBER,
                                  10          pi_t_app                    IN               DATE,
                                  11          pi_s_er                    IN               VARCHAR2,
                                            po_err_code                    OUT               NUMBER,
                                            po_B_party_locn_details          OUT          Pkg_Refcur.ref_type)
    help needed !! SOS!!! this silly problem has been bugging me since a day!!! im not very comfortable with JDBC/Core Java concepts...
    i searched ORA error...it said some conversion problem.
    i couldnt understand please explain.

    Thanks dcminter for that. .....
    Got rid of that NumberFormatException but ORA 01722 error is still bugging me :)
    straight from the console ::
    at src.SInterface.dbstorage.gSM(dbstorage.java:212)
    at src.FLoc.FLocJBean.fLoc(FLocJBeanjava:146)
    at org.apache.jsp.src.FLoc.SLoc_jsp._jspService(SLoc_jsp.java:93)
    where could be the error???

  • Sql to get the Monday of every IW week in a year!

    Hi There!
    This is an SOS :) I had to get a query to give me all the Mondays of a IW week in a year. I think as per the IW weeks there are around 52.1 weeks in a year. So basically, I want the starting Monday of every week. I would then store those values in a variable and use them in APEX as column headers. Online I saw some samples not related with this, but where looping was done using the all_objects. Not sure if that is the right approach.
    The problem is since this is not stored in any table, how can I loop like 52/53 times such that the output shows all the Mondays (date format) for a given year. Basically, the output would be 52/53 rows with a date(monday of the week).
    Please help!
    thanks,
    Sun
    Edited by: ryansun on Jun 28, 2012 11:09 PM

    Would this be something you are looking for?
    SQL> variable yr number
    SQL> exec :yr := 2015
    SQL> with dates as (
      2  select to_date('0101'||:yr,'ddmmyyyy')-4+level da
      3    from dual
      4  connect by level < 373
      5  )
      6  select :yr iyyy, to_char(da,'IW') iw, da monday
      7    from dates
      8   where to_char(da,'dyiyyy', 'nls_date_language=american')='mon'||:yr
      9  ;
          IYYY IW       MONDAY
          2015 01       29-12-2014
          2015 02       05-01-2015
          2015 03       12-01-2015
          2015 04       19-01-2015
          2015 05       26-01-2015
          2015 06       02-02-2015
          2015 07       09-02-2015
          2015 08       16-02-2015
          2015 09       23-02-2015
          2015 10       02-03-2015
          2015 11       09-03-2015
          2015 12       16-03-2015
          2015 13       23-03-2015
          2015 14       30-03-2015
          2015 15       06-04-2015
          2015 16       13-04-2015
          2015 17       20-04-2015
          2015 18       27-04-2015
          2015 19       04-05-2015
          2015 20       11-05-2015
          2015 21       18-05-2015
          2015 22       25-05-2015
          2015 23       01-06-2015
          2015 24       08-06-2015
          2015 25       15-06-2015
          2015 26       22-06-2015
          2015 27       29-06-2015
          2015 28       06-07-2015
          2015 29       13-07-2015
          2015 30       20-07-2015
          2015 31       27-07-2015
          2015 32       03-08-2015
          2015 33       10-08-2015
          2015 34       17-08-2015
          2015 35       24-08-2015
          2015 36       31-08-2015
          2015 37       07-09-2015
          2015 38       14-09-2015
          2015 39       21-09-2015
          2015 40       28-09-2015
          2015 41       05-10-2015
          2015 42       12-10-2015
          2015 43       19-10-2015
          2015 44       26-10-2015
          2015 45       02-11-2015
          2015 46       09-11-2015
          2015 47       16-11-2015
          2015 48       23-11-2015
          2015 49       30-11-2015
          2015 50       07-12-2015
          2015 51       14-12-2015
          2015 52       21-12-2015
          2015 53       28-12-2015
    53 rows selected.

  • Logical Operations in SQL decode function ?

    Hi,
    Is it possible to do Logical Operations in SQL decode function
    like
    '>'
    '<'
    '>='
    '<='
    '<>'
    not in
    in
    not null
    is null
    eg...
    select col1 ,order_by,decode ( col1 , > 10 , 0 , 1)
    from tab;
    select col1 ,order_by,decode ( col1 , <> 10 , 0 , 1)
    from tab;
    select col1 ,order_by,decode ( col1 , not in (10,11,12) , 0 , 1)
    from tab;
    select col1 ,order_by,decode ( col1 ,is null , 0 , 1)
    from tab;
    Regards,
    infan
    Edited by: user780731 on Apr 30, 2009 12:07 AM
    Edited by: user780731 on Apr 30, 2009 12:07 AM
    Edited by: user780731 on Apr 30, 2009 12:08 AM
    Edited by: user780731 on Apr 30, 2009 12:08 AM
    Edited by: user780731 on Apr 30, 2009 12:09 AM

    example:
    select col1 ,order_by,case when col1 > 10 then 0 else 1 end
    from tab;
    select col1 ,order_by,case when col1 &lt;&gt; 10 then 0 else 1 end
    from tab;
    select col1 ,order_by,case when col1 not in (10,11,12) then 0 else 1 end
    from tab;As for testing for null, decode handles that by default anyway so you can have decode or case easily..
    select col1 ,order_by,decode (col1, null , 0 , 1)
    from tab;
    select col1 ,order_by,case when col1 is null then 0 else 1 end
    from tab;

  • Unable to capture the parameter values from a PL/SQL procedure

    hi.
    i'm trying to capture the parameter values of a PL/SQL procedure by calling inside a anonymous block but i'm getting a "reference to uninitialized collection error" ORA-06531.
    Please help me regarding.
    i'm using following block for calling the procedure.
    declare
    err_cd varchar2(1000);
    err_txt VARCHAR2(5000);
    no_of_recs number;
    out_sign_tab search_sign_tab_type:=search_sign_tab_type(search_sign_type(NULL,NULL,NULL,NULL,NULL));
    cntr_var number:=0;
    begin
         rt843pq('DWS','3000552485',out_sign_tab,no_of_recs,err_cd,err_txt);
         dbms_output.put_line('The error is ' ||err_cd);
         dbms_output.put_line('The error is ' ||err_txt);
         dbms_output.put_line('The cntr is ' ||cntr_var);
         for incr in 1 .. OUT_SIGN_TAB.count
         loop
         cntr_var := cntr_var + 1 ;
    Dbms_output.put_line(OUT_SIGN_TAB(incr).ref_no||','||OUT_SIGN_TAB(incr).ciref_no||','||OUT_SIGN_TAB(incr).ac_no||','||OUT_SIGN_TAB(incr).txn_type||','||OUT_SIGN_TAB(incr).objid);
    end loop;
    end;
    Error is thrown on "for incr in 1 .. OUT_SIGN_TAB.count" this line
    Following is some related information.
    the 3rd parameter of the procedure is a out parameter. it is a type of a PL/SQL table (SEARCH_SIGN_TAB_TYPE) which is available in database as follows.
    TYPE "SEARCH_SIGN_TAB_TYPE" IS TABLE OF SEARCH_SIGN_TYPE
    TYPE "SEARCH_SIGN_TYPE" AS OBJECT
    (ref_no VARCHAR2(22),
    ciref_no VARCHAR2(352),
    ac_no VARCHAR2(22),
    txn_type VARCHAR2(301),
    objid VARCHAR2(1024))............

    We don't have your rt843pq procedure, but when commenting that line out, everything works:
    SQL> create TYPE "SEARCH_SIGN_TYPE" AS OBJECT
      2  (ref_no VARCHAR2(22),
      3  ciref_no VARCHAR2(352),
      4  ac_no VARCHAR2(22),
      5  txn_type VARCHAR2(301),
      6  objid VARCHAR2(1024))
      7  /
    Type is aangemaakt.
    SQL> create type "SEARCH_SIGN_TAB_TYPE" IS TABLE OF SEARCH_SIGN_TYPE
      2  /
    Type is aangemaakt.
    SQL> declare
      2    err_cd varchar2(1000);
      3    err_txt VARCHAR2(5000);
      4    no_of_recs number;
      5    out_sign_tab search_sign_tab_type:=search_sign_tab_type(search_sign_type(NULL,NULL,NULL,NULL,NULL));
      6    cntr_var number:=0;
      7  begin
      8    -- rt843pq('DWS','3000552485',out_sign_tab,no_of_recs,err_cd,err_txt);
      9    dbms_output.put_line('The error is ' ||err_cd);
    10    dbms_output.put_line('The error is ' ||err_txt);
    11    dbms_output.put_line('The cntr is ' ||cntr_var);
    12    for incr in 1 .. OUT_SIGN_TAB.count
    13    loop
    14      cntr_var := cntr_var + 1 ;
    15      Dbms_output.put_line(OUT_SIGN_TAB(incr).ref_no||','||OUT_SIGN_TAB(incr).ciref_no||','||OUT_SIGN_TAB(incr).ac_no||','||OUT_SIGN
    TAB(incr).txntype||','||OUT_SIGN_TAB(incr).objid);
    16    end loop;
    17  end;
    18  /
    The error is
    The error is
    The cntr is 0
    PL/SQL-procedure is geslaagd.Regards,
    Rob.

  • Unable to capture SQL Server Schema

    I am trying to capture SQL Server 2005 demo schema (AdventureWorks). It does shows the numbers of Tables/Indexes captured..but finishes with this error..
    Error ocurred during capture: Exhausted Resultset
    Column not found. Skipping index detail on index 'IX_StoreContact_ContactTypeID'
    Column not found. Skipping index detail on index 'IX_StoreContact_ContactID'
    Column not found. Skipping index detail on index 'AK_StoreContact_rowguid'
    Column not found. Skipping index detail on index 'IX_ProductVendor_VendorID'
    Column not found. Skipping index detail on index 'IX_ProductVendor_UnitMeasureCode'
    Column not found. Skipping index detail on index 'IX_Address_StateProvinceID'
    Column not found. Skipping index detail on index 'IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode'
    Column not found. Skipping index detail on index 'IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode'
    Column not found. Skipping index detail on index 'IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode'
    Column not found. Skipping index detail on index 'IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode'
    Column not found. Skipping index detail on index 'IX_Address_AddressLine1_AddressLine2_City_StateProvinceID_PostalCode'
    Column not found. Skipping index detail on index 'AK_Address_rowguid'
    Column not found. Skipping index detail on index 'AK_Department_Name'
    Any help is appreciated..
    Ajay

    Hi Nandu,
    As your description, you come across an error(vsjitdebugger.exe cannot be found). Please confirm if the error occurs during the installation of SQL Server 2012.  If so, please help post SQL Server setup logs. By default, SQL Server setup log file locates
    in C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log.
    Base on my research, this error could be caused by that the previous uninstallation is improper and vsjitdebugger.exe file could be mistakenly deleted.
    To troubleshoot the issue, you could start your computer into Safe Mode and fix your problem with one of the following methods. For more information, please refer to the article:
    http://www.fixerrorkit.com/fix-error/fix-vsjitdebugger.exe-error.html.
    1. You could execute the sfc /scannow command following steps below.
    a. Press "Windows+R", type in cmd and then right click "Run as administrator"
    b. Type in sfc /scannow (There's a space between sfc and /scannow) into the dialog and hit Enter key and click ok.
    c. Wait until the System File Checker finishes the check.
    2. You could use a Windows repair installation, also known as a Startup Repair to repair your Windows system files.
    3. You could install the latest Windows updates to fix vsjitdebugger.exe error. Microsoft often releases new service packs and system patches to replace or update some DLL files of Windows system.
    4. You could use third-party tool such as Automatic Error Fix Tool to fix your vsjitdebugger.exe error. However, Microsoft cannot make any representations regarding the quality, safety, or suitability of any third-party software or information found there.
    In addition, if you are unable to install  Visual Studio, I suggest you post your question in Visual Studio Setup and Installation forum at
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vssetup  . It is appropriate and more experts will assist you.
    Regards,
    Michelle Li

  • NoClassDefFoundError: com/sap/sql/log/OpenSQLException

    I have developed a Java project. It consists of 2 SQLJ files and then a Java class. When I try to execute the Java program, I get a Java error:
    java.lang.NoClassDefFoundError: com/sap/sql/log/OpenSQLException
         at com.mbb.crrs.business.report.dao.ReportDAO.<init>(ReportDAO.sqlj:23)
         at com.mbb.crrs.business.report.dao.Test.main(Test.java:24)
    Exception in thread "main"
    I notice a similar problem on message: Re: Which jar to include com.sap.sql.log.OpenSQLException
    Is that something that I need to maintain for it to work? Thank you.

    Hi,
    the problem one year ago was that the SQLException class was not available through remote access. I don't know if that might have been changed meanwhile in the latest release.
    I implemented a simple work around: I caught every SQL-exception in the method where it was thrown, wrapped the exception message and any nested exception in a self written exception and threw this new exception. That worked fine.
    Regards, Astrid

  • AND / OR  truth table in SQL

    why null is introduced in the AND and OR truth table?when will a statement/part of a statement return a null value??
    |AND               |True          |False             |NULL??        |
    |True               |True          |False             |Null             |
    |False              |False          |False             |False           |
    |Null                |Null             |Null               |Null             |is it introduced in AND/OR truth table for the null containing row(s)??
    select employee_id,last_name,job_id,salary
    from employees
    wheere salary >= 1000
    And job_id like '%man%';
    how the statement after the where cluz can return null value??Edited by: sayantan chakraborty on Aug 14, 2009 11:36 AM

    sayantan chakraborty wrote:
    how either of X and Y will return a null value?can you put any example?is there any syntax/ command which will print the return value of a statement as null?Say you had a table with columns X and Y. As long as NOT NULL constraints WERE NOT defined these values could contain NULLs. Then if you apply the WHERE condition of X = Y you would have the case of NULL = NULL which results in UNKNOWN.
    Simple Example:
    SQL > WITH test_data AS
      2  (
      3          SELECT 1 AS X, 1 AS Y FROM DUAL UNION ALL
      4          SELECT 2 AS X, 2 AS Y FROM DUAL UNION ALL
      5          SELECT 3 AS X, 5 AS Y FROM DUAL UNION ALL
      6          SELECT 4 AS X, 6 AS Y FROM DUAL UNION ALL
      7          SELECT 1 AS X, NULL AS Y FROM DUAL
      8  )
      9  SELECT  *
    10  FROM    test_data
    11  WHERE   X = Y
    12  /
             X          Y
             1          1
             2          2

  • If statement in sql

    regarding the following sql:
    SELECT a.lname, a.fname, a.user_id, c.address, c.city,
    c.zip, c.addresstypeid, d.descriptor as state
    FROM users a, address c, maintstatetype d
    WHERE a.user_id = c.user_id(+)
    AND c.statetypeid = d.statetypeid(+)
    AND c.addresstypeid in (1,2,3,4)
    I have a database of users and addresses. Each user can
    have multiple addresses and the addresses are
    designated by addresstypeid. In plain english, what I want
    to pull is "If they have an addresstypeid of 1, pull that one
    only, if not, check if they have a 2 and use that, if not, check
    for a 3, etc..".
    Any help with this?

    What you want, then, is to pull the address with the minimum addresstypeid ..
    SELECT a.lname, a.fname, a.user_id, c.address, c.city,
    c.zip, c.addresstypeid, d.descriptor as state
    FROM users a, address c, maintstatetype d
    WHERE a.user_id = c.user_id(+)
    AND c.statetypeid = d.statetypeid(+)
    AND c.addresstypeid =
    (select min(c2.addresstypeid)
    from address c2
    where c2.userid=a.userid
    I'm not sure what this will do to your outerjoin, though. You might have to get funky with a union ...
    SELECT a.lname, a.fname, a.user_id, c.address, c.city,
    c.zip, c.addresstypeid, d.descriptor as state
    FROM users a, address c, maintstatetype d
    WHERE a.user_id = c.user_id
    AND c.statetypeid = d.statetypeid
    AND c.addresstypeid =
    (select min(c2.addresstypeid)
    from address c2
    where c2.userid=a.userid
    Union all
    SELECT a.lname, a.fname, a.user_id, to_char(null), to_char(null),
    to_char(null), to_char(null), to_char(null)
    FROM users a
    WHERE not exists
    (select 1
    from address c
    where c.userid=a.userid
    )

  • If statement in reqular sql statement

    Hi everyone;
    I am trying to alter some trigger if I am in a certain environment. here what I am trying to do in pseudo-code
    if ((select dbenv from environments) = 'DEV') THEN
    ALTER TRIGGER XXX disable;
    end if;
    this sql script will be run from sqlplus' comand line
    reminder I don't want to do that from package or a procedure

    this to just explain
    i think select in the IF is not allowed that way please see the examples below
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2  vename VARCHAR2(10);
      3  BEGIN
      4   SELECT ename INTO vename FROM EMP WHERE ename='BLAKE';
      5   IF vename='BLAKE' THEN
      6    DBMS_OUTPUT.PUT_LINE('data found');
      7   ELSE
      8     DBMS_OUTPUT.PUT_LINE('no data found');
      9   END IF;
    10* END;
    11  /
    data found
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2  vename VARCHAR2(10);
      3  BEGIN
      4   --SELECT ename INTO vename FROM EMP WHERE ename='SMITH';
      5   IF ((SELECT ename FROM EMP WHERE ename ='SMITH')='BLAKE') THEN
      6    DBMS_OUTPUT.PUT_LINE('data found');
      7   ELSE
      8     DBMS_OUTPUT.PUT_LINE('no data found');
      9   END IF;
    10* END;
    SQL> /
    IF ((SELECT ename  FROM EMP WHERE ename ='SMITH')='BLAKE') THEN
    ERROR at line 5:
    ORA-06550: line 5, column 7:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + case mod new not null others <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    ORA-06550: line 5, column 50:
    PLS-00103: Encountered the symbol ")" when expecting one of the following:
    . ( * @ % & - + ; / at for mod rem <an exponent (**)> and or
    group having intersect minus order start union where connect
    ||
    but this is allowed
    SQL> ed
    Wrote file afiedt.buf
      1  DECLARE
      2  vename VARCHAR2(10);
      3  BEGIN
      4   --SELECT ename INTO vename FROM EMP WHERE ename='SMITH';
      5   IF 'BLAKE'='BLAKE' THEN
      6     SELECT ename INTO vename FROM EMP WHERE ename='SMITH';
    7    DBMS_OUTPUT.PUT_LINE(vename);
      8   ELSE
      9     DBMS_OUTPUT.PUT_LINE('no data found');
    10   END IF;
    11* END;
    SQL> /
    SMITH
    PL/SQL procedure successfully completed.formated
    Message was edited by:
    devmiral

  • IF statement in SQL*Plus - how to do it

    Hi,
    In SQL*Plus script, I would like to keep conditional checking (IF statement) and proceed. For example, whatever is done in PL/SQL block below, want to do the same in SQL*Plus script, I know partly it can be done using VARIABLE keyword, conditional checking can be done using DECODE in SELECT statement, but I want to carry out a more complex requirement, hence I want to use IF statement somehow in SQL*Plus.
    Another question, how to do spooling in PL/SQL script, it can be done using UTL_FILE, any other option is there to achieve this.
    declare
    v_ind_count int;
    begin
    select count(1) into v_ind_count from user_indexes where index_name = 'index_object_name';
    IF v_ind_count > 0
    THEN
    dbms_output.put_line('index found');
    ELSE
    dbms_output.put_line('index does not exist');
    END IF;
    end;
    /

    Hello,
    SQL*PLUS has no scripting language. It can only execute SQL and PL/SQL scripts. There are some commands like SPOOL or SET but no commands for conditional statements. You should describe your requirements, maybe we can find a way.
    Or you can search the forum, maybe your question has already been answered
    [Google for SQL*PLUS + condition|https://www.google.de/search?q=site%3Aforums.oracle.com+"SQL*PLUS"+condition]
    # {message:id=4189517}
    # {message:id=4105290}
    how to do spooling in PL/SQL scriptFrom within PL/SQL you can use dbms_output, the spool has to be started by the calling SQL script when it is executed in SQL*PLUS. Or you can use utl_file, but then you can only write to a server directory, not into a client file. To give an advice we need more information about what you want to do.
    Regards
    Marcus

  • Partner Application written in other language than PL/SQL and Java

    I have an application written in another language than PL/SQL or Java. I want to integrate this application as an Partner apps where I use the same user repository as Portal.
    Can I integrate the application by calling a stored PL/SQL-procedure based on the PLSQL SSO APIs examples that authenticates the user based on the username/password in portal and redirects the user to the application ?
    Are there any examples / references where this has been done ?
    Jens

    Check out the PDK referance for URL-Services, which allow you to integrate with any web based service/content.
    http://portalstudio.oracle.com/servlet/page?_pageid=350&_dad=ops&_schema=OPSTUDIO

  • NULL and dynamic SQL

    If table testrh2 has the following columns and data
    col1 --> NULL
    col2 --> 2
    and table testrh has the following columsn and data
    col1 --> NULL
    How could I write a dynamic SQL statement to join on the nulls? I've written the following block as a starting point.
    declare
    cursor c1 is select col1 from isis.testrh;
    lval varchar2(1000);
    lval2 varchar2(1000);
    begin
    for r1 in c1 loop
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    execute immediate lval into lval2;
    dbms_output.put_line(lval2);
    end loop;
    end;

    You can't compare null values with '=' in Oracle SQL.
    Null can only be compared with <column> is null .
    You can see it when you try these two queries:
    select * from dual where null is null;  -- you will see one row
    select * from dual where null=null;  -- you will see no rowsThat's why you have to write something like
    (<column1>=<column1>   or   (<column1> is null and <column2> is null))This should also work with null:
    decode(<column1>,<column2>,1,0)=1By the way, why do you use dynamic sql?
    lval := 'select col2 from isis.testrh2 where col1 = '||r1.col1;
    I think you could replace your two lines ( lval:= ... AND execute immediate) by this:
    begin
      select col2
      into lval
      from isis.testrh2
      where decode(col1,r1.col1,1,0)=1;
      dbms_output.put_line('lval='||lval);
    exception
    when no_data_found then
      dbms_output.put_line('no data found'); -- or whatever you want
    end;Edited by: hartmutm on 02.10.2010 23:54

Maybe you are looking for