How to execute procedure with dynamic where condition.
Hi All,
I am facing a probelem
Issue :
I am having a parameter p_id in my procedure based on the value of this parameter i want to change the where condition.
How to do so?
Code:---------
create or replace procedure p_1
( p_id in emp_dummy.empno%type)
is
parameter_1 varchar2(2000);
v_sal number;
begin
if p_id = 1 then
parameter_1 := 'where empno = 1';
else
parameter_1 := 'where 1=1';
end if;
select salary into v_sal from emp_dummy||' '||parameter_1;
end;
Dynamic SQL is not the best of ideas, but if you must...
EXECUTE IMMEDIATE 'select salary from emp_dummy where empno=nvl(:x,empno)' into v_sal using p_id;Then if you pass in the p_id to the procedure it will select the salary for that employee and if null is passed in then it will select the salary for all employees. Now here's a problem because you are trying to return a single value and if you don't specify the employee then it will try and return multiple values from that select, so you probably want to do something like give the sum of the salaries...
EXECUTE IMMEDIATE 'select sum(salary) from emp_dummy where empno=nvl(:x,empno)' into v_sal using p_id;
Similar Messages
-
Dynamic select query with dynamic where condition
Hi all,
I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
Please advice, if there is any other way to achieve this requirement.
Thanks,
Sanket Sethi
Code***************
PARAMETERS: p_tabnam TYPE tabname,
p_selfl1 TYPE edpline,
p_value TYPE edpline,
p_where1 TYPE edpline .
DATA: lt_where TYPE TABLE OF edpline,
lt_sel_list TYPE TABLE OF edpline,
l_wa_name TYPE string,
ls_where TYPE edpline,
l_having TYPE string,
dref TYPE REF TO data,
itab_type TYPE REF TO cl_abap_tabledescr,
struct_type TYPE REF TO cl_abap_structdescr,
elem_type TYPE REF TO cl_abap_elemdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp_fld TYPE cl_abap_structdescr=>component.
TYPES: f_count TYPE i.
FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
* <ls_outtab> TYPE ANY,
<l_fld> TYPE ANY.
struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
elem_type ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
comp_tab = struct_type->get_components( ).
comp_fld-name = 'F_COUNT'.
comp_fld-type = elem_type.
APPEND comp_fld TO comp_tab.
struct_type = cl_abap_structdescr=>create( comp_tab ).
itab_type = cl_abap_tabledescr=>create( struct_type ).
l_wa_name = 'l_WA'.
CREATE DATA dref TYPE HANDLE itab_type.
ASSIGN dref->* TO <lt_outtab>.
*CREATE DATA dref TYPE HANDLE struct_type.
*ASSIGN dref->* TO <ls_outtab>.
* Creation of the selection fields
APPEND p_selfl1 TO lt_sel_list.
APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
** Creation of the "where" clause
*CONCATENATE p_selfl1 '= '' p_value ''.'
* INTO ls_where
* SEPARATED BY space.
*APPEND ls_where TO lt_where.
* Creation of the "where" clause
APPEND p_where1 TO lt_where.
* Creation of the "having" clause
l_having = 'count(*) >= 1'.
* THE dynamic select
SELECT (lt_sel_list)
FROM (p_tabnam)
INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
* WHERE (lt_where).Hi Sanket,
The above given logic of mine works for you, put the code in the If condition and try-
just like below:
IF NOT P_EBELN IS INITIAL.
lt_where = '& = ''&'' '.
REPLACE '&' WITH p_ebeln INTO lt_where.
REPLACE '&' WITH field_value INTO lt_where.
SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
FROM (p_tabnam)
WHERE (lt_where).
ENDIF.
thanks\
Mahesh -
Issue with Dynamic WHERE condition in Cursor in FUNCTION.
Hi All,
I am facing an issue with cursor having dynamic WHERE condition in a function.
Below is the FUNCTION:
CREATE OR REPLACE FUNCTION EXCEPTION_MERGE(TABLE_NAME IN VARCHAR2, TAB_NAME IN VARCHAR2)
RETURN VARCHAr2
IS
stmt_tabcols VARCHAR2(32767);
v_columnname VARCHAR2(32767);
CURSOR C1 IS
SELECT 'A.'||A.COLUMN_NAME ||' = '|| 'B.'||B.COLUMN_NAME COLUMN_NAME
FROM
SELECT COLUMN_ID, COLUMN_NAME
FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = TABLE_NAME
AND COLUMN_NAME NOT IN ('ERROR_TAB_ID','ERROR_LOAD_DATE')
) A,
SELECT COLUMN_ID, COLUMN_NAME
FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = TAB_NAME
) B
WHERE A.COLUMN_ID = B.COLUMN_ID;
BEGIN
FOR TABCOL IN C1
LOOP
stmt_tabcols := stmt_tabcols ||TABCOL.COLUMN_NAME||',';
END LOOP;
stmt_tabcols := RTRIM(stmt_tabcols, ',');
RETURN stmt_tabcols;
END;
SELECT EXCEPTION_MERGE('WC_W_TEST_FS','WC_W_TEST_FS_GBL') FROM DUAL;It throws, below error:
ORA-06502 : PL/SQL : Numeric or value error : character string buffer too smallIf I REPLACE TABLE_NAME and TAB_NAME with hard coded values , it works fine. Can somebody look at the code and let me know the issue.
Edited by: ace_friends22 on Sep 9, 2012 1:08 PMEtbin neatly demonstrating the value of posting code in a manner which makes it easy to read.
It's obviously an naming/scoping issue. Faced with a join like this:
where table_name = table_namethe engine looks for something called table_name in the current scope. It finds it, a column on USER_TAB_COLUMNS and applies it to both sides of the filter. It has no way of knowing that there is also a parameter called TABLE_NAME, because that is outside its current scope. Consequently the query will join every table in your schema regardless of what values you pass, and that's why you blow the buffer.
Takw etbin's advice and name your parameter with a prefix:
where table_name = p_table_nameThis isn't a column in USER_TAB_COLUMNS which will force the engine to look in the next scope up, which in your case is the function, where it will find your parameter and so generate a query for the passed values only.
Cheers, APC
Edited by: APC on Sep 9, 2012 8:03 AM -
How to generate report with dynamic variable number of columns?
How to generate report with dynamic variable number of columns?
I need to generate a report with varying column names (state names) as follows:
SELECT AK, AL, AR,... FROM States ;
I get these column names from the result of another query.
In order to clarify my question, Please consider following table:
CREATE TABLE TIME_PERIODS (
PERIOD VARCHAR2 (50) PRIMARY KEY
CREATE TABLE STATE_INCOME (
NAME VARCHAR2 (2),
PERIOD VARCHAR2 (50) REFERENCES TIME_PERIODS (PERIOD) ,
INCOME NUMBER (12, 2)
I like to generate a report as follows:
AK CA DE FL ...
PERIOD1 1222.23 2423.20 232.33 345.21
PERIOD2
PERIOD3
Total 433242.23 56744.34 8872.21 2324.23 ...
The TIME_PERIODS.Period and State.Name could change dynamically.
So I can't specify the state name in Select query like
SELECT AK, AL, AR,... FROM
What is the best way to generate this report?SQL> -- test tables and test data:
SQL> CREATE TABLE states
2 (state VARCHAR2 (2))
3 /
Table created.
SQL> INSERT INTO states
2 VALUES ('AK')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('AL')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('AR')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('CA')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('DE')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('FL')
3 /
1 row created.
SQL> CREATE TABLE TIME_PERIODS
2 (PERIOD VARCHAR2 (50) PRIMARY KEY)
3 /
Table created.
SQL> INSERT INTO time_periods
2 VALUES ('PERIOD1')
3 /
1 row created.
SQL> INSERT INTO time_periods
2 VALUES ('PERIOD2')
3 /
1 row created.
SQL> INSERT INTO time_periods
2 VALUES ('PERIOD3')
3 /
1 row created.
SQL> INSERT INTO time_periods
2 VALUES ('PERIOD4')
3 /
1 row created.
SQL> CREATE TABLE STATE_INCOME
2 (NAME VARCHAR2 (2),
3 PERIOD VARCHAR2 (50) REFERENCES TIME_PERIODS (PERIOD),
4 INCOME NUMBER (12, 2))
5 /
Table created.
SQL> INSERT INTO state_income
2 VALUES ('AK', 'PERIOD1', 1222.23)
3 /
1 row created.
SQL> INSERT INTO state_income
2 VALUES ('CA', 'PERIOD1', 2423.20)
3 /
1 row created.
SQL> INSERT INTO state_income
2 VALUES ('DE', 'PERIOD1', 232.33)
3 /
1 row created.
SQL> INSERT INTO state_income
2 VALUES ('FL', 'PERIOD1', 345.21)
3 /
1 row created.
SQL> -- the basic query:
SQL> SELECT SUBSTR (time_periods.period, 1, 10) period,
2 SUM (DECODE (name, 'AK', income)) "AK",
3 SUM (DECODE (name, 'CA', income)) "CA",
4 SUM (DECODE (name, 'DE', income)) "DE",
5 SUM (DECODE (name, 'FL', income)) "FL"
6 FROM state_income, time_periods
7 WHERE time_periods.period = state_income.period (+)
8 AND time_periods.period IN ('PERIOD1','PERIOD2','PERIOD3')
9 GROUP BY ROLLUP (time_periods.period)
10 /
PERIOD AK CA DE FL
PERIOD1 1222.23 2423.2 232.33 345.21
PERIOD2
PERIOD3
1222.23 2423.2 232.33 345.21
SQL> -- package that dynamically executes the query
SQL> -- given variable numbers and values
SQL> -- of states and periods:
SQL> CREATE OR REPLACE PACKAGE package_name
2 AS
3 TYPE cursor_type IS REF CURSOR;
4 PROCEDURE procedure_name
5 (p_periods IN VARCHAR2,
6 p_states IN VARCHAR2,
7 cursor_name IN OUT cursor_type);
8 END package_name;
9 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY package_name
2 AS
3 PROCEDURE procedure_name
4 (p_periods IN VARCHAR2,
5 p_states IN VARCHAR2,
6 cursor_name IN OUT cursor_type)
7 IS
8 v_periods VARCHAR2 (1000);
9 v_sql VARCHAR2 (4000);
10 v_states VARCHAR2 (1000) := p_states;
11 BEGIN
12 v_periods := REPLACE (p_periods, ',', ''',''');
13 v_sql := 'SELECT SUBSTR(time_periods.period,1,10) period';
14 WHILE LENGTH (v_states) > 1
15 LOOP
16 v_sql := v_sql
17 || ',SUM(DECODE(name,'''
18 || SUBSTR (v_states,1,2) || ''',income)) "' || SUBSTR (v_states,1,2)
19 || '"';
20 v_states := LTRIM (SUBSTR (v_states, 3), ',');
21 END LOOP;
22 v_sql := v_sql
23 || 'FROM state_income, time_periods
24 WHERE time_periods.period = state_income.period (+)
25 AND time_periods.period IN (''' || v_periods || ''')
26 GROUP BY ROLLUP (time_periods.period)';
27 OPEN cursor_name FOR v_sql;
28 END procedure_name;
29 END package_name;
30 /
Package body created.
SQL> -- sample executions from SQL:
SQL> VARIABLE g_ref REFCURSOR
SQL> EXEC package_name.procedure_name ('PERIOD1,PERIOD2,PERIOD3','AK,CA,DE,FL', :g_ref)
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
PERIOD AK CA DE FL
PERIOD1 1222.23 2423.2 232.33 345.21
PERIOD2
PERIOD3
1222.23 2423.2 232.33 345.21
SQL> EXEC package_name.procedure_name ('PERIOD1,PERIOD2','AK,AL,AR', :g_ref)
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
PERIOD AK AL AR
PERIOD1 1222.23
PERIOD2
1222.23
SQL> -- sample execution from PL/SQL block
SQL> -- using parameters derived from processing
SQL> -- cursors containing results of other queries:
SQL> DECLARE
2 CURSOR c_period
3 IS
4 SELECT period
5 FROM time_periods;
6 v_periods VARCHAR2 (1000);
7 v_delimiter VARCHAR2 (1) := NULL;
8 CURSOR c_states
9 IS
10 SELECT state
11 FROM states;
12 v_states VARCHAR2 (1000);
13 BEGIN
14 FOR r_period IN c_period
15 LOOP
16 v_periods := v_periods || v_delimiter || r_period.period;
17 v_delimiter := ',';
18 END LOOP;
19 v_delimiter := NULL;
20 FOR r_states IN c_states
21 LOOP
22 v_states := v_states || v_delimiter || r_states.state;
23 v_delimiter := ',';
24 END LOOP;
25 package_name.procedure_name (v_periods, v_states, :g_ref);
26 END;
27 /
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
PERIOD AK AL AR CA DE FL
PERIOD1 1222.23 2423.2 232.33 345.21
PERIOD2
PERIOD3
PERIOD4
1222.23 2423.2 232.33 345.21 -
Hi, I'm building a procedure with 4 parameters το pass in input and I ask if it's possible to build a select inside the procedure with a dynamic where condition.
The query with 2 conditions is the following:
SELECT count(incident_number) FROM cs.cs_incidents_all_b
1st condition
WHERE (TO_DATE(incident_attribute_6,'dd-mm-yyyy hh24:mi') BETWEEN TO_DATE(p_create_date_ll,'dd-mm-yyyy hh24:mi') AND TO_DATE(p_create_date_ul,'dd-mm-yyyy hh24:mi'))
2nd condition
AND external_attribute_4 BETWEEN p_resolv_time_ll AND p_resolv_time_ul;
The first condition has to be always valid, but the second one, depending on the parameters has to be satisfied or not.
The first 2 parameters (p_create_date_ll and p_create_date_ul) are always written as a string (so the first condition always works).
The second pair of paramenters (p_resolv_time_ll and p_resolv_time_ul) can be written as numbers (from a form), or written both as '*'
So, If the parameters p_resolv_time_ll and p_resolv_time_ul are numbers, I should retrieve a small set of data (all the 2 where condition have to work),
while if they are both '*' ONLY the first condition has to work. Practically, in this last case the 2nd condition is how it was commented.
Is it possible to build something that satisfy my request ?
Thanks in advance
AlexYes I know....
If I use an IF THEN ELSE statement I can write 2 different queries with 2 different where conditions....but I want to avoid this solution because I have 4 pair of these parameters which can assume differents values and depending on their values I have to use different where conditions
If I use an IF THEN ELSE statement, this means to write 16 different queries....
I already used DECODE or CASE but they not satisfy my request....
Anybody has others ideas ?
Thanks -
How to Concatenate Table name and Where condition at runtime
I am passing parameter as User and Zone to Stored Procedure.How to concatenate Table Name
and WHERE CONDITION in SQL Statement.i have different type of users and zones.Hi !
declare
cur sys_refcursor;
r emp%rowtype;
v_sql varchar2(512);
begin
-- do your logic here
v_sql := 'select * from emp';
open cur for v_sql;
loop
fetch cur into r;
exit when cur%notfound;
dbms_output.put_line(r.ename);
end loop;
close cur;
end;In this example you can see how can be done this with cursor vars .. You should concatenate v_sql string according to your requirements.
But as in further posts has already been mentioned , be carefull at publishing such kind of procedures and think on security.
Also when you want dynamicaly change from clause , you should consider using different records to accept data ? Maybe all your tables has the same structure and then this problem will be smaller.
T
T -
How to execute procedure in toad software
hiii guy's i run my procedure on sql prompt and it run properly
but when i tried this on toad i got an problem
after compiling my procedure on toad
when i write
execute procedure_name(parameter1,parameter2);
then i get an error i.e
ORA-00900: invalid SQL statement
can someone tell me how to execute procedure on toad
thanks in adv...........how to execute procedure in toad softwareIn TOAD's schema browser you can go to the procedures tab - right click on the procedure in question and choose execute procedure - a window should pop up, where you can give optional parameters - the rest should be almost self explanatory ;)
-
Loop with dynamic where clause
hi,
In a program we need to use a loop into an internal table with a where condition is decided on run time.
"Select" from database table is using dynamic where clause and it is working fine.
For the loop part does any one have any idea on this? if we can have dynamic where clause in a loop into internal tab?
ThanksHi,
You can't use 'loop where' dynamically .
Have you already tried to use Ranges and CHECK statement?
Like:
First mount range options;
Loop at <table>.
Check using the range.
endloop.
Maybe it's works for you !!
Marcelo Ramos -
How to build a full dynamic WHERE expression in ADFBC Faces View Object ?
Dear Steve
>
I need an example about how to build a full dynamic WHERE expression in
ADFBC View Object
In UIX I known to do that, but i don't kwown how to do in ADFBC Faces.
please help me to see an example.
thanks
Juan CarlosYou write an AM level method to set the where clause and you expose it as a client method. (just like you did before)
Then you can drag this method onto a page as a button and then pressing on this button will execute the method.
If you want this to be done automatically without pressing a button - you go to the pagedef.xml file for your page and add a methodInvocation binding to that AM method, and then add a method executable to the executables section calling this method. -
Select three tables data with Same where condition
Hi i want sum data in three tables with same where condition. how can i do this code very simple.
SELECT SUM(SIGNA) FROM dbo.tblPLAG
WHERE VERSION='ACTUAL' AND STATS='ST_Z010'
AND FACILITY='FA_2003'
AND TD IN ( SELECT TIMEID FROM Time WHERE ID BETWEEN
@YEAR+'.'+(SELECT RIGHT ('000'+ CAST (@PERIOD-6 AS varchar), 3))
AND
@YEAR +'.'+(SELECT RIGHT ('000'+ CAST (@PERIOD AS varchar), 3)))
Try following
SELECT SUM(t1.SIGNA) + sum(t2.SIGNA) + sum(t3.SIGNA) and you query, it will add the SUMs of each table.. hopefully it will work -
REPORT with dynamic WHERE CLAUSE (run RDF or REP) ?
Hi:
When running a REPORT (myreport.rep) with dynamic where clause using a lexical parameter, I got this error:
REP-1439: Cannot compile .REP or .PLX file as it does not have source
If i run the report specifiying RDF extension (myreport.rdf) the report run successfully! Is this normal ?
If I specify RDF extension will Report Server COMPILE the report everytime I execute it ?
When using dynamic WHERE CLAUSE I will have to run RDF files instead of REP ?
I'm running Reports 9i under Linux, with IDS under Windows.
Waiting Help
Joao OliveiraIt sounds like you are building the .rep files on one platform (windows) and running them on another (linux). The reason that the .rdf file continues to work is that Reports recompiles the PL/SQL within the report when you move from one platform to another or change schemas. .rep files can't be re-compiled in this way so you need to ensure they are compiled successfully when converting them.
You need to convert from .rdf to .rep on the platform that you are intending to run on. Try running rwconverter on the linux platform with "compile_all=yes" to produce the .rep file and running that .rep file. -
Single quote in dynamic where condition
BAPI_STUDENT_IDENTIFIC_ADD has a field called IDENTIFICATIONNUMBER. This field is later used in a dynamic where condition and causes a short dump when it contains a single quote. I will change the program that calls the BAPI to check for single quotes, but is there anything else I need to check for to ensure a correct where condition?
Thanks,
DanHi Dan,
The best way to ensure correctness of syntax of a dynamic where condition is:
Run the program in debugging mode, Get the Query that is generated dynamically and write it to some other ABAP program and perform syntax check.
This will help you to remove all the syntax errors.
Regards,
Darshil -
Procedure with dynamic DB links
Hi Friends,
I have been writing procedures to insert data into remote oracle apps instances using db links.
The procedures are executed and run in the local instance. While using oracle apps tables I am suffixing them with a db link.
I want it to be made dynamic, so that same procedures with a parameter as db link can be used for all the instances.
The sample code is given below
CREATE OR REPLACE PROCEDURE XXX_MAIN(p_db_link VARCHAR2)
AS
CURSOR C1 IS SELECT * FROM XXX_ACCTS;
BEGIN
FOR i IN C1
LOOP
BEGIN
SELECT territory_code
INTO l_country_code
FROM APPS.FND_TERRITORIES_TL@SYSTEM_LINK_TEST --p_db_link
WHERE TERRITORY_SHORT_NAME = i.COUNTRY;
CNT:= 1;
EXCEPTION
WHEN OTHERS THEN
CNT:= 0;
END;
APPS.IBY_EXT_BANKACCT_PUB.create_ext_bank_acct@SYSTEM_LINK_TEST --p_db_link
p_api_version => 1.0,
p_init_msg_list => 'T',--PPS.FND_API.G_TRUE@SYSTEM_LINK_TEST, --p_db_link
p_ext_bank_acct_rec => p_ext_bank_acct_rec,
x_acct_id => p_acct_id,
x_return_status => p_return_status,
x_msg_count => p_msg_count,
x_msg_data => p_msg_data,
x_response => p_response
END LOOP;
END;
In the above procedure I would like to replace the db link SYSTEM_LINK_TEST with the parameter p_db_link
Please advice...
Thanks in advance.
Srikanth
Edited by: Srikanth on Apr 24, 2012 4:50 PM
Edited by: Srikanth on Apr 24, 2012 4:51 PMWell, we agree that static SQL performs best :-) One of the reasons it performs well is that the parsing is already done at compile time, not runtime.
For static SQL using db-links to parse at compile time, it needs to know the actual db-link. Consider this statement in your code:
SELECT territory_code
INTO l_country_code
FROM APPS.FND_TERRITORIES_TL@SYSTEM_LINK_TEST
WHERE TERRITORY_SHORT_NAME = i.COUNTRY;This is static SQL - at compile time the database will connect to the database at SYSTEM_LINK_TEST and check for example the datatype of the column territory_code in table APPS.FND_TERRITORIES (if it even exists.)
If you wish the database link to be a parameter, then static SQL cannot be used - it will have to be parsed at runtime, otherwise how can the database know if the db-link that it was given as parameter references a database that has an APPS schema with a FND_TERRITORIES_TL table with a territory_code column? Static SQL just cannot do that - it has to be dynamic.
A possible alternative I can think of might be to create a schema in your database for each of the remote databases. Each of those schemas has a private db-link that references the remote database for that schema but with the same name for the dblink in each schema.
Then you would use your source control to create a copy of all the procedures in each of those schemas - each copy would compile and parse the static sql using the same db-link name, but as the db-link references differently in each schema, the static sql in the procedure in each schema would compile OK.
Calling would then be a matter of calling SCHEMA_REMOTE01.PROCEDURE or SCHEMA_REMOTE02.PROCEDURE, etc. And if you needed to, then perhaps you could use dynamic SQL for the call to call the procedure in the correct schema.
But it would require many identical copies of each procedure/function/packages and it would require discipline to make sure that when you change some code in a procedure, you need to deploy that change to all schemas. You would need a source control system at the very least ;-) -
Dump using Dynamic WHERE condition (EXISTS + subquery)
Hi experts,
I want to use dynamic WHERE here, but I got a problem when using EXISTS + subuery.
Here is my code snippet:
And the actual SQL sentence should be like this:
When I execute this program, an exception CX_SY_DYNAMIC_OSQL_SEMANTICS is raised and the program dumps.
Dump Information:
Short text
A dynamically specified column name is unknown.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
not caught in
procedure "FRM_GET_ALL_PROD_ORDERS" "(FORM)", nor was it propagated by a
RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
An Open SQL clause was specified dynamically. The contained field name
"EXISTS" does not exist in any of the database tables from the FROM clause.
I'm confused because the plain text of my WHERE condition looks good. Could you tell me why I encountered this problem?
Many thanks,
ShelwinHi Shelwin !
Testing your code i dont have dump, using this:
REPORT z_test MESSAGE-ID z_test_msgs.
DATA: lt_where_tab1 TYPE STANDARD TABLE OF edpline WITH HEADER LINE,
lt_where_tab2 TYPE STANDARD TABLE OF edpline WITH HEADER LINE,
gt_detail TYPE STANDARD TABLE OF caufv WITH HEADER LINE.
CONCATENATE 'EXISTS (SELECT J_1~STAT FROM JEST AS J_1 INNER JOIN TJ02T AS T_1'
'ON J_1~STAT EQ T_1~ISTAT'
'WHERE J_1~OBJNR EQ CAUFV~OBJNR'
'AND J_1~INACT EQ '' '''
'AND T_1~SPRAS EQ ''E'''
'AND T_1~TXT04 EQ ''CRTD'')'
INTO lt_where_tab1.
CONCATENATE 'NOT EXISTS (SELECT J_2~STAT FROM JEST AS J_2 INNER JOIN TJ02T AS T_2'
'ON J_2~STAT EQ T_2~ISTAT'
'WHERE J_2~OBJNR EQ CAUFV~OBJNR'
'AND J_2~INACT EQ '' '''
'AND T_2~SPRAS EQ ''E'''
'AND T_1~TXT04 IN (''TECO'' , ''DLFL'', ''DLV'', ''CLSD''))'
INTO lt_where_tab2.
SELECT aufnr ftrms gltrs
FROM caufv
INTO CORRESPONDING FIELDS OF TABLE gt_detail
WHERE (lt_where_tab1)
AND (lt_where_tab2).
BREAK-POINT.
Regards,
Edited for error on image. -
Cannot find procedures with dynamic pages
Hi all,
I have a problem with dynamic pages. cannot find procedures.
This is the content of a a dynamic page (example):
<HTML>
<ORACLE>
begin
htp.print(htf.bold(‘Fill in field values and use the push button to buy ticket’));
htp.br;
htp.formOpen(‘NETU.BUY_TICKETS’);
htp.teletype(‘Student Id___:’);
htp.formText(‘p_id’,5,5);
htp.br;
htp.teletype(‘Event Id_____:’);
htp.formText(‘p_eventid’,5,5);
htp.br;
htp.teletype(‘# of Tickets_:’);
htp.formText(‘p_no_of_tickets’,5,5);
htp.br;
htp.teletype(‘Credit Card’);
htp.br;
htp.teletype(‘AMEX,MC,VISA_:’);
htp.formText(‘p_cc_type’,5,5);
htp.br;
htp.teletype(‘Card #_______:’);
htp.formText(‘p_cc_number’,10,10);
htp.br;
htp.formSubmit(NULL,’Buy Ticket’);
htp.formClose;
end;
</ORACLE>
<HTML>
and try to call to this procedure ‘NETU.BUY_TICKETS’ for save form data in BD:
begin
insert into tickets (id, eventid, no_of_tickets,cc_type,cc_number, trans_date) values (p_id, p_eventid, p_no_of_tickets, p_cc_type, p_cc_number, sysdate);
exception when others then htp.print(‘SQL Error Message:’||substr(SQLERRM,1, 200));
end;
All compiled fine.
The problem exact is when i submit the form, cannot find procedure.
In browser address show this -> http://portal:7778/pls/portal/NETU.BUY_TICKETS
and in the body...
404 Not Found
Unable to process request. Please check the log file for more details.
The dev is on OracleAS 10g, on a Solaris 5.10 dual Sparc machine.
With:
HTTP_Server
Internet Directory
OC4J_SECURITY
Single Sign-On:orasso
Gestión
on infra tier and
Discoverer
Forms
home
HTTP_Server
OC4J_BI_Forms
OC4J_Portal
OC4J_Wireless
Portal:portal
Reports Server: rep_portal_oracleas2
Web Cache
Wireless
Gestión
on middle tier, all running without problem...
mmm ... what's wrong? where is the log? i find a lot...I have tried your code and it works for me . Here are the steps and codes I have used to stimulate your process
1. Created the procedure
CREATE OR REPLACE PROCEDURE p_buy_tickets (p_id in number, p_eventid in number, p_no_of_tickets in number, p_cc_type in varchar2, p_cc_number in number) IS
BEGIN
htp.print('Processed Successfully');
EXCEPTION
WHEN OTHERS THEN
htp.print('SQL Error Message:'||substr(SQLERRM,1, 200));
END p_buy_tickets;
2. Granted 'Execute' privilge on this procedure to Public.
3. Created a dynamic page with the following code (same as yours except the schema):
<HTML>
<ORACLE>begin
htp.print(htf.bold('Fill in field values and use the push button to buy ticket'));
htp.br;
htp.formOpen('MY_SCHEMA.P_BUY_TICKETS');
htp.teletype('Student Id___:');
htp.formText('p_id',5,5);
htp.br;
htp.teletype('Event Id_____:');
htp.formText('p_eventid',5,5);
htp.br;
htp.teletype('# of Tickets_:');
htp.formText('p_no_of_tickets',5,5);
htp.br;
htp.teletype('Credit Card');
htp.br;
htp.teletype('AMEX,MC,VISA_:');
htp.formText('p_cc_type',5,5);
htp.br;
htp.teletype('Card #_______:');
htp.formText('p_cc_number',10,10);
htp.br;
htp.formSubmit(NULL,'Buy Ticket');
htp.formClose;
end;
</ORACLE>
<HTML>
4. I got the message 'Processed Successfully' when I ran the dynamic page and submitted the form.
You may need to check how you declared parameters in the procedure and how you supplied values when you run the procedure. In this case, I created the procedure with "No Default" value for all parameters , so I have to supply value for all parameters in the form otherwise I will encounter the 'Page Not Found' error.
Hope this helps!.
Thanks
Krishnamurthy
Maybe you are looking for
-
How can i manipulate pdf files with my swing application
hi all, in my database i have a column (blob type) in which i want to store pdf files from swing. is any body have solution. i need it urgently. thanks
-
I gave my second IPAD to a friend. I also recently changed the email associated with my own account because I will be moving and will be unable to use that address much longer... now I am not yet sure I can update my own apps (will it ask for old ema
-
Application Server Report Path
Dear Oracle Gurus I am new to this area of expertise. We have a peculiar problem. Let me try to explain this We are running Oracle Appication server in Windows based environment( windows server 2003 i presume) we have multiple projects running in thi
-
Whenever I try to make modifications to my workspace or really do anything complicated, I get this error message. I went to the applications folder and got the info for photoshop but then the box that allows you to unlock the application is not click
-
I can't upgrade itunes 10.5 to 11.7, it says it can't find 'itunes.msi'
I can't upgrade itunes 10.5 to 11.7, it says it can't find 'itunes.msi'