Create Procedure - How to Detect Compilation Errors

Hi,
I am working on an application where users will be able to type in their own stored procedures. I perform some basic parsing of the function spec, to make sure it is well-formed, but that's all the parsing I do. I assumed an SQLException would be thrown by the executeUpdate() call which creates the procedure if the procedure is malformed. This is not the case. executeUpdate() returns 0, whether or not the procedure was created with compilation errors.
After they type it in, I would like to be able to tell the user whether or not their procedure is syntactically correct. Given that writing a complete PL/SQL parser in Java is obviously out of the question, how can I do this? There must be a way.
Thanks in advance for any and all help,
James

Note that there is a USER_ERRORS table.
You could DELETE FROM USER_ERRORS before issuing the procedure declaration and then SELECT ... FROM USER_ERRORS to see if errors have occured and if so to print them out.

Similar Messages

  • How to suppress compiler errors without excluding database objects from the "Schema Compare" tool (using VS2013/SSDT)

    Hi,
    In short: How to suppress compiler errors without excluding the object from the "Schema Compare" tool ??
    A bit longer:
    We have a SQL Server 2008 project in Visual Studio 2013 running SQL Server Data Tool.
    An old database, with a lot of history in, has been imported into SSDT and there are many syntax errors preventing the project from compiling/running. An typical error is: "SQL70001: This statement is not recognized in this context".
    Running the "faulty" scripts on the server, executes just fine. I understand that there are syntax errors and they should be rewritten, but it's not gonna happen just like that - it is a slow process over a long period of time.
    I know it is possible to change Build Action to None, but that also exclude the object from appearing in the Schema Compare function/window.
    So - how to ignore some compiler errors and still having the objects to appear when doing "Schema Compare" ??
    Thank you in advance.

    Hi Steven,
    Thanks for your comments.
    Well, it sure does help in the future, but right now i would prefer the other way - to suppress some errors and still allow the scripts to build.
    The thing is that if we "rewrite" the objects into create scripts, then we have a huge test job ahead of us + the database environments (PROD vs DEV and UAT) does not share the same AD or DB users and therefore grants is lost if dropping/creating
    objects, right!
    If you drop a object before creating it, the drop will also drop the roles and grants and since they don't share user table, the create will not be able to add the permissions again. There might be a solution to that, but it is going to be very complicated
    for some newbies like us. We need something we can trust.
    BR
    Peter

  • With create procedure, How to clear Shared pool

    Hi, I have a sql script file it contains
    more than 300,000 line code, I use this file
    to create procedure in the Oracle.
    When I execute this sql script file, I receive a error message " out of cursor". I know when I create procedure, the procedure's code is stores in the shared pool. So when the code is stores out of shared pool's size, I receive that error.
    But how can I clear shared pool? With commit statement, it won't be use.
    Thanks a lot.

    you may try:
    alter system flush shared_pool;
    null

  • How to detect an error from ajax get

    Hi -- This is in a javascript function.
    I have an object ajaxRequest defined as:
    ajaxRequest = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=LOOKUP_VALUE',0);
    I call the app process as follows:
    ajaxResponse = ajaxRequest.get();
    The app process just looks up a value in the DB based on another. It works fine
    when there's a match. When there's not a match, I can see that the ajaxResponse
    contains "sqlerrm: ORA- ... ". And of course a json.parse fails.
    How can I detect that the get returned an error? I can't just search
    ajaxResponse for an string, right? (It doesn't appear that that object is
    simply treated as a string... )
    Thanks,
    Carol

    hi John -- Sounds good, but I guess I'm not sure how to go about it.
    LOOKUP_VALUE is:
    DECLARE
    -- Set wwv_flow.g_x01, g_x02, g_x03, g_x04 and g_x05 in the
    -- javascript part
    p_source_item_value varchar2(1000) := wwv_flow.g_x01;
    d_source_column_name varchar2(32) := wwv_flow.g_x02;
    d_dest_column_name varchar2(32) := wwv_flow.g_x04;
    d_lookup_table_name varchar2(32) := wwv_flow.g_x05;
    BEGIN
    --Use this to get a JSON string back in the javascript,
    -- based on the SQL query
    APEX_UTIL.JSON_FROM_SQL('SELECT '||d_dest_column_name||' RETURN_VAL FROM '||d_lookup_table_name||'@'||:DB_NAME||' WHERE '||d_source_column_name||' = '''|| p_source_item_value||'''');
    END;
    So, it's returning this JSON object to the javascript. As I said, it works fine when there's a match.
    I'm not sure how to catch an error in the LOOKUP_VALUE process and get it back to the javascript. Ideas?
    Also, even if I do get that going, I'm not sure how to check the returned object for some sort of problem.
    The javascript function code is below. Look for #### for my comments. Essentially, right now, if
    there is an error in the json object (it's showing up as a numeric or value error), the parse fails. So I
    need to detect the problem before the parse. OR, if I can just modify LOOKUP_VALUE to plug in
    something like 'NO MATCH' when there's a problem or no value is found, then I think json.parse will work
    and my page item can just be set to NO MATCH. Does this make sense?
    Here's the function.
    Thanks for your help!
    Carol
    function jsLookupValue(source_item_value, source_column_name, dest_item_name, dest_column_name, lookup_table_name){
    // Continue only if there are valid values
    if (valueOf(source_column_name)&&valueOf(dest_item_name)&&valueOf(dest_column_name)&&valueOf(lookup_table_name)){
    //Check to see if the source_item_value is null (either all spaces or empty
    //If it is, set the dest item to null, but only if it's not already --
    //otherwise we get into a loop.
    source_item_value = trim(source_item_value);
    dest_item_value = trim($v(dest_item_name));
    if (source_item_value.length==0) {
    if (dest_item_value.length != 0) {
    $s(dest_item_name, null);
    }else{
    //This is the AJAX call to the Application Process from step 1
    ajaxRequest = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=LOOKUP_VALUE',0);
    //Here we are adding that x01 parameter we use in the app process with the value of the objecttype_name field
    ajaxRequest.addParam('x01', source_item_value);
    ajaxRequest.addParam('x02', source_column_name);
    ajaxRequest.addParam('x03', dest_item_name);
    ajaxRequest.addParam('x04', dest_column_name);
    ajaxRequest.addParam('x05', lookup_table_name);
    //Now do the actual AJAX call and put the result in ajaxResponse
    ajaxResponse = ajaxRequest.get();
    //Check if there is a response
    if (ajaxResponse) {
    // ######### When there's no row matching the query, this alert shows
    // "sqlerrm: ORA-06502 PL/SQL: numeric or value error"
    // Can I somehow check ajaxResponse for that string?
    alert("Response from APP process: " + ajaxResponse);
    //We need to format the JSON return string and put it in a JSON object
    // the formatting is done by a function in the external JSON library
    // the jsonobj can be used to retrieve the data returned by the App process
    // ######### If there was an error, the parse fails
    var jsonobj= ajaxResponse.parseJSON();
    alert('Filtered returned value from APP process: ' + jsonobj.row[0].RETURN_VAL);
    // And finally, we set the DNAME item with the value of the jsonobj.DNAME
    // an array was created in the object with the name row, so that is why you have to include row[0] to retrieve the data
    if (jsonobj.row[0].RETURN_VAL != $v(dest_item_name)) {
    // ########## I'd like to just set the destination item w/ something like "NO MATCH"
    // probably regardless of the error...
    $s(dest_item_name, jsonobj.row[0].RETURN_VAL);
    }else{
    //alert ('NOT setting dest item');
    } //not setting
    }else{
    alert('No response from app process');
    } //no response
    } //no source item value
    } //no bad nulls
    } //function

  • How to Resize Compiler Error panel

    OK, this question seems so basic that I'm embarrassed to be
    asking it. And yet, I can't figure it out, and it's driving me
    crazy. When I run a check on my ActionScript, the Compiler Error
    panel opens up and displays the errors in my code. So far so good.
    But even if I have just one measly line of error messages,
    the window opens up large enough to fill my screen, covering up
    other panels. I want to resize it, but there's no visible resize
    "grab bar" (I don't know the real name for that little triangle of
    dots) in the bottom right corner of the panel (all my other panels
    have this).
    If I hover my cursor over the right edge of the panel, I get
    the double-arrow cursor indicating that I can make the panel
    narrower, but there's no corresponding arrow at the bottom of the
    panel to make the panel shallower. Nor, as I mentioned, is there a
    corner handle to resize both width and height of the panel. Is
    this, by any chance, a known bug of Flash? FWIW, I'm running on an
    intel iMac, OS 10.4.
    I thought perhaps the problem was that the Compiler Error
    panel was too far off below the screen, so that the bottom of it
    wasn't visible and thus, inaccessible. But when I grab the top of
    the panel and shove it all the way up flush with the top of the
    monitor screen, not only do I still not see the bottom of the
    panel, but Flash thinks I want to minimize the screen. I get the
    blue bar at the top, and the panel collapses.
    Whew. That's a lot of words for what I hope is a simple
    problem. If any of you kind and knowledgeable Flash folks could
    help me out, I'd be most grateful.
    Tom

    Thank you C-Rock. I just looked in the application folder and
    saw the Configuration folder. If I delete that, does Flash generate
    a new one when I relaunch? I don't see a folder called Register.
    Can you tell me where I would find that, and also, will Flash
    generate a new one of that as well?
    Thanks for the help.
    Tom

  • When i created procedure for error_log its giving errors:

    please give a solution for below procedure...
    just check the procedure its giving errors ... rec is not an identifier in loop in the procedure....
    Step 1:
    Create a table MAP_ERROR_LOG.
    Script:
    CREATE TABLE MAP_ERROR_LOG
    ERROR_SEQ NUMBER,
    MAPPING_NAME VARCHAR2(32 BYTE),
    TARGET_TABLE VARCHAR2(35 BYTE),
    TARGET_COLUMN VARCHAR2(35 BYTE),
    TARGET_VALUE VARCHAR2(100 BYTE),
    PRIMARY_TABLE VARCHAR2(100 BYTE),
    ERROR_ROWKEY NUMBER,
    ERROR_CODE VARCHAR2(12 BYTE),
    ERROR_MESSAGE VARCHAR2(2000 BYTE),
    ERROR_TIMESTAMP DATE
    TABLESPACE DW_OWNER_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 80K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    Step 2:
    Create a sequence MAP_ERROR_LOG_SEQ
    CREATE SEQUENCE MAP_ERROR_LOG_SEQ START WITH 1 INCREMENT BY 1
    Step 3:
    Create a procedure PROC_MAP_ERROR_LOG through OWB.
    In this i have used 3 cursor, first cursor is used to check the count of error messages for the corresponding table(WB_RT_ERROR_SOURCES).
    The second cursor is used to get the oracle error and the primary key values.
    The third cursor is used for get the ORACLE DBA errors such as "UNABLE TO EXTEND THE TABLESPACE" for this type errors.
    CREATE OR REPLACE PROCEDURE PROC_MAP_ERROR_LOG(MAP_ID VARCHAR2) IS
    --initialize variables here
    CURSOR C1 IS
    SELECT COUNT(RTA_IID) FROM OWB_REP.WB_RT_ERROR_SOURCES
    WHERE RTA_IID =( SELECT MAX(RTA_IID) FROM OWB_REP.WB_RT_AUDIT WHERE RTA_PRIMARY_TARGET ='"'||MAP_ID||'"');
    V_COUNT NUMBER;
    CURSOR C2 IS
    SELECT A.RTE_ROWKEY ERR_ROWKEY,SUBSTR(A.RTE_SQLERRM,1,INSTR(A.RTE_SQLERRM,':')-1) ERROR_CODE,
    SUBSTR(A.RTE_SQLERRM,INSTR(A.RTE_SQLERRM,':')+1) ERROR_MESSAGE,
    C.RTA_LOB_NAME MAPPING_NAME,SUBSTR(B.RTS_SOURCE_COLUMN,(INSTR(B.RTS_SOURCE_COLUMN,'.')+1)) TARGET_COLUMN,
    B.RTS_VALUE TARGET_VALUE,C.RTA_PRIMARY_SOURCE PRIMARY_SOURCE,C.RTA_PRIMARY_TARGET TARGET_TABLE,
    C.RTA_DATE ERROR_TIMESTAMP
    FROM OWB_REP.WB_RT_ERRORS A,OWB_REP.WB_RT_ERROR_SOURCES B, OWB_REP.WB_RT_AUDIT C
    WHERE C.RTA_IID = A.RTA_IID
    AND C.RTA_IID = B.RTA_IID
    AND A.RTA_IID = B.RTA_IID
    AND A.RTE_ROWKEY =B.RTE_ROWKEY
    --AND RTS_SEQ =1
    AND B.RTS_SEQ IN (SELECT POSITION FROM OWB_REP.ALL_CONS_COLUMNS A, OWB_REP.ALL_CONSTRAINTS B
    WHERE A.TABLE_NAME = B.TABLE_NAME
    AND A.CONSTRAINT_NAME = B.CONSTRAINT_NAME
    AND A.TABLE_NAME =MAP_ID
    AND CONSTRAINT_TYPE ='P')
    AND A.RTA_IID =(
    SELECT MAX(RTA_IID) FROM OWB_REP.WB_RT_AUDIT WHERE RTA_PRIMARY_TARGET ='"'||MAP_ID||'"');
    CURSOR C3 IS
    SELECT A.RTE_ROWKEY ERR_ROWKEY,SUBSTR(A.RTE_SQLERRM,1,INSTR(A.RTE_SQLERRM,':')-1) ERROR_CODE,
    SUBSTR(A.RTE_SQLERRM,INSTR(A.RTE_SQLERRM,':')+1) ERROR_MESSAGE,
    C.RTA_LOB_NAME MAPPING_NAME,SUBSTR(B.RTS_SOURCE_COLUMN,(INSTR(B.RTS_SOURCE_COLUMN,'.')+1)) TARGET_COLUMN,
    B.RTS_VALUE TARGET_VALUE,C.RTA_PRIMARY_SOURCE PRIMARY_SOURCE,C.RTA_PRIMARY_TARGET TARGET_TABLE,
    C.RTA_DATE ERROR_TIMESTAMP
    FROM OWB_REP.WB_RT_ERRORS A,OWB_REP.WB_RT_ERROR_SOURCES B, OWB_REP.WB_RT_AUDIT C
    WHERE C.RTA_IID = A.RTA_IID
    AND A.RTA_IID = B.RTA_IID
    AND A.RTE_ROWKEY =B.RTE_ROWKEY
    AND A.RTA_IID =(
    SELECT MAX(RTA_IID) FROM OWB_REP.WB_RT_AUDIT WHERE RTA_PRIMARY_TARGET ='"'||MAP_ID||'"');
    -- main body
    BEGIN
    DELETE DW_OWNER.MAP_ERROR_LOG WHERE TARGET_TABLE ='"'||MAP_ID||'"';
    COMMIT;
    OPEN C1;
    FETCH C1 INTO V_COUNT;
    IF V_COUNT >0 THEN
    FOR REC IN C2
    LOOP
    INSERT INTO DW_OWNER.MAP_ERROR_LOG
    (Error_seq ,
    Mapping_name,
    Target_table,
    Target_column ,
    Target_value ,
    Primary_table ,
    Error_rowkey ,
    Error_code ,
    Error_message ,
    Error_timestamp)
    VALUES(
    DW_OWNER.MAP_ERROR_LOG_SEQ.NEXTVAL,
    REC.MAPPING_NAME,
    REC.TARGET_TABLE,
    REC.TARGET_COLUMN,
    REC.TARGET_VALUE,
    REC.PRIMARY_SOURCE,
    REC.ERR_ROWKEY,
    REC.ERROR_CODE,
    REC.ERROR_MESSAGE,
    REC.ERROR_TIMESTAMP);
    END LOOP;
    ELSE
    FOR REC IN C3
    LOOP
    INSERT INTO DW_OWNER.MAP_ERROR_LOG
    (Error_seq ,
    Mapping_name,
    Target_table,
    Target_column ,
    Target_value ,
    Primary_table ,
    Error_rowkey ,
    Error_code ,
    Error_message ,
    Error_timestamp)
    VALUES(
    DW_OWNER.MAP_ERROR_LOG_SEQ.NEXTVAL,
    REC.MAPPING_NAME,
    REC.TARGET_TABLE,
    REC.TARGET_COLUMN,
    REC.TARGET_VALUE,
    REC.PRIMARY_SOURCE,
    REC.ERR_ROWKEY,
    REC.ERROR_CODE,
    REC.ERROR_MESSAGE,
    REC.ERROR_TIMESTAMP);
    END LOOP;
    END IF;
    CLOSE C1;
    COMMIT;
    -- NULL; -- allow compilation
    EXCEPTION
    WHEN OTHERS THEN
    NULL; -- enter any exception code here
    END;

    Yah i got the solution...
    scrip is
    Step 1:
    Create a table MAP_ERROR_LOG.
    Script:
    CREATE TABLE MAP_ERROR_LOG
    ERROR_SEQ NUMBER,
    MAPPING_NAME VARCHAR2(32 BYTE),
    TARGET_TABLE VARCHAR2(35 BYTE),
    TARGET_COLUMN VARCHAR2(35 BYTE),
    TARGET_VALUE VARCHAR2(100 BYTE),
    PRIMARY_TABLE VARCHAR2(100 BYTE),
    ERROR_ROWKEY NUMBER,
    ERROR_CODE VARCHAR2(12 BYTE),
    ERROR_MESSAGE VARCHAR2(2000 BYTE),
    ERROR_TIMESTAMP DATE
    TABLESPACE DW_OWNER_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 80K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    Step 2:
    Create a sequence MAP_ERROR_LOG_SEQ
    CREATE SEQUENCE MAP_ERROR_LOG_SEQ START WITH 1 INCREMENT BY 1
    Step 3:
    Create a procedure PROC_MAP_ERROR_LOG through OWB.
    In this i have used 3 cursor, first cursor is used to check the count of error messages for the corresponding table(WB_RT_ERROR_SOURCES).
    The second cursor is used to get the oracle error and the primary key values.
    The third cursor is used for get the ORACLE DBA errors such as "UNABLE TO EXTEND THE TABLESPACE" for this type errors.
    CREATE OR REPLACE PROCEDURE PROC_MAP_ERROR_LOG(MAP_ID VARCHAR2) IS
    --initialize variables here
    CURSOR C1 IS
    SELECT COUNT(RTA_IID) FROM OWB_REP.WB_RT_ERROR_SOURCES1
    WHERE RTA_IID =( SELECT MAX(RTA_IID) FROM OWB_REP.WB_RT_AUDIT1 WHERE RTA_PRIMARY_TARGET ='"'||MAP_ID||'"');
    V_COUNT NUMBER;
    CURSOR C2 IS
    SELECT A.RTE_ROWKEY ERR_ROWKEY,SUBSTR(A.RTE_SQLERRM,1,INSTR(A.RTE_SQLERRM,':')-1) ERROR_CODE,
    SUBSTR(A.RTE_SQLERRM,INSTR(A.RTE_SQLERRM,':')+1) ERROR_MESSAGE,
    C.RTA_LOB_NAME MAPPING_NAME,SUBSTR(B.RTS_SOURCE_COLUMN,(INSTR(B.RTS_SOURCE_COLUMN,'.')+1)) TARGET_COLUMN,
    B.RTS_VALUE TARGET_VALUE,C.RTA_PRIMARY_SOURCE PRIMARY_SOURCE,C.RTA_PRIMARY_TARGET TARGET_TABLE,
    C.RTA_DATE ERROR_TIMESTAMP
    FROM OWB_REP.WB_RT_ERRORS1 A,OWB_REP.WB_RT_ERROR_SOURCES1 B, OWB_REP.WB_RT_AUDIT1 C
    WHERE C.RTA_IID = A.RTA_IID
    AND C.RTA_IID = B.RTA_IID
    AND A.RTA_IID = B.RTA_IID
    AND A.RTE_ROWKEY =B.RTE_ROWKEY
    --AND RTS_SEQ =1
    AND B.RTS_SEQ IN (SELECT POSITION FROM ALL_CONS_COLUMNS A, ALL_CONSTRAINTS B
    WHERE A.TABLE_NAME = B.TABLE_NAME
    AND A.CONSTRAINT_NAME = B.CONSTRAINT_NAME
    AND A.TABLE_NAME =MAP_ID
    AND CONSTRAINT_TYPE ='P')
    AND A.RTA_IID =(
    SELECT MAX(RTA_IID) FROM OWB_REP.WB_RT_AUDIT1 WHERE RTA_PRIMARY_TARGET ='"'||MAP_ID||'"');
    CURSOR C3 IS
    SELECT A.RTE_ROWKEY ERR_ROWKEY,SUBSTR(A.RTE_SQLERRM,1,INSTR(A.RTE_SQLERRM,':')-1) ERROR_CODE,
    SUBSTR(A.RTE_SQLERRM,INSTR(A.RTE_SQLERRM,':')+1) ERROR_MESSAGE,
    C.RTA_LOB_NAME MAPPING_NAME,SUBSTR(B.RTS_SOURCE_COLUMN,(INSTR(B.RTS_SOURCE_COLUMN,'.')+1)) TARGET_COLUMN,
    B.RTS_VALUE TARGET_VALUE,C.RTA_PRIMARY_SOURCE PRIMARY_SOURCE,C.RTA_PRIMARY_TARGET TARGET_TABLE,
    C.RTA_DATE ERROR_TIMESTAMP
    FROM OWB_REP.WB_RT_ERRORS A,OWB_REP.WB_RT_ERROR_SOURCES1 B, OWB_REP.WB_RT_AUDIT C
    WHERE C.RTA_IID = A.RTA_IID
    AND A.RTA_IID = B.RTA_IID
    AND A.RTE_ROWKEY =B.RTE_ROWKEY
    AND A.RTA_IID =(
    SELECT MAX(RTA_IID) FROM OWB_REP.WB_RT_AUDIT WHERE RTA_PRIMARY_TARGET ='"'||MAP_ID||'"');
    -- main body
    BEGIN
    DELETE DW_OWNER.MAP_ERROR_LOG WHERE TARGET_TABLE ='"'||MAP_ID||'"';
    COMMIT;
    OPEN C1;
    FETCH C1 INTO V_COUNT;
    IF V_COUNT >0 THEN
    FOR REC IN C2
    LOOP
    INSERT INTO DW_OWNER.MAP_ERROR_LOG
    (Error_seq ,
    Mapping_name,
    Target_table,
    Target_column ,
    Target_value ,
    Primary_table ,
    Error_rowkey ,
    Error_code ,
    Error_message ,
    Error_timestamp)
    VALUES(
    DW_OWNER.MAP_ERROR_LOG_SEQ.NEXTVAL,
    REC.MAPPING_NAME,
    REC.TARGET_TABLE,
    REC.TARGET_COLUMN,
    REC.TARGET_VALUE,
    REC.PRIMARY_SOURCE,
    REC.ERR_ROWKEY,
    REC.ERROR_CODE,
    REC.ERROR_MESSAGE,
    REC.ERROR_TIMESTAMP);
    END LOOP;
    ELSE
    FOR REC IN C3
    LOOP
    INSERT INTO DW_OWNER.MAP_ERROR_LOG
    (Error_seq ,
    Mapping_name,
    Target_table,
    Target_column ,
    Target_value ,
    Primary_table ,
    Error_rowkey ,
    Error_code ,
    Error_message ,
    Error_timestamp)
    VALUES(
    DW_OWNER.MAP_ERROR_LOG_SEQ.NEXTVAL,
    REC.MAPPING_NAME,
    REC.TARGET_TABLE,
    REC.TARGET_COLUMN,
    REC.TARGET_VALUE,
    REC.PRIMARY_SOURCE,
    REC.ERR_ROWKEY,
    REC.ERROR_CODE,
    REC.ERROR_MESSAGE,
    REC.ERROR_TIMESTAMP);
    END LOOP;
    END IF;
    CLOSE C1;
    COMMIT;
    -- NULL; -- allow compilation
    EXCEPTION
    WHEN OTHERS THEN
    NULL; -- enter any exception code here
    END;

  • In creating  Procedure how to add a Varchar column?

    Hi, im doing a process to get a missing series of Official Reciepts (OR_NO Varchar2(10)). I have a problem running my procedure in a part of variable.
    The error is ORA-06502 PL/SQL: numeric or value error .
    In a sample statement below, if the value for nNo = 'PSFP000123' then if i add + 1 , variable nNo = ''PSFP000124'.
    My question is, how can i add nNo + 1 since nNO is a varchar data type?
    sample:
    Declare
    nNo Varchar2(10) := 'PSFP000123';
    Begin
    nNo := nNo + 1;
    End;
    Thank you.
    Lala

    Hi Lala,
    Try playing with something like below. Just to give you an idea.
    SELECT 'PSFP' || LPAD(SUBSTR('PSFP000123', 5) + 1, 6, '0') FROM DUALRegards,
    Chan Kelwin

  • How to detect data errors?

    In applications such as healthcare, errors in data stored in a database could lead to so called Adverse Events even death of a patient. Clearly, if erroneous data could be detected then the user could be warned not to trust what is displayed.
    So, what happens in practice? If hardware failure or flawed software were to cause occasional data errors in a Oracle Database, would such errors be detected by the database engine or is detection left to the application? For example, a single bit error relating to an index that is supposed to be unique or a field containing a code representing a patient's blood type. When would this violation of integrity be detected and how would such errors become evident? Is it credible that such errors could cause incorrect data to be returned from a query?
    Clearly CRC or hashing functions could be called using appropriate triggers to provide field or record level error detection.
    1. Is anyone doing this?
    2. What is the recomended approach ?
    3. What is the performance penalty likely to be?
    4. Is there any documentation that describes this ?
    Thanks,
    James

    Hi,
    you have two parameters called DB_BLOCK_CHECKSUM and DB_BLOCK_CHECKING, which calculate checksums by reading (DB_BLOCK_CHECKING) and writting (DB_BLOCK_CHECKSUM)
    Some storage vendors like Hitachi work closely with Oracle to provide additional protections against data corruption. Look for the Oracle H.A.R.D. initiative at http://otn.oracle.com/deploy/availability/htdocs/vendors_hard.html
    You will then find documentation on the storage vendor site as well.
    Regards
    Laurent Schneider
    OCM DBA

  • How to see compilation errors PAGEWISE?

    Just curious about it.
    When we compile a program, and if it contains lots of errors that are not fitting into one scrren (I am talking about DOS screen) what should i do if i want to see all erros in PAGEWISE fasion??
    --Bhupendra Mahajan

    Dear Bhoopsie:
    You can also get scroll bars in a DOS window. Right
    t click on the title bar icon. My recommendation is
    to use an editor like PFE. It allows one to capture
    output.
    Good LuckHi fstream,
    I couldn't get scroll bars in Dos window, will u please elaborate??
    and about PFE.. I will check it out..
    --Bhupendra Mahajan

  • How to detect conversion errors due to charset mismatch client/server?

    If a character cannot be converted by OCIStmtExecute (Bind Variable) and/or OCIStmtFetch (Into Variable), either a replacement character (usually question mark) or a similar character (e.g. è -> e) is used instead.
    I am looking for a possibility to get an indicator flag if a column could not be converted between client character encoding (NLS_LANG setting) and database encoding (NLS_CHARACTERSET).
    If I do the conversion in my code, setting OCI_ATTR_CHARSET_ID to OCI_UTF16ID and using OCICharSetToUnicode(), OCIUnicodeToCharSet() and OCICharSetConversionIsReplacementUsed(), this would be quite a bit of work, allocating extra buffers, and it detects only conversion errors during OCIStmtFetch (into variables), not for bind variables during OCIStmtExecute.

    If a character cannot be converted by OCIStmtExecute (Bind Variable) and/or OCIStmtFetch (Into Variable), either a replacement character (usually question mark) or a similar character (e.g. è -> e) is used instead.
    I am looking for a possibility to get an indicator flag if a column could not be converted between client character encoding (NLS_LANG setting) and database encoding (NLS_CHARACTERSET).
    If I do the conversion in my code, setting OCI_ATTR_CHARSET_ID to OCI_UTF16ID and using OCICharSetToUnicode(), OCIUnicodeToCharSet() and OCICharSetConversionIsReplacementUsed(), this would be quite a bit of work, allocating extra buffers, and it detects only conversion errors during OCIStmtFetch (into variables), not for bind variables during OCIStmtExecute.

  • How to detect CPU error in SMP system?

    I want to monitor if the CPU is working properly in real-time, especially at SMP system. My goal is to build a program that shows "CPU n is working properly" and if one is down, showing "CPU n down".
    Is there pre-defined C function I can use? Or is there better one?

    I think that kstat() does such a function, but for SMP system, how does it work? Is there a certain way to specify CPU?

  • How to troubleshoot SQL error when copying cube

    I was successful in creating Info Package and running it to copy data frin cube  1 to cube2.  However, I get an error when
    Running the package. My source cube has 1.9 million rows. However, Info Package only loaded 30,120 records.  Looking in monitor logs, it shows me following error stack:
    System error in program SAPLRS_EXECPTION and from RS_EXEPTION_TO_MESSAGE
    SQL Error 0
    Unknown error in SQL Interface
    Errors in source system
    When I click on long text button for Unknown error in SQL interface:
    The SQL interface of the application server (DBSL) has reported an unknown error. This error can be caused by:
    - Overflows when aggregated data is read from the database in ABAP.  If this occurs, the definition for the corresponding key figure must be changed.
    - Internal errors
    It seems to be some kind of Overflow error. Is there any way to get  more information on the cause
    Of this erroru2026.
    THANKS A LOT.

    I tried SM50, it shows me all processes, but I still cannot figure how to set developer trace. Following is detailed information on what I am doing in copy of cubes and errors I am getting:
    Subject: Troubleshoot Copy of Cubes
    I have tried to copy several cubes on my BI 7.0 and all of them same error, so I am wondering whether I am doing something fundamentally wrong.
                    System error in program SAPLRS_EXECPTION and from RS_EXEPTION_TO_MESSAGE
                    SQL Error 0
                    Unknown error in SQL Interface
                    Errors in source system
    After error occurs I get following message in mail:
              The error occurred in Extractor.
               Refer to the error message.
                     Procedure
                 How you remove the error depends on the error message.
                     Note
              If the source system is a Client Workstation, then it            is possible that the file that you wanted to load was being edited
    at the time of the data request. Make sure that the file is in
    the specified directory, that it is not being processed at the
    I  looked  in SM21, system logs, whenever error occurs, I see the  u201C
    Database selection with invalid cursor &5&5
    The database interface was called by a cursor (in a FETCH or CLOSE cursor operation) that is not flagged as opened. This can occur if a COMMIT or ROLLBACK was executed within a SELECT loop (which closes all opened cursors), followed by another attempt to access the cursor (for example, the next time the loop is executed).
    I DO NOT UNDERSTAND WHEN I AM COPYING FROM CUBE, WHY SAP BW will  generate u201Cinvalid cursoru201D message. Not sure whether it is normal, i.e., not a real error,
    My cube copying  (from cube 1 to cube 2) is a straightforward procedure:
    a.     Select Copy from Cube 1 and create Cube 2.
    b.     Create Export Data Source from Cube 1 Menu.
    c.     From Cube 2 menu, Create Update rules, In update rules select DataSource as 8Cube1.
    d.     Create an Info Package for 8Cube1 under Infosource/DataSource and then run the package.
    Certain no of records e.g.. 3248 or so get loaded and then the error messages are generated, why?
    Really appreciate any help. I tried SM37, does not give any clue. I also Tried SM50, it shows me the process, but I still cannot figure how to generate developer trace.
    Since behavior is same for several cubes I tried, something else also needs to be done, I do not know what???

  • Trigger compile errors

    Need some direction. I have a user table defined that I would like to track any change in the Active column. when this occurs, I want a trigger to fire on after update to the BPF.Users table. The trigger will insert into the user_audit_log table. There is a sequence defined for that table as well. Here is the trigger:
    CREATE OR REPLACE TRIGGER user_update
    AFTER UPDATE OF active ON BPF.users
    FOR EACH ROW
    when (new.Name <> NULL)
    DECLARE
         currentuser CHAR(6);
         timenow DATE;
    BEGIN
    SELECT USER INTO currentuser from DUAL;
    timenow := SYSDATE;
    INSERT INTO BPF.user_audit_log
    VALUES (user_audit_seq.NEXTVAL, currentuser,:New.Name, timenow, 'Active Status Change');
    END;
    The user_audit_log table is define:
    CREATE TABLE BPF.user_audit_log
    (uaID NUMBER(38) PRIMARY KEY,
    uacuruser VARCHAR2(20),
    uachguser VARCHAR2(20),
    uadate DATE,
    uamsg VARCHAR2(1000)
    Now for the weird part, when I create the trigger, it has compile errors but does not say what they are. I can create the trigger without the insert statement and it compiles fine. I have no idea what is wrong with it. Can anyone give me some direction? Thanks so much!

    Thank you for your help. It has to do with the NVARCHAR2 definition. The character values have to be in this format, n'value', in order for it to insert. Now I just have to figure out how to do that. But here is the table definition.
    SQL> describe BPF.Users
    Name Null? Type
    USER_ID NOT NULL NUMBER(10)
    NAME NOT NULL NVARCHAR2(100)
    FULL_NAME NVARCHAR2(100)
    EMAIL NVARCHAR2(400)
    ACTIVE NOT NULL NUMBER(1)
    PREFERENCES NVARCHAR2(4000)
    DEFAULT_BU_ID NOT NULL NUMBER(10)
    WF_USER_ID NUMBER(10)
    DEFAULT_SECURITY_PROFILE_ID NOT NULL NUMBER(10)
    SYSTEM NOT NULL NUMBER(1)
    REPORTSTO_USER_ID NUMBER(10)
    DEFAULT_FA_ID NOT NULL NUMBER(10)
    USER_ATTR_1 NVARCHAR2(1000)
    USER_ATTR_2 NVARCHAR2(1000)
    USER_ATTR_3 NVARCHAR2(1000)
    USER_ATTR_4 NVARCHAR2(1000)
    USER_ATTR_5 NVARCHAR2(1000)
    USER_ATTR_6 NVARCHAR2(1000)
    USER_ATTR_7 NVARCHAR2(1000)
    USER_ATTR_8 NVARCHAR2(1000)
    USER_ATTR_9 NVARCHAR2(1000)
    USER_ATTR_10 NVARCHAR2(1000)
    ORIGINAL_EMAIL NVARCHAR2(200)
    DEFAULT_PASSWORD NVARCHAR2(40)

  • Warning: Procedure created with compilation errors.

    I am trying to upload a pdf file into a blob column of a table. I get this error with these three ways of doing that:Warning: Procedure created with compilation errors.
    Any ideas why?
    -- THE STORAGE TABLE FOR THE IMAGE FILE
    ALTER TABLE PDM
    DROP PRIMARY KEY CASCADE;
    DROP TABLE PDM CASCADE CONSTRAINTS;
    CREATE TABLE PDM (
    DNAME VARCHAR2(30), -- DIRECTORY NAME
    SNAME VARCHAR2(30), -- SUBDIRECTORY NAME
    FNAME VARCHAR2(30), -- FILE NAME
    IBLOB BLOB); -- IMAGE FILE
    -- CREATE THE PROCEDURE TO LOAD THE FILE
    CREATE OR REPLACE PROCEDURE LOAD_FILE (
    PDNAME VARCHAR2,
    PSNAME VARCHAR2,
    PFNAME VARCHAR2) IS
    SRC_FILE BFILE;
    DST_FILE BLOB;
    LGH_FILE BINARY_INTEGER;
    BEGIN
    SRC_FILE := BFILENAME('PDF_DIR', '266-5210.pdf');
    -- INSERT A NULL RECORD TO LOCK
    INSERT INTO PDM
    (DNAME, SNAME, FNAME, IBLOB)
    VALUES
    (PDNAME, PSNAME, PFNAME, EMPTY_BLOB())
    RETURNING IBLOB INTO DST_FILE;
    -- LOCK RECORD
    SELECT IBLOB
    INTO DST_FILE
    FROM PDM
    WHERE DNAME = PDNAME
    AND SNAME = PSNAME
    AND FNAME = PFNAME
    FOR UPDATE;
    -- OPEN THE FILE
    DBMS_LOB.FILEOPEN(SRC_FILE, DBMS_LOB.FILE_READONLY);
    DBMS_LOB.OPEN(DST_FILE, DBMS_LOB.LOB_READWRITE);
    -- DETERMINE LENGTH
    LGH_FILE := DBMS_LOB.GETLENGTH(SRC_FILE);
    -- READ THE FILE
    DBMS_LOB.LOADFROMFILE(DST_FILE, SRC_FILE, LGH_FILE);
    -- UPDATE THE BLOB FIELD
    UPDATE PDM
    SET IBLOB = DST_FILE
    WHERE DNAME = PDNAME
    AND SNAME = PSNAME
    AND FNAME = PFNAME;
    -- CLOSE FILE
    DBMS_LOB.FILECLOSE(SRC_FILE);
    END LOAD_FILE;
    -- THE STORAGE TABLE FOR THE IMAGE FILE
    ALTER TABLE PDM
    DROP PRIMARY KEY CASCADE;
    DROP TABLE PDM CASCADE CONSTRAINTS;
    CREATE TABLE PDM
    FNAME VARCHAR2(1000)
    ,IBLOB BLOB
    -- CREATE THE PROCEDURE TO LOAD THE FILE
    CREATE OR REPLACE PROCEDURE LOAD_FILE AS (
    SRC_FILE BFILE := BFILENAME('PDF_DIR', '262-2827.pdf');
    DST_FILE BLOB;
    BEGIN
    -- INSERT A NULL RECORD TO LOCK
    INSERT INTO PDM
    (FNAME, IBLOB)
    VALUES
    ('262-2827.pdf', EMPTY_BLOB())
    RETURNING IBLOB INTO DST_FILE;
    -- OPEN THE FILE
    DBMS_LOB.FILEOPEN(SRC_FILE, DBMS_LOB.FILE_READONLY);
    DBMS_LOB.OPEN(DST_FILE, DBMS_LOB.LOB_READWRITE);
    -- READ THE FILE
    DBMS_LOB.LOADFROMFILE( SRC_FILE, DST_FILE);
    -- UPDATE THE BLOB FIELD
    UPDATE PDM
    SET FNAME = SRC_FILE,
    IBLOB = DST_FILE;
    -- CLOSE FILE
    DBMS_LOB.CLOSE(DST_FILE);
    DBMS_LOB.FILECLOSE(SRC_FILE);
    COMMIT;
    END LOAD_FILE;
    ALTER TABLE IMAGE_TABLE
    DROP PRIMARY KEY CASCADE;
    DROP TABLE IMAGE_TABLE CASCADE CONSTRAINTS;
    CREATE TABLE IMAGE_TABLE (
    ID NUMBER PRIMARY KEY,
    IMAGE ORDSYS.ORDIMAGE);
    CREATE OR REPLACE DIRECTORY IMAGEDIR AS 'C:\cards\';
    GRANT READ ON DIRECTORY IMAGEDIR TO PUBLIC;
    GRANT READ ON DIRECTORY MY_FILES TO twilliam;
    GRANT READ ON DIRECTORY MY_FILES TO tmwillia;
    CREATE OR REPLACE PROCEDURE IMAGE_IMPORT(DEST_ID NUMBER,
    FILENAME VARCHAR2)
    IS
    IMG ORDSYS.ORDIMAGE;
    CTX RAW(64) := NULL;
    BEGIN
    DELETE FROM IMAGE_TABLE
    WHERE ID = DEST_ID;
    INSERT INTO IMAGE_TABLE (ID, IMAGE)
    VALUES (DEST_ID, ORDSYS.ORDIMAGE.INIT())
    RETURNING IMAGE INTO IMG;
    IMG.IMPORTFROM(CTX, 'FILE', 'IMAGEDIR', FILENAME);
    UPDATE IMAGE_TABLE SET IMAGE=IMG WHERE ID=DEST_ID;
    END
    CALL IMAGE_IMPORT(7142,'125-0502.pdf');
    CALL IMAGE_IMPORT(7143,'125-0503.pdf');
    SELECT ID,
    T.IMAGE.GETHEIGHT(),
    T.IMAGE.GETWIDTH()
    FROM IMAGE_TABLE T;
    SELECT ID,
    T.IMAGE.GETFILEFORMAT(),
    T.IMAGE.GETCOMPRESSIONFORMAT()
    FROM IMAGE_TABLE T;
    SELECT ID,
    T.IMAGE.GETCONTENTFORMAT(),
    T.IMAGE.GETCONTENTLENGTH()
    FROM IMAGE_TABLE T;

    In the second load_file procedure you should probably change the update command
    -- UPDATE THE BLOB FIELD
    UPDATE PDM
    SET FNAME = SRC_FILE,
    IBLOB = DST_FILE;into this
    -- UPDATE THE BLOB FIELD
    UPDATE PDM
    SET IBLOB = DST_FILE
    WHERE  FNAME = '262-2827.pdf';but I'm not sure how to explain the eof error message. Usually this happens when you forget an "END;" or "END LOOP;" command.
    Ok I rechecked and the declaration of the second procedure seems wrong
    -- CREATE THE PROCEDURE TO LOAD THE FILE
    CREATE OR REPLACE PROCEDURE LOAD_FILE AS (
    SRC_FILE BFILE := BFILENAME('PDF_DIR', '262-2827.pdf');
    DST_FILE BLOB;
    BEGINshould be rewritten as
    -- CREATE THE PROCEDURE TO LOAD THE FILE
    CREATE OR REPLACE PROCEDURE LOAD_FILE
      AS
      SRC_FILE BFILE := BFILENAME('PDF_DIR', '262-2827.pdf');
      DST_FILE BLOB;
    BEGIN
    ...I removed one parenthesis which was not closed.
    And for the image_import procedure there is a semikolon missing after the final END.
    END*;*
    Edited by: Sven W. on Nov 24, 2008 5:54 PM.
    Edited by: Sven W. on Nov 24, 2008 5:56 PM
    Edited by: Sven W. on Nov 24, 2008 5:59 PM

  • How to create procedure to mail ORA-error

    hi all,
    anyone please tell me how to create a procedure to mail the ORA-error when ORA- error comes in alert.log

    Ok, I can't really do this for you. It's not hard, just a lot of back-and-forth testing needs to be done. To do it solely in PL/SQL you need to monitor the alter_<sid>.log file for changes and filter the changed records for ORA- errors.. So, first step is to create, or get the dba to create a directory for that bdump directory. This will allow you to open the file for reading in PL/SQL
    This is on an XE 10g database as SYSTEM user, with poly being the database user that is monitoring the file.
    select value from v$parameter where name like 'background_dump_dest';
    /usr/lib/oracle/xe/app/oracle/admin/XE/bdump
    SQL> CREATE DIRECTORY BDUMP_DIR AS '/usr/lib/oracle/xe/app/oracle/admin/XE/bdump';
    create directory succeeded.
    SQL> grant read on directory alert_dir to poly;
    grant read succeeded.After this, you need to read the file and search for ORA- messages. You use the UTL_FILE package to do this. The following subprograms in UTL_FILE will be useful to you.
    Function: UTL_FILE.FOPEN You use this to open the file in readonly mode. Please look at the UTL_FILE documentation examples.
    Procedure: UTL_FILE.GET_LINE You use this to read lines into PL/SQL
    Procedure: UTL_FILE.GETATTR You use this to get the filelength. If the filelength is different from your previous call, you know some writes occurred.
    Procedure UTL_FILE.FSEEK You use this to position the reading stream to the first byte of new data read. You've detected the file has grown in size and do something like utl_file.fseek(file_desc,last_file_length+1)
    Procedure UTL_FILE.FCLOSE Close file when done.
    Pseudologic:
    This logic assumes you have a table which stores the filelength from the last time you executed the procedure. This allows you to only process records that have not already been processed.
    1. Read last file length from persistent storage such as a table. Default to zero if no value.
    2. Get filelength using UTL_FILE.GETATTR
    3. Compare filelength. If equal to prior value, exit. If greater, than more lines added. If less, then dba must have rolled the log, reset prior filelength to zero to process entire new file.
    4. Use UTL_FILE.FSEEK to position reader to one byte past last file length. This is why we default it to zero, 0+1=1.
    5. Open file using UTL_FILE.FOPEN
    6. Loop while data is avaliable, read each line, use instr or whatever to detect ORA- messages, call SMTP mailer as needed. You may want to log each email into a log table.
    7. After loop, set persisted last file length (update a table and commit maybe) to value returned from UTL_FILE.FGETPOS.
    8. Sleep for some interval of time. Start back at step 1.
    You should consider using DBMS_SCHEDULER to set up this job.
    There are lots of other ways of doing this. Remember that it's possible for your database to crash and your procedure might not be able to send an email. If someone edits the alter file and adds lines anywhere other than at the end, your program may resend some messages.
    Edited by: david.sweet on Feb 19, 2011 10:16 AM: changed the word function to procedure for most of them

Maybe you are looking for

  • How do I sync photos from iPhone to iMac with a hardwire?

    How do I sync photos from my iPhone to my iMac with a hardwire now that I am on iCloud?

  • Can't launch Safari after upgrade to 10.5

    Dang Upgraded to Leopard (OS 10.5) from 10.4.11. When launching Safari, it refused to start and sent me error message "PithHelmet version xxx.xx.x hasnt been tested with Safari 3.x so it won't launch." After that, I have disabled and removed PithHelm

  • Error in PDF File APEX

    Hi!! i´m new in APEX, i´m creating a custom PDF, i have downloaded the Oracle BI, and i generate my *.rtf Archive, all is OK, except when i try to open the PDF file, i get an error that i can't see, but i can read this when i export to *.doc file. i

  • Auto-opening of Photos app in Yosemite...

    Hey all, I am a photographer and have a pretty set workflow revolving around Lightroom/Photoshop.  Ever since installing the software update that introduced the new Photos app on Yosemite, whenever I insert a new SD card it pops up as the preferred a

  • Planning query donu2019t show current data

    Hello, I have an input ready query over an aggregation level of a real time cube. Whenever the yellow request is closed and a new request is opened, the input ready query does not show the old data. And sometimes it shows incorrect data. We found tha