SQLERRM function
Dear sir,
Suppose the table(AA) contain field(aa) of varchar2(2).
If we insert into AA values('123') then the sql plus will show message like
ORA-12899: value too large for column "SDE"."AA"."AA" (actual: 3, maximum: 2)
SQLERRM function returns the error message in plsql.
The SQLERRM function only returns ORA-12899: value too large message in stored procedure.
Is their any way to get full error message including field name for which error is generated in plsql.
Thank you.
db version is 10.2.0.4.0
SQL> drop table t1;
Table dropped.
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> create table t1(
2 aa varchar2(2)
3 );
Table created.
SQL> insert into t1 values('123');
insert into t1 values('123')
ERROR at line 1:
ORA-12899: value too large for column "T1"."AA" (actual: 3, maximum: 2)
SQL> set serveroutput on
SQL> begin
2 insert into t1 values('456');
3 exception
4 when others then
5 dbms_output.put_line(sqlerrm);
6 end;
7 /
ORA-12899: value too large for column "T1"."AA" (actual: 3, maximum: 2)
PL/SQL procedure successfully completed.
SQL> Regards,
Ritesh
Similar Messages
-
How can I capture in forms the text from a database error
In forms6i, how can I capture the text of an error during the execution of a dabatase procedure or package.
Thanks for your help.You can use SQLERRM function :
SQL> create or replace procedure procerr
2 is
3 n number;
4 begin
5 n := 1/0;
6* end;
SQL> /
Procedure created.
SQL> set serveroutput on
SQL> declare
2 err1 varchar2(200);
3 begin
4 procerr;
5 exception
6 when others then
7 err1 := SQLERRM;
8 dbms_output.put_line(err1);
9* end;
SQL> /
ORA-01476: divisor is equal to zero
PL/SQL procedure successfully completed.
SQL> -
How to get more detailed error information when calling Java SP
Hi
Sorry for reposting this in here but I got no responses in the JVM forum...
I am calling a Java stored procedure from a PL/SQL stored procedure (Oracle DB 9.2.0.8.0) and I am getting the exception:
ORA-29532: Java call terminated by uncaught Java exception: java.lang.NullPointerException
It does not help much though... Is it possible to get the full Java error stack from within PL/SQL so I can log a more informative message?
Thanks!
LuisThanks for the replies! However I am not sure if they help...
I will give some more info about my problem. I have an Oracle job that runs every morning and executes a PL/SQL procedure, which in turn calls that Java SP.
Sometimes the Java SP fails and the error is logged; however only the message "java.lang.NullPointerException" is reported by the SQLERRM function (apparently the last Java error message in the error stack). I am unable to reproduce the error when calling the Java SP manually as was suggested.
I need to log a more detailed error message from within PL/SQL to know exactly where the error occurred, when it occurs next time...
I will take a look to see if I can get some information in some trace file, though ideally I would like to do it programatically.
Thanks
Luis -
When and where to use Dbms_Error_Code, Error_Code and SqlCode.
I have gone thru some docs and books on dev to understand error messages in Developer. After reading i am more confused reg the difference between
Dbms_Error_Code, Error_Code and SqlCode.
Can any one tell me concisely the difference and the situation where these are used.
This is my understanding so far.....
DBMS_ERROR_CODE and DBMS_ERROR_TEXT return the last Oracle Server error code and message due to an implicit DML within form application.
SQLCODE and SQLERRM return the last Oracle Server error code and message due to an explicit DML within a form application.
So why use ERROR_CODE at all?
Below is an extract from the Oracle help Docs...
When an implicit DML raises an error, it is handled with an ON-ERROR trigger using the ERROR_CODE function. This function contains the last Oracle Form error code. These errors are prefixed with FRM-.
Okay but why not just use DBMS_ERROR_CODE instead of ERROR_CODE?
Example: /*
** Built-in: DBMS_ERROR_CODE,DBMS_ERROR_TEXT
** Example: Reword certain Oracle Forms error messages by
** evaluating the DBMS error code that caused them
** Trigger: On-Error
DECLARE
errcode NUMBER := ERROR_CODE;
dbmserrcode NUMBER;
dbmserrtext VARCHAR2(200);
BEGIN
IF errcode = 40508 THEN
** Oracle Forms had a problem INSERTing, so
** look at the Database error which
** caused the problem.
dbmserrcode := DBMS_ERROR_CODE;
dbmserrtext := DBMS_ERROR_TEXT;
IF dbmserrcode = -1438 THEN
** ORA-01438 is "value too large for column"
Message('Your number is too large. Try again.');
ELSIF dbmserrcode = -1400 THEN
** ORA-01400 is "Mandatory column is NULL"
Message('You forgot to provide a value. Try again.');
ELSE
** Printout a generic message with the database
** error string in it.
Message('Insert failed because of '||dbmserrtext);
END IF;
END IF;
END;Regards
GusSorry Steve as wonderful as your code example may be you are putting the cart before the horse as far as the purpose of this thread goes. I don't need guidance on HOW to use certain error functions at least not until i know WHEN i should use them and thats why i started this thread. There are 3 different sets of Oracle functions below for use in forms but not enough guidance in the docs as to when to use them for the newcomer to forms. All i need is a simple definition as to when these functions should be used appropriately in forms. The rest I will find out for myself when i start using forms properly (including the use of your wonderful code). At the moment i just want to pass the Forms exam and to have a better understanding of what i am doing.
DBMS_ERROR_CODE & DBMS_ERROR_TEXT
SQLCODE & SQLERRM
ERROR_CODE & ERROR_TEXT
I've got one person saying this....
DBMS_ERROR_TEXT and DBMS_ERROR_CODE built-ins are intended to be used in a form-level ON-ERROR trigger.
SQLCODE and SQLERRM functions are intended to be used in a WHEN OTHERS exception handler.
and another saying ...
Use error_code to handle Forms error
Use dbms_error_code to handle database error
.. then i've got your code which predominantly uses ERROR_CODE.
Then the STS test papers say this...
When an implicit DML raises an error, it is handled with an ON-ERROR trigger using the ERROR_CODE function. This function contains the last Oracle Form error code. These errors are prefixed with FRM-.
Example:
IF ERROR_CODE = 40508 THEN
MESSAGE ('Invalid insert');
RAISE FORM_TRIGGER_FAILURE;
END IF;DBMS_ERROR_CODE and DBMS_ERROR_TEXT return the last Oracle Server error code and message due to an implicit DML within form application. These errors are prefixed with ORA-.
SQLCODE and SQLERRM return the last Oracle Server error code and message due to an explicit DML within a form application. These functions must be used in the exception handler of the program unit that issues the DML command.
A little Confusing to say the least!!!
Okay, so is this correct...
SQLCODE and SQLERRM are used with explicit DML within a form application and are used in the exception handler of the program unit that issues the DML command.
When an implicit DML raises an error, it is handled with an ON-ERROR trigger using the ERROR_CODE function. These errors are prefixed with FRM-.
DBMS_ERROR_CODE and DBMS_ERROR_TEXT are also used with implicit DML within form application. These errors are prefixed with ORA-.
So why use DBMS_ERROR_CODE and DBMS_ERROR_TEXT if ERROR_CODE and ERROR_TEXT are to be used in ON-ERROR triggers and if an implicit DML error arises then whats the difference between ERROR_CODE FRM- errors and DBMS_ERROR_CODE ORA- errors? Apart from one being a form error and the other being a server error, what different things do they tell us? If an implicit DML error ocurrs would this generate ORA- and FRM- errors at the same time.
Cheers
Gus
Message was edited by:
gusora -
What Tables or Views for ORA- errors?
What are those tables or views where you can lookup for the ORA- errors which has a description or meaning?
Thanks,
WarrenOf course, you can always use the SQLERRM function, as well:
SQL> begin
2 for i in 1..100 loop
3 dbms_output.put_line(SQLERRM(i * -1));
4 end loop;
5 end;
6 /
ORA-00001: unique constraint (.) violated
ORA-00002: Message 2 not found; product=RDBMS; facility=ORA
ORA-00003: Message 3 not found; product=RDBMS; facility=ORA
ORA-00004: Message 4 not found; product=RDBMS; facility=ORA
ORA-00005: Message 5 not found; product=RDBMS; facility=ORA
ORA-00006: Message 6 not found; product=RDBMS; facility=ORA
ORA-00007: Message 7 not found; product=RDBMS; facility=ORA
ORA-00008: Message 8 not found; product=RDBMS; facility=ORA
ORA-00009: Message 9 not found; product=RDBMS; facility=ORA
ORA-00010: Message 10 not found; product=RDBMS; facility=ORA
ORA-00011: Message 11 not found; product=RDBMS; facility=ORA
ORA-00012: Message 12 not found; product=RDBMS; facility=ORA
ORA-00013: Message 13 not found; product=RDBMS; facility=ORA
ORA-00014: Message 14 not found; product=RDBMS; facility=ORA
ORA-00015: Message 15 not found; product=RDBMS; facility=ORA
ORA-00016: Message 16 not found; product=RDBMS; facility=ORA
ORA-00017: session requested to set trace event
ORA-00018: maximum number of sessions exceeded
ORA-00019: maximum number of session licenses exceeded
ORA-00020: maximum number of processes () exceeded
ORA-00021: session attached to some other process; cannot switch session
ORA-00022: invalid session ID; access denied
ORA-00023: session references process private memory; cannot detach session
ORA-00024: logins from more than one process not allowed in single-process mode
ORA-00025: failed to allocate
ORA-00026: missing or invalid session ID
ORA-00027: cannot kill current session
ORA-00028: your session has been killed
ORA-00029: session is not a user session
ORA-00030: User session ID does not exist.
ORA-00031: session marked for kill
ORA-00032: invalid session migration password
ORA-00033: current session has empty migration password
ORA-00034: cannot in current PL/SQL session
ORA-00035: LICENSE_MAX_USERS cannot be less than current number of users
ORA-00036: maximum number of recursive SQL levels () exceeded
ORA-00037: cannot switch to a session belonging to a different server group
ORA-00038: Cannot create session: server group belongs to another user
ORA-00039: Message 39 not found; product=RDBMS; facility=ORA
ORA-00040: Message 40 not found; product=RDBMS; facility=ORA
ORA-00041: Message 41 not found; product=RDBMS; facility=ORA
ORA-00042: Message 42 not found; product=RDBMS; facility=ORA
ORA-00043: Message 43 not found; product=RDBMS; facility=ORA
ORA-00044: Message 44 not found; product=RDBMS; facility=ORA
ORA-00045: Message 45 not found; product=RDBMS; facility=ORA
ORA-00046: Message 46 not found; product=RDBMS; facility=ORA
ORA-00047: Message 47 not found; product=RDBMS; facility=ORA
ORA-00048: Message 48 not found; product=RDBMS; facility=ORA
ORA-00049: Message 49 not found; product=RDBMS; facility=ORA
ORA-00050: operating system error occurred while obtaining an enqueue
ORA-00051: timeout occurred while waiting for a resource
ORA-00052: maximum number of enqueue resources () exceeded
ORA-00053: maximum number of enqueues exceeded
ORA-00054: resource busy and acquire with NOWAIT specified
ORA-00055: maximum number of DML locks exceeded
ORA-00056: DDL lock on object '.' is already held in an incompatible mode
ORA-00057: maximum number of temporary table locks exceeded
ORA-00058: DB_BLOCK_SIZE must be to mount this database (not )
ORA-00059: maximum number of DB_FILES exceeded
ORA-00060: deadlock detected while waiting for resource
ORA-00061: another instance has a different DML_LOCKS setting
ORA-00062: DML full-table lock cannot be acquired; DML_LOCKS is 0
ORA-00063: maximum number of LOG_FILES exceeded
ORA-00064: object is too large to allocate on this O/S (,)
ORA-00065: initialization of FIXED_DATE failed
ORA-00066: LOG_FILES is but needs to be to be compatible
ORA-00067: invalid value for parameter ; must be at least
ORA-00068: invalid value for parameter , must be between and
ORA-00069: cannot acquire lock -- table locks disabled for
ORA-00070: command is not valid
ORA-00071: process number must be between 1 and
ORA-00072: process "" is not active
ORA-00073: command takes between and argument(s)
ORA-00074: no process has been specified
ORA-00075: process "" not found in this instance
ORA-00076: dump not found
ORA-00077: dump is not valid
ORA-00078: cannot dump variables by name
ORA-00079: variable not found
ORA-00080: invalid global area specified by level
ORA-00081: address range [, ) is not readable
ORA-00082: memory size of is not in valid set of [1], [2], [4]
ORA-00083: warning: possibly corrupt SGA mapped
ORA-00084: global area must be PGA, SGA, or UGA
ORA-00085: current call does not exist
ORA-00086: user call does not exist
ORA-00087: command cannot be executed on remote instance
ORA-00088: command cannot be executed by shared server
ORA-00089: invalid instance number in ORADEBUG command
ORA-00090: failed to allocate memory for cluster database ORADEBUG command
ORA-00091: LARGE_POOL_SIZE must be at least
ORA-00092: LARGE_POOL_SIZE must be greater than LARGE_POOL_MIN_ALLOC
ORA-00093: must be between and
ORA-00094: requires an integer value
ORA-00095: Message 95 not found; product=RDBMS; facility=ORA
ORA-00096: invalid value for parameter , must be from among
ORA-00097: use of Oracle SQL feature not in SQL92 Level
ORA-00098: Message 98 not found; product=RDBMS; facility=ORA
ORA-00099: timed out while waiting for resource, potential PDML deadlock
ORA-00100: no data found
PL/SQL procedure successfully completed -
Oracle Error Code Table Exist?
I am wondering if there is a table in the DD (or elsewhere) that contains the message text associated with Oracle error codes? I know that oerr can be used (outside of the DB), but we are hoping these exist in a table for an auditing application we are trying to work.
Thanks.They are accessible via the SQLERRM function, e.g.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> SET SERVEROUTPUT ON;
SQL> BEGIN
2 FOR i IN 100 .. 110 LOOP
3 DBMS_OUTPUT.PUT_LINE (SQLERRM (-i));
4 END LOOP;
5 END;
6 /
ORA-00100: no data found
ORA-00101: invalid specification for system parameter DISPATCHERS
ORA-00102: network protocol cannot be used by dispatchers
ORA-00103: invalid network protocol; reserved for use by dispatchers
ORA-00104: deadlock detected; all public servers blocked waiting for resources
ORA-00105: too many dispatcher configurations
ORA-00106: cannot startup/shutdown database when connected to a dispatcher
ORA-00107: failed to connect to ORACLE listener process
ORA-00108: failed to set up dispatcher to accept connection asynchronously
ORA-00109: invalid value for attribute :
ORA-00110: invalid value for attribute , must be between and
PL/SQL procedure successfully completed.
SQL> -
Hallo,
is there a list where I can see all the error codes and description why a geometry can be invalid when I validate geometries? We wanna program and want to catch all exceptions.
In release 9.2 there are not that much routines for fixing validation errors? Any extra literature about this topic?
Regards KatrinHi Matic,
The error messages reside in file %ORACLE_HOME%\RDBMS\mesg\oraus.msb (Windows that is). Format not published (see http://www.jlcomp.demon.co.uk/faq/windowsoerr.html)
The message text can be retrieved in sql / plsql using the sqlerrm function :
dbms_output.put_line(sqlerrm(-13037));
--olaf -
Hi all ,
I have written a function to get the gl_date from ce_reconcilied transactions_v . but when i call th function in a select query , it is not returning any data.
I have used the following intialization in the function
Mo_Global.set_policy_context('S',p_org_id);
cep_standard.init_security;
But when i use anonymous block to get gl_date printed it is fetching data from the view.
Below is the code for Function
CREATE OR REPLACE Function l3get_gl_date(p_org_id NUMBER,p_statement_line_id NUMBER)
RETURN DATE
AS
v_gl_date DATE;
ct NUMBER;
BEGIN
Mo_Global.set_policy_context('S',p_org_id);
cep_standard.init_security;
SELECT count(*) into ct from ce_reconciled_transactions_v where org_id=p_org_id ;
dbms_output.put_line('count:' ||ct || 'org ' ||p_org_id || ' line ' ||p_statement_line_id);
SELECT gl_date INTO v_gl_date
FROM ce_reconciled_transactions_v where statement_line_id=p_statement_line_id;
RETURN v_gl_date;
EXCEPTION
WHEN OTHERS
THEN
dbms_output.put_line('unable to get GL_DATE' ||SQLERRM);
RETURN NULL;
END;
below is tha anonymous block
declare
p_org_id NUMBER;
p_statement_line_id NUMBER;
ct NUMBER;
v_gl_date DATE;
BEGIN
select org_id into p_org_id from ce_bank_acct_uses_all where bank_account_id=10911;
select statement_line_id into p_statement_line_id from ce_statement_lines where statement_header_id=41130 and line_number=4;
Mo_Global.set_policy_context('S',p_org_id);
cep_standard.init_security;
SELECT count(*) into ct from ce_reconciled_transactions_v where org_id=p_org_id ;
dbms_output.put_line('count: ' ||ct || 'org ' ||p_org_id || ' line ' ||p_statement_line_id);
SELECT gl_date INTO v_gl_date
FROM ce_reconciled_transactions_v where statement_line_id=p_statement_line_id;
dbms_output.put_line('GL Date: ' || v_gl_date);
EXCEPTION
WHEN OTHERS
THEN
dbms_output.put_line(SQLERRM);
END;
please suggest .Hi,
Try adding the following code so we can verify the org is set in your function:
Add to the definition:
v_org_id number;
Add after setting the policy:
select MO_GLOBAL.get_current_org_id()
into v_org_id from dual;
FND_FILE.PUT_LINE(FND_FILE.LOG,'Current MO Org_id='||v_org_id);
This will verify that the org_id was set.
Are you getting any errors, or simply no data found.
Cheryl -
Item Conversion Template Issue for Oracle Migration - Copy functionality
Hi,
I am working on Migration project which is from Radius ERP to Oracle 11.5.10.2.
Currently working on Item Conversion. This Item conversion having the fileds like (ORGANIZATION_ID,SEGMENT1,DESCRIPTION,ITEM_TYPE,COST_OF_SALES_ACCOUNT,SALES_ACCOUNT,ATTRIBUTE_CATEGORY,ATTRIBUTE1,ATTRIBUTE2,ATTRIBUTE3,ATTRIBUTE4,ATTRIBUTE5,ATTRIBUTE6,ATTRIBUTE7,ATTRIBUTE8,ATTRIBUTE9,ATTRIBUTE10,ATTRIBUTE11,ATTRIBUTE12,ATTRIBUTE13,ATTRIBUTE14,ATTRIBUTE15,GLOBAL_ATTRIBUTE10,REF_INVENTORY_ITEM_ID,REF_ORGANIZATION_ID).
I have validated those fields and loaded into interfacing to Oracle Successfully in the master Org and Validated through Frontend.
when I close the form, I will be receiving the below warning message and telling that Template id needs to be assign to the item before assigning item to the Org. The message is showing like
"*You have not applied a template to this item, please apply a template before assigning this item to an ORG.*"
Please find the below package which I wrote for this conversion requirement.
The customer is saying like need to achieve the copy functionality based on the "REF_INVENTORY_ITEM_ID and REF_ORGANIZATION_ID".
The Issue is am not able to handle the copy functionality and getting above message. kindly refer the package and suggest me where i am doing the mistake. Its high priority issue for me.
Thanks in advance.
CREATE OR REPLACE PACKAGE APPS.xxxx_inv_items_conv_pkg
AS
PROCEDURE xxx_item_conversion_proc (
errbuf OUT VARCHAR2,
retcode OUT VARCHAR2,
p_org_id IN NUMBER,
-- p_commit_point IN NUMBER,
p_load_code IN VARCHAR2
IS
<<Local Variables Declaration>> <<For space limit deleted these variables>>
CURSOR cur_item_master (pc_org_code VARCHAR2)
IS
SELECT itemstg.*
FROM xxx_inv_system_items_stg itemstg
WHERE itemstg.organization_id = pc_org_code
AND itemstg.status_flag IS NULL;
CURSOR cur_item_master_dup (pc_org_code VARCHAR2)
IS
SELECT itemstg.segment1, itemstg.organization_id
FROM xxx_inv_system_items_stg itemstg
WHERE itemstg.ROWID <
(SELECT MAX (b.ROWID)
FROM xxx_inv_system_items_stg b
WHERE b.segment1 = itemstg.segment1
AND b.organization_id = itemstg.organization_id
AND b.organization_id = pc_org_code
AND itemstg.status_flag IS NULL
AND b.status_flag IS NULL);
BEGIN
IF p_load_code = 'Insert'
THEN
l_transaction_type := 'CREATE'; -- Default Value in I/F Table
ELSIF p_load_code = 'Update'
THEN
l_transaction_type := 'UPDATE'; -- Default Value in I/F Table
END IF;
DBMS_OUTPUT.put_line ( 'Validation Starts At :'
|| TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS')
--Checking for Duplicate Records items
BEGIN
UPDATE xxx_inv_system_items_stg a
SET a.status_flag = 'E',
a.error_message = 'Duplicate Record'
WHERE a.ROWID >
ANY (SELECT b.ROWID
FROM xxx_inv_system_items_stg b
WHERE a.segment1 = b.segment1
AND a.organization_id = b.organization_id)
AND a.organization_id = p_org_id
AND a.status_flag IS NULL;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Exception in updating duplicates'
|| SQLERRM
END;
DBMS_OUTPUT.put_line ('CheckPoint: Duplicate Record');
BEGIN
SELECT organization_id
INTO l_organization_id
FROM org_organization_definitions
WHERE organization_id = p_org_id;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.PUT_LINE(p_org_id||' Org Does Not Exist');
-- p_retcode := '2';
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Exception in Getting Org Id'||'Cannot Proceed');
-- p_retcode := '2';
END ;
DBMS_OUTPUT.put_line ('CheckPoint: Orgcode' || l_organization_id);
/* IF p_retcode = '2'
THEN
RETURN;
END IF;*/
--Block : Setting Master and Validation Orgs Flags
BEGIN
SELECT DECODE (master_organization_id, l_organization_id, 'Y', 'N'),
master_organization_id
INTO l_master_org,
l_master_org_id
FROM mtl_parameters
WHERE organization_id = l_organization_id;
EXCEPTION
WHEN OTHERS
THEN
l_master_org := 'N';
l_master_org_id := NULL;
DBMS_OUTPUT.PUT_LINE(p_org_id||' Org Does Not Exist');
END ;
DBMS_OUTPUT.put_line ('master_organization_id');
SELECT fnd_profile.VALUE ('USER_ID')
INTO l_user_id
FROM DUAL;
-- Block : Set the SET_PROCESS_ID
l_set_process_id := l_organization_id;
l_insert_count := 0;
LOOP
BEGIN
SELECT COUNT (segment1)
INTO l_insert_count
FROM mtl_system_items_interface
WHERE set_process_id = l_set_process_id
AND transaction_type = l_transaction_type
AND process_flag = 1;
EXCEPTION
WHEN OTHERS
THEN
l_insert_count := 0;
END;
EXIT WHEN l_insert_count = 0;
l_set_process_id := l_set_process_id + 10;
END LOOP;
DBMS_OUTPUT.put_line ('SET PROCESS ID -l_insert_count ' || l_insert_count);
IF p_load_code = 'Insert'
THEN
BEGIN
FOR recitem_data IN cur_item_master_dup (p_org_id)
LOOP
UPDATE xxx_inv_system_items_stg
SET status_flag = l_processed_flag,
error_message = l_error_message
WHERE segment1 = recitem_data.segment1
AND organization_id = recitem_data.organization_id
AND status_flag IS NULL;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Update of Duplicates Failed : '
|| SQLCODE
|| '--'
|| SQLERRM
END ;
END IF;
FOR recitem_data IN cur_item_master (p_org_id)
LOOP
<<Local Variables Declaration>> <<For space limit deleted these variables>>
IF p_load_code = 'Update'
THEN
l_error_message := 'Update Mode' || l_error_delimiter;
END IF;
--l_count := -1;
BEGIN
DBMS_OUTPUT.put_line ('CheckPoint: ItemValidationStart');
SELECT DISTINCT inventory_item_id,
restrict_subinventories_code,
restrict_locators_code
INTO l_inventory_item_id,
l_restrict_subinventories_code,
l_restrict_locators_code
FROM apps.mtl_system_items_b msi
WHERE msi.organization_id = l_organization_id
AND msi.segment1 = UPPER (recitem_data.segment1);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_count := 0;
-- l_processed_flag := 'F';
DBMS_OUTPUT.put_line ('inventory_item_id - AFTER MAIN LOOP' || l_inventory_item_id||'-'||l_processed_flag);
DBMS_OUTPUT.put_line ('inventory_item_id - AFTER MAIN LOOP' || l_inventory_item_id||'-'||recitem_data.ref_inventory_item_id);
WHEN OTHERS
THEN
l_count := -1;
-- l_processed_flag := 'F';
DBMS_OUTPUT.put_line ('inventory_item_id - AFTER MAIN LOOP' || l_inventory_item_id||'-'||l_processed_flag);
END ;
DBMS_OUTPUT.put_line ('inventory_item_id - AFTER MAIN LOOP'||recitem_data.ref_inventory_item_id);
IF l_count = -1
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Exception - Checking Item already Present'
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('Exception - Checking Item already Present'||l_processed_flag);
ELSIF (l_count > 0 AND p_load_code = 'Insert')
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Item Already Exists In '
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('Exception - Checking Item already Present1'||l_processed_flag);
ELSIF (l_count = 0 AND p_load_code = 'Update')
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Item Not Present In '
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('Exception - Checking Item already Present2'||l_processed_flag);
END IF;
BEGIN
SELECT count(*)
INTO l_seg_count
FROM apps.mtl_system_items_b msi
WHERE msi.organization_id = l_organization_id
AND msi.segment1 = UPPER (recitem_data.segment1);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_seg_count := 0;
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Item Not Present In Oracle'
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('inventory_item_id - l_seg_count ' ||l_seg_count||'-'||l_processed_flag );
WHEN OTHERS
THEN
l_seg_count := -1;
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Item Not Present In Oracle'
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
END ;
IF p_load_code = 'Insert'
THEN
IF l_organization_id != l_master_org_id
THEN
BEGIN
SELECT COUNT (1)
INTO l_org_item_count
FROM apps.mtl_system_items_b msi
WHERE msi.organization_id = l_master_org_id
AND msi.segment1 = UPPER (recitem_data.segment1);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_org_item_count := 0;
DBMS_OUTPUT.put_line ('l_org_item_count ' ||l_org_item_count||'-'||l_processed_flag );
WHEN OTHERS
THEN
l_org_item_count := -1;
END ;
IF l_org_item_count = -1
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Exception - Checking Item in Master '
|| l_error_delimiter;
ELSIF l_org_item_count = 0
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Item Does Not Exist in Master '
|| l_error_delimiter;
END IF;
END IF;
END IF;
DBMS_OUTPUT.put_line ( 'CheckPoint: Iteminmasterorg'
|| l_org_item_count
IF (recitem_data.description IS NULL AND p_load_code = 'Insert')
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message || 'Description is NULL' || l_error_delimiter;
END IF;
IF (recitem_data.sales_account IS NOT NULL)
THEN
BEGIN
SELECT code_combination_id
INTO l_sales_account
FROM gl_code_combinations_kfv
WHERE code_combination_id= recitem_data.sales_account;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
-- l_processed_flag := 'F'; --QUESTION
l_error_message :=
l_error_message
|| 'Sales Account Not Setup '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ( 'CheckPoint: Salesacct_Validation'
|| l_sales_account||'-'||l_processed_flag
WHEN OTHERS
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Sales Account Exception '
|| SQLERRM
|| l_error_delimiter;
DBMS_OUTPUT.put_line ( 'CheckPoint: Salesacct_Validation'
|| l_sales_account||'-'||l_processed_flag
END ;
END IF;
IF (recitem_data.cost_of_sales_account IS NOT NULL)
THEN
BEGIN
SELECT code_combination_id
INTO l_cost_of_sales_account
FROM gl_code_combinations_kfv
WHERE code_combination_id =
recitem_data.cost_of_sales_account;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'COGS Account Not Setup '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ( 'l_cost_of_sales_account'
|| l_cost_of_sales_account||'-'||l_processed_flag
WHEN OTHERS
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'COGS Account Exception '
|| SQLERRM
|| l_error_delimiter;
DBMS_OUTPUT.put_line ( 'l_cost_of_sales_account'
|| l_cost_of_sales_account||'-'||l_processed_flag
END check_cogs_account;
END IF;
BEGIN
select distinct organization_code
into l_ref_org_code
from org_organization_definitions
where organization_id = recitem_data.ref_organization_id ;
EXCEPTION
WHEN OTHERS THEN
l_ref_org_code:= NULL;
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Reference Org Not Present'
|| p_org_id
|| ' Organization '
|| l_error_delimiter ;
DBMS_OUTPUT.put_line ('l_ref_org_code'|| l_ref_org_code||'-'||l_processed_flag);
END;
BEGIN
select concatenated_segments
into l_ref_inventory_item_code
from mtl_system_items_kfv
where inventory_item_id = recitem_data.ref_inventory_item_id
and organization_id = recitem_data.ref_organization_id ;
EXCEPTION
WHEN OTHERS THEN
l_ref_inventory_item_code :=NULL;
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Reference Item Not Present'
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('l_ref_inventory_item_code'|| l_ref_inventory_item_code||'-'||l_processed_flag);
END;
IF (l_master_org = 'N' AND p_load_code = 'Insert')
THEN
BEGIN
SELECT count(*)
INTO l_description_count
FROM mtl_system_items_tl
WHERE organization_id = l_master_org_id
AND inventory_item_id =
(SELECT inventory_item_id
FROM mtl_system_items_b
WHERE organization_id = l_master_org_id
AND segment1 = recitem_data.segment1);
END ;
IF l_description_count > 0 THEN
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Item Description Not Present'
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
END IF;
END IF;
IF l_processed_flag = 'S'
THEN
BEGIN
INSERT INTO mtl_system_items_interface
(organization_id,
segment1,
description,
ITEM_TYPE,
COST_OF_SALES_ACCOUNT,
SALES_ACCOUNT,
attribute_category,
set_process_id,
transaction_type,
process_flag,
copy_organization_code,
copy_item_number,
creation_date,
created_by,
last_updated_by,
last_update_date
--attribute_category
, attribute1
, attribute2
,attribute3
,attribute4
,attribute5
,attribute6
,attribute7
,attribute8
,attribute9
,attribute10
,attribute11
,attribute12
,attribute13
,attribute14
,attribute15
,global_attribute10
VALUES (l_organization_id,
recitem_data.segment1,
recitem_data.description,
recitem_data.ITEM_TYPE,
recitem_data.COST_OF_SALES_ACCOUNT,
recitem_data.SALES_ACCOUNT,
recitem_data.ATTRIBUTE_CATEGORY,
l_set_process_id,
l_transaction_type, --,l_transaction_type
l_process_flag,
l_ref_org_code,
l_ref_inventory_item_code,
SYSDATE, l_user_id,
l_user_id, SYSDATE
-- l_attribute_category
,recitem_data.attribute1
,recitem_data.attribute2
,recitem_data.attribute3
,recitem_data.attribute4
,recitem_data.attribute5
,recitem_data.attribute6
,recitem_data.attribute7
, recitem_data.attribute8
,recitem_data.attribute9
, recitem_data.attribute10
,recitem_data.attribute11
,recitem_data.attribute12
,recitem_data.attribute13
,recitem_data.attribute14
,recitem_data.attribute15
, substr(recitem_data.global_attribute10,1,length(recitem_data.global_attribute10)-1) --recitem_data.global_attribute10
l_insert_count := l_insert_count + 1;
/* IF (l_insert_count = NVL (p_commit_point, 10000))
THEN
-- l_set_process_id := l_set_process_id + 10; -- REVERT BACK CHANGE
l_insert_count := 0;
END IF;
EXCEPTION
WHEN OTHERS
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Error in Inserting Item '
|| SQLERRM
|| l_error_delimiter;
END ;
COMMIT;
DBMS_OUTPUT.put_line ('CheckPoint: Insertion Completed in Intfacetable');
END IF;
BEGIN
UPDATE xxx_inv_system_items_stg
SET status_flag = l_processed_flag,
error_message = l_error_message
WHERE segment1 = recitem_data.segment1
AND organization_id = recitem_data.organization_id
AND status_flag IS NULL;
COMMIT;
DBMS_OUTPUT.put_line ('Error Message'||l_error_message);
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG,
'Error:Updating Item:'
|| SQLCODE
|| '-'
|| SQLERRM
END;
END LOOP; --FOR recitem_data IN cur_item_master
DBMS_OUTPUT.put_line ( 'Validation Ends At :'
|| TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS')
DBMS_OUTPUT.put_line ('Number of records inserted into Table Successfully -->'|| l_insert_count);
END;
END xxxx_inv_items_conv_pkg;
Edited by: 896170 on Apr 12, 2013 11:58 PMIssue got solved... changed the PO line amount as:
<?xdoxslt:set_variable($_XDOCTX,'line_amt',xdoxslt:to_number(LINE_AMOUNT))?>
Reference :Syntax for 'to_number'
Regards
Manikanta Panigrahi -
How to test a simple PL SQL function from another PL SQL script
Hi,
I have created a function. Now i need to test that whether it is returning the correct values or not.
For that, i have written anothe pl sql script and trying to call this function. Im passing all the IN parameters in that function. I assume here that OUT parameters will provide me the result. Im trying to display the OUT parameter one by one to see my result.
I'm using toad as sql client here connected with oracle.
pl sql script:-
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('$$$$$$$ VINOD KUMAR NAIR $$$$$$$');
FETCH_ORDER_PRODUCT_DATA(320171302, 1006, 6999,
ODNumber OUT VARCHAR2, Line_Number OUT VARCHAR2,
ServiceID OUT VARCHAR2, BilltoNumber OUT VARCHAR2,
AnnualPrice OUT NUMBER, CoverageCode OUT VARCHAR2)
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ODNumber );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | Line_Number );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ServiceID );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | BilltoNumber );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | AnnualPrice );
DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | CoverageCode );
END;
Function:-
Program Name : SPOT_Order_Product_Data_For_CFS.sql
Description : Function to Validate parameters from CFS
By : Vinod Kumar
Date : 08/19/2011
Modification History
By When TAR Description
CREATE OR REPLACE FUNCTION FETCH_ORDER_PRODUCT_DATA(orderNumber IN VARCHAR2, customerNumber IN VARCHAR2,
productLine IN VARCHAR2, ODNumber OUT VARCHAR2,
Line_Number OUT VARCHAR2, ServiceID OUT VARCHAR2,
BilltoNumber OUT VARCHAR2, AnnualPrice OUT NUMBER,
CoverageCode OUT VARCHAR2)
RETURN VARCHAR2 IS
lv_err_msg VARCHAR2(100) := '';
lv_bucket_id VARCHAR2(14);
lv_bill_number VARCHAR2(30);
lv_anual_price NUMBER;
lv_coverage_code VARCHAR2(8);
lv_quote_num NUMBER(10) := NULL;
lv_line_num NUMBER(5) := 0;
lv_customer_number VARCHAR2(30) := customerNumber;
lv_product_id VARCHAR2(14) := productLine;
lv_count_quote NUMBER := 0;
lv_quote_status VARCHAR2(5);
lv_quote_version NUMBER(2):=0;
BEGIN
IF INSTR(orderNumber, '-') = 0 THEN
lv_quote_num := orderNumber;
ELSE
lv_quote_num := SPT_Delimiter(orderNumber, 1, '-');
lv_line_num := SPT_Delimiter(orderNumber, 2, '-');
END IF;
--Check status of the quote COM, APP
SELECT COUNT(*) INTO lv_count_quote FROM sot_order_header WHERE ORDER_NUMBER=lv_quote_num
AND ORDER_STATUS IN ('APP', 'COM') AND CUSTOMER_NUMBER = lv_customer_number;
IF lv_count_quote = 0 THEN
lv_err_msg := 'Invalid Order number';
RETURN lv_err_msg;
END IF;
-- Fetch the latest version on SPOT quote
SELECT MAX(VERSION_NUMBER) INTO lv_quote_version FROM SPT_QUOTE_HEADER WHERE QUOTE_NUMBER = lv_quote_num
AND CUSTOMER_NUMBER = lv_customer_number;
-- If quote is valid fetch the data in OUT parameters
IF lv_line_num = 0 THEN
BEGIN
SELECT a.CUSTOMER_BILLTO_NUMBER,
b.LINE_NUMBER, b.BUCKET_ID,
b.ANNUAL_REF_RATE_USD, b.COVERAGE_CODE
INTO lv_bill_number,lv_line_num,lv_bucket_id,lv_anual_price,lv_coverage_code
FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
WHERE a.QUOTE_NUMBER = lv_quote_num
AND a.CUSTOMER_NUMBER = lv_customer_number
AND a.VERSION_NUMBER = lv_quote_version
AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
AND a.VERSION_NUMBER = b.VERSION_NUMBER
AND b.PRODUCT_ID = lv_product_id;
ODNumber := lv_quote_num;
BilltoNumber := lv_bill_number;
Line_Number := lv_line_num;
ServiceID := lv_bucket_id;
AnnualPrice := lv_anual_price;
CoverageCode := lv_coverage_code;
RETURN '';
EXCEPTION WHEN OTHERS THEN
lv_err_msg := 'Multiple PIDs existing in the SPOT order, please provide the SPOT order + line number as input data';
RETURN lv_err_msg;
END;
ELSE
BEGIN
SELECT a.CUSTOMER_BILLTO_NUMBER,
b.BUCKET_ID, b.ANNUAL_REF_RATE_USD,
b.COVERAGE_CODE
INTO lv_bill_number,lv_bucket_id,lv_anual_price,lv_coverage_code
FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
WHERE a.QUOTE_NUMBER = lv_quote_num
AND a.CUSTOMER_NUMBER = lv_customer_number
AND a.VERSION_NUMBER = lv_quote_version
AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
AND a.VERSION_NUMBER = b.VERSION_NUMBER
AND b.PRODUCT_ID = lv_product_id
AND b.LINE_NUMBER = lv_line_num;
ODNumber := lv_quote_num;
BilltoNumber := lv_bill_number;
Line_Number := lv_line_num;
ServiceID := lv_bucket_id;
AnnualPrice := lv_anual_price;
CoverageCode := lv_coverage_code;
RETURN '';
EXCEPTION WHEN OTHERS THEN
lv_err_msg := 'Multiple SPOT lines exist with same parameter';
RETURN lv_err_msg;
END;
END IF;
EXCEPTION
WHEN OTHERS THEN
lv_err_msg := '@@@ EXCEPTION THROWN @@@ '|| SUBSTR(SQLERRM,1,120);
RETURN lv_err_msg ;
END;
Don't look at the function, it might have errors but my primary concern is how to test this function. Once I start doing its testing then only i can understand any bugs(if any).
My pl sql is not so good. Im still learning. I don't understand IN and OUT parameters are.
I just know that IN parameters r those whick we pass in to the function wen we call it and OUT parameters are those through which we get the result.
Thanks in advance
Vinod Kumar Nair20100511 wrote:
I wondered how I could test the output of the function from within TOAD?I usually create the following function in my developer schema:
create or replace function BoolToChar( b boolean ) return varchar2 is
begin
if b then
return( 'TRUE' );
else
return( 'FALSE' );
end if;
end;To test a function like yours, the following will do in SQL*Plus/TOAD/etc:
begin
DBMS_OUTPUT.put_line(
BoolToChar( XCCC_PO_APPROVALLIST_S1.does_cpa_exist(1017934) )
end;
I'm probably doing 101 things wrong here, but thought I'd ask anyway and risk being shouted at.Shout at? You reckon? I thought people risked being beaten with a lead pipe, or pelted with beer cans and stale pretzels - which makes being shouted at a really safe and viable alternative. {noformat};-){noformat} -
How to break the output in a function
Hi All,
I am using oracle Db 10g
I have write a function to get the output of Expire date and pass this function to Alert in oracle.
My Function is Like this
create or replace
function Expiry_alert (P_EXPIRY_DATE date)
return VARCHAR2
IS
lv_return_value varchar2(10000);
cursor c_exp_alt
is
SELECT Distinct c_po_number,c_bg_type,c_guarantee_number,c_expiry_date,c_supplier_name
from xxbgs_bank_guarantee_master
WHERE TRUNC (TO_DATE (C_expiry_date) -15) = TRIM (SYSDATE)
and c_expiry_date= p_expiry_date;
BEGIN
for c_exp_alt_rec in c_exp_alt
loop
lv_return_value:= lv_return_Value||CHR(10)||'Bank Guarantee('||c_exp_alt_rec.C_guarantee_number||','||c_exp_alt_rec.C_BG_TYPE ||','||c_exp_alt_rec.C_po_number||','||c_exp_alt_rec.c_supplier_name ||')'||'is getting expired on'||'('||C_EXP_ALT_REC.C_EXPIRY_DATE||')'||;
end loop;
return(lv_return_value);
exception
when others then
null;
--dbms_output.put_line ('Error:'sqlerrm);
--return(lv_return_value);
END;
When i execute the function using select statement like this
SELECT distinct Expiry_alert(C_EXPIRY_DATE)
FROM xxbgs_bank_guarantee_master
WHERE TRUNC (TO_DATE (C_expiry_date)-15) =
TRIM (SYSDATE)
My output is like this
Bank Guarantee(100012,Parent Company Guarantee,1000,Advantage Corp)is getting expired on(02-MAR-12) Bank Guarantee(123890,Advance Bank Guarantee,1011,Office Supplies, Inc.)is getting expired on(02-MAR-12)
In a single line, But here i have two different Guarantee number so i need two records like this
Bank Guarantee(100012,Parent Company Guarantee,1000,Advantage Corp)is getting expired on(02-MAR-12)
Bank Guarantee(123890,Advance Bank Guarantee,1011,Office Supplies, Inc.)is getting expired on(02-MAR-12)
Can any one pls tell me how to change the function to achieve this.
Regards
Srikanth
Edited by: Srikkanth.M on Feb 16, 2012 4:41 PMSrikkanth.M wrote:
Hi All,
I am using oracle Db 10g
I have write a function to get the output of Expire date and pass this function to Alert in oracle.
My Function is Like this
.. snip ..
exception
when others then
null;
Seriously? Your function contains an exception handler to mask any and all errors that may occur? WHY?
When i execute the function using select statement like this
SELECT distinct Expiry_alert(C_EXPIRY_DATE)
FROM xxbgs_bank_guarantee_master
WHERE TRUNC (TO_DATE (C_expiry_date)-15) =
TRIM (SYSDATE)
My output is like this
Bank Guarantee(100012,Parent Company Guarantee,1000,Advantage Corp)is getting expired on(02-MAR-12) Bank Guarantee(123890,Advance Bank Guarantee,1011,Office Supplies, Inc.)is getting expired on(02-MAR-12)
In a single line, But here i have two different Guarantee number so i need two records like this
Bank Guarantee(100012,Parent Company Guarantee,1000,Advantage Corp)is getting expired on(02-MAR-12)
Bank Guarantee(123890,Advance Bank Guarantee,1011,Office Supplies, Inc.)is getting expired on(02-MAR-12)
Can any one pls tell me how to change the function to achieve this.Sounds like you need a pipelined function to return multiple rows...
Basic example of pipelined function with multiple columns...
CREATE OR REPLACE TYPE myrec AS OBJECT
( col1 VARCHAR2(10),
col2 VARCHAR2(10)
CREATE OR REPLACE TYPE myrectable AS TABLE OF myrec
CREATE OR REPLACE FUNCTION pipedata(p_str IN VARCHAR2) RETURN myrectable PIPELINED IS
v_str VARCHAR2(4000) := REPLACE(REPLACE(p_str, '('),')');
v_obj myrec := myrec(NULL,NULL);
BEGIN
LOOP
EXIT WHEN v_str IS NULL;
v_obj.col1 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
IF INSTR(v_str,',')>0 THEN
v_obj.col2 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
ELSE
v_obj.col2 := v_str;
v_str := NULL;
END IF;
PIPE ROW (v_obj);
END LOOP;
RETURN;
END;
SQL> select *
2 from table(pipedata('(1,2),(3,4),(5,6)'));
COL1 COL2
1 2
3 4
5 6of course why you need to do this in a function in the first place? Can't you just query the data concatenated as you want it? -
Error message in compliing a function
Hi All,
I am trying to compiling the following function, but it is throwing the an error.
CREATE OR REPLACE FUNCTION parapage_discosessions
RETURN bumber
IS
discosessions number;
BEGIN
discosessions := select count(*) from gv$session where username IN ('DISCOFIELD', 'DISCOUSER','DISCOADMIN');
RETURN discosessions;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END;
The above function is giving the following error message
Error(9,21): PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character set specification> <an alternatively-quo
Please give me any suggestionsSQL> CREATE OR REPLACE FUNCTION parapage_discosessions
2 RETURN number IS
3 discosessions number;
4 BEGIN
5 select count(*) into discosessions
6 from gv$session
7 where username IN ('DISCOFIELD', 'DISCOUSER','DISCOADMIN');
8 RETURN discosessions;
9 EXCEPTION
10 WHEN OTHERS THEN
11 raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
12 END;
13 /
Function created -
Error while using row_num function in forms6i
Oracle forms6i
Hai
While using row num function in my forms i had a error.
My coding is
declare
pin_no varchar2(16);
pin_date date;
pin_time varchar2(25);
mstr varchar2(200);
m_file TEXT_IO.FILE_TYPE;
m_file_path varchar2(100) := :global.filename;
line_count number;
M_BARCODE VARCHAR2(16);
M_BARDATE DATE;
M_BARTIME varchar2(25);
M_No number;
Cursor c1 is
select barcode,bardate,bartime,
row_number() over (partition barcode order by bartime) as RN-------------------the error at this line
from temp_attendance
group by barcode,bardate,bartime
order by bardate;
begin
If m_file_path is not null then
m_file:= TEXT_IO.fopen(m_file_path, 'r');
--DELETE FROM temp_attendance;
Loop
begin
TEXT_IO.get_line(m_file,mstr);
mstr := ltrim(rtrim(mstr));
M_barcode :=substr(mstr,1,16);
M_bardate := to_date(substr(mstr,17,8),'DD/MM/YYYY');
M_bartime := (substr(mstr,25,4));
INSERT INTO temp_attendance(BARCODE,BARDATE,BARTIME,RN) VALUES(M_BARCODE,M_BARDATE,M_BARTIME,M_No);
Exception
when no_data_found then
text_io.fclose(m_file);
exit;
End;
End loop;
go_block('TEST_MS1');
clear_block(no_validate);
For r1 in c1 loop
:barcode := r1.barcode;
:bardate := r1.bardate;
:bartime := r1.bartime;
next_Record;
end loop;
first_record;
end if;
exception
when others then
forms_ddl('ROLLBACK');
message (sqlerrm);
end;
Thanks & Regards
Srikkanth.MHi,
Try using:
row_number() over (partition BY barcode order by bartime) as RN
If that wasn't the problem, what is the error you are getting?
Regards. -
Display error message in forms from function "verify_function"
Hi,
We have a number of users with our own created profile attached to them.
We have enabled the 'PASSWORD_VERIFY_FUNCTION' for our own profile.
Function "verify_function" is used to validate a user's password.
In "verify_function" we have used "raise_application_error" message in case password validation fails.
Example:
raise_application_error(-20001,'Password must be minimum 8 characters in length and maximum 30 characters long');Question) "raise_application_error" displays the error message only in SQL Plus prompt. How do I display the same message from Oracle forms?.
I have used DBMS_ERROR_TEXT & DBMS_ERROR_CODE in ON-ERROR trigger. This is not displaying the error message in forms in case validation failed in "verify_function". Oracle simply clears the username/password field with a new window. We want to display the error message that occured in "verify_function".
Thanksuse the following code in validating the item, e.g when-button-pressed
begin
verify_function;
exception
when others then
message(sqlerrm);
raise form_trigger_failure;
end ;
OR
instead of writing a procedure rewrite it as a function to return 1 if password is correct or 0 if password is wrong
Regards
Jihad -
Decode function in order by clause
Hi,
I need a help from you..
SELECT 'ALTER ' || object_type || ' '|| object_name ||' COMPILE;' FROM user_objects WHERE object_type IN ('FUNCTION', 'PACKAGE', 'PROCEDURE', 'TRIGGER', 'VIEW') ORDER BY DECODE(object_type, 'VIEW','A', 'FUNCTION','B', 'PROCEDURE', 'C', 'PACKAGE','D', 'Z');
Explanation: This will sort by type of an object, in the decode assigned value A to VIEW, B FUNCTION, C PROCEDURE, D to PACKAGE and Z to OTHERS. so all the views will be at the top and then functions, then procedures, then packages and finally the rest of the object.
Please let me know how this query will be executed.
Cheers,
bell.Hi,
Try this:
FOR obj_cur IN (
SELECT 'ALTER ' || object_type || ' '|| object_name ||' COMPILE;' exc_cmd FROM user_objects WHERE object_type IN ('FUNCTION', 'PACKAGE', 'PROCEDURE', 'TRIGGER', 'VIEW') ORDER BY DECODE(object_type, 'VIEW','A', 'FUNCTION','B', 'PROCEDURE', 'C', 'PACKAGE','D', 'Z')
LOOP
BEGIN
EXECUTE IMMEDIATE obj_cur.exc_cmd ;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(obj_cur.exc_cmd || SQLERRM);
END;
END LOOP;
Regards
Maybe you are looking for
-
My iTunes won't let me add or remove my music or playlists from my iPhone?
I recently got an iPhone and have downloaded my music from one computer and stuff, but now I have a laptop I can use for my iTunes. I've authorized my apple ID with the computer, but it's still not letting me add or remove things to/from my iPhone. I
-
Hi i need help in sort in out issue in worflow in sap EDI
i sap gurus i have two issues in sap workflow .can u guys help me out in sorting out these issues. 1) When checking out/reserving a work flow item(TC: SBWP), there is no option to display who has it checked out. When the workflow item is reserved, it
-
How to create License Key in Java ?
Hi, I need to Generate License keys of my application for different users. How to do it ? Regards, Ajay
-
I have iWork 09 DVD version and am running Yosemite. The app store and the applications both say there are updates available. When i go to run the update for either of the 3 applications i get the following message: Update unavailable with this Apple
-
Customer Id 172557703 I Have Illustrator 9 and want to upgrade to CS4 I Downloaded trail Illustrator CS4 I continue to get the message during set up: When I run set up I get the message that a min system requirement of 512.MB Ram is required. My Oper