SQL PLUS QUESTIONS

According to the tables and attributes below I need to solve 25 questions. I answered some of them and some of them I couldn't solve. I need your help please.
school (sch_code, sch_name, sch_phone, sch_dean)
advisor (adv_code, adv_fname, adv_lname, adv_phone, sch_code)
major (maj_code, maj_desc, sch_code)
maj_adv (maj_code, adv_code)
student (std_code     , std_lname, std_fname, std_gend, maj_code, std_dob)
grade (std_code,     gr_lname, gr_fname, gr_t1, gr_t2, gr_hw, gr_pr)
create table school
(sch_code varchar2(8) constraint school_sch_code_pk primary key,
sch_name varchar2(50),
sch_phone varchar2(12),
sch_dean varchar2(20));
insert into school values (‘BUS’, ‘School of Business’, ‘281-283-3100’, ‘Ted Cummings’);
insert into school values (‘EDU’, ‘School of Education’, ‘281-283-3600’,’Dennis Spuck’);
insert into school values (‘HSH’, ‘School of Humanities and Human Sciences’, ‘281-283-3333’, ‘Bruce Palmer’);
insert into school values (‘SCE’, ‘School of Science and Computer Engineering’, ‘281-283-3700’,’Sadegh Davari’);
create table advisor
(adv_code     varchar2(08)     constraint advisor_adv_code_pk primary key,
adv_lname     varchar2(15),
adv_fname     varchar2(15),
adv_phone     varchar2(12),
sch_code     varchar2(8) constraint advisor_sch_code_fk references school (sch_code));
insert into advisor values (‘A1’, ‘Porter’, ‘Mattie’, ‘281-283-3163’, ‘BUS’);
insert into advisor values ( ‘A2’, ‘Grady’, ‘Perdue’ ,‘281-283-3400’, ‘BUS’);
insert into advisor values (‘A3’, ’Tran’, ’Van’, ‘281-283-3203’, ‘BUS’);
insert into advisor values (‘A4’, ‘Saleem’, ‘Naveed’, ‘281-283-3202’, ‘BUS’);
insert into advisor values (‘A5’, ‘Kwok-Bon’, ‘Yue’, ‘281-283-3864’, ‘SCE’);
insert into advisor values (‘A6’, ‘Jones’, ‘Lisa’, ‘281-283-3551’, ‘EDU’);
insert into advisor values (‘A7’, ‘Palmer’, ‘Bruce’, ‘281-283-3445’, ‘HSH’);
create table major
(maj_code     varchar2(10)     constraint major_maj_code_pk primary key,
maj_desc      varchar2(30),
sch_code     varchar2(8)      constraint major_sch_code_fk references school(sch_code));
insert into major values (‘ACCT’, ‘Accounting’, ‘BUS’);
insert into major values (‘FINC’, ‘Finance’, ‘BUS’);
insert into major values (‘ISAM’, ‘Management Information Systems’, ‘BUS’);
insert into major values (‘CSCI’, ‘Computer Science’, ‘SCE’);
insert into major values (‘HIST’, ‘History’, ‘HSH’);
insert into major values (‘INST’, ‘Instructional Technology’, ‘EDU’);
create table maj_adv
(maj_code      varchar2(10)     constraint maj_adv_maj_code_fk references major (maj_code),
adv_code     varchar2(08)     constraint maj_adv_adv_code_fk references advisor (adv_code),
constraint maj_adv_maj_code_adv_code_cpk primary key (maj_code, adv_code));
insert into maj_adv values (‘ACCT’, ’A1’);     
insert into maj_adv values (‘ACCT’, ‘A2’);
insert into maj_adv values (‘FINC’, ’A2’);
insert into maj_adv values (‘ISAM’, ’A3’);
insert into maj_adv values (‘ISAM’, ’A4’);
insert into maj_adv values (‘CSCI’, ‘A5’);
insert into maj_adv values (‘INST’, ‘A6’);
insert into maj_adv values (‘HIST’, ‘A7’);
create table student
(std_code     varchar2(9),
std_lname     varchar2(15)     constraint student_std_lname_nn not null,
std_fname     varchar2(15)     constraint student_std_fname_nn not null,
std_gend     varchar2(8),     
maj_code     varchar2(10)     constraint student_maj_code1_fk references major (maj_code),
std_dob     date,
constraint student_std_code_pk primary key (std_code));
insert into student values (‘S1’, ‘Jordan’, ‘Michael’, ‘F’, ‘FINC’, to_date(‘10-Mar-1962’, 'DD-Mon-YYYY'));
insert into student values (‘S2’, ‘Barkley’, ‘Charles’, ‘M’, null, to_date(‘12-Sep-1964’, 'DD-Mon-YYYY'));
insert into student values (‘S3’, ‘Johnson’, ’Magic’, ‘M’, ‘ACCT’, to_date(‘13-Sep-1960’, 'DD-Mon-YYYY'));
insert into student values (‘S4’, ‘Williams’, ‘Serena’, ‘F’,‘ISAM’, to_date(‘23-Oct-1980’, 'DD-Mon-YYYY'));
insert into student values (‘S5’, ‘Duncan’, ‘Tim’, ‘M’, ‘ISAM’, to_date(‘07-Aug-1972’, 'DD-Mon-YYYY'));
insert into student values (‘S6’, ‘Graff’, ’Steffi’, ‘F’, ‘CSCI’, to_date(‘30-Apr-1962’, 'DD-Mon-YYYY'));
insert into student values (‘S7’, ‘Navratilova’, ’Martina’, ‘F’, ’ACCT’, to_date(‘18-Dec-1972’, 'DD-Mon-YYYY'));
REMARK insert into student (std_code, std_lname, std_fname, std_dob)
REMARK values (‘S2’, ‘Barkley’, ‘Charles’, to_date(‘12-Sep-1964’,'DD-Mon-YYYY'));
create table grade
(std_code     varchar2(9)     constraint grade_std_code_pk primary key
                    constraint grade_std_code_fk references student (std_code),
gr_lname     varchar2(15)     constraint grade_gr_lname_nn not null,
gr_fname     varchar2(15)     constraint grade_gr_fname_nn not null,
gr_t1          number(5),     constraint grade_gr_t1_cc check (gr_t1 between 0 and 100),
gr_t2          number(5),     
gr_hw          number(5),     
gr_pr          number(5));
insert into grade values (‘S1’, ‘Jordan’, ‘Michael’, 90, 80, 98, 90);
insert into grade values (‘S2’, ‘Barkley’, ‘Charles’, 60, 100, 100, 60);
insert into grade values (‘S3’, ‘Johnson’, ’Magic’, 88, 98, 96, 98);
insert into grade values (‘S4’, ‘Williams’, ‘Serena’, 92, 92, 92, 92);
insert into grade values (‘S5’, ‘Duncan’, ‘Tim’, 94, 90, 94, 96);
insert into grade values (‘S6’, ‘Graff’, ’Steffi’, 80, 84, 83, 72);
insert into grade values (‘S7’, ‘Navratilova’, ’Martina’, 91, 88, 94, 95);
the questions are:
Give the commands for the following:
1.     Display the names of students who don't have a major.
2.     Display the names of students whose last name has two "o" in it.
3.     Display the names of students whose first name includes an "e" in it.
4.     Display the names of students whose first name has exactly five characters in it.
5.     Display the names of students whose test 1 grade is higher than test 2 grade.
6.     Display the names of students whose project grade is between tests 1 and test 2 grades.
7.     Give the name of student whose last name starts with the character "B" or who never turned in homework.
8.     Give the command that will list two columns and one record. The first column will have the heading "Major" and "ACCT" as the value. The second column will have the heading “MIS_Count” and will display the number of accounting advisors.
9.     Display the name of the student whose test 1 score is higher than the average on test 1.
10.     Give the first and last names of students who scored above average on test 1 as well as above average on test 2.
11.     Display the system date variable using the dual table.
12.     Display the system date variable using the grade table making sure that the date is displayed only once.
13.     Give the name of the student who is the oldest student and scored the highest on the first test.
14.     List different majors and number of advisors for these majors.
15.     Display the names of students who don't have grade for any item.
16.     Display the names of the students who don't have grade for at least one item.
17.     Display names of students who have the same major as “Michael Jordan.”
18.     Give the names of students whose average on test 1 and test 2 is greater than the average on homework and project.
19.     Display the name and average on test 1 and test 2 for each student.
20.     Display the number of students in student table using three different methods.
21.     Display the number accounting students in the student table.
22.     Display the number of accounting and finance students in the student table.
23.     Display the average on test 1 and test 2 for female students.
24.     Display the number of accounting and finance students whose test 1 grades are higher than the average on test 1.
25.     Display the name of the major that has more than two students.
I am stuck with the following questions(1,12,13, 15,16,17,24) and the rest I finished them but I am not quite sure.
Thank you and looking forward to hear your suggestions.

