SQL *Plus vs SQL *Plus Worksheet

Hi - I created a table in one product and inserted 4 rows. The other product sees the table but returns 0 rows. So I create a table Test in SQL+ and insert 4 rows. I issue a Select * From Test; in SQL+ WkSheet and it returns 0 rows but in SQL+ it returns 4 rows. I dropped the table and then recreated it inSQL+ WkSheet and had the same result only SQL+ returned 0 rows and SQL+ Wksheet returned 4.
THis just happened with the last table I created, the others I did both can see.
Any ideas? I logged on with
connect System/manager@bers
for both.
Thanks, George

Hi,
Did you issue a commit after the insert statements?
create table,alter table,truncate table,drop table are examples of DDL statements and have an implicit commit once they are issued.hence the actions of these are evident once these statements are over.
insert,update and delete are DML statements and are visible only in the session that they are issued unless a commit is issued and then after the commit these changes can be seen from different sessions.
hence if u issue a commit after the insert statements and then select from a different tool,you should be able to see the records.
hope this helps.

Similar Messages

  • AUTOTRACE stats different in SQL Developer vs SQL Plus

    Using SQL Developer 3.2.20.09, database is 11.2 on Linux. I'd like to know why I get different stats when using AUTOTRACE in SQL Developer vs SQL Plus. If I do the following in SQL Developer and in SQL Plus I get a very different set of stats:
    set autotrace on
    select * from emp;
    set autotrace off
    I run this with "run worksheet" in SQL Developer and I see this set of stats:
    Statistics
    4 user calls
    0 physical read total multi block requests
    0 physical read total bytes
    0 cell physical IO interconnect bytes
    0 commit cleanout failures: block lost
    0 IMU commits
    0 IMU Flushes
    0 IMU contention
    0 IMU bind flushes
    0 IMU mbu flush
    I do the same in SQL Plus and I see these stats:
    Statistics
    0 recursive calls
    0 db block gets
    7 consistent gets
    0 physical reads
    0 redo size
    1722 bytes sent via SQL*Net to client
    519 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    14 rows processed
    A very different set of stats. The stats in shown in SQL Plus seem to be much more useful to performance optimization over the one shown in SQL Developer. Why the different set of stats for each? Thanks.

    Cross-referencing to another recent thread on this topic:
    Re: set autotrace on statistics in sqldeveloper (oracle 11g) is wrong

  • Cannot see table in sql developer or sql plus

    I have created a record in application designer. I have then built the table. I can close the record and then find it again in application designer. But if I go to sql plus or sql developer, I cannot see it. Am I missing a step?

    You probably can see all the tables of sysadm because someone else give you proper grant for that on existing sysadm's objects.
    For the new or modified object (drop+create) you should :
    1. connect as sysadm and run
    grant select on new_table_name to your_own_user;2. connect with your own user and run
    create synonym new_table_name for sysadm.new_table_name;Then you'll be able to query that table without using schema name alias.
    Some admin have also a ddl trigger to make it automatically.
    You could also work through a role and public synonym if more than one user needs to access sysadm's objects.
    Nicolas.

  • Copying and pasting sql statement in sql*plus

    how do you paste sql statement in sql*plus...I have tried the following options, getting the windows interface for this following the documentation below but that didnt work
    http://download.oracle.com/docs/html/A88829_01/ch3.htm
    then i tried creating a simple .txt file with my sql statement and tried running it using @name(where name is the name of the file) and it is giving me the following error SP2-0310: unable to open file "firstscriot.sql

    Hi,
    Using the command-line interface, copying is a pain. Right click on the title bar at the top of the window, then click on "Edit" and "Mark". After you highlight the text you want to copy, you can press the Enter key to copy it.
    To paste, simply right-click. It doesn't matter how the copy buffer got filled (the cumbersome process I described above, using Control-C in Notepad, or whatever).

  • Oracle 8i SQL and PL/SQL plus

    hi everybody, i am trying from two weeks to install oracle 8i SQL and PL/SQL plus on my PC on both Windows 2000 & XP and I installed every java runtime environment I found "the old and the new" but the SETUP insists on not working though it worked on the instructor's PC smoothly without problems.

    If you are getting any errors, you should tell us. Also, you should let us know what version you are trying to install.
    A very common problem at the moment is with Pentium 4 processors. If you have a Pentium 4, search the forums to find the answer.
    Alison

  • Calling SQL Loader from SQL Plus

    Hi everyone,
    I currently use both SQL Loader and SQL Plus to load data and to then carry out certain DML tasks and to reinstate indexes. That all works fine but of course I need to be present to start and to monitor the various scripts.
    What I would really like to do is to be able to incorporate the calls to SQL-Loader into my SQL-Plus scripts and am wondering if this is possible.
    At the moment I run some parts of the load in 'batch' (i.e. command line calls to SQL-Loader and to SQL-Plus) but this won't work for the whole load because the batch calls (from Windows) are not able to wait for particular processes to finish before they start the next. This works OK for the SQL-Loader scripts (because they can run in parallel) but will not work for the whole load because the load needs to be finished before the further processing starts.
    Or maybe there is a way (Windows .BAT files?) to set up batch processes which are intelligent enough to wait for one action to finish before starting the next action.
    Any thoughts or any links to HOWTOs on this would be a great help.
    Regards and thanks,
    Alan Searle

    Hi Alan,
    In SQL*Plus you have the HOST command.
    I would go for the .bat solution using [START /WAIT|http://www.computerhope.com/starthlp.htm]
    Regards
    Peter

  • Tracking the order of execution of sql scripts in SQL*Plus

    In our production environment we sometimes have to run some .sql scripts in a particular order. Since the order of execution is important , i have created another .sql file caller caller.sql(shown at the bottom) which will call all the scripts in the right order.
    i thought of putting a exec DBMS_LOCK.SLEEP (5); after the end of every execution of the script so that i can see the
    'Ending script1'message .
    The spooling within the caller script(execute_stack.log) has become meaningless because each script has a spool <filename.log> and spool off within it. These spool logs (for every script) is important for tracking purposes as each script belongs to a different development team and i have to send them the spooled log file after the execution.
    I don't want to see the entire scripts running by in my screen. Since these scripts have their own spooling, i can later check the logs if the scripts where executed properly.
    So i need two things.
    1.I just need to see the following and nothing else in the screen.
    Ending script1
    Ending script2
    Ending script3
    .2. I need to log the order of execution. ie. the execute_stack.log should look like the above.Since there is a spool off within each script, this wouldn't be possible.Right?
    Ending script1
    Ending script2
    Ending script3
    .The caller.sql script which calls all the scripts in the right order
    alter session set nls_date_format = 'DD-MON-YYYY hh24:MI:SS';
    set serveroutput on
    set echo on;
    set feedback on;
    spool execute_stack.log
    @script1.sql
    exec dbms_output.put_line ('Ending script1');
    dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
    exec DBMS_LOCK.SLEEP (5);
    @script2.sql
    exec dbms_output.put_line ('Ending script2');
    dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
    exec DBMS_LOCK.SLEEP (5);
    @script3.sql
    exec dbms_output.put_line ('Ending script3');
    dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
    exec DBMS_LOCK.SLEEP (5);
    @script4.sql
    dbms_output.put_line(chr(10)||chr(10)||'.'||chr(10)||'.'||chr(10));
    exec dbms_output.put_line ('Ending script3');
    commit;
    spool off;Is this a professional way of tracking the execution of .sql scripts?

    Pete_Sg1 wrote:
    Is this a professional way of tracking the execution of .sql scripts?No. There is very little professional about using .sql scripts on a production system - when stored procedures are safer, more robust, easier managed and controlled and secure.. and where a log table can be used to properly log the runtimes (and other stats) of each processing step.
    Let's just take a look at the number of moving parts you need to schedule and run a .sql script. A cron job needs to be configured with the proper environment setting. It needs to run a shell script. That shell script needs to load SQL*Plus. SQL*Plus needs to connect to the database (starting a dedicated server process most likely). SQL*Plus then needs to read a .sql file, parse these commands and either execute these locally (SQL*Plus commands) or remotely (PL/SQL and SQL commands).
    How can this be considered professional when the very same can be achieved with a
    - stored procedure
    - using DBMS_JOB to schedule the procedure for execution
    There are so many things that can go wrong with the first method. And so few things that could go wrong with the last one. No contest as to which method is not only better, but also professional.
    PS. See that you use Windows to run these scripts. It is even worse as it introduces another hardware and software layer making the scenario even more insecure & unsafe with more moving parts that can go wrong or simply fail.

  • How to pass Unix environment variable to a SQL procedure or SQL * Plus

    Can any body suggest me how to ,
    How to pass Unix environment variable to a SQL procedure or SQL * Plus file..
    I am trying to invoke a SQL Procedure from Unix
    by passing the value of a Unix environment variable.
    Is it possible..?
    Thanks in advance.
    Regards,
    Srinivas Jaltaru

    Within your shell script you can use what is known as a "here document" which is basically a way of wrapping a call to Oracle. The following call to Oracle loops and writes rows to files with numerically increasing file names. Two unix shell variables are used, one in a select statement and one in a spool command :
    <pre>
    #!/bin/bash
    export ORACLE_SID=DEV05
    FILENO=1007351
    while [ ${FILENO} -le 1008400 ]
    do
    FILENAME=farm_${FILENO}.txt
    DUMMY=`sqlplus -s user20/user20 <<SQLSTOP
    set lines 73
    set pages 0
    set head off
    set termout off
    set echo off
    set feedback off
    select rpad(searchx, 8)
    from blastx@PRODUCTION
    where searchx = ${FILENO} ### here's a shell variable
    spool /export/home/user20/sql/psiblast/BACKUP2_D/${FILENAME} ### here's a shell variable
    spool off
    SQLSTOP`
    FILENO=`expr ${FILENO} + 1`
    done
    exit 0
    </pre>

  • After running sql scripts in SQL plus, where are the results(tables) stored

    Hi ,
    I am using oracleDb10g . i have used SQL plus to create a database. I have run 2 sql scripts and constructed the tables , but i dont know where the data is stored and how to make the data into a database, so that i can use it for connection through some UI.
    for example: schema.sql, data.sql script files.
    SQL> start schema.sql
    SQL> start data.sql
    The tables are created.
    Now how can i group those table into a database and name it.(i mean i can create a database using SQL plus, but how to dump the tables into the database created). Because i want to use this database name for connecting to MS SQL, so i need the name.
    Thanks
    babu.

    when you are in Rome, sing with the romans !
    Oracle is different from SQL Server.
    Time to read some basic books.
    --> http://tahiti.oracle.com

  • SQL developer vs SQL*plus

    hi i am not able to run the command connect username/password on SQL developer but when i run the command on
    sqlplus through command prmpt then it work .....wht might be the issue..i am a newbe to use of SQL developer

    Technohub wrote:
    sql devloper is a third party tool. Hmm last time I checked, it was a tool from Oracle only. Let's check again,
    http://www.oracle.com/technetwork/developer-tools/sql-developer/index.html
    Its not a 3rd party but Oracle's own tool.
    >
    once u connect to the db then u can switch to other users as follows
    SQL> conn user/pwd@connect_string

  • Calling SQL function in SQL query fails

    Hi There,
    I am trying to execute INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('?')) using ODBC C
    SQLBindParameter APIs.
    If I execute the INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('<name>milind</name>')) works fine.
    Can anybody please help me out here?
    Thanks,
    Milind
    /* blob.c
    * The following C code demonstrates how to read an input file, piecewise
    * (in chunks), and write it into a BLOB or LONG RAW column in the database.
    * It then reads that BLOB or LONG RAW data, piecewise, from the database
    * and writes it back to the OS as an output file that you specify.
    * Enter the following SQL statement via SQL*Plus to create the table
    * 'images_data' for use with this sample. Make sure you log into
    * Oracle as a user appropriate for running this example.
    * For BLOB, use the following table:
    * CREATE TABLE images_data (
    * name VARCHAR2(100),
    * imagesize NUMBER,
    * image BLOB);
    * For LONG RAW, use the following table:
    * CREATE TABLE images_data (
    * name VARCHAR2(100),
    * imagesize NUMBER,
    * image LONG RAW);
    * Change the connection information at the beginning of the procedure OpenOra
    * to your DSN, username and password.
    * To run this program, open a Command Prompt and use the following syntax:
    * Syntax: <program_name> <infile_name> <outfile_name>
    * Example call: C:\> blob my_photo.jpg copy_of_my_photo.jpg
    #include "stdafx.h"
    #include <stdio.h>
    #include <io.h>
    #ifndef NUTC
    #include <windows.h>
    #endif
    #include <sql.h>
    #include <sqlext.h>
    #ifdef NUTC
    #include <sys/types.h>
    #include <sys/stat.h>
    #endif
    * Global variables
    HENV hOdbcEnv = NULL; /* Environment handle */
    HDBC hDbConn = NULL; /* Connection handle */
    int sr; /* Return value */
    #define BUFSIZE 32020 /* Chunksize */
    * Connect routine
    void OpenOra()
    char szDSN[] = "XY10g2"; /* Data Source Name (DSN) */
    char szUID[] = "odbc1"; /* Username */
    char szAUTH[] = "pdmuser"; /* Password */
    * Allocate environment handle
    sr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hOdbcEnv);
    if (sr != SQL_SUCCESS)
    printf ("Error allocating environment handle\n");
    * Set the ODBC Version
    sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
    if (sr != SQL_SUCCESS)
    printf ("Error setting ODBC version\n");
    * Allocate connection handle
    sr = SQLAllocHandle (SQL_HANDLE_DBC, hOdbcEnv, &hDbConn);
    if (sr != SQL_SUCCESS)
    printf ("Error allocating connection handle\n");
    * Connect
    sr = SQLConnect(hDbConn, (UCHAR *)szDSN, SQL_NTS,(UCHAR *)szUID, SQL_NTS, (UCHAR *)szAUTH, SQL_NTS);
    if (sr != SQL_SUCCESS)
    printf("Connection failed\n");
    * Disconnect routine
    void CloseOra()
    * Disconnect and free connection and environment handles
    sr = SQLDisconnect(hDbConn);
    if (hDbConn != SQL_NULL_HANDLE)
    SQLFreeHandle(SQL_HANDLE_DBC, hDbConn);
    if (hOdbcEnv != SQL_NULL_HANDLE)
    SQLFreeHandle(SQL_HANDLE_ENV, hOdbcEnv);
    * Read INFILE into the database and read data back out and save as OUTFILE.
    void readCertImage(char read_name, long filesize, char write_name)
    SQLCHAR iSqlCmd[300] = "INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('?'))";
    SQLCHAR iSqlCmd1[300] = "SELECT DATA FROM XML_DATA WHERE NAME = ?";
    FILE ifile, ofile; /* File pointers */
    time_t startTime, endTime;
    time_t startTimeIO, endTimeIO;
    int IOtime = 0;
    unsigned char buf[BUFSIZE]; /* Buffer to hold chunk */
    unsigned char buf1[BUFSIZE]; /* Buffer to hold chunk */
    SQLINTEGER type[3]; /* Type of data */
    SQLPOINTER pToken; /* Which column is piecewise */
    HSTMT hstmt = NULL; /* Statement handle */
    long i; /* Byte Counter */
    long count; /* Piecewise Counter */
    long rd; /* Amount to read */
    * Log on
    OpenOra();
    ifile = fopen(read_name, "r"); /* Open the file for reading in ASCII mode */
    * Allocate statement handle
    sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
    if (sr != SQL_SUCCESS)
    printf("Error allocating statement handle\n");
    * Prepare insert statement
    sr = SQLPrepare(hstmt, iSqlCmd, SQL_NTS);
    if (sr != SQL_SUCCESS)
    printf("Error preparing insert statement\n");
    * Bind Parameters
    /* Name of BLOB */
    sr = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0,read_name, strlen(read_name), &type[0]);
    if (sr != SQL_SUCCESS)
    printf("Error binding name variable\n");
    /* Size of BLOB */
    sr = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_NUMERIC, 0, 0,&filesize, 0, &type[1]);
    if (sr != SQL_SUCCESS)
    printf("Error binding length variable\n");
    * As this will be a piecewise insert do not need to pass a buffer here.
    * Instead pass the parameter number for identification purposes.
    /* BLOB data */
    sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)3, 0, &type[2]);
    if (sr != SQL_SUCCESS)
    printf("Error binding data variable\n");
    type[0] = SQL_NTS; /* Null terminated string */
    type[1] = 0; /* Ignored for numbers */
    type[2] = SQL_LEN_DATA_AT_EXEC(filesize); /* Data at execution time */
    time( &startTime );
    * Execute the insert
    sr = SQLExecute(hstmt);
    if (sr == SQL_NEED_DATA)
    printf("\nAbout to perform piecewise insert of data\n\n");
    else if (sr != SQL_SUCCESS)
    printf("Error executing insert statement\n");
    * Retrieve the pointer to the buffer containing the address
    * of the location where the source BLOB will be sent
    sr = SQLParamData(hstmt, &pToken);
    if (sr != SQL_NEED_DATA)
    printf("Error - no piecewise operations required\n");
    * Write the data in BUFSIZE chunks
    i = 0; /* Initialize bytes inserted
    count = 0; /* Initialize pieces/chunks inserted */
    do
    count++; /* Increment chunk number */
    * If remaining bytes to read is greater than BUFSIZE,
    * read another BUFSIZE chunk. Otherwise, read remaining
    * chunk of bytes (which will be less than BUFSIZE)
    if (filesize - i >= BUFSIZE)
    rd = BUFSIZE;
    else
    rd = (filesize - i);
    printf("%5ld:%10ld - About to write %ld bytes to the database\n",count,i,rd);
    * Reads one rd sized chunk of data into buffer from source file (BLOB)
    time( &startTimeIO );
    fread(buf, rd, 1, ifile);
    time( &endTimeIO );
    IOtime = IOtime + (endTimeIO - startTimeIO);
    * Sends the contents of the buffer to the ODBC driver
    SQLPutData(hstmt, buf, rd);
    /* Recalculate total bytes sent */
    if (filesize - i >= BUFSIZE)
    i+= BUFSIZE;
    else
    i+= (filesize - i);
    } while (i < filesize);
    /* Check to see if all data has been sent */
    sr = SQLParamData(hstmt, &pToken);
    if (sr == SQL_NEED_DATA)
    printf("Error - still need data\n");
    printf("%5ld:%10ld - Done writing data\n",++count,i);
    time( &endTime );
    printf("BLOB Write completed StartTime: %d, EndTime: %d, IOTime: %d in seconds.\n", endTime, startTime, IOtime);
    printf("BLOB Write completed in %d seconds.\n", (endTime - startTime) - IOtime);
    fclose(ifile); /* Close the INFILE */
    printf("\nData inserted into database\n\n");
    * Now read the data back. Reuse the previous statement handle.
    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
    if (sr != SQL_SUCCESS)
    printf("Error allocating statement handle\n");
    * Prepare select statement, bind variable and execute
    sr = SQLPrepare(hstmt, iSqlCmd1, SQL_NTS);
    if (sr != SQL_SUCCESS)
    printf("Error preparing select statement\n");
    sr = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, read_name, strlen(read_name), &type[0]);
    if (sr != SQL_SUCCESS)
    printf("Error binding name variable\n");
    time( &startTime );
    sr = SQLExecute(hstmt);
    if (sr != SQL_SUCCESS)
    printf ("Error executing insert statement\n");
    ofile = fopen(write_name, "w"); /* Open the file for writing in ASCII mode */
    sr = SQLFetch(hstmt);
    if (sr != SQL_SUCCESS)
    printf ("Error fetching data\n");
    * Read the data in BUFSIZE chunks.
    i = 0; /* Initialize bytes inserted */
    count = 0; /* Initialize pieces/chunks inserted */
    memset(buf, NULL, BUFSIZE);
    do
    * Retrieve a BUFSIZE chunk of data into the buffer
    sr = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, BUFSIZE, &type[2]);
    if (sr == SQL_ERROR)
    printf("Error fetching data\n");
    break;
    time( &startTimeIO );
    count++; /* Increment chunk number */
    /* Determine if this is a full chunk or the last chunk */
    if (filesize - i >= BUFSIZE)
    printf("%5ld:%10ld - About to write %ld bytes to file\n",count,i,BUFSIZE);
    fwrite(buf, BUFSIZE, 1, ofile); /* Write BUFSIZE chunk to file */
    else
    printf("%5ld:%10ld - About to write %ld bytes to file\n",count,i,filesize-i);
    fwrite(buf, filesize-i, 1, ofile); /* Write remaining chunk to file */
    time( &endTimeIO );
    IOtime = IOtime + (endTimeIO - startTimeIO);
    /* Recalculate total bytes retrieved */
    if (filesize - i >= BUFSIZE)
    i+= BUFSIZE;
    else
    i+= (filesize - i);
    } while (sr == SQL_SUCCESS_WITH_INFO);
    printf("%5ld:%10ld - Done writing file\n",++count,i);
    time( &endTime );
    printf("BLOB Read completed StartTime: %d, EndTime: %d, IOTime: %d in seconds.\n", endTime, startTime, IOtime);
    printf("BLOB Read completed in %d seconds.\n", (endTime - startTime) - IOtime);
    fclose(ofile); /* Close the OUTFILE */
    printf("\nData written to file\n");
    * Log off
    SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
    CloseOra();
    * Main routine
    void main(argc, argv)
    int argc; /* Number of command line arguments */
    char argv[]; / Array of command line arguments */
    long filesize = 0; /* Size of INFILE */
    FILE ifile; / Pointer to INFILE */
    #ifdef NUTC
    struct stat statbuf; /* Information on a file. */
    #endif
    /* Check for the proper number of command line arguments entered by user */
    if (argc != 3)
    printf("\nCommand line syntax: <program_name> <infile_name> <outfile_name>");
    printf("\n Example call: blob input.exe output.exe\n");
    exit(1);
    /* Open INFILE */
    if( (ifile = fopen(argv[1], "rb" )) == NULL )
    printf( "\nThe file '%s' could not be opened\n",argv[1]);
    exit(1);
    else
    printf( "\nThe file '%s' was opened successfully\n",argv[1]);
    #ifdef NUTC
    /* Determine length of the INFILE */
    if (fstat(fileno(ifile), &statbuf) == 0)
    filesize = statbuf.st_size;
    else
    filesize = 0;
    #else
    filesize = filelength(fileno(ifile));
    #endif
    printf( "The file is %d bytes long\n",filesize);
    /* Close INFILE */
    fclose(ifile);
    /* Insert and retrieve BLOB */
    readCertImage(argv[1], filesize, argv[2]);
    }

    During binding, strings are generally skipped. As such, you should first try replacing XMLType('?') with XMLType(?). You don't need to specify '?' because the system knows the proper type from your SQLBindParameter call.
    Also, you should try replacing:
    sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)3, 0, &type[2]);
    with
    sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)buf, BUFSIZE, &type[2]);

  • Issue with running PL/SQL function returning Sql query

    hi, I am trying to create a report region by using the option of PL/SQL function returning sql query.
    I notice that it's very slow for the report region page to show up. In my PL/SQL function body, there are only 3 steps, first update all the 10 rows of varchar2 fields to null,then insert values to those fields, then select all from the table to show report results. It takes more than 5 minitues for the page to load up, how ever, if i run those steps in SQL*Plus, it only takes a couple of seconds to finish. Any suggestions?
    Thanks,
    gina

    Sergio, the codes are as followed,
    Declare
    q varchar2(32767); -- query
    Begin
    q := 'select "ID",'||
    '"ENTRY NAME","TOTAL","#CM","%CM","#CA",'||
    '"%CA", from Info_table';
    update info_table
    set "TOTAL" = '',
    "#CM" = '',
    "%CM" = '',
    "#CA" ='',
    "%CA"=''
    where "ID"<=10;
    // set all data in column Total to null,there is only 10 rows in the table
    update info_Table set Total = vTotal,
    "#CM" = vCM
    (those variables hold user key-in Text filed value)
    where ID = 1;
    return q;
    End;

  • SQL Query (PL/SQL function body returning SQL query) when using to_char

    we are trying to build a report page of Type SQL Query (PL/SQL function body returning SQL query).
    our query is so simple, we need to extract the month from the recording_date column.
    declare
    l_query varchar2(1000);
    begin
    l_query:='select to_char(recording_date,'MM')from re_productive';
    return l_query;
    end;
    but we are having the following problem for this query
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the generic columns checkbox below the region source to proceed without parsing.
    (ORA-06550: line 4, column 42: PLS-00103: Encountered the symbol "MON" when expecting one of the following: . ( * @ % & = - + ; < / > at in is mod remainder not rem <> or != or ~= >= <= <> and or like between || multiset member SUBMULTISET_ The symbol ". was inserted before "MON" to continue.)
    Notes:
    1-the query is correct and it was tested under Toad and SQL Plus.
    2- we tried Use Generic Column Names (parse query at runtime only) option but we get the same problem.
    any quick help please.

    Hi
    You haven't escaped your quotes in the string. Try this...
    DECLARE
    l_query VARCHAR2(32767);
    BEGIN
    l_query:= 'select to_char(recording_date,''MM'') from re_productive';
    RETURN l_query;
    END;Cheers
    Ben

  • [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'dbo.sp_SPNAMEHERE'.

    OK, something seemed to have changed with my system because this error is NEW. It might be related to my system upgrade from Vista to Win7, but just guessing here.
    I run a database on a corporate MS Sql Server (2005) and an ASP application that connects via ODBC. The real world application works fine, however when I attempt to access Stored Procedures from Dreamweaver (on my development machine)  I am getting the following error:
    [Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'dbo.sp_SPNAMEHERE'.
    This only seems to happen on Stored procedures that RETURN a recordset.
    system:
    Win7
    Dreamweaver CS4
    Code: VBScript/Classic ASP
    SQL Server 2005
    Connecting via ODBC: MM_MY_STRING = "Driver={SQL Server};Server=wscxxxxxxxxx;Database=dbsystem;Uid=username;Pwd=XXXXXXXXXXXX"
    Stored procedures that do not return a recordset are not an issue.... this has put my development work at a standstill!!
    Thanks in advance!

    Well, I hate bumps, but I am really running out of solutions. I have now tried to use a system DSN on my development machine and that didnt solve the problem. I just un-installed DW and re-installed it and that didnt solve my problem either.
    This is very frustrating, because I cannot use any stored procs that return recordsets... I am stuck... can anybody think of a relatively easy work-around to working in DW w/ recordsets that come from SPs when you cant actually access them?
    The really weird thing is, when I build the command, and choose the stored proc, and give it valid input variables, and TEST it from the TEST button, everything works and data is returned as expected. Once I click "OK" and actually add it to the ASP page the recordset that should be visible isnt... and when I click the plus sign in the bindings window I get the error...
    Help!!

  • Can i run all the SQL And PL/SQL in Oracle SQL Developer?

    hi all
    I have heard that Oracle Sql Developer is a free editor for Oracle DB from Oracle.
    Is it possible to run all the the procedres and functions in that editor
    is there any limitation for that ,can i run all the things that we can run on the SQL Plus
    if anybody knows please let me know
    thanks & regards

    Interesting way of putting it.
    When it comes to SQL and PL/SQL, SQLPlus and SQL Developer do not really 'run' very much.
    Most of the time, these things are just shells that pass the SQL and PL/SQL requests to the appropriate engine (database) which will run the command.
    The challenges are:
    - will the shell interpret the request as something to pass to an engine?
    - will the shell display the response from the engine appropriately?
    For answers to those questions, TongucY provided approriate links.

  • Oracle SQL and PL/SQL interview questions.

    Can anyone forward me all Oracle SQL and PL/SQL Interview questions and answers asap.
    Many Thanks.
    Bba

    Dear Pal
    I not sure all the all answers are correct. I got one mail couple yrs back. I am just sharing mail contents. Kindly keep question and compare answers.
    1 Which is more faster - IN or EXISTS?
    EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value.
    2 Which datatype is used for storing graphics and images?
    LONG RAW data type is used for storing BLOB's (binary large objects).
    3 When do you use WHERE clause and when do you use HAVING clause?
    HAVING clause is used when you want to specify a condition for a group function and it is written after GROUP BY clause. The WHERE clause is used when you want to specify a condition for columns, single row functions except group functions and it is written before GROUP BY clause if it is used.
    4 What WHERE CURRENT OF clause does in a cursor?
    LOOPSELECT num_credits INTO v_numcredits FROM classesWHERE dept=123 and course=101;UPDATE studentsSET current_credits=current_credits+v_numcreditsWHERE CURRENT OF X;END LOOPCOMMIT;END;
    5 What should be the return type for a cursor variable.Can we use a scalar data type as return type?
    The return type for a cursor must be a record type.It can be declared explicitly as a user-defined or %ROWTYPE can be used. eg TYPE t_studentsref IS REF CURSOR RETURN students%ROWTYPE
    6 What is use of a cursor variable? How it is defined?
    A cursor variable is associated with different statements at run time, which can hold different values at run time. Static cursors can only be associated with one run time query. A cursor variable is reference type (like a pointer in C).Declaring a cursor variable:TYPE type_name IS REF CURSOR RETURN return_type type_name is the name of the reference type,return_type is a record type indicating the types of the select list that will eventually be returned by the cursor variable.
    7 What is the purpose of a cluster?
    Oracle does not allow a user to specifically locate tables, since that is a part of the function of the RDBMS. However, for the purpose of increasing performance, oracle allows a developer to create a CLUSTER. A CLUSTER provides a means for storing data from different tables together for faster retrieval than if the table placement were left to the RDBMS.
    8 What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function?
    1,000,00
    9 What is syntax for dropping a procedure and a function .Are these operations possible?
    Drop Procedure procedure_nameDrop Function function_name
    10 What is OCI. What are its uses?
    Oracle Call Interface is a method of accesing database from a 3GL program. Uses--No precompiler is required,PL/SQL blocks are executed like other DML statements. The OCI library provides· -functions to parse SQL statemets· -bind input variables· -bind output variables· -execute statements· -fetch the results
    11 What is difference between UNIQUE and PRIMARY KEY constraints?
    A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.
    12 What is difference between SUBSTR and INSTR?
    SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output BCDEINSTR provides character position in which a pattern is found in a string. eg INSTR('ABC-DC-F','-',2) output 7 (2nd occurence of '-')
    13 What is difference between SQL and SQL*PLUS?
    SQL*PLUS is a command line tool where as SQL and PL/SQL language interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an Oracle database. SQL is a language used to query the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, Edit SQL commands and PL/SQL.
    14 What is difference between Rename and Alias?
    Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column which do not exist once the SQL statement is executed.
    15 What is difference between a formal and an actual parameter?
    The variables declared in the procedure and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the values that are passed to a procedure and receive results. Formal parameters are the placeholders for the values of actual parameters
    16 What is an UTL_FILE.What are different procedures and functions associated with it?
    UTL_FILE is a package that adds the ability to read and write to operating system files. Procedures associated with it are FCLOSE, FCLOSE_ALL and 5 procedures to output data to a file PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH.PUT, FFLUSH.PUT_LINE,FFLUSH.NEW_LINE. Functions associated with it are FOPEN, ISOPEN.
    17 What is a view ?
    A view is stored procedure based on one or more tables, it’s a virtual table.
    18 What is a pseudo column. Give some examples?
    It is a column that is not an actual column in the table.eg USER, UID, SYSDATE, ROWNUM, ROWID, NULL, AND LEVEL.
    19 What is a OUTER JOIN?
    Outer Join--Its a join condition used where you can query all the rows of one of the tables in the join condition even though they don’t satisfy the join condition.
    20 What is a cursor?
    Oracle uses work area to execute SQL statements and store processing information PL/SQL construct called a cursor lets you name a work area and access its stored information A cursor is a mechanism used to fetch more than one row in a Pl/SQl block.
    21 What is a cursor for loop?
    Cursor For Loop is a loop where oracle implicitly declares a loop variable, the loop index that of the same record type as the cursor's record.
    22 What are various privileges that a user can grant to another user?
    · SELECT· CONNECT· RESOURCES
    23 What are various constraints used in SQL?
    · NULL· NOT NULL· CHECK· DEFAULT
    24 What are ORACLE PRECOMPILERS?
    Using ORACLE PRECOMPILERS, SQL statements and PL/SQL blocks can be contained inside 3GL programs written in C,C++,COBOL,PASCAL, FORTRAN,PL/1 AND ADA.The Precompilers are known as Pro*C,Pro*Cobol,...This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is embedded is known as the host language. The prcompiler translates the embedded SQL and pl/sql ststements into calls to the precompiler runtime library.The output must be compiled and linked with this library to creater an executable.
    25 What are different Oracle database objects?
    · TABLES· VIEWS· INDEXES· SYNONYMS· SEQUENCES· TABLESPACES etc
    26 What are different modes of parameters used in functions and procedures?
    · IN· OUT· INOUT
    27 What are cursor attributes?
    · %ROWCOUNT· %NOTFOUND· %FOUND· %ISOPEN
    28 What a SELECT FOR UPDATE cursor represent. [ANSWER]SELECT......FROM......FOR......UPDATE[OF column-reference][NOWAIT] The processing done in a fetch loop modifies the rows that have been retrieved by the cursor. A convenient way of modifying the rows is done by a method with two parts: the FOR UPDATE clause in the cursor declaration, WHERE CURRENT OF CLAUSE in an UPDATE or declaration statement.
    29 There is a string 120000 12 0 .125 , how you will find the position of the decimal place?
    INSTR('120000 12 0 .125',1,'.')output 13
    30 There is a % sign in one field of a column. What will be the query to find it?
    '' Should be used before '%'.
    31 Suppose a customer table is having different columns like customer no, payments.What will be the query to select top three max payments?
    SELECT customer_no, payments from customer C1
    WHERE 3<=(SELECT COUNT(*) from customer C2
    WHERE C1.payment <= C2.payment)
    32 minvalue.sql Select the Nth lowest value from a table
    select level, min('col_name') from my_table where level = '&n' connect by prior ('col_name') <
    'col_name')
    group by level;
    Example:
    Given a table called emp with the following columns:
    -- id number
    -- name varchar2(20)
    -- sal number
    -- For the second lowest salary:
    -- select level, min(sal) from emp
    -- where level=2
    -- connect by prior sal < sal
    -- group by level
    33 maxvalue.sql Select the Nth Highest value from a table
    select level, max('col_name') from my_table where level = '&n' connect by prior ('col_name') >
    'col_name')
    group by level;
    Example:
    Given a table called emp with the following columns:
    -- id number
    -- name varchar2(20)
    -- sal number
    -- For the second highest salary:
    -- select level, max(sal) from emp
    -- where level=2
    -- connect by prior sal > sal
    -- group by level
    34 How you will avoid your query from using indexes?
    SELECT * FROM emp
    Where emp_no+' '=12345;
    i.e you have to concatenate the column name with space within codes in the where condition.
    SELECT /*+ FULL(a) */ ename, emp_no from emp
    where emp_no=1234;
    i.e using HINTS
    35 How you will avoid duplicating records in a query?
    By using DISTINCT
    36 How you were passing cursor variables in PL/SQL 2.2?
    In PL/SQL 2.2 cursor variables cannot be declared in a package.This is because the storage for a cursor variable has to be allocated using Pro*C or OCI with version 2.2, the only means of passing a cursor variable to a PL/SQL block is via bind variable or a procedure parameter.
    37 How you open and close a cursor variable.Why it is required?
    OPEN cursor variable FOR SELECT...Statement
    CLOSE cursor variable In order to associate a cursor variable with a particular SELECT statement OPEN syntax is used. In order to free the resources used for the query CLOSE statement is used.
    38 How will you delete duplicating rows from a base table?
    delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name); or
    delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from table_name tb where ta.dv=tb.dv);
    39 How do you find the numbert of rows in a Table ?
    A bad answer is count them (SELECT COUNT(*) FROM table_name)
    A good answer is :-
    'By generating SQL to ANALYZE TABLE table_name COUNT STATISTICS by querying Oracle System Catalogues (e.g. USER_TABLES or ALL_TABLES).
    The best answer is to refer to the utility which Oracle released which makes it unnecessary to do ANALYZE TABLE for each Table individually.
    40 Find out nth highest salary from emp table
    SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
    For Eg:-
    Enter value for n: 2
    SAL
    3700
    41 Display the records between two range?
    select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start);
    42 Display the number value in Words?
    SQL> select sal, (to_char(to_date(sal,'j'), 'jsp'))
    from emp;
    the output like,
    SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP'))
    800 eight hundred
    1600 one thousand six hundred
    1250 one thousand two hundred fifty
    If you want to add some text like, Rs. Three Thousand only.
    SQL> select sal "Salary ",
    (' Rs. '|| (to_char(to_date(sal,'j'), 'Jsp'))|| ' only.'))
    "Sal in Words" from emp
    Salary Sal in Words
    800 Rs. Eight Hundred only.
    1600 Rs. One Thousand Six Hundred only.
    1250 Rs. One Thousand Two Hundred Fifty only.
    43 Display Odd/ Even number of records
    Odd number of records:
    select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
    Output:-
    1
    3
    5
    Even number of records:
    select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
    Output:-
    2
    4
    6
    44 Difference between procedure and function.
    Functions are named PL/SQL blocks that return a value and can be called with arguments procedure a named block that can be called with parameter. A procedure all is a PL/SQL statement by itself, while a Function call is called as part of an expression.
    45 Difference between NO DATA FOUND and %NOTFOUND
    NO DATA FOUND is an exception raised only for the SELECT....INTO statements when the where clause of the querydoes not match any rows. When the where clause of the explicit cursor does not match any rows the %NOTFOUND attribute is set to TRUE instead.
    46 Difference between database triggers and form triggers?
    Data base trigger(DBT) fires when a DML operation is performed on a data base table. Form trigger(FT) Fires when user presses a key or navigates between fields on the screen
    Can be row level or statement level No distinction between row level and statement level.
    Can manipulate data stored in Oracle tables via SQL Can manipulate data in Oracle tables as well as variables in forms.
    Can be fired from any session executing the triggering DML statements. Can be fired only from the form that define the trigger.
    Can cause other database triggers to fire.Can cause other database triggers to fire, but not other form triggers.
    47 Difference between an implicit & an explicit cursor.
    PL/SQL declares a cursor implicitly for all SQL data manipulation statements, including quries that return only one row. However,queries that return more than one row you must declare an explicit cursor or use a cursor FOR loop.
    Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT statement via the CURSOR...IS statement. An implicit cursor is used for all SQL statements Declare, Open, Fetch, Close. An explicit cursors are used to process multirow SELECT statements An implicit cursor is used to process INSERT, UPDATE, DELETE and single row SELECT. .INTO statements.
    48 Can you use a commit statement within a database trigger?
    No.
    49 Can the default values be assigned to actual parameters?
    Yes
    50 Can cursor variables be stored in PL/SQL tables.If yes how. If not why?
    No, a cursor variable points a row which cannot be stored in a two-dimensional PL/SQL table.
    51 Can a primary key contain more than one columns?
    Yes
    52 Can a function take OUT parameters. If not why?
    No. A function has to return a value,an OUT parameter cannot return a value.
    53 What are various joins used while writing SUBQUERIES?
    Self join-Its a join foreign key of a table references the same table. Outer Join--Its a join condition used where One can query all the rows of one of the tables in the join condition even though they don't satisfy the join condition.
    Equi-join--Its a join condition that retrieves rows from one or more tables in which one or more columns in one table are equal to one or more columns in the second table.
    54 Differentiate between TRUNCATE and DELETE
    TRUNCATE deletes much faster than DELETE
    TRUNCATE
    DELETE
    It is a DDL statement It is a DML statement
    It is a one way trip,cannot ROLLBACK One can Rollback
    Doesn't have selective features (where clause) Has
    Doesn't fire database triggers Does
    It requires disabling of referential constraints. Does not require
    1 What is PL/SQL ?
    PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.
    2 Write the order of precedence for validation of a column in a table ?
    I. done using Database triggers.
    ii. done using Integarity Constraints.
    I & ii.
    Exception :
    3 Where the Pre_defined_exceptions are stored ?
    In the standard package.
    Procedures, Functions & Packages ;
    4 What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
    % TYPE provides the data type of a variable or a database column to that variable.
    % ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
    The advantages are : I. Need not know about variable's data type
    ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.
    5 What will happen after commit statement ?
    Cursor C1 is
    Select empno,
    ename from emp;
    Begin
    open C1; loop
    Fetch C1 into
    eno.ename;
    Exit When
    C1 %notfound;-----
    commit;
    end loop;
    end;
    The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
    The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.
    6 What is the basic structure of PL/SQL ?
    PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.
    7 What is Raise_application_error ?
    Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.
    8 What is Pragma EXECPTION_INIT ? Explain the usage ?
    The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
    e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)
    9 What is PL/SQL table ?
    Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.
    Cursors
    10 What is Overloading of procedures ?
    The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.
    e.g. DBMS_OUTPUT put_line
    What is a package ? What are the advantages of packages ?
    11 What is difference between a PROCEDURE & FUNCTION ?
    A FUNCTION is always returns a value using the return statement.
    A PROCEDURE may return one or more values through parameters or may not return at all.
    12 What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
    A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
    A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.
    13 What is difference between % ROWTYPE and TYPE RECORD ?
    % ROWTYPE is to be used whenever query returns a entire row of a table or view.
    TYPE rec RECORD is to be used whenever query returns columns of different
    table or views and variables.
    E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type
    e_rec emp% ROWTYPE
    cursor c1 is select empno,deptno from emp;
    e_rec c1 %ROWTYPE.
    14 What is an Exception ? What are types of Exception ?
    Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
    CURSOR_ALREADY_OPEN
    DUP_VAL_ON_INDEX
    NO_DATA_FOUND
    TOO_MANY_ROWS
    INVALID_CURSOR
    INVALID_NUMBER
    LOGON_DENIED
    NOT_LOGGED_ON
    PROGRAM-ERROR
    STORAGE_ERROR
    TIMEOUT_ON_RESOURCE
    VALUE_ERROR
    ZERO_DIVIDE
    OTHERS.
    15 What is a stored procedure ?
    A stored procedure is a sequence of statements that perform specific function.
    16 What is a database trigger ? Name some usages of database trigger ?
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.
    17 What is a cursor for loop ?
    Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes
    when all the records have been processed.
    eg. FOR emp_rec IN C1 LOOP
    salary_total := salary_total +emp_rec sal;
    END LOOP;
    18 What is a cursor ? Why Cursor is required ?
    Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.
    19 What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
    Mutation of table occurs.
    20 What are two virtual tables available during database trigger execution ?
    The table columns are referred as OLD.column_name and NEW.column_name.
    For triggers related to INSERT only NEW.column_name values only available.
    For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
    For triggers related to DELETE only OLD.column_name values only available.
    21 What are two parts of package ?
    The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
    Package Specification contains declarations that are global to the packages and local to the schema.
    Package Body contains actual procedures and local declaration of the procedures and cursor declarations.
    22 What are the two parts of a procedure ?
    Procedure Specification and Procedure Body.
    23 What are the return values of functions SQLCODE and SQLERRM ?
    SQLCODE returns the latest code of the error that has occurred.
    SQLERRM returns the relevant error message of the SQLCODE.
    24 What are the PL/SQL Statements used in cursor processing ?
    DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.
    25 What are the modes of parameters that can be passed to a procedure ?
    IN,OUT,IN-OUT parameters.
    26 What are the datatypes a available in PL/SQL ?
    Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
    Some composite data types such as RECORD & TABLE.
    27 What are the cursor attributes used in PL/SQL ?
    %ISOPEN - to check whether cursor is open or not
    % ROWCOUNT - number of rows fetched/updated/deleted.
    % FOUND - to check whether cursor has fetched any row. True if rows are fetched.
    % NOT FOUND - to check whether cursor has fetched any row. True if no rows are featched.
    These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.
    28 What are the components of a PL/SQL Block ?
    Declarative part, Executable part and Exception part.
    Datatypes PL/SQL
    29 What are the components of a PL/SQL block ?
    A set of related declarations and procedural statements is called block.
    30 What are advantages fo Stored Procedures /
    Extensibility,Modularity, Reusability, Maintainability and one time compilation.
    1 What is PL/SQL ?
    PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.
    2 Write the order of precedence for validation of a column in a table ?
    I. done using Database triggers.
    ii. done using Integarity Constraints.
    I & ii.
    Exception :
    3 Where the Pre_defined_exceptions are stored ?
    In the standard package.
    Procedures, Functions & Packages ;
    4 What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
    % TYPE provides the data type of a variable or a database column to that variable.
    % ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
    The advantages are : I. Need not know about variable's data type
    ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.
    5 What will happen after commit statement ?
    Cursor C1 is
    Select empno,
    ename from emp;
    Begin
    open C1; loop
    Fetch C1 into
    eno.ename;
    Exit When
    C1 %notfound;-----
    commit;
    end loop;
    end;
    The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
    The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.
    6 What is the basic structure of PL/SQL ?
    PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.
    7 What is Raise_application_error ?
    Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.
    8 What is Pragma EXECPTION_INIT ? Explain the usage ?
    The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
    e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)
    9 What is PL/SQL table ?
    Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.
    Cursors
    10 What is Overloading of procedures ?
    The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.
    e.g. DBMS_OUTPUT put_line
    What is a package ? What are the advantages of packages ?
    11 What is difference between a PROCEDURE & FUNCTION ?
    A FUNCTION is always returns a value using the return statement.
    A PROCEDURE may return one or more values through parameters or may not return at all.
    12 What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
    A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
    A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.
    13 What is difference between % ROWTYPE and TYPE RECORD ?
    % ROWTYPE is to be used whenever query returns a entire row of a table or view.
    TYPE rec RECORD is to be used whenever query returns columns of different
    table or views and variables.
    E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type
    e_rec emp% ROWTYPE
    cursor c1 is select empno,deptno from emp;
    e_rec c1 %ROWTYPE.
    14 What is an Exception ? What are types of Exception ?
    Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
    CURSOR_ALREADY_OPEN
    DUP_VAL_ON_INDEX
    NO_DATA_FOUND
    TOO_MANY_ROWS
    INVALID_CURSOR
    INVALID_NUMBER
    LOGON_DENIED
    NOT_LOGGED_ON
    PROGRAM-ERROR
    STORAGE_ERROR
    TIMEOUT_ON_RESOURCE
    VALUE_ERROR
    ZERO_DIVIDE
    OTHERS.
    15 What is a stored procedure ?
    A stored procedure is a sequence of statements that perform specific function.
    16 What is a database trigger ? Name some usages of database trigger ?
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.
    17 What is a cursor for loop ?
    Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes
    when all the records have been processed.
    eg. FOR emp_rec IN C1 LOOP
    salary_total := salary_total +emp_rec sal;
    END LOOP;
    18 What is a cursor ? Why Cursor is required ?
    Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.
    19 What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
    Mutation of table occurs.
    20 What are two virtual tables available during database trigger execution ?
    The table columns are referred as OLD.column_name and NEW.column_name.
    For triggers related to INSERT only NEW.column_name values only available.
    For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
    For triggers related to DELETE only OLD.column_name values only available.
    21 What are two parts of package ?
    The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
    Package Specification contains declarations that are global to the packages and local to the schema.
    Package Body contains actual procedures and local declaration of the procedures and cursor declarations.
    22 What are the two parts of a procedure ?
    Procedure Specification and Procedure Body.
    23 What are the return values of functions SQLCODE and SQLERRM ?
    SQLCODE returns the latest code of the error that has occurred.
    SQLERRM returns the relevant error message of the SQLCODE.
    24 What are the PL/SQL Statements used in cursor processing ?
    DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.
    25 What are the modes of parameters that can be passed to a procedure ?
    IN,OUT,IN-OUT parameters.
    26 What are the datatypes a available in PL/SQL ?
    Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
    Some composite data types such as RECORD & TABLE.
    27 What are the cursor attributes used in PL/SQL ?
    %ISOPEN - to check whether cursor is open or not
    % ROWCOUNT - number of rows fetched/updated/deleted.
    % FOUND - to check whether cursor has fetched any row. True if rows are fetched.
    % NOT FOUND - to check whether cursor has fetched any row. True if no rows are featched.
    These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.
    28 What are the components of a PL/SQL Block ?
    Declarative part, Executable part and Exception part.
    Datatypes PL/SQL
    29 What are the components of a PL/SQL block ?
    A set of related declarations and procedural statements is called block.
    30 What are advantages fo Stored Procedures /
    Extensibility,Modularity, Reusability, Maintainability and one time compilation.
    31 Name the tables where characteristics of Package, procedure and functions are stored ?
    User_objects, User_Source and User_error.
    32 Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ? Why ?
    It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.
    33 How packaged procedures and functions are called from the following?
    a. Stored procedure or anonymous block
    b. an application program such a PRC C, PRO COBOL
    c. SQL *PLUS
    a. PACKAGE NAME.PROCEDURE NAME (parameters);
    variable := PACKAGE NAME.FUNCTION NAME (arguments);
    EXEC SQL EXECUTE
    b.
    BEGIN
    PACKAGE NAME.PROCEDURE NAME (parameters)
    variable := PACKAGE NAME.FUNCTION NAME (arguments);
    END;
    END EXEC;
    c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any
    out/in-out parameters. A function can not be called.
    34 How many types of database triggers can be specified on a table ? What are they ?
    Insert Update Delete
    Before Row o.k. o.k. o.k.
    After Row o.k. o.k. o.k.
    Before Statement o.k. o.k. o.k.
    After Statement o.k. o.k. o.k.
    If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.
    If WHEN clause is specified, the trigger fires according to the returned Boolean value.
    35 Give the structure of the procedure ?
    PROCEDURE name (parameter list.....)
    is
    local variable declarations
    BEGIN
    Executable statements.
    Exception.
    exception handlers
    end;
    36 Give the structure of the function ?
    FUNCTION name (argument list .....) Return datatype is
    local variable declarations
    Begin
    executable statements
    Exception
    execution handlers
    End;
    37 Explain the usage of WHERE CURRENT OF clause in cursors ?
    WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor.
    Database Triggers
    38 Explain the two type of Cursors ?
    There are two types of cursors, Implicit Cursor and Explicit Cursor.
    PL/SQL uses Implicit Cursors for queries.
    User defined cursors are called Explicit Cursors. They can be declared and used.
    39 Explain how procedures and functions are called in a PL/SQL block ?
    Function is called as part of an expression.
    sal := calculate_sal ('a822');
    procedure is called as a PL/SQL statement
    calculate_bonus ('A822');
    Programmatic Constructs
    Last Update: September 06, 2004
    1 What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ?
    Procedures and Functions,Packages and Database Triggers.
    2 What are the differences between Database Trigger and Integrity constraints ?
    A declarative integrity constraint is a statement about the database that is always true. A constraint applies to existing data in the table and any statement that manipulates the table.
    A trigger does not apply to data loaded before the definition of the trigger, therefore, it does not guarantee all data in a table conforms to the rules established by an associated trigger.
    A trigger can be used to enforce transitional constraints where as a declarative integrity constraint cannot be used.
    3 What is difference between Procedures and Functions ?
    A Function returns a value to the caller where as a Procedure does not.
    4 What is Database Trigger ?
    A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in,update to, or delete from a table.
    5 What is a Procedure ?
    A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a specific problem or perform a set of related tasks.
    6 What is a Package ?
    A Package is a collection of related procedures, functions, variables and other package constructs together as a unit in the database.
    7 What are the uses of Database Trigger ?
    Database triggers can be used to automatic data generation, audit data modifications, enforce complex Integrity constraints, and customize complex security authorizations.
    8 What are the advantages of having a Package ?
    Increased functionality (for example,global package variables can be declared and used by any proecdure in the package) and performance (for example all objects of the package are parsed compiled, and loaded into memory once)
    1 With which function of summary item is the compute at options required?
    percentage of total functions.
    2 Why is it preferable to create a fewer no. of queries in the data model?
    Because for each query, report has to open a separate cursor and has to rebind, execute and fetch data.
    3 Why is a Where clause faster than a group filter or a format trigger?
    Because, in a where clause the condition is applied during data retrieval than after retrieving the data.
    4 Which parameter can be used to set read level consistency across multiple queries?
    Read only.
    5 Which of the two views should objects according to possession?
    view by structure.
    6 Which of the above methods is the faster method?
    performing the calculation in the query is faster.
    7 Where is the external query executed at the client or the server?
    At the server.
    8 Where is a procedure return in an external pl/sql library executed at the client or at the server?
    At the client.
    9 When do you use data parameter type?
    When the value of a data parameter being passed to a called product is always the name of the record group defined in the current form. Data parameters are used to pass data to produts invoked with the run_product built-in subprogram.
    10 When a form is invoked with call_form, Does oracle forms issues a save point?
    Yes
    11 What are the important difference between property clause and visual attributes?
    Named visual attributes differ only font, color & pattern attributes, property clauses can contain this and any other properties. You can change the appearance of objects at run time by changing the named visual attributes programmatically , property clause assignments cannot be changed programmatically. When an object is inheriting from both a property clause and named visual attribute, the named visual attribute settings take precedence, and any visual attribute properties in the class are ignored.
    12 What use of command line parameter cmd file?
    It is a command line argument that allows you to specify a file that contain a set of arguments for r20run.
    13 What is WHEN-Database-record trigger?
    Fires when oracle forms first marks a record as an insert or an update. The trigger fires as soon as oracle forms determines through validation that the record should be processed by the next post or commit as an insert or update. c generally occurs only when the operators modifies the first item in the record, and after the operator attempts to navigate out of the item.
    14 What is use of term?
    The term file which key is correspond to which oracle report functions.
    15 What is trigger associated with the timer?
    When-timer-expired.
    16 What is the use of transactional triggers?
    Using transactional triggers we can control or modify the default functionality of the oracle forms.
    17 What is the use of place holder column?
    A placeholder column is used to hold calculated values at a specified place rather than allowing is to appear in the actual row where it has to appear.
    18 What is the use of image_zoom built-in?
    To manipulate images in image items.
    19 What is the use of hidden column?
    A hidden column is used to when a column has to embed into boilerplate text.
    20 What is the use of break group?
    A break group is used to display one record for one group ones. While multiple related records in other group can be displayed.
    21 What is the remove on exit property?
    For a modelless window, it determines whether oracle forms hides the window automatically when the operators navigates to an item in the another window.
    22 What is the purpose of the product order option in the column property sheet?
    To specify the order of individual group evaluation in a cross products.
    23 What is the maximum no of chars the parameter can store?
    The maximum no of chars the parameter can store is only valid for char parameters, which can be upto 64K. No parameters default to 23Bytes and Date parameter default to 7Bytes.
    24 What is the main diff. bet. Reports 2.0 & Reports 2.5?
    Report 2.5 is object oriented.
    25 What is the frame & repeating frame?
    A frame is a holder for a group of fields. A repeating frame is used to display a set of records when the no. of records that are to displayed is not known before.
    26 What is the difference between OLE Server & Ole Container?
    An Ole server application creates ole Objects that are embedded or linked in ole Containers ex. Ole servers are ms_word & ms_excel. OLE containers provide a place to store, display and manipulate objects that are created by ole server applications. Ex. oracle forms is an example of an ole Container.
    27 What is the difference between object embedding & linking in Oracle forms?
    In Oracle forms, Embedded objects become part of the form module, and linked objects are references from a form module to a linked source file.
    28 What is the difference between boiler plat images and image items?
    Boiler plate Images are static images (Either vector or bit map) that you import from the file system or database to use a graphical elements in your form, such as company logos and maps. Image items are special types of interface controls that store and display either vector or bitmap images. Like other items that store values, image items can be either base table items(items that relate directly to database columns) or control items. The definition of an image item is stored as part of the form module FMB and FMX files, but no image file is actually associated with an image item until the item is populate at run time.
    29 What is the difference between $$DATE$$ & $$DBDATE$$ $$DBDATE$$ retrieves the current database date $$date$$ retrieves the current operating system date.
    30 What is the diff. when Flex mode is mode on and when it is off?
    When flex mode is on, reports automatically resizes the parent when the child is resized.
    31 What is the diff. when confine mode is on and when it is off?
    When confine mode is on, an object cannot be moved outside its parent in the layout.
    32 What is the diff. bet. setting up of parameters in reports 2.0 reports 2.5?
    LOVs can be attached to parameters in the reports 2.5 parameter form.
    33 What is the advantage of the library?
    Libraries provide a convenient means of storing client-side program units and sharing them among multiple applications. Once you create a library, you can attach it to any other form, menu, or library modules. When you can call library program units from triggers menu items commands and user named routine, you write in the modules to which you have attach the library. When a library attaches another library, program units in the first library can reference program units in the attached library. Library support dynamic loading-that is library program units are loaded into an application only when needed. This can significantly reduce the run-time memory requirements of applications.
    34 What is term?
    The term is terminal definition file that describes the terminal form which you are using r20run.
    35 What is system.coordination_operation?
    It represents the coordination causing event that occur on the master block in master-detail relation.
    36 What is synchronize?
    It is a terminal screen with the internal state of the form. It updates the screen display to reflect the information that oracle forms has in its internal representation of the screen.
    37 What is strip sources generate options?
    Removes the source code from the library file and generates a library files that contains only pcode. The resulting file can be used for final deployment, but can not be subsequently edited in the designer. ex. f45gen module=old_lib.pll userid=scott/tiger strip_source YES output_file
    38 What is relation between the window and canvas views?
    Canvas views are the back ground objects on which you place the interface items (Text items), check boxes, radio groups etc.,) and boilerplate objects (boxes, lines, images etc.,) that operators interact with us they run your form . Each canvas views displayed in a window.
    39 What is pop list?
    The pop list style list item appears initially as a single field (similar to a text item field). When the operator selects the list icon, a list of available choices appears.
    40 What is new_form built-in?
    When one form invokes another form by executing new_form oracle form exits the first form and releases its memory before loading the new form calling new form completely replace the first with the second. If there are changes pending in the first form, the operator will be prompted to save them before the new form is loaded.
    41 What is lexical reference? How can it be created?
    Lexical reference is place_holder for text that can be embedded in a sql statements. A lexical reference can be created using & before the column or parameter name.
    42 What is forms_DDL?
    Issues dynamic Sql statements at run time, including server side pl/SQl and DDL
    43 What is difference between open_form and call_form?
    when one form invokes another form by executing open_form the first form remains displayed, and operators can navigate between the forms as desired. when one form invokes another form by executing call_form, the called form is modal with respect to the calling form. That is, any windows that belong to the calling form are disabled, and operators cannot navigate to them until they first exit the called form.
    44 What is bind reference and how can it be created?
    Bind reference are used to replace the single value in sql, pl/sql statements a bind reference can be created using a (:) before a column or a parameter name.
    45 What is an user exit used for?
    A way in which to pass control (and possibly arguments ) form Oracle report to another Oracle products of 3 GL and then return control ( and ) back to Oracle reports.
    46 What is an OLE?
    Object Linking & Embedding provides you with the capability to integrate objects from many Ms-Windows applications into a single compound document creating integrated applications enables you to use the features form .
    47 What is an object group?
    An object group is a container for a group of objects; you define an object group when you want to package related objects, so that you copy or reference them in other modules.
    48 What is an anchoring object & what is its use?
    An anchoring object is a print condition object which used to explicitly or implicitly anchor other objects to itself.
    49 What is a User_exit?
    Calls the user exit named in the user_exit_string. Invokes a 3Gl program by name which has been properly linked into your current oracle forms executable.
    50 What is a timer?
    Timer is an "internal time clock" that you can programmatically create to perform an action each time the timer expires.
    51 What is a Text_io Package?
    It allows you to read and write information to a file in the file system.
    52 What is a text list?
    The text list style list item appears as a rectangular box which displays the fixed number of values. When the text list contains values that can not be displayed, a vertical scroll bar appears, allowing the operator to view and select undisplayed values.
    53 What is a property clause?
    A property clause is a named object that contains a list of properties and their settings. Once you create a property clause you can base other object on it. An object based on a property can inherit the setting of any property in the clause that makes sense for that object.
    54 What is a physical page ? & What is a logical page ?
    A physical page is a size of a page. That is output by the printer. The logical page is the size of one page of the actual report as seen in the Previewer.
    55 What is a library?
    A library is a collection of subprograms including user named procedures, functions and packages.
    56 What is a difference between pre-select and pre-query?
    Fires during the execute query and count query processing after oracle forms constructs the select statement to be issued, but before the statement is actually issued. The pre-query trigger fires just before oracle forms issues the select statement to the database after the operator as define the example records by entering the query criteria in enter query mode. Pre-query trigger fires before pre-select trigger.
    57 What is a combo box?
    A combo box style list item combines the features found in list and text item. Unlike the pop list or the text list style list items, the combo box style list item will both display fixed values and accept one operator entered value.
    58 What does the term panel refer to with regard to pages?
    A panel is the no. of physical pages needed to print one logical page.
    59 What are visual attributes?
    Visual attributes are the font, color, pattern proprieties that you set for form and menu objects that appear in your application interface.
    60 What are three panes that appear in the run time pl/sql interpreter?
    1.Source pane. 2. interpreter pane. 3. Navigator pane.
    Regards
    B RANGARAJAN

Maybe you are looking for