Forms :: Executing Procedure Based On Variable Name
Apr 1, 2011
I need to execute a procedure based on a value in a form. So the procedure name will be changing for value selected in a list.
I need to know a method where i could store the procedure name in a table and when ever i select a value from the list, the respective procedure needs to be executed.
I am reading in a selection of parameters. I have created a new variable which I want to set according to the value of one of the input parameters.
I am doing this straight after declaring the variable, but before the cursors and BEGIN statement It is throwing an error when I do this - but I have to do it before the cursors.the variable I am setting is: v_fptransType you can see the IF statement towards the end of the code.
the error I am getting is:Error(28,3): PLS-00103: Encountered the symbol "IF" when expecting one of the following: begin function package pragma procedure subtype type use <an identifier> <a double-quoted delimited-identifier> form current cursor The symbol "begin" was substituted for "IF" to continue.
beginning of the
create or replace PROCEDURE "P_GLPOST" (i_entity IN varchar2, i_transType IN varchar2, i_startDate IN VARCHAR2, i_endDate IN VARCHAR2, i_accountPeriod IN VARCHAR2, i_includeInternals IN NUMBER, i_chargeable IN NUMBER, i_trialPost IN NUMBER, i_postingReport IN NUMBER, TESTER IN VARCHAR2) is --set serveroutput on size 1000000;
I'm trying to find a simple way of getting around this. I have a PL/SQL procedure which loops through a list of values in a table. These values are the actual names of the functions I want it to run in sequence. The problem is I can get the string value each time but I need to store the return value of each function into a number variable e.g.
BEGIN open all_tests; fetch all_tests BULK COLLECT INTO test_tabl; close all_tests;
for myindex IN 1..test_tabl.count LOOP
time_taken := test_source1 ==> this will work but how do I avoid hardcoding the name of the function to be executed and use the test_name value instead?? time_taken is declared as a number (ie the return value of each function is a number)
test_detail := test_tabl(myindex).test_name; ==> test_detail now contains the string name of the function dbms_output.put_line('Test detail is ' || test_detail); end loop;
I am trying to create a datablock based on a procedure , but im getting errors in compilation:
Errors are : 1) identifier 'HSM_WSH_DEL_UTIL.DEL_TBL' must be declared
2) PL/SQL ERROR 320 at line 7, column 27 the declaration of the type of this expression is incomplete or malformed
Heres my pkg spec and body for the data block:
CREATE OR REPLACE PACKAGE hsm_wsh_del_util IS TYPE del_record IS RECORD (delivery_id NUMBER); TYPE del_tbl IS TABLE OF del_record INDEX BY BINARY_INTEGER;
PROCEDURE do_query (p_del IN OUT del_tbl); END hsm_wsh_del_util; [Code] .....
I am getting errors while executing the following block.
create TYPE c_Rec as object(a VARCHAR2(1), b NUMBER); DECLARE -- TYPE c_Rec as object(a VARCHAR2(1), b NUMBER); TYPE c_collection IS TABLE OF c_Rec; l_coll c_collection := c_collection(); BEGIN [code]........
error
06530. 00000 - "Reference to uninitialized composite"
I'm trying to execute a procedure within a Declare/Begin/End statement and using variables as input parameters in my procedure but I keep on getting an Invalid SQL Statement Error. My code is below:
declare
START_dt VARCHAR2(30); END_DT VARCHAR2(30);
begin
SELECT '01-APR-2011' INTO END_DT FROM DUAL; [code]....
The table the procedure is pulling data from doesn't have proper date/time stamps but my procedure takes the varchar dates above and turns them into dates in the procedure so the input date parameters are left as just string characters.
How to execute Sql Server procedure from Oracle.I have created a dblink and when calling directly to that procedure it is throwing error.
--creationg sqlserver procedure create proc getRecords as print 'testing'; --creating db link create database link remote connect by ss identified by ss using 'remote'; [code]....
I have found DBMS_HS_PASSTHROUGH package is capable of doing it but not sure how to do. Nathan
I've the following package having a procedure with OUT parameter as refcursor .The following is the sample example having same structure with different table name,exception handling in my dev environment
CREATE OR REPLACE PACKAGE TEST_PACK IS Type refCursor is REF CURSOR; PROCEDURE TEST_PROC (out_data out refCursor); END; [code]...
i am getting the follwoing errror ORA-00932: inconsistent datatypes: expected - got.
I'm not attaching any tables / data..etc...I just want to know how to pass the record type to a procedure (which are actually obtained from a table) -- see ** below where I'm getting an error..Need to pass the whole record type "l_shl_order_msg"
CREATE OR REPLACE PROCEDURE CM_BUILD_MSG_PRC (P_IN_BLD_MSG_CURSOR IN SYS_REFCURSOR, P_OUT_BLD_MSG_CURSOR OUT SYS_REFCURSOR) IS l_shl_order_msg CRAE_INTERFACE.GLB_VAR_PKG.deid_SHELL_order_typ; V_MSG_SHELL_NAME VARCHAR2(1000); V_MESG_TEXT_SEGMENT VARCHAR2(1000); V_TEXT VARCHAR2(1000); V_MSG_TEXT VARCHAR2(4000); V_MSG_FINAL_TEXT VARCHAR2(4000); V_MSG_PROC VARCHAR2(1000); V_SQL VARCHAR2(4000); V_CNT NUMBER; L_STATUS VARCHAR2(100); L_REASON VARCHAR2(1000); [code]...
I get an error saying that "wrong number or types of arguments in call to ||"..Not sure how to pass record type dynamically...
Procedure: CREATE OR REPLACE procedure test (a number, b varchar2) is
begin dbms_output.put_line(a ||'->'||b); end;
Anyonymous Block:
begin exec test(1,'m'); end; / When i run this i am getting this error ORA-06550: line 2, column 7: PLS-00103: Encountered the symbol "TEST" when expecting one of the following [code]...
create or replace procedure test as stmt varchar2(2000); begin EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE tt_Local(ID VarChar2(38)) ON COMMIT PRESERVE ROWS';
stmt := 'INSERT INTO tt_Local SELECT cardnumber FROM cards'; execute immediate stmt; end;
-- when am trying to execute this
begin test; end; -- showing ora-01031, insufficient privileges.
After creating this procedure...we r not able to execute it...
SQL> ed Wrote file afiedt.buf 1 create or replace procedure dyn_pro1 2 (tablename varchar2,colname varchar2, prodid number) is 3 cmd varchar2(100); 4 begin 5 cmd := 'delete ' || tablename || ' where'|| colname|| '=' ||prodid; 6 execute immediate cmd ;--using College_id; 7* end; SQL> /
Procedure created.
SQL> exec dyn_pro1('stu_4','COLLEGE_ID',200); BEGIN dyn_pro1('stu_4','COLLEGE_ID',200); END; * ERROR at line 1: ORA-00933: SQL command not properly ended ORA-06512: at "APPS.DYN_PRO1", line 6 ORA-06512: at line 1
I am trying to execute the SQLPLUS command (CONNECT) from the stored procedure.It is throwing below error message.
Stored Procedure:
SQL> select user from dual 2 ; USER ------------------------------ SYS SQL> create or replace 2 PROCEDURE PROCEDURE1 AS 3 BEGIN 4 sqlplus sys/sys@D as sysdba; 5 --execute immediate 'create user 'kkk' identified by 'kkk'; 6 END PROCEDURE1; 7 /
Warning: Procedure created with compilation errors.
SQL> show err Errors for PROCEDURE PROCEDURE1: LINE/COL ERROR -------- ----------------------------------------------------------------- 3/9 PLS-00103: Encountered the symbol "SYS" when expecting one of the following: := . ( @ % ; The symbol ":=" was substituted for "SYS" to continue. [code]....
In Database A I have a series of config tables and stored procedures/functions In Database B I have a lot of tables.
I would like to execute my stored procedures and all associated functions in database A on my data in database B.
Now I've figured out that creating a database link enables me to do SQL selects on data in both A and B...but how do I run SP/Funcs ? I've read something about packages but not sure if I'm heading in the right direction.
Do I need to create a simple synonym ? Can I use the existing DB link ? or is there a special way of calling them, or...
I like the A/B database set up since I can keep battle tested code in one location and have it work across multiple dbs...saves me having to create everything in every database.
I have created one procedure based on one table item master which has a field called item stock or non stock based on this i will fetch data from one of two tables .If its a stock item data will be retrieved from wip_main_acnt table and if its non stock it will pick from ns_main_acnt.my procedure is working fine but all i need is i just want to put an exception that if data is not found in one of the table based on the item selected.I am confused which one to be used whether no_data_found or notfound%.
CREATE OR REPLACE PROCEDURE dflt_pr_acnt ( l_item_code IN VARCHAR2, l_main_acnt_code OUT VARCHAR2 ) [code]....
CREATE OR REPLACE PROCEDURE test IS CURSOR cusers IS SELECT user_name, user_date FROM users; uname users.user_name%TYPE; udate users.user_date%TYPE; BEGIN OPEN cusers;
[code].....
When I try to execute this procedure I get following error:
ORA-00900: invalid SQL statement
Compilation of procedure is successful.
SQL code for creating the USERS table is here:
CREATE TABLE "USERS" ("USER_ID" NUMBER(10,0) NOT NULL ENABLE, "USER_NAME" VARCHAR2(50) NOT NULL ENABLE, "USER_EMAIL" VARCHAR2(50) NOT NULL ENABLE, "USER_PASS" VARCHAR2(50) NOT NULL ENABLE, "USER_DATE" DATE NOT NULL ENABLE, CONSTRAINT "USERS_PK" PRIMARY KEY ("USER_ID") ENABLE )
I'm wondering how I can use a counter to number records in a table I'm inserting into. I need the counter to reset based on changing data in my table. For example, I have the following
seq_number name_type 1 Short Name 1 Short Name 1 Short Name 2 Short Name 2 Short Name
I'd like my results to be the following: seq_number name_type 1 Short Name - 1 1 Short Name - 2 1 Short Name - 3 2 Short Name - 1 2 Short Name - 2
I'd like my counter to increment so that I can add a sequence number to the end of my name type, but when my seq_number field changes I'd like to reset and restart my counter.
In the query below, I'm attempting to replace task codes with task descriptions by left joining to a multi-purpose control table.
In our corp, the description for the task code varies based on the value of change_program in each record, so rather than referencing the value of code_index.tabl statically as I do in the query below (201), I need a dyanamic variable to be defined for each record based on the value of work.change_program, which would represent the value for code_index.tabl.
For each record if change_program =1 then v_tabl = 201 elseif change_program =2 then v_tabl = 202 elseif change_program =3 then v_tabl = 203 else v_tabl = 201
how to declare and use variables.
SELECT account, change_program, task_code_01, task_code_02, task1.longdesc, task2.longdesc FROM work
I have created the following procedure. Since I am using this first time I don't know how to execute this.
CREATE OR REPLACE PACKAGE GAFT_PROG_DIT.ram_package IS TYPE type_ots IS TABLE OF ORDER_TREND_SCORE%ROWTYPE INDEX BY PLS_INTEGER; PROCEDURE InsertTrend( P_TYPE_OTS_REC IN type_ots ); END; /
I am calling a select query inside a procedure but i need to set environment variable 'set linesize 200' inside that procedure but i am not able to create the procedure due to some error. I am attaching the procedure query here with:
before the select query i need to insert this environment variable : "set linesize 200"
I am using ORACLE SQL developer.. I am trying to schedule a package to run daily..here is the overview of my package.. ----- create or replace PACKAGE BODY xxx_MTO_yyy AS PROCEDURE yyy_mto (p_message OUT VARCHAR2, p_detail OUT VARCHAR2, p_value OUT VARCHAR2) IS XXXXXX CXXXXXX XXXXXXX END yyy_mto; end xxx_MTO_yyy;
Now I created schedule as shown (The sql is processed)
begin dbms_scheduler.create_schedule (schedule_name => 'MTO_DAILY', start_date=> trunc(sysdate)+6/24, repeat_interval=> 'FREQ=DAILY; BYDAY=MON,TUE,WED,THU,FRI,SAT,SUN; BYHOUR=22;', comments=>'Runtime: Every day (Mon-Sun) at 6:00 ); END;
Now I am creating SCHEDULER PROGRAM as shown (sql processed)
begin dbms_scheduler.create_program (program_name=> 'mto_DATA', program_type=> 'STORED_PROCEDURE', program_action=> xxx_MTO_yyy.yyy_mto', enabled=>true, comments=>'Procedure to collect session information' ); end;
Now i am creating the scheduler jobs as shown (here also the sql processed)
a) the job should have been visible under the "jobs" tab in sql developer. I dont see that. b) When I tried to run the job manually using ********** (BEGIN DBMS_SCHEDULER.RUN_JOB ( JOB_NAME =>'STR_DATA' ); END;
it failed , saying that "ORA-06553: PLS-ORA-06553: PLS-306: wrong number or types of arguments in call to 'yyy_MTO'". When defining the "dbms_ scheduler. create_program" object , how can I define the arguments?. My procedure has 3 variable out arguments?
I have two procedure , from first procedure having some ref cursor output.
from second procedure I need to call first procedure and i need to process ref cursor output from first procedure so I decide to use bind variable to process ref cursor output but it showing error .
can I define bind variable inside the procedure , then how can I define it .
SQL> CREATE OR REPLACE PROCEDURE emp_by_job ( 2 p_job VARCHAR2, 3 p_emp_refcur OUT SYS_REFCURSOR 4 ) 5 IS 6 BEGIN
I have started reading ORACLE 11g R2 PL/SQL programming doc, and I am stuck at bind variable. I just copied the example in the books and found error -
First I have written below procedure and compiled successfully -
CREATE OR REPLACE PROCEDURE FORMAT_STRING ( string_in IN OUT VARCHAR2) AS BEGIN string_in := '[' || string_in || ']'; END FORMAT_STRING; Then I have written below function and also compiled successfully - create or replace function join_strings (str1 varchar2, str2 varchar2) [code]......
how can I pass the sh variable (.i.e file name stored in sh variable called($F)) as a input of below mention procedure (YODEL_XL_ INS_SDG_ COMMER_ PROD)
for F in *.dat; do # echo $F # #sqlldr apps/apps control=$CONTROL data=$F # Below Part is used for Add the file name into table [code]...
I have to use bind variable for dynamic sql in a procedure. Is there a way to have control on these values. Say for example:
Procedur MyProc ( In_EmpID Number default null, In_EmpName Varchar2 default null, in_JoinDate Date default null [code]....
I have more than 5 In parameters, all 5 is not compulsory by default they are null and sql formation is also dynamic with in the procedure.I need to map bind variable to a proper one.. Is there a way to handle bind variable.
I have a table that has 10 columns which is used to store the customer information (e.g Gender, Age, Name). And i have wrote a store procedure to compare the before and after value of column since there has a parameter to control which column need/no need to be updated while the value being changed.
For example, master table "CUST" has column (NAME, GENDER, AGE). "CUST_TEMP" is a temporary table to store the input image which has the same table structure as "CUST".
DECLARE bef_val CUST%ROWTYPE; aft_val CUST_TEMP%ROWTYPE; BEGIN SELECT * INTO bef_val FROM CUST WHERE name = 'ABC'; SELECT * INTO aft_val FROM CUST_TEMP WHERE name = 'ABC'; [code]....
For the above case, i need to type 3 times of "sp_compare_val ( bef_val.xxx, aft_val.xxx )" on the program. And if the table has more than 10 columns, i need to type more than 10 times.Thus, is it possible to pass in a dynamic variable while calling the store procedure. let say, where the 'xxx' can be definable?