Hi,
user11956564 wrote:
13.     Give the name of the student who is the oldest student and scored the highest on the first test.
I can get the oldest student and the highest score but in two different queries. My question is how can I use them together in one query
List oldest student in class
select std_fname, std_lname from student
where std_dob = (select min(std_dob) from student);
List highest grade in class
select gr_fname, gr_lname from grade
where gr_t1 = (select max(gr_t1) from grade);
because they are two tables. I think this is a confusing question: I'm not sure what the expected output is, or what the lesson you're supposed to learn is.
One way of combining results from different tables is UNION. As long as two queries produce the same number of columns, and the same datatypes, they can be combined with UNION.
For example: the following query displays the name of the employee whose job is 'PRESIDENT' (from the scott.emp table) and the name of department 10 (from the scott.dept table) in one query:
SELECT  ename
,       job
FROM  scott.emp
WHERE   job = 'PRESIDENT'
    UNION
SELECT  dname
,       TO_CHAR (deptno)
FROM    scott.dept
WHERE   deptno = 10
;Both SELECT clauses have 2 columns.
This 1st column in the 1st part is a VARCHAR2, so the 1st column of the 2nd part must also be a VARCHAR2. It is.
The 2nd column in the 1st part is a VARCHAR2, so the 2nd column of the 2nd part must also be a VARCHAR2. However, deptno (which we want to display here) is not a VARCHAR2, but a NUMBER; that's why I used TO_CHAR to put a VARCHAR2 value in that place.
17.     Display names of students who have the same major as “Michael Jordan.”
here is what I did
select std_fname, std_lname, maj_code
from student
where maj_code=(select maj_code
from studentJordan');
I am not sure if my answer is correct or not because in the output I got Michael JordanThis question is unclear, too.
Assuming you do not want Michael Jordan in the results, add a 2nd condition to the WHERE clause, so that you select
people who have the right major (which you say you are doing correctly, but the query seems to have lost something when you posted it)
AND
people who are not named Micheal Jordan
24.     Display the number of accounting and finance students whose test 1 grades are higher than the average on test 1.
It was too confusing for me.Are you sure?
Look at what you tried for 13.
select  std_fname, std_lname from student
where   std_dob = (select min(std_dob) from student);
select  gr_fname, gr_lname from grade
where   gr_t1 = (select max(gr_t1) from grade);The function for average (AVG) is used very much like the other aggregate function, like MIN and MAX.

Similar Messages

  • SQL*Plus Question

    All -
    I am in the process of creating a series of reports for the users to run through SQL*Plus. Instead of them having to the individual report names, I wanted to create a menu type interface.
    Here is a simple example:
    set lines 1000
    set pages 0
    set head off
    set trims on
    set trim on
    set echo off
    set verify off
    set timing on
    prompt Available Reports:
    prompt
    prompt 1 - Customer Dealer Trades
    prompt 2 - Customer Dealer Volume
    prompt
    accept rpt number prompt 'Enter the number you wish to run: '
    variable runrpt varchar2(15)
    execute select decode(&rpt, 1, '@CustDlrTrds', '@CustDlrVols') into :runrpt from dual;
    print runrpt
    This will accept the input and display the necessary command, but is there a way to run the script instead of printing out the name?
    Thx

    I saved your script as d:\start_rpt.sql
    set lines 1000
    set pages 0
    set head off
    set trims on
    set trim on
    set echo off
    set verify off
    set timing on
    prompt Available Reports:
    prompt
    prompt 1 - Customer Dealer Trades
    prompt 2 - Customer Dealer Volume
    prompt
    column rpt_val new_value rpt_val
    accept rpt number prompt 'Enter the number you wish to run: '
    select decode(&rpt, 1, 'CustDlrTrds', 'CustDlrVols') rpt_val from dual;
    @ &rpt_valIt works for me
    D:\>sqlplus scott/tiger
    SQL*Plus: Release 10.2.0.1.0 - Production on Mon Aug 22 18:37:30 2005
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> @start_rpt
    Available Reports:
    1 - Customer Dealer Trades
    2 - Customer Dealer Volume
    Enter the number you wish to run: 1
    CustDlrTrds
    Elapsed: 00:00:00.03
    SP2-0310: unable to open file "CustDlrTrds.sql"
    SQL>

  • A question about the impact of SQL*PLUS SERVEROUTPUT option on v$sql

    Hello everybody,
    SQL> SELECT * FROM v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0  Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL>
    OS : Fedora Core 17 (X86_64) Kernel 3.6.6-1.fc17.x86_64I would like to ask a question about the SQL*Plus SET SERVEROUTPUT ON/OFF option and its impact on queries on views such as v$sql and v$session. Here is the problem
    Actually I define three variables in SQL*Plus in order to store sid, serial# and prev_sql_id columns from v$session in order to be able to use them later, several times in different other queries, while I'm still working in the current session.
    So, here is how I proceed
    SET SERVEROUTPUT ON;  -- I often activate this option as the first line of almost all of my SQL-PL/SQL script files
    SET SQLBLANKLINES ON;
    VARIABLE mysid NUMBER
    VARIABLE myserial# NUMBER;
    VARIABLE saved_sql_id VARCHAR2(13);
    -- So first I store sid and serial# for the current session
    BEGIN
        SELECT sid, serial# INTO :mysid, :myserial#
        FROM v$session
        WHERE audsid = SYS_CONTEXT('UserEnv', 'SessionId');
    END;
    PL/SQL procedure successfully completed.
    -- Just check to see the result
    SQL> SELECT :mysid, :myserial# FROM DUAL;
        :MYSID :MYSERIAL#
           129   1067
    SQL> Now, let's say that I want to run the following query as the last SQL statement run within my current session
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;According to Oracle® Database Reference 11g Release 2 (11.2) description for v$session
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/dynviews_3016.htm#REFRN30223]
    the column prev_sql_id includes the sql_id of the last sql statement executed for the given sid and serial# which in the case of my example, it will be the above mentioned SELECT query on the employees table. As a result, right after the SELECT statement on the employees table I run the following
    BEGIN
        SELECT prev_sql_id INTO :saved_sql_id
        FROM v$session
        WHERE sid = :mysid AND serial# = :myserial#;
    END;
    PL/SQL procedure successfully completed.
    SQL> SELECT :saved_sql_id FROM DUAL;
    :SAVED_SQL_ID
    9babjv8yq8ru3
    SQL> Having the value of sql_id, I'm supposed to find all information about cursor(s) for my SELECT statement and also its sql_text value in v$sql. Yet here is what I get when I query v$sql upon the stored sql_id
    SELECT child_number, sql_id, sql_text
    FROM v$sql
    WHERE sql_id = :saved_sql_id;
    CHILD_NUMBER   SQL_ID          SQL_TEXT
    0              9babjv8yq8ru3    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;Therefore instead of
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;for the value of sql_text I get the following value
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES);Which is not of course what I was expecting to find in v$sql for the given sql_id.
    After a bit googling I found the following thread on the OTN forum where it had been suggested (well I think maybe not exactly for the same problem) to turn off SERVEROUTPUT.
    Problem with dbms_xplan.display_cursor
    This was precisely what I did
    SET SERVEROUTPUT OFFafter that I repeated the whole procedure and this time everything worked pretty well as expected. I checked SQL*Plus documentation for SERVEROUTPUT
    and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
    are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
    Could anyone kindly make some clarification?
    thanks in advance,
    Regards,
    Dariyoosh

    >
    and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
    are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
    Hi Dariyoosh,
    SET SERVEROUTPUT ON has the effect of executing dbms_output.get_lines after each and every statement. Not only related to system view.
    Here below what Tom Kyte is explaining in this page:
    Now, sqlplus sees this functionality and says "hey, would not it be nice for me to dump this buffer to screen for the user?". So, they added the SQLPlus command "set serveroutput on" which does two things
    1) it tells SQLPLUS you would like it <b>to execute dbms_output.get_lines after each and every statement</b>. You would like it to do this network rounding after each call. You would like this extra overhead to take place (think of an install script with hundreds/thousands of statements to be executed -- perhaps, just perhaps you don't want this extra call after every call)
    2) SQLPLUS automatically calls the dbms_output API "enable" to turn on the buffering that happens in the package.Regards.
    Al

  • Instant Client SQL*Plus License Question

    Can anyone shed some light on a license question for me? (I know that most license questions are for Oracle Sales to handle, but this involves a supposedly free product.)
    I want to use SQL*Plus with the Instant Client in a production environment, but I am not sure whether I am entitled to. Does Instant Client "support" SQL*Plus only in the sense that if I already own a license for SQL*Plus I can use it with the Instant Client, or is the Instant Client SQL*Plus package also truly free to deploy and use?
    The download page has links to download a basic Instant Client, plus several optional packages, one of which is SQL*Plus. However, the FAQ does not tell me whether the optional packages (specifically SQL*Plus) is also free to deploy and use in a production environment, and I could not find any other helpful document.
    The FAQ says that "Instant Client is FREE for anyone to use in a development or production environment." It also says immediately following that "Instant Client can be used to run your OCI, OCCI, Pro*C, JDBC, and ODBC applications without installing a full Oracle Client. In addition, Instant Client supports SQL*Plus." [emphasis mine]
    I would appreciate any help on this.
    Thanks in advance,
    Anthony

    Why don't you call Oracle sales? I guess they'll be happy to answer your question.
    Yours,
    Laurenz Albe

  • Question about The SQL*Plus menu item

    The help doc says we can use SQL*Plus commands. So I open it from the SQL*Plus menu item under Tools. After I gave the installed SQL*Plus location and file name, SQL*Plus was opened by itself asking for a password. The question is are all SQL*Plus commands are supported/will be supported in Raptor? Thanks.
    ben

    See this.. http://www.oracle.com/technology/products/database/project_raptor/sql_worksheet_commands.html
    Not everything in plus is supported
    -kris

  • Quick SQL*Plus OS X questions

    I'm going to try to post quick OS X questions here that don't deserve their own threads.
    For starters:
    When I'm in the terminal I can hit the up arrow to scroll through previous commands. After I log into sqlplus and hit the up arrow I just get ^[[A.  I tried searching google but you could probably imagine I didn't get anything useful searching for that.  [b]Is there a way to enable the up arrow to scroll through previous commands?

    I am in the same boat (SQL*Plus on terminal on OS X) and the closest I came to cycle through old commands is the "/" which just runs the previous command. I did a lot of research, and was unsuccessful. I'll keep looking, but it doesn't look good for us.
    Rich

  • Question about setting column width in SQL*Plus using info retrieved w SQL

    Good morning,
    Is there a way to tell SQL*Plus to set the width of a column to the greatest width of the elements found in the column ? (as opposed to the default which is the width declared in the DDL)
    In other words, I'd like to do something functionally equivalent to this:
    COL <columname> format a[select max(length(<columnname>)) from <thetablethatcontainscolumname>]
    I'm doing the above manually in two steps
    1. select max(length(columnname)) from .....
    2. col columnname format a[resultofstep1]
    Is there a way of doing it in one step ?
    Thank you for your help,
    John.

    Hi Munky,
    >
    you should consider whther you are using the correct tool for the job, SQLplus isn't exactly ideal for doing presentation layer stuff
    >
    I'm not really doing presentation stuff, I asked because it would be very convenient for everyday stuff. I commonly query the tables that I am going to deal withm just to have a look at the column names and a few values, something like:
    select * from EMP where rownum <= 10; -- just to have a look at the table and some values
    when the table contains a wide column then the display gets all messed up. It would be nice to have an option or a mechanism to tell SQL*Plus to automatically use the width of the widest value, instead of having to determine the value and then manually set the column.
    thank you for your help, it's good to know that I didn't miss some trivial setting in the documentation that would do it ;)
    John.

  • Opening multiple sessions in SQL*Plus - Basic Question

    Hi All,
    I'm trying to issue an update on a table consists of 100 million rows.(update is done on every row). I have queries that updates this table in chunks of 20 million rows. So, if I open 5 sessions in SQL*Plus and run these 5 queries, does that mean Oracle opens up 5 processes in parallel for me ?
    If yes, can I use parallel hint in each of these 5 queries and make the update even faster ? How does the above 2 differ ?
    I'll be very glad if I hear from anyone,
    Thanks,
    Madhu.

    For every client session there is a server session associated with it. Such as, when you open five session you will have five server session and it serve queires.
    Regarding paralle queries, depends whether your table is defined as parallel, how many cpu do you have and also parallel parameters.
    Jaffar

  • SQL*Plus Upgrade Questions [Help!!]

    Hello,
    Our project is using Oracle 8i Enterprise Edition Release 8.1.7.3.0 database and Oracle Dev Tools 6i Patch 3 (Form/Report Builder 6.0.8.12.1).
    The SQL*Plus version that comes with this version is 8.0.6.0.0. We would like to upgrade to version 8.1.7.0.0. without having to upgrade the entire tool set [don't ask me why- politics ;)]. How can I do this? Is it even possible? I found some documentation that said all that was required for SQL Plus version 8.1.7.0.0 was Oracle 8i 8.1.7.0.0 database, which we have.
    I grabbed Dev Tools 6i Patch 10 from MetaLink and installed in a seperate directory from one that our developers use as a test [for other unrelated issues]. Well, Patch 10 also comes with SQL Plus verison 8.0.6.0.0, even though it came out in early 2002, well after version 8.1.7.0.0 was released.
    One of our test boxes has Oracle 9i iSuite installed, which does have SQL Plus 8.1.7.0.0. As a lark, I tried various was of simply moving its version (the .exe) and related .dlls to our existing test Dev 6i bin directory. No luck- all sorts of bizarre error messages. After I got through all the .dlls errors, I now get a
    "The procedure entry point OCIUserCallbackRegister could not be located in the dll OCI.dll", even though the updated OCI.dll is in the bin.
    I assume this all means that to upgrade from SQL Plus 8.0.6.0.0 to 8.1.7.0.0 it has to be installed [and not simply dropped]. Since the latest version of our tools [Dev 6i Patch 10] only has version 8.0.6.0.0, how can I install it?
    HELP!!
    Thanks in advance,
    James Walters

    Hello,
    Our project is using Oracle 8i Enterprise Edition Release 8.1.7.3.0 database and Oracle Dev Tools 6i Patch 3 (Form/Report Builder 6.0.8.12.1).
    The SQL*Plus version that comes with this version is 8.0.6.0.0. We would like to upgrade to version 8.1.7.0.0. without having to upgrade the entire tool set [don't ask me why- politics ;)]. How can I do this? Is it even possible? I found some documentation that said all that was required for SQL Plus version 8.1.7.0.0 was Oracle 8i 8.1.7.0.0 database, which we have.
    I grabbed Dev Tools 6i Patch 10 from MetaLink and installed in a seperate directory from one that our developers use as a test [for other unrelated issues]. Well, Patch 10 also comes with SQL Plus verison 8.0.6.0.0, even though it came out in early 2002, well after version 8.1.7.0.0 was released.
    One of our test boxes has Oracle 9i iSuite installed, which does have SQL Plus 8.1.7.0.0. As a lark, I tried various was of simply moving its version (the .exe) and related .dlls to our existing test Dev 6i bin directory. No luck- all sorts of bizarre error messages. After I got through all the .dlls errors, I now get a
    "The procedure entry point OCIUserCallbackRegister could not be located in the dll OCI.dll", even though the updated OCI.dll is in the bin.
    I assume this all means that to upgrade from SQL Plus 8.0.6.0.0 to 8.1.7.0.0 it has to be installed [and not simply dropped]. Since the latest version of our tools [Dev 6i Patch 10] only has version 8.0.6.0.0, how can I install it?
    HELP!!
    Thanks in advance,
    James Walters

  • SQL*Plus Worksheet Question

    I just upgraded to 8.1.6 and started using SQLPlus worksheet. Is there away to set output screen to display horizontal instead of vertical?
    Thank you in Advance
    null

    In some client version (8.1.5 or 8.1.6), I remember I had the same problem. I think that the solution is to use or not the semi-column at th end of the command.
    But, remember that Java SQL*Plus Worksheet is using SQL*Plus. Then if U have a lot of results to display, it's longer with the worksheet version.

  • 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

  • Apex 4.0 - Can see view data in SQL*Plus but no data in Object Browser

    Hi There,
    I have just started using Apex 4.o and migrated some apps. I have an issue with a report, but see the same issue with Object browser, which is easier to describe.
    I have a view:
    create or replace view V_PLJ_USERDEF_CODES (
             CODE_SET_ID,
             CODE_SET_CODE,
             CODE_SET_DESC,
             CODE_ID,
             CODE_SYS_CODE,
             CODE_VALUE,
             CODE_DESC,
             DISPLAY_SEQ,
             DISPLAY_FLAG,
             LANGUAGE_CODE) as
      select CS.CODE_SET_ID,
             CS.CODE_SET_CODE,
             CS.CODE_SET_DESC,
             C.CODE_ID,
             C.CODE_SYS_CODE,
             C.CODE_VALUE,
             C.CODE_DESC,
             C.DISPLAY_SEQ,
             C.DISPLAY_FLAG,
             C.LANGUAGE_CODE
        from PLJ_CODES C,
             PLJ_CODE_SETS CS
       where C.CODE_SET_ID         = CS.CODE_SET_ID
         and CS.CODE_SET_TYPE_CODE = SYS_CONTEXT('PLJUMPSTART','C_USERDEF_CODE_SET');This returns data in SQL*Plus, but no data in Object Browser OR report region based on this view.
    Workspace parses in the same schema as tested in SQL*Plus.
    If, in report, I swap out view, and use underlying table - no problem.
    Any ideas -
    thanks
    P

    Hi all,
    Thanks for getting back so promptly.
    It just seems weird to me, as tables are just fine, but not views.
    In the underlying schema:
    SQL> sho user
    USER is "ICSREPORTING"
    SQL> select count(*) from plj_codes;
      COUNT(*)
           107
    SQL> select count(*) from v_plj_userdef_codes;
      COUNT(*)
            29And in the APEX schema
    SQL> sho user
    USER is "APEX_040000"
    SQL> select count(*) from icsreporting.plj_codes;
    select count(*) from icsreporting.plj_codes
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> select count(*) from icsreporting.v_plj_userdef_codes;
    select count(*) from icsreporting.v_plj_userdef_codes
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL>However, in SQL browser, I can see the data in PLJ_CODES but in V_PLJ_USERDEF_CODES, just the message "This view has no data". Indeed, it is like this for all views.
    I even explicitly granted access to APEX_040000 but no good.
    In fact, I would like to know more about how Apex gets access to do DML against the underlying parsing schema(s).
    This is a little frustrating though. It worked just fine in lots of apps in version 2.1 to 3.2
    Am I missing something
    paul
    p.s I knew there would be a question about the context, but I had already checked that. :)
    Edited by: PJ on Nov 19, 2010 4:09 AM

  • Checking Module to Prevent SQL Plus usage on Database

    I have a question regarding logon triggers checking against SYS_CONTEXT('USERENV', 'MODULE'). I created a logon trigger that looks for SYS_CONTEXT('USERENV', 'MODULE') = 'SQLPLUS.EXE'
    and if it matches then it only allows specified users to log in to the database. This code works but I am confused as to why when I check SYS_CONTEXT('USERENV', 'MODULE') after I login in
    shows SQL*Plus which clearly does not match my IF statement in my logon trigger.
    Second issue. If I rename sqlplus.exe to jeff.exe and run it I am abled to log in to the database as a non DBA user. But the module still shows as SQL*Plus. Why is this?
    Database Version: 11.2.0.2 64bit
    OS: Windows Server 2003 R2
    Client: 11.2.0.1
    /*********************Create Trigger******************************/
    CREATE OR REPLACE TRIGGER application_check_al
      after logon ON database 
    DECLARE
      l_username VARCHAR2(20);
      l_module   VARCHAR2(20);
    BEGIN
      l_username := SYS_CONTEXT('USERENV', 'SESSION_USER');
      l_module   := UPPER(SYS_CONTEXT('USERENV', 'MODULE'));
      IF l_module LIKE 'SQLPLUS.EXE' AND
         l_username NOT IN ('SYS', 'SYSTEM', 'DVOWNER', 'DVMGR') THEN
        raise_application_error(-20001, 'SQLPLUS ACCESS RESTRICTED FOR NON DBA USERS');
      END IF;
    END application_check_al;
    /*********************Run SQLPLUS******************************/
    SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 7 12:22:23 2012
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Enter user-name: jeffc@dev
    Enter password:
    ERROR:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-20001: SQLPLUS ACCESS RESTRICTED FOR NON DBA USERS
    ORA-06512: at line 10
    Enter user-name: system@dev
    Enter password:
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining, Oracle Database Vault
    and Real Application Testing options
    system@dev> select sys_context('USERENV','MODULE') from dual;
    SYS_CONTEXT('USERENV','MODULE')
    SQL*Plus
    SQL>

    jeff81 wrote:
    That doesn't make sense. Why am I able to log in when I renamed the exe? And why does the module still show as SQL*Plus?You are right - it does not make sense. The idea that Oracle might perhaps set module to SQLPLUS.EXE on executable start, and then re set from SQLPLUS.EXE to SQL*Plus after connect, or in glogin.sql, to ensure it is consistent across all operating system never crossed my mind.
    You might want to refer to Support Note "SQL*Plus Session/Module is Not Showing in V$SESSION" [ID 1312340.1] to see whether anything in there helps. I'm pretty sure http://docs.oracle.com/cd/E11882_01/server.112/e16604/ch_twelve040.htm#i2698573 doesn't help much, though.
    I'd certainly be raising it with Support as a potential security challenge, to get that potential hole closed.
    Edited by: Hans Forbrich on Mar 7, 2012 2:23 PM
    I wonder whether Oracle put that capability in there - if an untained SQLPLUS.EXE, it tells you that it is SQLPLUS.EXE, but if renamed it tells you 'SQL*Plus'? Specuklation, but it is one thing I might do to subtly raise the flag. Best bet - ask Support.
    Edited by: Hans Forbrich on Mar 7, 2012 2:29 PM

  • Can we use xml Publisher reporting for sql* Plus in EBS

    Hello All,
    The current report is designed in Sql* Plus Executable report and the output is in txt format, Now the requirement is to have the output in Excel format.
    So is it possible to use the xml reporting and make the output as Excel from the word template we design from MSword as we do for rdf(I have done few reports created in rdf to xml publisher reports in EBS and stand alone as well.).
    Do the same procedure will suit for Sql*Plus reports tooo or Is there any work around to achieve this.
    Thanks and Regards
    Balaji.

    Hi
    Thanks for the reply..
    I tried to do the follwoing
    1. changed the output to xml in the conc. prog.
    2. ran the same report but i am getting the follwoing error in the output file
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource
    Other reports which are using the Oracle Reports(rdf) as source, i am able to generated the xml as expected....
    So my question is whether we can use sql* reports executable and generate xml in the conc.prog.
    if any one has used the sql*reports for xml publisher reporting... please let me know, so that if its possible i will check my sql needs some validation or tuning...
    thanks in advance
    Balaji.

  • Print a report from sql*plus.

    Regards all
    Let me know whether it is possible to print a hard report rom sql*plus and how.
    waiting

    Let me know whether it is possible to print a hard report rom sql*plus Yes. SPOOL is a command to get SQL*Plus screen results to disk real-time.
    and how.A "report" is such a generic term, that you will have to get started with at least some reading :)
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a90842/toc.htm
    (search for: "How Can I Learn SQL*Plus")
    You may also address specific questions about the SQL*Plus product (that are not really Database SQL and/or PL/SQL related) via the [Technologies>Tools>iSQL*Plus] forum rather than here.
    waiting That's up to you! Dig in!
    Michael O'Neill
    Publisher of the PigiWiki
    clever-idea.com

Maybe you are looking for

  • Picture Black and White

    How can I take a Black and White photo and make ONE item (lets say flowers) and make that red?

  • Harddisk problem - how to resolve when out of warre

    Hello all, I dropped my Creative Zen Xtra today, until now I have had no problems whatsoever with this fantastic machine.... Basically now though, the menus won't load, when it's switched on it just hangs on the EAX screen for a couple of minutes bef

  • OWB Runtime repository installing error

    Hello I'm a newbie here and in Oracle world. I'm student who tries to learn Oracle Warehouse Builder use on freetime, so any help would be appriciated. So the problem is, always when i try to install Runtime Repository (using OWB Runtime Assistant) i

  • Mac is getting to full of photos need to move to external HD

    My Macbook HD is getting full of photos, I need to move to a external HD but how do I get Iphoto work where I can go back and forth between the Macbook and External Iphotos?

  • Enlarging book pages to make proofreading captions easier

    Is there a way to zoom pages of a book to a larger size when proofing so that small font sizes can be more easily read? I find that font size below 12 is difficult when checking for spelling, etc., and I was wondering if there is a way i haven't disc