SQL & PL/SQL :: Difference Between Include Program Header Before CREATE OR REPLACE PACKAGE Statement
Mar 2, 2010
Is there any difference between include program header before CREATE OR REPLACE PACKAGE statement and program header after CREATE OR REPLACE PACKAGE statement
CREATE OR REPLACE PACKAGE pkg_mkt_hub_load_collection AS PROCEDURE sp_final_load_mkt_hub; END pkg_mkt_hub_load_collection; / CREATE OR REPLACE PACKAGE BODY pkg_mkt_hub_load_collection AS c_default_limit CONSTANT PLS_INTEGER:=5000;
[code]....
show error
error code
SQL> @pkg_mkt_hub_load_collection.sql Package created. Warning: Package Body created with compilation errors. Errors for PACKAGE BODY PKG_MKT_HUB_LOAD_COLLECTION: LINE/COL ERROR -------- ----------------------------------------------------------------- 57/4 PL/SQL: Statement ignored PLS-00306: wrong number or types of arguments in call to 'MULTISET_INTERSECT_ALL' SQL>
how to write this query using all three tables in one query statement.
Result:
Input value of "GM" would return "GM@EMAIL.COM"
Input value of "GM" and "GMC" would return "GMC@EMAIL.COM"
If "GM" is supplied, then only return the "GM@EMAIL.COM" email.
If "GM" and "GMC" is supplied, then only return the "GMC@EMAIL.COM" email
Test Case : GM would return "GM@EMAIL.COM" email
Test Case : GM and GMC would return "GMC@EMAIL.COM" email
select email from email a, company b, sub_company c where (company = "GM" but no match found in sub_company) (company = "GM" and sub_company_name = "GMC" match is found in sub_company)
I want to creat a table using Execute Immediate that includes tablespace name in the create table command. But I don't know the tablespace name that the client is using. Can I incorporate in a script? If yes, then how?
I have written the following proc. While executing , it gives me the error: ORA-00959: tablespace 'V_TABLESPACE_NAME' does not exist.
create or replace procedure pr_create_table as v_tablespace_name varchar2(4000); begin select distinct tablespace_name into v_tablespace_name from user_tables where table_name like 'ABC%'; [code]....
I am about to pass 1Z0-051 and have been cramming. Ran across this scenario: Create or replace view. Correct answer: allows insert from view in multitable insert statement. Can I actually insert data from a view? My understanding is no data actually exists in a view. This has created a cavernous feeling of inadequacy.
I have make a new trigger.Create a trigger that inserting a new job_id MAX_SALARY assigned as the employee's salary more than 80 departmental charges
I have that code, is that correct?
CREATE OR REPLACE TRIGGER TR27 AFTER INSERT ON JOBS FOR EACH ROW BEGIN (SELECT MAX(SALARY) FROM EMPLOYEES WHERE DEPARMENT_ID=80); :NEW.MAX_SALARY := :OLD.MAX_SALARY; END;
CREATE OR REPLACE TRIGGER T_HST AFTER INSERT On HST FOR EACH ROW DECLARE Begin INSERT INTO HST (EMP_NO, START_DATE ) SELECT EMP_NO, SYSDATE FROM HST WHERE EMP_NO = :NEW.EMP_NO; End T_HRS_SAL_PERIOD_HSTY_UPD_PRI; /
when I insert a new record in table HST I get this error:
ORA-04091: table HST is mutating, trigger/function may not see it ORA-06512: at "T_HST", line 3 ORA-04088: error during execution of trigger 'T_HST'
i try to make trigger to execute immediate create or replace view
( CREATE OR REPLACE TRIGGER xxxx BEFORE INSERT ON table1 REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW declare l number ; v_ddl varchar2(4000); v_job number; [code]....
it give me error for insuffition privilage in execute immediate and after i make GRANT CREATE ANY TRIGGER TO user give me error can't commit in trigger.
create or replace procedure my_proc(p_user in varchar2) is l_cursor sys_refcursor; l_query constant varchar2(1000) := 'select a' || 'from ' || p_user || '.user_table' || 'where param0 = :x' || 'and param1 = :x' || 'and param2 = :x'
[Code]...
Suppose I execute my_proc many times and for multiple values of p_user. For performance reasons, will l_query be stored in the cache as I am using bind variables or it will not since I have the concatenation with p_user value ?
create or replace trigger aifer_transfer after insert on transfer for each new row begin
UPDATE Account SET balance = balance-:new.amount WHERE acc_id = from_acc_id; UPDATE Account SET balance = balance+:new.amount WHERE acc_id = to_acc_id; end if; end; create or replace trigger bifer_transfer before insert on transfer for each new row begin if get_balance(:new.from_acc_id) < :new.amount then raise_application_error(-20001, 'Not enough money in account!'); end if; end; create or replace function get_balance(p_acc_id in number) return number as v_balance account.balance%type; begin select balance into v_balance from account where acc_id = p_acc_id; return v_balance; end; select get_balance(123) from dual..................................................i am geting this error when executing the trigger..................................................Error report:ORA-01912: ROW keyword expected01912. 00000 - "ROW keyword expected"*Cause: keyword missing*Action:
I have the following statement dynamic sql statement in a database package.
begin EXECUTE IMMEDIATE 'SELECT REPLACE(SUBSTR('||V_WHERE_CLAUSE||',1,3, ''AND'', NULL) INTO V_WHERE_FILTER FROM DUAL'; EXCEPTION NULL; end;
When executed it gives following error.
ORA-20000: ORA-20000: ORA-00936: missing expression ### TRACE ### ORA-06512: at "NDSS.DUP_SRCH_PKG_MOD", line 931 ### END TRACE ### ### TRACE ### ORA-06512: at "NDSS.DUP_SRCH_PKG_MOD", line 935 ORA-06512: at "NDSS.DUP_SRCH_PKG_MOD", line 164 ### END TRACE ### ORA-06512: at "NDSS.DUP_SRCH_PKG_MOD", line 184 ORA-06512: at line 9
I have two tables have almost the same columns, how can I use merge statement to update the target table only when there is difference between source and target table. Is there any easier way not compare each column one by one? I am using Oracle 11.2
Here is the MERGE statement:
Merge into tb_trgt trgt using tb_src src on (src.id = trgt.id) when not matched then insert (trgt.id, trgt.nm, trgt.addr) values (src.id, src.nm, src.nm) when matched then update set trgt.nm = src.nm, trgt.addr = src.addr where trgt.nm <> src.nm or trgt.addr <> src.addr ;
Is there any easier way to specify the where clause in the NOT MATCHED? I don't want compare each column of the tables. Since I may have many columns in the tables.
I´m having a trouble creating a db package. I´ve changed my job and now i´m working full on DB instead of Forms Developer.
So my trouble is that i want to create some like a global cursor on DB package, i know you can create global variables and use it on all the procedures/function inside the package. But how about cursors?
My problem: I dont´know how to declare into the spec. I don´t know how to use it on body.
My actual
I have the structure below:
PackageSpec: CREATE OR REPLACE PACKAGE [i]MyPackageName[/i] IS CURSOR [i]myGlobalCursor[/i](par1 IN VARCHAR2, par2 IN DATE)( ); PROCEDURE [i]MyProcedure1[/i](par1 IN VARCHAR2, par2 VARCHAR2);
By referring through net I have written the following PCK file. I have installed my Oracle 11g database in VirtualBox(Win XP). I can able to select the tables using query from the host(Windows 7)
CREATE OR REPLACE PACKAGE APEX_SYS_PCK AS TYPE refcursortype IS REF cursor PROCEDURE GET_USER_DETAILS( D1 OUT refcursortype, P_USER IN VARCHAR2, P_PASS IN VARCHAR2);END APEX_SYS_PCK; / CREATE OR REPLACE PACKAGE BODY APEX_SYS_PCKAS PROCEDURE GET_USER_DETAILS( D1 OUT refcursortype, P_USER IN VARCHAR2, P_PASS IN VARCHAR2) IS BEGIN OPEN D1 FOR SELECT * FROM APEX.PERSONS; END GET_USER_DETAILS; END APEX_SYS_PCK;/
When I try to run the script I am getting the following error. How to solve this problem?
Project: sqldev.temp:/IdeConnections%23vAPEX.jprF:PACKAGESAPEX_SYS_PCK.sqlError: PL/SQL: Compilation unit analysis terminatedError(1,14): PLS-00905: object APEX.APEX_SYS_PCK is invalidError(1,14): PLS-00304: cannot compile body of 'APEX_SYS_PCK' without its specification
I want to use UTL_FILE package to create OS file. How to resolve this error. Oracle11g under XP.
SQL> create directory my_dir as 'c: emp';
Directory created.
1 create or replace procedure test_1(md in varchar2) 2 is 3 file utl_file.file_type; 4 begin 5 file := utl_file.fopen(md,'abc.log','w'); 6 utl_file.put_line(file,'EMPLOYE REPORT'); 7 utl_file.fclose(file); 8* end; SQL> /
Procedure created.
SQL> execute test_1('MY_DIR'); BEGIN test_1('MY_DIR'); END;
RROR at line 1: RA-06510: PL/SQL: unhandled user-defined exception RA-06512: at "SYS.UTL_FILE", line 98 RA-06512: at "SYS.UTL_FILE", line 157 RA-06512: at "SCOTT.TEST_1", line 5 RA-06512: at line 1
I need to create a bat file which include a query to run a package. I use plsql developer to develop the package. its username,password and database is user,pswd,db1 respectively. the query to run the package is "SELECT
COLUMN1 AS "LAST NAME", COLUMN2 AS "FIRST NAME", COLUMN3 AS "LOCATION"
FROM TABLE(PKG.GET_SUM('09-NOV-2010','12-NOV-2010')) "