Converting application SQL code

I see that the migration workbench will convert stored procedures. Are there any tools that will help to sniff out or convert application SQL code for MS SQL into SQL supported by Oracle. I am converting from SQL Server 7 to Oracle 8i. Any help would be appreciated

Hello,
Yes it probably will return multiple rows...but I spot this:
CURSOR c_schemas IS
select owner from <table>@<db-link> where table_name = 'DDL_LOG' and num_rows > 0 order by owner;
Does that cursor return multiple rows as well? Or just one? Because if it returns more rows you'll get multiple SQL statements...
Good links?? There is APEX documentation in your installation directory...
Just try the different kinds of regions I suggested, see if it works and what fits your needs the best.
Greetings,
Roel
http://roelhartman.blogspot.com/
http://www.bloggingaboutoracle.org/
http://www.logica.com/

Similar Messages

  • How to convert pl/sql code into java/j2ee

    Hi,
    We have a PL/SQL Oracle App server application that we will support if we can convert in j2ee/java. But when i did take a look at the code, these pl/sql contains all HTML and java code inside the stored procedures.
    And iam looking to explore some tools and mechanisms that can convert these pl/sql in a JAVA application so that i can deploy this new app into my BEA81 environment.
    Does any body has any idea:
    a) How to convert from pl/sql > java ?
    b) Any plugins or tools of BEA that can run these pl/sql (the way thay are currently...i.e w/o converting) in BEA 81 container ?
    thanks, sangita

    these pl/sql contains all HTML and java code insideJava or JavaScript. They are not the same. I wouldn't expect to see Java inside html, whereas JavaScript would be intermixed. On the other hand you might have a java stored proc (Oracle 9/10) which is generating HTML.
    >
    Does any body has any idea:Refactor.
    I doubt it just has html and JavaScript/Java. So what you have is a mess that mixes several things that should have been seperate in the first place.

  • Hi all Plz convert this SQL code to ORACLE

    -- Insert Not Available Record
    set identity_insert Dim_Region on
    if not exists ( select 'x' from Dim_Region where Region_Id = 99999 and Region = '#NA#' )
    Begin
    insert into Dim_Region (Region_Id , Region , Region_Description , Process_Date ) values
    (99999 , '#NA#' , 'Not Available' , getdate())
    End
    set identity_insert Dim_Region off

    Hi,
    I am not sure what is getdate() I have assumed it to be a function which returns date.
    Hopefully this is what you want a Procedure called "identity_insert Dim_Region"
    create procedure identity_insert Dim_Region is
         cursor c_exists is
              select 'x' from Dim_Region where Region_Id = 99999 and Region = '#NA#';
        v_var char (1);
        v_date date;
    begin
         open c_exists;
         fetch c_exists into v_var;
         if c_exists%notfound then
             v_date := getdate ();
             insert into Dim_Region
                (Region_Id , Region , Region_Description , Process_Date )
             values
                (99999 , '#NA#' , 'Not Available' , v_date);
        end if;   
        close c_exists;
    end;Best Regards
    Arif Khadas

  • Plz convert this SQL code to ORALCE

    select title,
    case when right(title , 2) = 12 then cast(left(title,2) + 1 as varchar(2)) + cast('01' as varchar(2))
    else title + 1 end next_title ,
    case when right(title,2) = '01' then cast(left(title,2) - 1 as varchar(2)) + cast('12' as varchar(2))
    else title - 1 end prev_title
    from strdc_admin.st_glt_shipment
    group by title
    order by title

    Hi,
    Wouldn't it be better if you first explained what this is supposed to do:
      select title
            ,case
                when right(title, 2) = 12
                then
                   cast(left(title, 2) + 1 as varchar(2)) + cast('01' as varchar(2))
                else
                   title + 1
             end
                next_title
            ,case
                when right(title, 2) = '01'
                then
                   cast(left(title, 2) - 1 as varchar(2)) + cast('12' as varchar(2))
                else
                   title - 1
             end
                prev_title
        from strdc_admin.st_glt_shipment
    group by title
    order by titleI mean, there seems to be some confusion about data types. First you have
    when right(title, 2) = 12which indicates title is numeric.
    Later on you have
    when right(title, 2) = '01'which indicates that title is of char type.
    (My guess is that right and left are like substr with positive and negative positions)
    Next you have
    cast(left(title, 2) + 1 as varchar(2)) + cast('01' as varchar(2))First part, seems to indicate that title is numeric, but what does the second + mean. Is that concatenation?
    If not, you have some really confusing implicit type conversions.
    And why do you do this:
    cast('01' as varchar(2))'01' is already of char datatype, so why cast it?
    Please return once you have worked a little more on your question.
    Regards
    Peter

  • PL/SQL code written in db or in application...????

    Hi ,
    Which is the best...at performance , maintability... e.t.c.???
    To write PL/SQL as validation process of data values going to be inserted in db:
    1) as db trigger (before insert or update row-level trigger)
    2) in application level - in Forms10g...
    This PL/SQL code compares some pairs of data values only.... there DML statement....
    Both db server and App server are considered to be or in the same machine or in two machines very close to each other...
    Note: i use Db10g .
    Thanks...
    Sim

    It is all about moving parts. How many there are. Where they are located.
    The less moving parts, the less the complexity, the bugs - and the better the performance (less wheels to turn to crunch data), the easier the maintenance and the better the flexibility.
    Part of this is having the moving parts close to the data. Kind of obvious - what is faster? Shipping data from the db engine to a front-end application via a app server and web server? Or shipping the data from the db (SQL) engine to a PL/SQL process running as part and parcel of db instance? IPC is significantly faster than TCP/IP.
    Having the moving parts close to the data also means that it can scale with the data. Oracle is good at scalability. It is designed at its very core to be scalable. Partitions to reduce I/O. Shared Server to reduce o/s resource footprint per client session. Shared pool to re-use SQL. DB buffer to cache data. RAC to run multiple db instances for a single physical database. Etc. Etc.
    With the application moving parts being close to the data, it inherits this scalability. You can "multi-thread" application code using table pipelines. You have access to forking application code using background processes (DBMS_JOB and DBMS_SCHEDULER). You have bulk processing in order to transfer more data per SQL engine call, between the buffer cache and your application, and thus also reduce expensive context switching.
    This list goes on and on.
    All this is summarised into the following rules.
    Rule 1. Do it in SQL.
    Rule 2. Only when SQL cannot do it, use PL/SQL. (e.g. SQL is not suited for managing and controlling process flow - PL/SQL is)
    Rule 3. Only when PL/SQL cannot do it, use <insert-language-here> (e.g. PL/SQL cannot render a Windows grid on the client - but Delphi/C#//Java can).
    Also keep in mind that in the modern client-server paradigm we deal with a web architecture. Which means the client is a web browser. And this means that PL/SQL can pass the data (HTML) required by the client (web browser) to render the User Interface.
    Have a look at APEX (Oracle's Application Express) for how this works. http://apex.oracle.com
    All you need to develop web applications is APEX (a PL/SQL product suite in the database) and a web browser. Kickass stuff... :-)

  • Can I create a file using pl/sql code in application server ?

    Hi
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?
    Please help me with an example...in this regard
    Regards
    Sa

    864334 wrote:
    I wanted to create a file(any kind of file .txt .csv .exe etc..) using pl/sql code in application server?And how is this "file" to be delivered?
    Files can be created by PL/SQL code and stored in the Oracle database as CLOBs. This a fairly easy and robust process. It runs entirely in the database. It conforms to transaction processing. The "file" (as a CLOB) resides in the database and can thus be secured via database security, is part of database backups and so on.
    The basic issue is how to deliver the contents of the CLOB to the user. If via FTP, then the database can directly FTP the contents of the CLOB to the FTP server as a file. If via HTTP, the database can deliver the CLOB as a HTTP download directly to the web browser.
    If the client is Java or .Net, then the CLOB contents can be delivered via SQL or DBMS_LOB or a custom PL/SQL interface.
    In such cases, there is no need to step outside the secure and flexible database environment and create a physical o/s file in the wild (outside the controls of database security, data integrity and transaction processing). This is thus recommended and is the preference.

  • How to run an external application from PL/SQL code?

    Hi,
    I want to call an application like "Notepad" from PL/SQL code in a Windows2000 server. Is there any way to do that?
    Thanks, best regards.
    Paulo.

    declare
    r varchar(4000);
    begin
    dbms_java.set_output(10000);
    system_util.runshell('sh /ora9/runBackup.sh', r);
    dbms_output.put_line(r);
    end;
    System_util package is
    CREATE OR REPLACE PACKAGE System_Util IS
    *System: Generic
    *Package Name: System_util
    *Description: This is an open source package which holds regular used
         * methods by developers and dba's.
    *Created by:         Rae Smith
    *Created Date:       27/06/2001
    *Notes: This ia an free open source package that holds no warranty and
    * therefore no-one connected to the development of this package
    * can be made reasponsible for any outcomes by it's use.
    MODIFICATION LOG**************************************************************
    *DETAILS                                    DATE          VERS          CHANGED BY
    *===============================================================================
    *Created                                 27-06-2001     1.0           Rae Smith
         /********************************* Public Methhods ***************************************/
         --- getDir returns the first directory value held in the init.ora file
         FUNCTION getDir RETURN VARCHAR2;
         --- getPrev.. returns the prevoise day from a gievn date
         FUNCTION getPrevSat(pDate IN DATE) RETURN DATE;
         FUNCTION getPrevSun(pDate IN DATE) RETURN DATE;
         FUNCTION getPrevMon(pDate IN DATE) RETURN DATE;
         FUNCTION getPrevTue(pDate IN DATE) RETURN DATE;
         FUNCTION getPrevWed(pDate IN DATE) RETURN DATE;
         FUNCTION getPrevThu(pDate IN DATE) RETURN DATE;
         FUNCTION getPrevFri(pDate IN DATE) RETURN DATE;
         --- isNumber returns TRUE or FALSE depending on a datatype passed
         FUNCTION isNumber(pnumber IN VARCHAR2) RETURN BOOLEAN;
         FUNCTION isNumber(pnumber IN NUMBER) RETURN BOOLEAN;
         FUNCTION isNumber(pnumber IN DATE) RETURN BOOLEAN;
         --- The writeFile allow you to write data to a file
         --- writeFile has 2 Versions
         --- v1 pass in the file name and the text to write to a file.
         --- v2 pass in the file name, dbms_sql.varhar2s object
         --- and the amount of rows to procces at a time
         --- This enables you to write to afile in batch mode
         PROCEDURE writeFile(pName IN VARCHAR2, pText IN VARCHAR2);
         PROCEDURE writeFile(pName IN VARCHAR2, pText IN DBMS_SQL.VARCHAR2S, pRows IN PLS_INTEGER);
         --- The appendFile methods allow you to append data to a file
    --- This also has the inteligents to create the file if ts does not exist.
         --- appendFile has 2 Versions
         --- v1 pass in the file name and the text to write to a file.
         --- v2 pass in the file name, dbms_sql.varhar2s object
         --- and the amount of rows to procces at a time
         --- This enables you to write to afile in batch mode
         PROCEDURE appendFile(pName IN VARCHAR2, pText IN DBMS_SQL.VARCHAR2S, pRows IN PLS_INTEGER);
         PROCEDURE appendFile(pName IN VARCHAR2, pText IN VARCHAR2);
         --- The clearFile clears the data from a file.
         PROCEDURE clearFile(pName IN VARCHAR2);
         --- checkSyntax is a quick syntax checker for sql statements the is a limit to
         --- the size used in the statement. If you have a error with
         --- a statement then pass in the statement watch as it displays
         --- the point where the error arose.
         PROCEDURE checkSyntax(pSql IN VARCHAR2);
         --- isEmpty this returns TRUE or FALSE
         FUNCTION isEmpty(pValue IN VARCHAR2) RETURN BOOLEAN;
         --- getTimeInMins returns the time in minutes for a specified date
         FUNCTION getTimeInMins (pDate IN DATE) RETURN NUMBER;
         --PROCEDURE get_time_in_mins (pDate IN DATE);
         --- incDate returns a specified date incremented by value
         FUNCTION incDate(pInc IN NUMBER DEFAULT .999999, pDate IN DATE DEFAULT SYSDATE) RETURN DATE;
         --- decDate returns a specified date decremented by value
         FUNCTION decDate(pInc IN NUMBER DEFAULT .999999, pDate IN DATE DEFAULT SYSDATE) RETURN DATE;
         --- getTime returns the time in milliseconds
         FUNCTION getTime RETURN NUMBER;
         --- daysDiff returns the amount of days between two values
         FUNCTION daysDiff(pHigh IN DATE, pLow IN DATE) RETURN NUMBER;
         --- difference returns the diffeence between two numbers always
         --- taking the lowest away from the highest
         FUNCTION difference(pAnum IN NUMBER,pBnum IN NUMBER)RETURN NUMBER;
         --- total returns the value of two numbers added together
         FUNCTION total(pAnum IN NUMBER, pBnum IN NUMBER)RETURN NUMBER;
         --- numberToWords returns the string for a number passed in
         FUNCTION numberToWords(pNumb IN NUMBER) RETURN VARCHAR2;
         --- runShell allows you to run operating commands from pl/sql
         --- Only available with 8i
         --- PROCEDURE runShell(pCmnd IN VARCHAR2, pErrMsg IN OUT VARCHAR2);
         /**************************** Public Vaiables *******************************/
         --- Public variable that holds the operating system directory
         --- that the can be written to from withing the database.
         vDir VARCHAR2(50);
    END;
    CREATE OR REPLACE PACKAGE BODY System_Util IS
         FUNCTION getDir RETURN VARCHAR2
         IS
         BEGIN
              RETURN vDir;
         EXCEPTION
              WHEN OTHERS THEN
                   dbms_output.put_line('ERROR...ERROR...System_Util.getDir');
                   RAISE;
         END getDir;
         /**** Private module to get the first directory for utl_file to use ****/
         PROCEDURE getDir
         IS
              CURSOR cDir(p1 IN VARCHAR2)
              IS
              SELECT DECODE(INSTR(value, ','), 0, value, SUBSTR(value, 1, INSTR(value, ',')-1)) dir
              FROM v$parameter
              WHERE name = p1;
         BEGIN
              FOR rDir IN cDir('utl_file_dir') LOOP
                   vDir := rDir.dir;
              END LOOP;
         EXCEPTION
              WHEN OTHERS THEN
                   dbms_output.put_line('ERROR...ERROR...System_Util.getDir');
                   RAISE;
         END getDir;
         FUNCTION getPrevDate(pDate IN DATE, pDay IN VARCHAR2) RETURN DATE
         IS
         BEGIN
              RETURN NEXT_DAY(pDate - 7, pDay);
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getPrevDate;
         FUNCTION getPrevSat(pDate IN DATE) RETURN DATE
         IS
         BEGIN
              RETURN getPrevDate(pDate, 'saturday');
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getPrevSat;
         FUNCTION getPrevSun(pDate IN DATE) RETURN DATE
         IS
         BEGIN
              RETURN getPrevDate(pDate, 'sunday');
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getPrevSun;
         FUNCTION getPrevMon(pDate IN DATE) RETURN DATE
         IS
         BEGIN
              RETURN getPrevDate(pDate, 'monday');
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getPrevMon;
         FUNCTION getPrevTue(pDate IN DATE) RETURN DATE
         IS
         BEGIN
              RETURN getPrevDate(pDate, 'tuesday');
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getPrevTue;
         FUNCTION getPrevWed(pDate IN DATE) RETURN DATE
         IS
         BEGIN
              RETURN getPrevDate(pDate, 'wednesday');
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getPrevWed;
         FUNCTION getPrevThu(pDate IN DATE) RETURN DATE
         IS
         BEGIN
              RETURN getPrevDate(pDate, 'thursday');
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getPrevThu;
         FUNCTION getPrevFri(pDate IN DATE) RETURN DATE
         IS
         BEGIN
              RETURN getPrevDate(pDate, 'friday');
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getPrevFri;
         FUNCTION isNumber(pNumber IN VARCHAR2) RETURN BOOLEAN
         IS
         BEGIN
              IF TO_NUMBER(pNumber)> 0 THEN
                   RETURN TRUE;
              ELSE
                   RETURN FALSE;
              END IF;
         EXCEPTION
              WHEN OTHERS THEN
                   RETURN FALSE;
         END isNumber;
         FUNCTION isNumber(pNumber IN NUMBER) RETURN BOOLEAN
         IS
         BEGIN
              IF TO_NUMBER(pNumber) > 0 THEN
                   RETURN TRUE;
              ELSE
                   RETURN FALSE;
              END IF;
         EXCEPTION
              WHEN OTHERS THEN
              RETURN FALSE;
         END isNumber;
         FUNCTION isNumber(pNumber IN DATE) RETURN BOOLEAN
         IS
         BEGIN
              IF TO_NUMBER(TO_CHAR(pNumber, 'YYYYMMDD')) > 0 THEN
                   RETURN TRUE;
              ELSE
                   RETURN FALSE;
              END IF;
         EXCEPTION
              WHEN OTHERS THEN
                   RETURN FALSE;
         END isNumber;
         PROCEDURE writeFile(pName IN VARCHAR2, pText IN VARCHAR2)
         IS
              vFtype utl_file.file_type;
         BEGIN
              vFtype := UTL_FILE.FOPEN(vDir, pName,'w');
              UTL_FILE.PUT_LINE(vFtype,pText);
              UTL_FILE.FCLOSE(vFtype);
         EXCEPTION
              WHEN OTHERS THEN
                   UTL_FILE.FCLOSE(vFtype);
                   RAISE;
         END writeFile;
         PROCEDURE writeFile(pName IN VARCHAR2, pText IN VARCHAR2, pFtyp IN OUT utl_file.file_type)
         IS
              vFtype utl_file.file_type;
         BEGIN
              vFtype := UTL_FILE.FOPEN(vDir, pName,'w');
              UTL_FILE.PUT_LINE(vFtype,pText);
              UTL_FILE.FCLOSE(vFtype);
         EXCEPTION
              WHEN OTHERS THEN
                   UTL_FILE.FCLOSE(vFtype);
                   RAISE;
         END writeFile;
         PROCEDURE writeFile(pName IN VARCHAR2, pText IN DBMS_SQL.VARCHAR2S, pRows IN PLS_INTEGER)
         IS
              vFtype utl_file.file_type;
              vText VARCHAR2(2000);
              vCnt BINARY_INTEGER;
              vRem BINARY_INTEGER;
              vRowcnt PLS_INTEGER := 0;
         BEGIN
              vRem := MOD(pText.COUNT, pRows);
              vFtype := UTL_FILE.FOPEN(vDir, pName, 'w');
              vCnt := pText.FIRST;
              LOOP
                   EXIT WHEN vCnt IS NULL;
              vRowcnt := vRowcnt + 1;
                   IF vCnt = pText.LAST THEN
                        vText := vText||pText(vCnt);
                        UTL_FILE.PUTF(vFtype,vText);
                        UTL_FILE.FFLUSH(vFtype);
                        vText := '';
                   ELSIF MOD(vCnt, pRows) = 0 THEN
                        vText := vText||pText(vCnt)||'\n';
                        UTL_FILE.PUTF(vFtype,vText);
                        UTL_FILE.FFLUSH(vFtype);
                        vText := '';
                   ELSIF vRowcnt = vRem THEN
                        vText := vText||pText(vCnt)||'\n';
                        UTL_FILE.PUTF(vFtype,vText);
                        UTL_FILE.FFLUSH(vFtype);
                   ELSE
                        vText := vText||pText(vCnt)||'\n';
                   END IF;
                   vCnt := pText.NEXT(vCnt);
              END LOOP;
              UTL_FILE.FCLOSE(vFtype);
         EXCEPTION
              WHEN OTHERS THEN
                   dbms_output.put_line('ERROR...ERROR...SYSTEM_UTIL.WRITE_FILE');
                   UTL_FILE.FCLOSE(vFtype);
                   RAISE;
         END writeFile;
         PROCEDURE appendFile(pName IN VARCHAR2, pText IN DBMS_SQL.VARCHAR2S, pRows IN PLS_INTEGER)
         IS
              vFtype utl_file.file_type;
              vText VARCHAR2(2000);
              vCnt BINARY_INTEGER;
              vRem BINARY_INTEGER;
              vMode VARCHAR2(2) := 'a';
              vRowcnt PLS_INTEGER := 0;
         BEGIN
              vRem := MOD(pText.COUNT, pRows);
              vFtype := UTL_FILE.FOPEN(vDir, pName, vMode);
              vCnt := pText.FIRST;
              LOOP
                   EXIT WHEN vCnt IS NULL;
                   vRowcnt := vRowcnt + 1;
                   IF vCnt = pText.LAST THEN
                        vText := vText||pText(vCnt);
                        UTL_FILE.PUTF(vFtype,vText);
                        UTL_FILE.FFLUSH(vFtype);
                        vText := '';
                   ELSIF MOD(vCnt, pRows) = 0 THEN
                        vText := vText||pText(vCnt)||'\n';
                        UTL_FILE.PUTF(vFtype,vText);
                        UTL_FILE.FFLUSH(vFtype);
                        vText := '';
                   ELSIF vRowcnt = vRem THEN
                        vText := vText||pText(vCnt)||'\n';
                        UTL_FILE.PUTF(vFtype,vText);
                        UTL_FILE.FFLUSH(vFtype);
                   ELSE
                        vText := vText||pText(vCnt)||'\n';
                   END IF;
                   vCnt := pText.NEXT(vCnt);
              END LOOP;
                   UTL_FILE.FCLOSE(vFtype);
         EXCEPTION
              WHEN UTL_FILE.INVALID_OPERATION THEN
                   IF vMode = 'a' THEN
                        writeFile(pName, pText, pRows);
                   ELSE
                        RAISE;
              END IF;
         WHEN OTHERS THEN
              dbms_output.put_line('ERROR...ERROR...SYSTEM_UTIL.APPENDFILE');
              UTL_FILE.FCLOSE(vFtype);
              RAISE;
         END appendFile;
         PROCEDURE appendFile(pName IN VARCHAR2, pText IN VARCHAR2)
         IS
              vFtype utl_file.file_type;
              vMode VARCHAR2(2) := 'a';
         BEGIN
              vFtype := UTL_FILE.FOPEN(vDir, pName, vMode);
              UTL_FILE.PUTF(vFtype, pText);
              UTL_FILE.FFLUSH(vFtype);
              UTL_FILE.FCLOSE(vFtype);
         EXCEPTION
         WHEN UTL_FILE.INVALID_OPERATION THEN
         IF vMode = 'a' THEN
              writeFile(pName, pText);
         ELSE
              RAISE;
         END IF;
         WHEN OTHERS THEN
              dbms_output.put_line('ERROR...ERROR...SYSTEM_UTIL.APPENDFILE');
              UTL_FILE.FCLOSE(vftype);
              RAISE;
         END appendFile;
         PROCEDURE clearFile(pName IN VARCHAR2)
         IS
              vFtype utl_file.file_type;
              vText VARCHAR2(2000);
              vCnt BINARY_INTEGER;
              vRem BINARY_INTEGER;
              vRowcnt PLS_INTEGER := 0;
         BEGIN
              vFtype := UTL_FILE.FOPEN(vDir, pName, 'w');
              UTL_FILE.PUTF(vFtype,'');
              UTL_FILE.FFLUSH(vFtype);
              UTL_FILE.FCLOSE(vFtype);
         EXCEPTION
         WHEN OTHERS THEN
         dbms_output.put_line('ERROR...ERROR...System_Util.CLEARFILE');
         UTL_FILE.FCLOSE(vFtype);
         RAISE;
         END clearFile;
         PROCEDURE checkSyntax(pSql IN VARCHAR2)
         IS
         sqlCur PLS_INTEGER := DBMS_SQL.OPEN_CURSOR;
         errPos PLS_INTEGER;
         sqlStmt VARCHAR2(2000);
         BEGIN
              sqlStmt := pSql;
              DBMS_SQL.PARSE(sqlCur, sqlStmt, DBMS_SQL.NATIVE);
         EXCEPTION
              WHEN OTHERS THEN
                   errPos := DBMS_SQL.LAST_ERROR_POSITION;
                   DBMS_OUTPUT.PUT_LINE(SQLERRM);
                   DBMS_OUTPUT.PUT_LINE(sqlStmt);
                   DBMS_OUTPUT.PUT_LINE(' ');
                   DBMS_OUTPUT.PUT_LINE(LPAD('^', errPos, '-'));
                   DBMS_SQL.CLOSE_CURSOR(sqlCur);
         END checkSyntax;
         FUNCTION isEmpty(pValue IN VARCHAR2) RETURN BOOLEAN
         IS
         BEGIN
              IF pValue IS NULL OR pValue = '' OR pValue = ' ' THEN
                   RETURN TRUE;
              ELSE
                   RETURN FALSE;
              END IF;
         END isEmpty;
         FUNCTION getTimeInMins (pDate IN DATE) RETURN NUMBER
         IS
              vHours NUMBER;
              vMins NUMBER;
              vRetval PLS_INTEGER;
         BEGIN
              vHours := TO_NUMBER(TO_CHAR(pDate,'HH24'));
              vMins := TO_NUMBER(TO_CHAR(pDate,'MI'));
              vRetval := ((60 * vHours) + vMins);
              RETURN vRetval;
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getTimeInMins;
         PROCEDURE getTimeInMins (pDate IN DATE)
         IS
              vHours NUMBER;
              vMins NUMBER;
              vRetval PLS_INTEGER;
         BEGIN
              vHours := TO_NUMBER(TO_CHAR(pDate,'HH24'));
              vMins := TO_NUMBER(TO_CHAR(pDate,'MI'));
              vRetval := ((60 * vHours) + vMins);
              DBMS_OUTPUT.PUT_LINE('The time IN minutes IS: '||vRetval);
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END getTimeInMins;
         FUNCTION incDate(pInc IN NUMBER DEFAULT .999999, pDate IN DATE DEFAULT SYSDATE) RETURN DATE
         IS
         BEGIN
         RETURN (TO_DATE(TO_CHAR(pDate + pInc, 'DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YYYY HH24:MI:SS'));
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END incDate;
         FUNCTION decDate(pInc IN NUMBER DEFAULT .999999, pDate IN DATE DEFAULT SYSDATE) RETURN DATE
         IS
         BEGIN
         RETURN (TO_DATE(TO_CHAR(pDate - pInc, 'DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YYYY HH24:MI:SS'));
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END decDate;
         FUNCTION getTime RETURN NUMBER
         IS
         BEGIN
              RETURN dbms_utility.get_time;
         END getTime;
         FUNCTION daysDiff(pHigh IN DATE, pLow IN DATE) RETURN NUMBER
         IS
              vHighdate DATE;
              vLowdate DATE;
         BEGIN
         IF pHigh > pLow THEN
                   vHighdate := TO_DATE(TO_CHAR(pHigh, 'YYYYMMDD'), 'YYYYMMDD');
                   vLowdate := TO_DATE(TO_CHAR(pLow, 'YYYYMMDD'), 'YYYYMMDD');
         ELSIF pLow > pHigh THEN
                   vHighdate := TO_DATE(TO_CHAR(pLow, 'YYYYMMDD'), 'YYYYMMDD');
                   vLowdate := TO_DATE(TO_CHAR(pHigh, 'YYYYMMDD'), 'YYYYMMDD');
         END IF;
              RETURN (vHighdate - vLowdate);
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END daysDiff;
         PROCEDURE dateCheck(pDateFrom IN OUT DATE, pDateTo IN OUT DATE)
         IS
              /* Declare the variable to hold the "from" date */
              vDateFrom DATE;
         BEGIN
              /* If either date_from or date_to is null then set to todays date **
              ** using the sysdate **
              ** today's DATE AND IN the correct format */
              pDateFrom := NVL(pDateFrom, SYSDATE);
              pDateTo := NVL(pDateTo, SYSDATE);
              /* Check that the from date is not greater than the to date if so **
              ** use the system_util.incDate to Increment the date by 1 day */
              IF (pDateFrom > pDateTo) THEN
              vDateFrom := pDateFrom;
              pDateTo := System_Util.incDate(1, vDateFrom);
              END IF;
         EXCEPTION
              WHEN OTHERS THEN
              RAISE;
         END;
         /* calculates the difference of two numbers always taken the high from the low*/
         FUNCTION difference(pAnum IN NUMBER, pBnum IN NUMBER)RETURN NUMBER
         IS
              vTotal NUMBER;
         BEGIN
              IF (pAnum > pBnum )OR (pAnum = pBnum)THEN
                   vTotal := (pAnum - pBnum);
              ELSIF (pAnum < pBnum) THEN
                   vTotal := (pBnum - pAnum);
              END IF;
              RETURN (vTotal);
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END difference;
         /* calculates the Total of two numbers*/
         FUNCTION total(pAnum IN NUMBER, pBnum IN NUMBER)RETURN NUMBER
         IS
              vTotal NUMBER;
         BEGIN
              vTotal := (pAnum + pBnum);
         RETURN (vTotal);
         EXCEPTION
              WHEN OTHERS THEN
                   RAISE;
         END total;
         FUNCTION numberToWords(pNumb IN NUMBER) RETURN VARCHAR2
         IS
              vRetval VARCHAR2(255);
              vNumb PLS_INTEGER;
         BEGIN
              vNumb := pNumb;
              vRetval := REPLACE(TO_CHAR(TO_DATE(vNumb,'j'),'jsp'),'-',' ');
              RETURN (vRetval);
         EXCEPTION
              WHEN OTHERS THEN
              RAISE;
         END;
    /*************** Only Available on 8i ********************************\
         FUNCTION Catcherr(pStr IN VARCHAR2) RETURN VARCHAR2
         IS
              LANGUAGE JAVA
              NAME 'catchErr.run(java.lang.String) return String';
         PROCEDURE runShell(pCmnd IN VARCHAR2, pErrMsg IN OUT VARCHAR2)
         IS
         BEGIN
              pErrMsg := Catcherr(pCmnd);
         EXCEPTION
         WHEN OTHERS THEN
              RAISE;
         END runShell;
    BEGIN
    getDir;
    END;

  • Pls convert this piece of SQL code to oracle

    Following is the SQL code----
    Update reg_dim
    set reg_dim.Region_Description = st_reg.Region_Desc ,
    reg_dim.Process_Date = sysdate
    from st_glt_region st_reg
    left join
    Dim_Region reg_dim
    on st_reg.Region_Abbreviation = reg_dim.Region
    where reg_dim.Region is not null
    I have tried this in oracle -----
    update Dim_region_test set Dim_region_test.REGION_DESCRIPTION = (select st_glt_region.Region_Desc
    from st_glt_region left join Dim_region_test
    on Dim_region_test.Region=st_glt_region.Region_Abbreviation where Dim_region_test.Region not in null)
    group by st_glt_region.Region_Desc;
    This is executing but in Dim_region_test, REGION_DESCRIPTION column is empty
    Pls help me..................

    Something like this?
    UPDATE reg_dim
       SET reg_dim.region_description = st_reg.region_desc,
           reg_dim.process_date = (SELECT SYSDATE
                                     FROM st_glt_region st_reg LEFT JOIN dim_region reg_dim
                                             ON st_reg.region_abbreviation = reg_dim.region
                                    WHERE reg_dim.region IS NOT NULL);*009*

  • Convert PL/SQL block returning html to a plugin - render function

    I have a PL/SQL region that uses htp.p('...') to output HTML. It's dynamic in that it uses a page value to call data from the database. I'd like this region to appear on every page in my application, but also to have the ability to update it once rather than having to update a copy on every page.
    From my limited understanding of ApEx the best way to achieve this is to convert my PL/SQL region to a Plugin. I've copied my PL/SQL code into the plugin's source and set the plugin's type to "region" but when I try to load a page that I've added it to, it displays the error "No render function has been defined for plug-in [PLUGIN NAME]".
    How do I define a render function? Or is there a better way to achieve what I'm after?

    Hi 925454,
    have a look at the "Render Function Name" attribute in the region "Callbacks" of your plug-in definition. You just have to specify the name of the function you used in the plug-in source.
    Regards
    Patrick
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Converting MS SQL Server Query to Oracle Query

    Hi There,
    I've a strange problem. My project uses both MS SQL Server and Oracle server at run time. I've lot of queries which are written in MS SQL Style. Now, iam planning to write a helper class whic converts MS SQL Query to Oracle Query. Please Help me if any one has that kind of Helper with you.
    Thanks And Regards,
    Sasi Kanth

    That is why persistence applications like Hibernate or
    CMP get used for apps that will use more than one DB,
    but it takes upfront planning.
    If you have a set of automated unit tests that work
    with SQL Server, they will be a big help in getting
    your Oracle code up and running.Indeed - JUnit and Ant would be a big help here.
    It sounds like you have SQL in your JSPs, that will
    work against you as well if so. If you are using a
    DAO pattern, this will be much easier, as you can
    re-implement each DAO for Oracle.If you'd layered this app properly, you might just implement an OracleDAOFactory and be done with it. Interfaces and a DAO layer would go a long way.
    This is why layering is such a good idea. It isolates changes in a smaller subset of classes.
    But your problem sounds pretty big. It'd be daunting even if it were well designed.

  • How to 100% Protect PL/SQL Code By Wrapped in Oracle Database 10g R2

    Hello,
    Is Possible to 100% Protect PL/SQL Code By Wrapped in Oracle 10g R2 ?
    If it is not possible by wrap in oracle 10g R2,
    Please, let me suggest, how i will be able to 100% protect PL/SQL code in Oracle Database 10g R2.
    Because, I have lot of functions, procedures & package's in my project.
    Which is running in field filed.
    So, i have needed to protect 100%.
    Also, will i convert to al functions, procedures & package's to .pll file ?
    And .pll file to .plx file?
    Is it possible to convert .plx file to .pll file ?
    Please, let know any better solutions in this case....
    Regards
    Mehedi

    Hello,
    No, wrapping is not a 100% secure method. It could prevent your code from amateurs, but not from professional hackers. Look at the article http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/wrap.htm#BEHGBJAA
    It says: "•Wrapping is not a secure method for hiding passwords or table names.
    Wrapping a PL/SQL unit prevents most users from examining the source code, but might not stop all of them."
    Edited by: apiminov on 03.12.2012 3:23
    Edited by: apiminov on 03.12.2012 3:24

  • Can I have a PL/SQL code for LOV

    Hi,
    I apologize for this dumb question. I have been so out of touch with dev (almost 8 years). Plus new to pl/sql.
    I am creating a status report application. On the dashboard, I currently have some metrics (horizontal charts). I wanted to expose these metrics based on filter.
    I had created 2 filters. The first one will identify the type (Week, Month, Qtr or Year) and the 2nd filter would be based on the type. For e.g. if I select Month as type, the 2nd filter should show May-12, April-12 etc. Once I select the 2nd filter, I should use them to show the appropriate metrics. The metric that I currently have would show all the projects that users have worked on during the week/month/qtr or year (depending on the 1st and 2nd filter).
    On the dashboard region, I added a condition to check if the value for both 1st and 2nd filter is not null. This allows me to show the dashboard only if the 2 filters have been selected.
    For the 2nd filter, I need to write a PL/SQL code to show the LOV.
    I am assuming that the pl/sql would return a SQL query. The SQL query will be based on week, month etc. Is that right?
    Thanks
    balaji
    Edited by: user644868 on May 17, 2012 11:29 AM

    rbalaji2026 wrote:
    For the 2nd filter, I need to write a PL/SQL code to show the LOV. Doesn't appear necessary. With filter 2 cascading from filter 1, why not:
    select
            /* Week query */
    from
    where
    and     :p1_filter_1 = 'WEEK'       
    union all
    select
            /* Month query */
    from
    where
    and     :p1_filter_1 = 'MONTH'       
    union all
    select
            /* Quarter query */
    from
    where
    and     :p1_filter_1 = 'QUARTER'       
    union all
    select
            /* Year query */
    from
    where
    and     :p1_filter_1 = 'YEAR'       

  • APEX,PDF's, BI Publisher and SQL Query returning SQL code..

    I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
    I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
    Here is my dilemma:
    I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
    The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
    I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
    An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
    Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
    Thank you,
    Tony Miller
    UTMB/EHN
    Title adjusted to allow people to know what I am talking about...
    Message was edited by:
    Tony Miller

    Tony,
    You can find the log as follows:
    - go to http://[yourserver]:[yourport]/em
    - logon to OC4J EM: oc4jadmin/[yourpassword]
    - click on "logs" at the bottom of the page
    - in the hgrid/tree, expand OC4J->home->Application
    xmlpserver
    - click on view log icon
    You can also observe what's going on in BI Publisher
    by going to the command prompt from where you started
    it.
    Or, as a third option, you can locate the file on
    your file system, depending on your setup, the path
    would be something similar to this:
    \oracle\product\10.2.0\bip\j2ee\home\application-deplo
    yments\xmlpserver\application.log
    With that said though, I don't expect you'll find
    much in there that would help with your particular
    problem. I suspect you either get no rows in your XML
    at runtime, due to some session state issues, or your
    XML structure does in fact not match your RTF
    template.
    I'm not quite following your problem description,
    i.e. when did you do what and are you associating
    your report layout with a report query or report
    region. So just some general notes, your query needs
    to be parseable at design-time, when exporting the
    XML, so that you get the XML file with the proper
    column names derived from your query. If you want to
    use your RTF template with a standard report region,
    you must export the XML file first using the advanced
    XML structure option. And of course the column names
    in your report query need to match the column names
    in your report region.
    Perhaps this helps you further diagnose what's going
    on, if you have additional information that could
    help, let me know. And if you could stage this on
    apex.oracle.com, I'd be happy to take a look.
    Regards,
    MarcMarc,
    Thanks for looking at this issue. Below find my remarks to your questions..
    Re: your query needs
    to be parseable at design-time, when exporting the
    XML, so that you get the XML file with the proper
    column names derived from your query.At the start of this process, the query code was a function in a package. The function was returning an SQL select statement, for a report region on a page. I took the select statement, built an application query to build a sample of the xml for BI Publisher desktop (Add-on for Word). The code was producing the usual Col01, Col02.. since at design time that is were the column names.
    When I then took the xml from this and built the rtf for loading into my APEX application.
    When testing the Application Query with this RTF report layout, I am getting PDF's. When using it with the report region sending an xml feed to BI Publisher I am getting nothing back.
    I have since taken the sql code and moved it back into the report region, and set the region to have a type of straight SQL Query. I have even tried to hard-code the parameters I was getting from the page to limit data returned.
    Is it possible to see the xml being produced by the APEX page?
    Re: Stage this on apex.oracle.com.. I would love to, but we would have HIPPA issues if I posted the data on a public website.
    Can I send you the RTF file and the xml file that the application query is creating to see if there something weird about them?
    Thank you,
    Tony Miller
    UTMB/EHN

  • How to use new sequence when one is reached its maxvalue in PL SQL code

    Hi,
    Currently, I am populating a unique product serial number in a table column using a sequence call to generate new number. For different products, I have different sequences and in my PL SQL code usiing IF..Else block I populate serial number for different products. For one most selling product sequence, we are reaching a Max value in production in a month and to make sure that application will continue to work fine for various end users without getting any error on their screens, I want my code to switch to new sequence automatically. I just need to add another if condition but my problem is how to find accurately when max value is reached for old sequence.
    As call to old sequence can happen in different sessions there could be inconsistency and can end up at error. My new sequence value has to start with AV1000. Please suggest.
    My old sequence look like this :
    SEQUENCE Prd
    INCREMENT BY 1
    START WITH AS1000
    MAXVALUE AS9999
    MINVALUE AS1000
    CYCLE NOCYCLE
    CACHE 2
    Order Yes;
    Edited by: user11695088 on Jul 15, 2009 12:14 AM

    Catch the exception and use your new sequence. But somehow, I'm not liking your alternative approach.
    SQL> set line 300
    SQL> set pages 50000
    SQL> set serveroutput on
    SQL> create sequence testing_seq increment by 1 start with 1 maxvalue 3
      2  /
    Sequence created.
    SQL>
    SQL> create or replace procedure test_seq_proc(p_seq out number)
      2  is
      3  begin
      4     select testing_seq.nextval
      5     into p_seq
      6     from dual;
      7  --
      8     dbms_output.put_line(p_seq);
      9  --
    10  end;
    11  /
    Procedure created.
    SQL> declare v_out number;
      2  begin
      3     test_seq_proc(v_out);
      4  end;
      5  /
    1
    PL/SQL procedure successfully completed.
    SQL> /
    2
    PL/SQL procedure successfully completed.
    SQL> /
    3
    PL/SQL procedure successfully completed.
    SQL> /
    declare v_out number;
    ERROR at line 1:
    ORA-08004: sequence TESTING_SEQ.NEXTVAL exceeds MAXVALUE and cannot be instantiated
    ORA-06512: at "ETL_ADMIN.TEST_SEQ_PROC", line 4
    ORA-06512: at line 3
    SQL>Cheers
    Sarma.

  • How to insert sql code in module (not form) other than API?

    I generated module as web pl/sql in Oracle Design Editor 6i. I have different user types with different privileges. I want to do some permission checking before a user can reach the tables. All the help are related to API and Form. Is there a way to execute sql code with out using API?

    Yes, you can add in your own user defined PL/SQL (and JavaScript)at module component and item level. Select the module component in the Design Editor and expand the node until you see "Application Logic" -> Events. Now add your logic. For help on this use the context sensitive help and you should find the PL/SQL help. (or try the topic "About user-defined application logic and Web PL/SQL Generator"
    (Is this the piece you wanted to avoid?) You can also add user defined PL/SQL to the Table API generated code. For this you need to use the Server Model tab. Navigate to the Table and expand the node for the desired table and find the Table TAPI/trigger Logic section. Again, make use of the context sensitive help here.
    Regards
    Sue

Maybe you are looking for

  • I got an ipod touch from my friend, but can't figure out how to change the apple id to get games. Help?

    I got an ipod touch from my friend, but can't figure out how to change the apple id to get games. Help?

  • Muse content moves to bottom in browser, and it's not a footer issue.

    Items I've added to a left column seem to move down the page to below a tabbed box widget in the right hand column. It's leaving a huge blank space in the middle of the page. When I view the source on business catalyst, it looks like the problem left

  • Songs not counting PlayCount

    Since installing iTunes 7, I have noticed some of my songs play all the way through, but do not count it as a play. I have a smart playlist based on last played date for easy finding of music I haven't listened to in a while. However, sometimes songs

  • Problems sharing disks using OpenFiler.

    Hi There I am following below link to prepare shared disks between two Oracle VM Nodes. After creating rules files "/etc/udev/rules.d/55-openiscsi.rules" and "/etc/udev/scripts/iscsidev.sh". I have restarted the Service but i do not see iscsi directo

  • Word: Mac 2011 to PDF problems

    Hi, I am preparing a dissertation in Word: Mac 2011 and must convert the file to a PDF for my submission process.  When I save the document as a PDF, the result is multiple PDFs, which is okay as I know how to recombine them; however, the top or left