Calling Dynamic Variable within a select
Hi
Trying to build up a dynamic proc and can't see to figure out why I can re use variable If I specify within the select what the code is then its fine but when I add in the variable doesn't workany help would be great !
create table basetable (id int, code varchar(15))
insert into basetable values (1,'SAP'),(2,'REG'),(3,'NRI')
create table Transactiontable (id int identity(1,1), baseid int, Product varchar(15))
insert into Transactiontable values (1,'AAAA'),(1,'BBBB'),(1,'CCCC'),(1,'DDDD'),(1,'unknown'),(2,'AAAA')
DECLARE @SQL NVARCHAR(max),@Cols NVARCHAR(max),@Cols2 NVARCHAR(max);
SELECT * FROM basetable
SELECT * FROM Transactiontable
DECLARE @SQL NVARCHAR(max),@Cols NVARCHAR(max),@Cols2 NVARCHAR(max), @Code NVARCHAR (3) ;
SET @CODE = 'REG'
;WITH mycte0
AS (SELECT ROW_NUMBER()
OVER(
partition BY baseid
ORDER BY id) rn
FROM transactiontable ),
mycte
AS (SELECT DISTINCT rn
FROM mycte0)
SELECT @Cols = STUFF((SELECT ', ' + QUOTENAME(rn)
FROM mycte
ORDER BY rn
FOR XML PATH('')),
1,
2,
,@Cols2 = STUFF((SELECT ', ' + QUOTENAME(rn) +' as [Product'+ cast(rn as varchar(5)) +']'
FROM mycte
ORDER BY rn
FOR XML PATH('')),
1,
2,
SET @SQL = 'select code,'+ @Cols2+' from (select b.code, t.Product, row_number() over(partition by t.baseid order by t.id) rn
from transactiontable t inner join basetable b on b.id=t.baseid where code = '+ @Code + ' --- ''REG''
) src PIVOT (max(Product) For rn In ('
+ @Cols + ')) pvt'
EXEC (@SQL)
DROP TABLE transactiontabledrop ;
DROP TABLE basetable;
but when I add in the variable doesn't workany help would be great !
DECLARE @SQL NVARCHAR(max),@Cols NVARCHAR(max),@Cols2
NVARCHAR(max);
SELECT * FROM basetable
SELECT * FROM Transactiontable
DECLARE @SQL NVARCHAR(max),@Cols NVARCHAR(max),@Cols2
NVARCHAR(max), @Code NVARCHAR (3) ;
Within a batch the declare variable name must be unique,you can not (or don't Need to) declare it twice, like here @SQL, @Cols, @Cols2...
In the second declaration part just declare @Code and remove the other; they already exists.
Olaf Helper
[ Blog] [ Xing] [ MVP]
Similar Messages
-
Dynamic variable Time for Select
Hi,
I try to develop some scripts but always I have the same problem , when I try to put in a Select instruction the variable Time, it doesn´t work correctly (for example):
*SELECT(%example%,"ID","TIME","[ID]='%TIME_SET%' ")
It doesn´t read correctly the variable Time_Set.
Have you got any idea to try to do selects using dynamic variable?
Thanks for all.Hi,
Dynamic variables like %TIME_SET% do not interact very well with the compiled default logic (LGX files) when it is run after a data send. If you look at the Default.LGX file, you will notice that your *SELECT statement does not appear there because that *SELECT statement has already been compiled. That is why the logic works when it is run via the debugger (because the LGF file is getting executed at run time) and it does not work when it is run via a data send (because the LGX is being executed).
What you will need to do is:
1. Create a another logic file (for example: Calculation1.LGF) and copy the text from the Default.LGF to this new logic file.
2. Place the following text in the Default.LGF file:
*RUNLOGIC
*LOGIC=Calculation1.LGF
*ENDRUNLOGIC
3. Validate and save the Default.LGF file
Now try running the logic after a data send and see if that works.
Good luck,
John -
Use variables in a SELECT INTO FROM command
Hi,
How do I use variables within a select into from command? I want to loop through SYS.DBA_TABLES using a cursor and count the number of rows in a
selection of tables an then insert into a cardinality table.
The count of rows will be stored in a variable called CNT, that bit is easy however I need a variable in the FROM clause because that
value changes with every iteration of the cursor.
e.g.
CNT := 0;
TN := "MyTable";
select count(*) into CNT FROM TN;
insert into cardinality (table_name, row_count) values (TN, CNT);
This is Oracle 9i and I need the row counts in a separate table as they are shipped over to a different environment for analysis purposes.
Any ideas?
Regards
Dave
Edited by: Yorky001 on Sep 15, 2010 10:32 AMHi,
Thanks for the info, unfortunately I can get neither example to work on this 9i system, could well be pilot error as I only ever get
to do any Oracle about once per year. In the first query I have tried both "user_tables" and SYS.DBA_TABLES, same result.
set serveroutput on size 1000000;
DECLARE
row_count INTEGER;
vstr VARCHAR2(500);
vstr1 VARCHAR2(500);
BEGIN
vstr := 'SELECT count(*) FROM ';
dbms_output.put_line(vstr);
FOR i IN (SELECT table_name FROM user_tables WHERE rownum < 10) LOOP
vstr1 := vstr || i.table_name;
EXECUTE IMMEDIATE vstr1
INTO row_count;
dbms_output.put_line(i.table_name || ':' || row_count);
END LOOP;
END;
This one complains about the execute immediate line.
Error report:
ORA-00933: SQL command not properly ended
ORA-06512: at line 12
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
BEGIN
FOR i IN (select
table_name,
to_number(
extractvalue(
xmltype(
dbms_xmlgen.getxml('select count(*) c from '||table_name))
,'/ROWSET/ROW/C')) count
from user_tables
where rownum<6) LOOP
dbms_output.put_line(i.table_name || ':' || i.count);
END LOOP;
END;
ORA-19206: Invalid value for query or REF CURSOR parameter
ORA-06512: at "SYS.DBMS_XMLGEN", line 121
ORA-06512: at line 1
ORA-06512: at line 2
19206. 00000 - "Invalid value for query or REF CURSOR parameter"
*Cause: The queryString argument passed to DBMS_XMLGEN.newContext was not a valid query, or REF CURSOR.
*Action: Rewrite the query so that the queryString argument is a valid query or REF CURSOR. -
How to run the variable exit without calling the variable selection screen?
Hi all
I have a query with 2 variables 0P_PRQUA (Previous Calendar Quarter (SAP Exit)) and ZCCDAT02.
ZCCDAT02 is a Key Date variable that is derived based on the last day of the quarter that is entered in 0P_PRQUA. The exit code works correctly when calling up the variable screen and ZCCDAT02 is derived properly.
The problem is that 0P_PRQUA is set to "Can be changed in query navigation". So if the user changes the value of the quarter the exit is not triggered and the value of ZCCDAT02 does not change.
Is it possible to trigger the exit or is there another way to do it? Ideas would be appreciated. I am trying to create a Web Template with a Dropbox box for the Quarter.
Query is written in BW 3.X.
Regards
ChamiHi guys
Just to restate the requirement. I want the user to be able to change the value of the variable, WITHOUT calling the variable selection screen.
I want the user to be able to change the value of the quarter by using a dropdown box from within the web template. Once that is selected I want the value of ZCCDAT02 to be derived from the new value of the quarter.
Regards
Chami -
I can not use the Global Variable in the subvi which be called dynamic
Hi,everybody,
i have a problem.
i called dynamic a subvi (subvi.vi) in the MainVI(main.vi),and putted it in the subpanel in the main.vi .the subvi should show the string (success!),but it not
why? Help me
WinXP LavVIEW8.0
Using LabVIEW 8.0.0 on Windows XP
附件:
MyTest.zip 16 KB
MainVI.JPG 41 KB
subvi.JPG 13 KBsubpanel中的VI要运行才可以。
-
Dynamic SQL within a SQL Query ?
is there any possibility to do like this ?
SELECT table_name, XXXXXXXX('SELECT Count(*) FROM '||table_name) tot_rows
FROM dba_tables
WHERE owner = 'SCOTT';or any other trick to run dynamic SQL within the SQL Query?
Hoping....that it should be.
Regards,
OrapdevOne small disadvantage: it is executing 202 SQL statements: 3 "user SQL statements" (the one above and the 2 "select count(*)..."), and 199 internal ones ...How did you get to those numbers?
I just traced this statement and found completely different results:
TKPROF: Release 10.2.0.3.0 - Production on Tue Jul 10 12:12:10 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Trace file: diesl10r2_ora_5440.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
declare cursor NlsParamsCursor is SELECT * FROM
nls_session_parameters;begin SELECT Nvl(Lengthb(Chr(65536)),
Nvl(Lengthb(Chr(256)), 1)) INTO :CharLength FROM dual; for NlsRecord in
NlsParamsCursor loop if NlsRecord.parameter = 'NLS_DATE_LANGUAGE' then
:NlsDateLanguage := NlsRecord.value; elsif NlsRecord.parameter =
'NLS_DATE_FORMAT' then :NlsDateFormat := NlsRecord.value; elsif
NlsRecord.parameter = 'NLS_NUMERIC_CHARACTERS' then
:NlsNumericCharacters := NlsRecord.value; elsif NlsRecord.parameter =
'NLS_TIMESTAMP_FORMAT' then :NlsTimeStampFormat := NlsRecord.value;
elsif NlsRecord.parameter = 'NLS_TIMESTAMP_TZ_FORMAT' then
:NlsTimeStampTZFormat := NlsRecord.value; end if; end loop;end;
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 1
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
SELECT NVL(LENGTHB(CHR(65536)), NVL(LENGTHB(CHR(256)), 1))
FROM
DUAL
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.01 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 1
total 3 0.01 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
1 FAST DUAL (cr=0 pr=0 pw=0 time=7 us)
SELECT *
FROM
NLS_SESSION_PARAMETERS
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 17
total 3 0.00 0.00 0 0 0 17
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
17 FIXED TABLE FULL X$NLS_PARAMETERS (cr=0 pr=0 pw=0 time=124 us)
select PARAMETER,VALUE
from
nls_session_parameters where PARAMETER in('NLS_NUMERIC_CHARACTERS',
'NLS_DATE_FORMAT','NLS_CURRENCY')
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 3
total 3 0.00 0.00 0 0 0 3
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
3 FIXED TABLE FULL X$NLS_PARAMETERS (cr=0 pr=0 pw=0 time=57 us)
select to_char(9,'9C')
from
dual
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 1
total 3 0.00 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
1 FAST DUAL (cr=0 pr=0 pw=0 time=2 us)
SELECT table_name,
DBMS_XMLGEN.getxmltype ('select count(*) c from ' || table_name).EXTRACT
('//text').getstringval
() tot
FROM dba_tables
WHERE table_name IN ('EMP', 'DEPT') AND owner = 'SCOTT'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.01 0.02 0 48 0 2
total 3 0.01 0.02 0 48 0 2
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
2 HASH JOIN (cr=42 pr=0 pw=0 time=2952 us)
2 MERGE JOIN CARTESIAN (cr=42 pr=0 pw=0 time=1206 us)
2 NESTED LOOPS OUTER (cr=42 pr=0 pw=0 time=478 us)
2 NESTED LOOPS OUTER (cr=36 pr=0 pw=0 time=421 us)
2 NESTED LOOPS OUTER (cr=30 pr=0 pw=0 time=379 us)
2 NESTED LOOPS OUTER (cr=30 pr=0 pw=0 time=365 us)
2 NESTED LOOPS (cr=22 pr=0 pw=0 time=312 us)
2 NESTED LOOPS (cr=16 pr=0 pw=0 time=272 us)
2 NESTED LOOPS (cr=8 pr=0 pw=0 time=172 us)
1 TABLE ACCESS BY INDEX ROWID USER$ (cr=2 pr=0 pw=0 time=56 us)
1 INDEX UNIQUE SCAN I_USER1 (cr=1 pr=0 pw=0 time=30 us)(object id 44)
2 INLIST ITERATOR (cr=6 pr=0 pw=0 time=111 us)
2 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=6 pr=0 pw=0 time=87 us)
2 INDEX RANGE SCAN I_OBJ2 (cr=4 pr=0 pw=0 time=54 us)(object id 37)
2 TABLE ACCESS CLUSTER TAB$ (cr=8 pr=0 pw=0 time=98 us)
2 INDEX UNIQUE SCAN I_OBJ# (cr=4 pr=0 pw=0 time=26 us)(object id 3)
2 TABLE ACCESS CLUSTER TS$ (cr=6 pr=0 pw=0 time=39 us)
2 INDEX UNIQUE SCAN I_TS# (cr=2 pr=0 pw=0 time=13 us)(object id 7)
2 TABLE ACCESS CLUSTER SEG$ (cr=8 pr=0 pw=0 time=37 us)
2 INDEX UNIQUE SCAN I_FILE#_BLOCK# (cr=4 pr=0 pw=0 time=21 us)(object id 9)
0 INDEX UNIQUE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=4 us)(object id 36)
2 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=6 pr=0 pw=0 time=33 us)
2 INDEX UNIQUE SCAN I_OBJ1 (cr=4 pr=0 pw=0 time=23 us)(object id 36)
2 TABLE ACCESS CLUSTER USER$ (cr=6 pr=0 pw=0 time=28 us)
2 INDEX UNIQUE SCAN I_USER# (cr=2 pr=0 pw=0 time=12 us)(object id 11)
2 BUFFER SORT (cr=0 pr=0 pw=0 time=716 us)
1 FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=661 us)
1436 FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=1449 us)
select count(*) c
from
EMP
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 1 0 1
total 4 0.00 0.00 0 1 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
1 SORT AGGREGATE (cr=1 pr=0 pw=0 time=96 us)
14 INDEX FULL SCAN EMP_IDX (cr=1 pr=0 pw=0 time=46 us)(object id 61191)
select metadata
from
kopm$ where name='DB_FDO'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 2 0 1
total 3 0.00 0.00 0 2 0 1
Misses in library cache during parse: 0
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
1 TABLE ACCESS BY INDEX ROWID KOPM$ (cr=2 pr=0 pw=0 time=42 us)
1 INDEX UNIQUE SCAN I_KOPM1 (cr=1 pr=0 pw=0 time=22 us)(object id 365)
select count(*) c
from
DEPT
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 1 0 1
total 4 0.00 0.00 0 1 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
ALTER SESSION SET sql_trace=FALSE
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Parsing user id: 50
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 5 0.00 0.00 0 0 0 0
Execute 5 0.00 0.00 0 0 0 1
Fetch 3 0.01 0.02 0 48 0 6
total 13 0.01 0.03 0 48 0 7
Misses in library cache during parse: 0
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 5 0.00 0.00 0 0 0 0
Execute 5 0.01 0.00 0 0 0 0
Fetch 7 0.00 0.00 0 4 0 21
total 17 0.01 0.00 0 4 0 21
Misses in library cache during parse: 0
9 user SQL statements in session.
1 internal SQL statements in session.
10 SQL statements in session.
Trace file: diesl10r2_ora_5440.trc
Trace file compatibility: 10.01.00
Sort options: default
1 session in tracefile.
9 user SQL statements in trace file.
1 internal SQL statements in trace file.
10 SQL statements in trace file.
10 unique SQL statements in trace file.
132 lines in trace file.
0 elapsed seconds in trace file.I only see a ratio of 1:9 for user- to internal SQL statements?
michaels> select * from v$version
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production -
FUNCTION Variable within Data Template
Hi Im calling a function within my sql and i want to use the result as a bind variable.... here goes...
Data Template...... XML
<sqlStatement name="Q1">
<![CDATA[select function_name(ppp.id) the_main_one,
:the_main_one + 10 new_value
from per_ppp]]>
</sqlStatement>
I get null value .... but from the_main_one i get a value..... any ideas... i checked for number and nvl(,0) and all that no luck
is there a grouping thing involved here... where as i need to call the function from within another sql statement...It can be done.
Step 1: Setup package.
Step 2: Create a global variable for your function value
Step 3: Before the calling function returns the value, set a global variable (placeholder)
Step 4: Create a new function that returns the global variable, make sure it's after the first function call. Returning the value you might want to reset the global variable to null....
Your good to go.
Ike Wiggins
http://bipublisher.blogspot.com -
Accessing a javascript variable within a EL, does anyone ....
know how to do this.
I have a variable, say eventid, defined as:
<SCRIPT>
var eventid = "GA20045533";
</SCRIPT>
and a button defined as:
<hx:commandExButton >
<f:param id="param_eventID" name="eventID" value = "#{window.eventid}" ></f:param>
</hx:commandExButton>but this somehow fails. How can I access this variable within the EL for the param tag??if you want to access the variable in the same page at the same time?
you can't
if you want to access the variable in other page? wich is called from the form? then you just call the parameter request.getParameter("province")
the value must be the same that the selected index, otherwise use a hidden input for store the selectedIndex -
I have a script that uses the Desktop Administrator Call Variables 1 through 7 that are in the Enterprise Data section. These fields are used for reporting against this script. I now have a request to add some call variables in another script to report against this one as well. Since it doesn't look like I can actually create more than the 10 Call Variables that are available in the Desktop Administrator, and because the stock variables are the only ones available in the set enterprise call info step, if I use the 10 call variables for this second script, will it mess up the reports for the other script if I use the same call variables but with different values in the second script?
Hi Joe-
To add to Gergely response to make the report less confusing you could filter the report by the Application(s) the calls came into.
So, if you end up with five scripts and applications that all use Call Peripheral Variable 1 for Customer ID and Call Peripheral Variable 2 for Option Selected those applications could be grouped into one report. Then if you had three other scripts and applications that use Call Peripheral Variable 1 for Caller City and Call Peripheral Variable 2 for Caller State as another group.
Also- In the Call Peripheral Variables you have six possible tokens for each variable you can use (0-5, default is 'all') which you can use to pack additional data into. In your report they will be pipe (|) delimited within each Call Peripheral Variable.
DJ -
How do I use a variable within a sql statement
I am trying to use a local variable within an open SQL step but I keep getting an error.
My sql command looks like this "SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " + locals.CurrentSerialNo
If I replace the locals.CurrentSerialNo with an actual value such as below the statement works fine.
"SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " + " 'ABC001' "
Can someone tell me how to correctly format the statement to use a variable?Hi,
Thanks for the reply. I have changed the required variable to a string, but with no success. I have reattached my updated sequence file and an image of the error.
When looking at the Data operation step I see that the sql statement is missing everything after the last quotation mark.
Thanks again,
Stuart
Attachments:
Database Test Sequence.seq 10 KB
TestStand error.JPG 37 KB -
Binding dynamic variable in XQuery doesn't work: ORA-00932
I have a table with several columns. One of those columns is a XMLType.
My goal is to have a query which selects rows from the table of which the XML column matches certain criteria.
I'm trying following example (JDBC) : http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb_xquery.htm#insertedID11
First, I created my own query, which looks like:
select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement[contains(Element, "someValue")] return "true"' passing t.xmlColumn)This works as expected. Next, as done in the example, I'm trying to replace the "someValue" with a dynamic variable.
Query then looks like:
select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement[contains(Element, $val)] return "true"' passing t.xmlColumn, :1 as "val")This does not seem to work, neither in SQLDeveloper nor in java.
I always get the :
java.sql.SQLException: ORA-00932: inconsistent datatypes: expected - got CHAR(SQLDeveloper just gives ORA-00932)
When I put $val between quotes (so "$val") then I get no error, but then I get no results either.
I think it will not replace $val in that case but just use it as a literal, so thats not what I want
I also tried to remove "contains" xpath and use the exact same example as on the oracle page
select * from MyTable t, XMLTABLE( xmlnamespaces (DEFAULT 'http://test), 'for $i in /RootElement where $i/SubElement/Key = $val return "true"' passing t.xmlColumn, :1 as "val")But this doens't help either.
I'm clueless about this, so any help would be appreciated
Edited by: user5893566 on Nov 29, 2008 6:24 AMOk, I tested it using the latest enterprise edition (11g) and there it works as expected.
However, on 10.2.0.1.0 and 10.2.0.3.0 it gives this error.
Is this a bug which has been fixed or should I do something special on 10g ?
I installed all of these as normal without any special settings, created the tables and ran the query... -
How do I use a dynamic variable from a prolog script?
I have my test broken in to three scripts, a login, an update, and a logout. There is a dynamic variable, SERVICE_VIRTUAL_CLIENT, from the login script that I need to use in the update script, but I can't figure out how to do it. Any help would be appreciated.
Edit: I forgot to mention that the login script is only run in the prolog portion of the UDP.
Scott
Message was edited by: scottmorganScott,
You would do this the same way you would in a stand-alone script. Create the variable pattern in the login in script and name the variable. Save the login script and open the other script and select the parameter where you need the value. Set the parameter value to {{variableNameFromLogin}} (Variables are transferred from one script to the next in a UDP).
I hope this makes sense -
IMPORT statement with dynamic variable
Friends, Need Help!!!!!!!
Im trying IMPORT variable contents from a cluster table VARI. I can do a IMPORT without issues when I use exact name of the variable but I have issues with dynamic variable selection. Pls see code below.
loop at objects.
assign objects-name to <fs>.
IMPORT <fs> to tmp_var from database vari(va) id st_key.
endloop.
I do not get any value to tmp_var. Need help!
thanks
BhaskarTry this.
loop at objects.
IMPORT (objects-name) to tmp_var from database vari(va) id st_key.
endloop.
Does it work?
Regards,
RIch Heilman -
Hello,
I am trying to sort my query based on a dynamic variable p_sorton in the cursor as follows:
function getMarketView2(
p_event_id in ex_event.event_id%type,
p_fromrow in integer,
p_torow in integer,
p_appTZ in char,
p_calcTZ in char,
p_sorton in varchar2) return varchar2 as
type t_ticket_trade is ref cursor return ex_ticket_trade%rowtype;
v_return varchar2(32767);
v_return_integer integer;
v_String varchar2(32767);
v_ex_ticket_trade_obj ex_ticket_trade_obj;
v_rowcount integer:=0;
v_rowtotal integer:=0;
v_done boolean:=false;
v_sysdate date:=NEW_TIME(SYSDATE,trim(p_appTZ),trim(p_calcTZ));
cursor cur_ticket_trade_event_open (p_event_id in ex_event.event_id%type, v_sysdate in date) is
select "TICKET_TRADE_ID","SELLER_ACCESS_ID","CREATE_DATETIME","MODIFY_DATETIME","LASTMODIFY_BY",
"BUYER_ACCESS_ID","OPEN_TRADE_DATE","CLOSE_TRADE_DATE","TICKET_SUITE_CODE","TICKET_DATETIME",
"TICKET_TIMEZONE","TICKET_EVENT_ID","TICKET_TYPE","TICKET_SEAT_TYPE","TICKET_OPPONENT",
"TICKET_TOTAL_SEAT","TICKET_PRICE","TICKET_PRICE_EXT","START_BID_DATE","OPEN_BID_PRICE",
"CURRENT_BID_COUNT","CURRENT_HIGH_BID","CURRENT_LAST_BID_DATETIME","CURRENT_BID_INCREMENT_BY","TICKET_TRANSACTION_DATE",
"TICKET_TRADE_STATUS" from ex_ticket_trade
where ex_ticket_trade.TICKET_EVENT_ID = p_event_id
and (ex_ticket_trade.ticket_datetime > v_sysdate)
and (ex_ticket_trade.ticket_trade_status in ('F','A','AB'))
and (ex_ticket_trade.ticket_suite_code='N' OR ex_ticket_trade.ticket_suite_code='Y')
order by p_sorton desc;
--ex_ticket_trade.ticket_datetime desc;
........then comes the rest of the code........
This code compiles fine but does not use the value passed in the param p_sorton in the order by clause.
the same code works fine when hardcoded to "ex_ticket_trade.ticket_datetime"
No idea where I may be going wrong?
Also can I do anything like ORDER BY v1 v2
where v1 specifies columns to sort on and v2 asc/desc, coz that's what I really need to do?
Pls help ...
Thanks,
KarunaHi,
Thanks for the reply ... I tried the same but due to my basic knowledge of pl-sql, I'm running into some other problem.
================================================
CREATE OR REPLACE FUNCTION testMarketView(p_event_id in ex_event.event_id%type,
p_fromrow in integer,p_torow in integer,
p_appTZ in char, p_calcTZ in char, p_sorton in varchar2
) return varchar2 as
type t_ticket_trade is ref cursor return ex_ticket_trade%rowtype;
v_return varchar2(32767);
v_return_integer integer;
v_String varchar2(32767);
v_ex_ticket_trade_obj ex_ticket_trade_obj;
v_rowcount integer:=0;
v_rowtotal integer:=0;
v_done boolean:=false;
v_sysdate date:=NEW_TIME(SYSDATE,trim(p_appTZ),trim(p_calcTZ));
TYPE t_ticket_trade_event IS REF CURSOR;
cur_ticket_trade_event t_ticket_trade_event;
v_dynQuery VARCHAR2(1000);
cursor cur_event_seat_section_row (p_ticket_trade in ex_event_seat_inv.ticket_trade_id%type) is
select distinct event_seat_section, event_seat_row
from ex_event_seat_inv
where ticket_trade_id = p_ticket_trade;
type t_event_seat_section_row is ref cursor return cur_event_seat_section_row%rowtype;
/*v_section varchar2(32767);
v_section_row varchar2(32767);
the 26 variables that belong to table ex_ticket_trade-----------
v_ticket_transaction_date date;
v_ticket_trade_status varchar2(10);*/
begin
v_dynQuery := 'select
"TICKET_TRADE_ID","SELLER_ACCESS_ID","CREATE_DATETIME","MODIFY_DATETIME","LASTMODIFY_BY",
"BUYER_ACCESS_ID","OPEN_TRADE_DATE","CLOSE_TRADE_DATE","TICKET_SUITE_CODE","TICKET_DATETIME",
"TICKET_TIMEZONE","TICKET_EVENT_ID","TICKET_TYPE","TICKET_SEAT_TYPE","TICKET_OPPONENT",
"TICKET_TOTAL_SEAT","TICKET_PRICE","TICKET_PRICE_EXT","START_BID_DATE",
"OPEN_BID_PRICE","CURRENT_BID_COUNT","CURRENT_HIGH_BID",
"CURRENT_LAST_BID_DATETIME","CURRENT_BID_INCREMENT_BY",
"TICKET_TRANSACTION_DATE","TICKET_TRADE_STATUS"
from ex_ticket_trade where
ex_ticket_trade.TICKET_EVENT_ID = ' || p_event_id || ' and (ex_ticket_trade.ticket_datetime > '|| v_sysdate||')
and (ex_ticket_trade.ticket_trade_status in ('||'''F'''||','||'''A'''||','||'''AB'''||'))
and (ex_ticket_trade.ticket_suite_code='||'''N'''||' OR ex_ticket_trade.ticket_suite_code='||'''Y'''||')
order by '|| p_sorton ||'desc ' ;
select count(*) into v_rowtotal
from ex_ticket_trade
where
ex_ticket_trade.TICKET_EVENT_ID = p_event_id
and (ex_ticket_trade.ticket_datetime > v_sysdate)
and (ex_ticket_trade.ticket_trade_status in ('F','A','AB'))
and (ex_ticket_trade.ticket_suite_code='N' OR ex_ticket_trade.ticket_suite_code='Y')
order by ex_ticket_trade.ticket_datetime asc;
v_ex_ticket_trade_obj:=ex_ticket_trade_tabobj.initialize;
v_rowcount:=1;
OPEN cur_ticket_trade_event FOR v_dynQuery;
LOOP
FETCH cur_ticket_trade_event INTO t_ticket_trade;
/* -- THIS IS WHAT I HAVE TO DEAL WITH IF I CAN"T
--PUT THE RESULTS OF THE CURSOR in t_ticket_trade
v_ticket_trade_id , v_seller_access_id , v_create_datetime, v_modify_datetime , v_lastmodify_by ,
v_buyer_access_id, v_open_trade_date, v_close_trade_date, v_ticket_suite_code, v_ticket_datetime,
v_ticket_timezone, v_ticket_event_id , v_ticket_type, v_ticket_seat_type, v_ticket_opponent,
v_ticket_total_seat, v_ticket_price , v_ticket_price_ext , v_start_bid_date, v_open_bid_price ,
v_current_bid_count , v_current_high_bid , v_current_last_bid_datetime , v_current_bid_increment_by ,
v_ticket_transaction_date , v_ticket_trade_status ;
if (t_ticket_trade.TICKET_SEAT_TYPE is null) then
for t_event_seat_section_row in cur_event_seat_section_row(t_ticket_trade.ticket_trade_id) loop
if (t_event_seat_section_row.event_seat_section is not null) then
v_section := t_event_seat_section_row.event_seat_section;
BEGIN
select alt_txt into v_parking_desc from ex_alt_txt
where event_id = p_event_id
and alt_txt_type = 'PARKING_DESC'
and original_txt = v_section;
t_ticket_trade.TICKET_SEAT_TYPE := v_parking_desc;
EXCEPTION
WHEN no_data_found THEN
v_section_row := 'Sec. ' || v_section;
if (t_event_seat_section_row.event_seat_row is not null) then
v_section_row := v_section_row || ', Row ' || t_event_seat_section_row.event_seat_row;
end if;
v_section_row := substr(v_section_row, 1, 30);
t_ticket_trade.TICKET_SEAT_TYPE := v_section_row;
END;
exit;
end if;
end loop;
end if;
if ((v_rowcount >= p_fromrow) and (v_rowcount <= p_torow)) then
-- p_ex_ticket_trade => t_ticket_trade
-- THIS IS WHAT I CAN'T DO in the next line IF I get the results of the cursor in seperate variables
v_ex_ticket_trade_obj:=ex_ticket_trade_tabobj.maprowtoobj(p_ex_ticket_trade => t_ticket_trade);
v_string:=v_string||v_ex_ticket_trade_obj.todatastring;
end if;
if (v_rowcount>=p_torow) then
exit;
end if;
v_section := null;
v_section_row := null;
v_parking_desc := null;
v_rowcount:=v_rowcount+1;
end loop;
v_prefix:='1' || v_delimiter || v_rowtotal || v_terminator;
v_return:= v_prefix || v_ex_ticket_trade_obj.tometadata||v_string;
return v_return;
end;
===========================================
I keep running into one error:
PLS-00403: expression 'T_TICKET_TRADE' cannot be used as an INTO-target of a SELECT/FETCH statement
How can I get each row of the cursor either as an object or as 'T_TICKET_TRADE' ?
Thanks,
Karuna -
Optional variables within report not shown on portal
Hello,
I have got following phenomenon:
I created a report with the Report Designer. This report contains different queries that all use the same optional variable. Our first tries showed the selection screen for this variable within the portal.
After we changed the technical name and the description and published it into portal again the selection for the optioanl variable isn't shown anymore.
It's no general problem because on queries for example the optional variables are shown.
Has anybody an idea what could be the problem and how we can solve it?
Greetings & thanks
BettinaHello,
if I execute the report within the Report Designer there occurs a drop down menu on the variable screen "Available variants:" with on item "Report with variable".
I can save this variant - but it's not possible to choose this special variant for publishing into portal (ok, maybe it works but my first tries didn't work). Do you have an idea how this setting can be used in portal??
Greetings & thanks
Bettina
Maybe you are looking for
-
Installation of SAP MI WAS 6.4
HI folks; We are doing MI Web AS 6.40 installation.We have successfully proceeded with central instance installation of ABAP stack.After this we were installing Database instance and facing a weird error which reads "unable to create sapssexc.tsk fil
-
After deployment i get an error [AnnotatedClassNotFoundException]
Hello. Iam using SOA suite 10.1.3.4 and jdeveloper 10.1.3.4. Till now everything have worked fine. But suddenly i get an error when i want to go "localhost:port/project/faces/Login.jsp". When i deploy Jdeveloper says no errors and deployment finished
-
MDSModelDeploy listservices - how update incorrect services
Hi all, when I run MDSModelDeploy listservices results similar to the below are returned. The first two services are the result of me incorrectly naming the MDS website in the Web Configuration section of the MDS Configuration Manager. Does anyone
-
Error while congiguring config tool
HI, I tried to change the JVM settings using config tool but it is giving an error and the config tool is automatically closing.can anybody help me to resolve this problem. Error occurred while working with Configuration. com.sap.engine.frame.core.co
-
Question I hope this will make sense
okay my question is last weekend I formatted my hard drive BUT I saved Lightoom on another drive I was working on some images in Lightroom, BUT forgot to export those images I opened Lightroom in that drive and can see the images, but of course Light