Variable as table
I have to join one view about 15 times in my procedure. This view is so heavy, select * from it takes ab 5 seconds.
Is there any posibility to use this view as variable in SQL? Maybe same others ideas how to make it faster?
For Example:
tmp_table = select pk_id1, pk_id2, name, date from heawyView;
select count(*) from mainTable a
join tmp_table b on (a.pk_id1 = b.pk_id1 and a.pk_id2 = b.pk_id2);
Rozpalacz wrote:
I tried to do that earlier, like
My bad. Bulk collect should be:
SELECT view_obj_type(col1,col2,...)
BULK COLLECT
INTO v_view_tbl
FROM view;For example:
SQL> CREATE OR REPLACE
2 TYPE emp_obj_type
3 AS OBJECT(
4 empno number,
5 ename varchar2(30),
6 deptno number
7 )
8 /
Type created.
SQL> CREATE OR REPLACE
2 TYPE emp_tbl_type
3 AS TABLE OF emp_obj_type
4 /
Type created.
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 v_emp_tbl emp_tbl_type;
3 BEGIN
4 SELECT emp_obj_type(empno,ename,deptno)
5 BULK COLLECT
6 INTO v_emp_tbl
7 FROM emp;
8 FOR v_rec IN (SELECT e.*,d.dname FROM dept d JOIN TABLE(v_emp_tbl) e ON(d.deptno = e.deptno)) LOOP
9 DBMS_OUTPUT.PUT_LINE(RPAD(v_rec.ename,30) || v_rec.dname);
10 END LOOP;
11 END;
12 /
SMITH RESEARCH
ALLEN SALES
WARD SALES
JONES RESEARCH
MARTIN SALES
BLAKE SALES
CLARK ACCOUNTING
SCOTT RESEARCH
KING ACCOUNTING
TURNER SALES
ADAMS RESEARCH
JAMES SALES
FORD RESEARCH
MILLER ACCOUNTING
PL/SQL procedure successfully completed.
SQL> SY.
Similar Messages
-
Error: Variable not found in variable substitution table
Hi,
I am getting following error in file adapter receiver communication channel.
error:Could not process due to error: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during variable substitution: java.text.ParseException: Variable 'file' not found in variable substitution table
<b>variable substitution values:</b>
Variable name: File
reference :payload:MT_DC_Recr,1,Target,1,Filename,1
file name scheme : %File%.txt
<b>inpu file:</b>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_DC_Send xmlns:ns0="http://urn:psr/ff/DC">
<Source>
<Filename>dat1</Filename>
<Record>
<Name1>123</Name1>
<Name2>abc</Name2>
<Name3>XYZ</Name3>
</Record>
</Source>
</ns0:MT_DC_Send>
Regards,
SriniHi varun,
This is the error i am getting now..
Could not process due to error: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variable was not found in the message payload: File
what i am trying to get is reading filename from the message payload.
Reg,
Srini -
Using variables in table constaraints
Hi,
I am facing problem in using global variables in table constraints. It is giving error "911 : 42000 : java.sql.SQLException: ORA-00911: invalid character".Since I was not able to use project variable s,I have used global variables.
following is the code
insert into DEV_TGT.E$_TEST_TGT
ERR_TYPE,
ERR_MESS,
CHECK_DATE,
ORIGIN,
CONS_NAME,
CONS_TYPE,
C1,
C2
select
'F',
sysdate,
'(161666)TEST_2.TEST_TO_TETS_TGT',
'CHK',
'CK',
C1,
C2
from DEV_TGT.I$_TEST_TGT TEST_TGT
where not (
TEST_TGT.C1=#GLOBAL.V_LOAD_ID
)Hi,
Did you refreshed or Assigned that variable before using in interface ?
Flow :-
Assgin/Refresh Variable -> interface (with contrsaint using variable)
Also,
If constarint is not an integer please use quotes ( '#GLOBAL.V_LOAD_ID' )
Regards,
Rathish
Edited by: Rathish on Sep 24, 2009 5:44 PM -
Hello,
i want to analyse a programe source code, so i want to get all variable declaration.
like in SE38->utilities->display list object, but in abap code.
can you please help me.Hi Yassir,
If ur program has TOP include then all global variables declarations will exist in this include. All local variables declarations exist with in the FORM.
Open ur program in SE80. Here u can see all objects of ur program like Fields(Variables), TYPES,Tables, Routines etc.
Thanks,
Vinod. -
Global variable (internal table)
Hello Experts,
how can I create a global variable (internal table) so that I can fill in inside WDDOINIT and later within another
method inside the view.
Thx in advance
Best Reagards
ertas ilhanHi,
Go to attribute tab and declare Your variable there.
You can access that variable in the following way in another method as well.
to use that variable use following syntax.
wd_this->variable_name
If you will declare the variable in component controller and define as public.
then you can access this in all the views of component.
to access that use following syntax.
wd_comp_controller->variable name.
I hope it helps.
Regards,
Rohit
Edited by: Rohit Makkar on Apr 28, 2009 7:53 PM -
A way to find as to a variable from table TAVRV is used in which program?
Hello Experts,
Is there a way to find as to a variable from table TAVRV is used in which of the variants and in what programs. Example: can we find a variable ZZ_AAAA_ACTUEL (from table TVARV) is used in which variants / programs?
I want maintain one variable and i will be sure that not affect others programs.
Regards.Hi Salhi
open your table in SE11 and click on that variable, then there is a option 'where used list' in your application tool bar
click on that option, it will give you a small pop up window from where you can select in which options you want to search for that variable.
i hope this will work for you
Thanks
lalit Gupta -
Duplicate variable 'altova:table' definition
I have a little class that I wrote to apply a XSLT file to a XML using Oracle XML Parser.
Here is the code:
XSLProcessor processor = new XSLProcessor();
String sInputXSL = "d:/xsl.xsl";
String sInputXML = "d:/xml.xml";
File fXSL = new File(sInputXSL);
URI uri = fXSL.toURI();
URL url = uri.toURL();
XSLStylesheet stylesheet = processor.newXSLStylesheet(url); (*)
When I execute it, I get the following error on the line (*)
XML-22050: (Error) Duplicate variable 'altova:table' definition.
XML-22050: (Error) Duplicate variable 'altova:table' definition.
XML-22050: (Error) Duplicate variable 'altova:table' definition.
oracle.xml.xslt.XSLException: XML-22050: (Error) Duplicate variable 'altova:table' definition.
at oracle.xml.xslt.XSLStylesheet.flushErrors(XSLStylesheet.java:1848)
The XSL file is a XSL file that was generated by Altova Stylevision.
I opened the XSL to watch is content and there is in dead several declarations of altova:table variable:
<xsl:variable name="altova:table">:
The XSLT is valid because when I execute the transformation with java.xml.Transformer class it works.
What can I do to solve the problem?Please don't cross-post your questions.
-
Whats the difference betweeen passing the table variable and table valued parameter?
Hi Everbody
Can someone one tell me what's the difference between passing a table variable and table valued parameter to a stored procedure or function? Can both be used to pass a table to a stored procedure/function?
Regards
RegardsThey are essentially the same. What we call a table variable is a local
variable. A table-valued parameter is an incoming parameter to the
procedure. The only difference is that the parameter is readonly.
When you call a stored procedure, you can pass a table variable as the
actual parameter. Or a table-valued parameter that you pass on.
CREATE PROCEDURE nisse_sp @tvp sometype READONLY AS
DECLARE @local someothertabletype
EXEC pelle_sp @tvp, @local
Erland Sommarskog, SQL Server MVP, [email protected] -
Connecting Query variable with Table Values
Hi all,,
I'm trying to connect a query variable to table column contents. The problem is, there is an additional Date as input which is single value. As a result, the query does not get executed. It gives an error that it expects a single value for the date field.
Am I doing something wrong. Please guide.
Regds,
Srinivasan.Hi Srinivasan,
Sorry but i didnt got exactly what you are trying to do? You have query to which you are passing multiple values from a table. or are you selecting a single row in the table and passing it to the query? How is the variable defined in the query?
Thanks,
Regards,
Vikram -
ADFBC: LOV with bind variable inside Table
Hi,
I can't seem to find information on how to use bind variables on LOV's that are inside an af:table.
Please help.
Thank you.
Links that didn't work :
http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcquerying.htm#ADFFD345
http://www.oracle.com/technology/products/jdev/tips/fnimphius/restrictlovlist/restrictlov.html
http://groundside.com/blog/DuncanMills.php?title=executewithparams_my_new_best_buddy&more=1&c=1&tb=1&pb=1You are not really specific about the actual problem. What are you trying to do?
Show some peaces of code. Got any errors?
Timo -
Customer exit variable - internal table in BEX
Hi,
i am running a report and using variables in it.
The report runs over a info cube. There are few challenges in it.
One of the variable is posting date, and when user enters posting date i need to negate it with current system date.
If the negated value is greater than 28 then i need to exclude documnet type 'YG' and display the query, else i need to include the dcumnet type 'YG' and document type ' '. The above logic can be well implemented via a customer exit variable(for posting date) using an internal table. We have internal tables like C_T_DATA which is used in data source enhancement, which help us to implement our own desired logic.
Do we have such kind of internal tables, based on which the report output (result set) is derived?
i know that we have l_t_range and e_t_range, but dont know their usage, some one can explain in detail about them?
Thanks in advance.Hi Selva & Lakshmin,
The code given by Selva is almost correct . If my understanding is clear , you also wanted to include document type ' ' when the negated value is less than 28 .
Modification in Selvas Code :
Variable 'V_DOCTYP' must be of type Multiple Single Values.
DATA : V_DATE LIKE SY-DATUM.
DATA : V_DAYS TYPE I.
if i_step = 2.
when 'V_DOCTYP'.
READ TABLE i_t_var_range INTO loc_var_range WITH KEY vnam = 'ZV_PDATE''.
IF SY-SUBRC = 0.
V_DATE = loc_var_range-low.
ENDIF.
V_DAYS = SY-DATUM - V_DATE.
IF V_DAYS > 28.
l_s_range-low = 'YG'
l_s_range-sign = 'E'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ELSE.
l_s_range-low = 'YG'
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
clear l_s_range.
l_s_range-low = ' '.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
ENDIF.
ENDIF.
Hope the above reply was helpful.
Kind Regards,
Ashutosh Singh -
Using a Variable for Table Name with a cursor
Hello All
Is it possible to use a Parameter passed to a procedure as the table name
in a cursor selection statment. I thought the below would work but I get
a error. Does anyone have any ideas?? The Error is listed below to.
Here's the code I just complied
CREATE OR REPLACE PROCEDURE Dup_Add(NEWQATABLE IN VARCHAR2) IS
CURSOR c1 IS SELECT MUNI,PROV FROM NEWQATABLE GROUP BY MUNI, PROV;
c1rec c1%ROWTYPE;
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO c1rec;
EXIT WHEN c1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(c1rec.MUNI);
END LOOP;
CLOSE c1;
END;
Here is the errors
LINE/COL ERROR
3/8 PLS-00341: declaration of cursor 'C1' is incomplete or malformed
3/15 PL/SQL: SQL Statement ignored
3/38 PLS-00201: identifier 'NEWQATABLE' must be declared
5/7 PL/SQL: Item ignored
10/3 PL/SQL: SQL Statement ignored
10/17 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
12/3 PL/SQL: Statement ignored
12/24 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
LINE/COL ERROR
Thanks
PeterIf you are going to have a table name or a column name as a parameter, then you have to open the cursor dynamically. The following example uses Native Dynamic SQL (NDS) to open a ref cursor dynamically. I also eliminated the group by clause, since it is intended for use with aggregate functions and you weren't using an aggregate function. Also notice that there are some other differences in terms of defining variables and fetching and so forth.
SQL> CREATE TABLE test_table
2 AS
3 SELECT deptno AS muni,
4 dname AS prov
5 FROM dept
6 /
Table created.
SQL> CREATE OR REPLACE PROCEDURE Dup_Add
2 (newqatable IN VARCHAR2)
3 IS
4 TYPE cursor_type IS REF CURSOR;
5 c1 cursor_type;
6 c1muni NUMBER;
7 c1prov VARCHAR2 (20);
8 BEGIN
9 OPEN c1 FOR 'SELECT muni, prov FROM ' || newqatable;
10 LOOP
11 FETCH c1 INTO c1muni, c1prov;
12 EXIT WHEN c1%NOTFOUND;
13 DBMS_OUTPUT.PUT_LINE (c1muni || ' ' || c1prov);
14 END LOOP;
15 CLOSE c1;
16 END;
17 /
Procedure created.
SQL> SHOW ERRORS
No errors.
SQL> SET SERVEROUTPUT ON
SQL> EXECUTE dup_add ('test_table')
10 ACCOUNTING
20 RESEARCH
30 SALES
40 OPERATIONS
PL/SQL procedure successfully completed. -
How to insert variable for table name in Select statement ?
I am creating a stored procedure which will take two table names as IN parameters. Within the procedures I would like to use the parameters in the following manner;
SELECT count(*)
INTO v_target_cnt
FROM TargetTable;
TargetTable is one of the parameters passed in. When I do this however it does not recognize the parameter. I have tried assigning the parameter to a local variable and using the variable, with not luck.
Any help....thanksNull,
What you are describing is called a LEXICAL parameter, which is allowed (preceded by an ampersand) in sql but not in pl/sql because it would not be possible to compile it. That is why you need to use Andrew's suggestion to make the sql dynamic. In older versions you would need to use DBMS_SQL which is horrible and now thankfully redundant. -
Variables within Tables in Insets
We use insets. We have just upgraded to FrameMaker 11 recently. We share inset files in multiple "container" FrameMaker files. When a variable is within a table in an inset, when the inset is updated in any way, the inset does not respect the variable definitions of its "container" file.
If you sweep new variables into the container file, the inset updates. As soon as you update the file via a book update or update the inset itself in the container file, the inset reverts to its own definitions. The insets are properly set to inherit their formatting/variables/conditions/etc from their container files. If the variables are outside of a table, they inherit the definitions properly. Is this a bug? Has anyone else experienced this and fixed in on their own?Here are the answers to your questions:
1. When you "edit" the text inset source, exactly what are you changing - the variables or some other content?
Any change to the file. I can open the file, press the space bar, and save. If I update the inset in the container, the inset shows the inset's variable definitions
2. When you say the "inset's settings" win, do you mean that the source variable definitions used in the inset show instead of those in the container file?
Yes. It is using the defintions that are in the inset upon updating the inset.
3. When you "update" the inset, do you mean that you've made some sort of edit to inset source file and then do a Save on that file?
Yes and then I double-click on the inset and click Update to manually update the container to reflect my changes.
4. What precisely do you mean by "sweep the correct variable into every inset" ?
Sorry what I wrote was a bit unclear. What I meant to say was in order to ensure the variables are displayed properly, the only thing I can see to do is to sweep the variable definitions I want into the inset before publishing.
5. How exactly (menu, double-click the inset & update or close & open file) are you doing the inset updates in the container files?
I usuallly double-click on the inset within the container file and click Update. -
Variable as table name in update statement
Hi everyone,
I am trying to update a table whose name is based on bind variables in the form and is unknown until runtime. However, I haven't been able to find a way to do this. I'm currently trying the FORMS_DDL built-in, but no success here either. Has anyone ever done this?
DECLARE
matrix_temp_table VARCHAR2(50);
BEGIN
matrix_temp_table := 'TEMP_'||:mgmt_matrix_master.div_idkey||'_'||TO_CHAR(:mgmt_matrix_master.dept_idkey);
FORMS_DDL('UPDATE '||matrix_temp_table||' SET create_date = :mgmt_matrix_master.create_date');
END;You're right, issuing the statement using the table name itself only works outside of FORMS_DDL. After trudging through the documentation it seems the best way to accomplish what I am trying to do is by using the EXEC_SQL package. But, once again, I cant get this to work either. It seems to me what I am trying to do is a fairly simple thing, but apparently not. I'm now trying to use this code, but the table still isn't being updated.
PROCEDURE update_matrix_temp_table IS
matrix_temp_table VARCHAR2(50);
update_connid EXEC_SQL.ConnType;
update_cursor EXEC_SQL.CursType;
ignore PLS_INTEGER;
BEGIN
matrix_temp_table := 'TEMP_'||:mgmt_matrix_master.div_idkey;
update_connid := EXEC_SQL.CURR_CONNECTION;
update_cursor := EXEC_SQL.OPEN_CURSOR(update_connid);
EXEC_SQL.PARSE(update_connid, update_cursor, 'UPDATE '||matrix_temp_table||' SET emp_no = '||:mgmt_matrix_master.emp_no);
ignore := EXEC_SQL.EXECUTE(update_connid, update_cursor);
EXEC_SQL.PARSE(update_connid, update_cursor, 'COMMIT');
ignore := EXEC_SQL.EXECUTE(update_connid, update_cursor);
EXEC_SQL.CLOSE_CURSOR(update_cursor);
EXCEPTION
WHEN EXEC_SQL.PACKAGE_ERROR THEN
IF EXEC_SQL.LAST_ERROR_CODE(update_connid) != 0 THEN
Message('ERROR (source: ' ||TO_CHAR(EXEC_SQL.LAST_ERROR_CODE(update_connid))|| '): ' ||EXEC_SQL.LAST_ERROR_MESG(update_connid));
END IF;
END; -
Using variable as table name in pl/sql query - Is possible?
I am relatively new to PL/SQL and I am trying to create a function that accepts a table name and a rowid as arguments and returns a comma-delimited record string of the values of the table/rowid being passed. The problem is , I cannot code a select stmt as follows
SELECT * FROM v_table_name
WHERE rowid = v_row_id
in PL/SQL. There must be a easy way to approach this.
Thanks for any and all advice.
GCI don't understand the use of the concat symbol along with the commas and field namesYou just need (if you really need it) to create variable which contains you column separated by comma:
Simple example (in the second case separate variables are used to create
the list of columns):
SQL> declare
2 rc sys_refcursor;
3 cols varchar2(200) := 'ename, empno, sal';
4 tab varchar2(30) := 'emp';
5 begin
6 open rc for 'select ' || cols || ' from ' || tab;
7 close rc;
8 end;
9 /
PL/SQL procedure successfully completed.
SQL> declare
2 rc sys_refcursor;
3
4 ename_col varchar2(10) := 'ename';
5
6 empno_col varchar2(10) := 'empno';
7
8 sal_col varchar2(10) := 'sal';
9
10 tab varchar2(30) := 'emp';
11
12 begin
13
14 open rc for 'select ' || ename_col || ',' || empno_col || ',' || sal_col ||
15 ' from ' || tab;
16
17 close rc;
18 end;
19 /
PL/SQL procedure successfully completed.Rgds.
Maybe you are looking for
-
Can t open Docs stored from pages in cloud
I have been using pages on iPad 2 for sometime with no problems. Somehow this week during some back up the docs left iPad and I can find them in iCloud -storage and backup -manage storage but can t open them or restore to iPad or send. They are just
-
HI, I am using JAXP Template object to cache my XSLT files. Can my code pass parameters to a cached XSLT file? Thanks, Java-Junkie
-
OS X Yosemite WiFi Still Sporadically Disconnecting Even After Update
I have a late-2013 MacBook Pro Retina. I've had Yosemite on it for a while now, and am now only facing this. I know a lot of other people in the community have had this issue, and I know there was a recent update that fixes it, but it's just not lett
-
Copy of notifications (mails) not received in business workplace
Hi, The users stopped receiving a copy of the notifications in their business workplaces sent via mail step in a workflow. The WF is using the SAP username to send the mails in the mail step of the workflow (we are not using the e-mail address, just
-
If I restore my iPhone from iTunes can I be selective as to what I restore? Can I restore my notes and nothing else? Thanks.