Number of Parameter of dynamic statement
How i can get the number of parameter tobe set of dynamic statements.
Example:
I got a string with a placeholders to be interpreted as a statement and I create a statament using the string.
"select * from MyTable where Name like :1 AND Surname like :2¨
Is there any way available to get the number of parameter?
No, I that's the result set... I need the number of bind variables that need to be set to avoid a "not all variables bound" error at execute time.
I realize that it is a bit tricky to get that (due to input and output vars, vars having same names, etc.), but OCI has it and I was hoping a C++ wrapper existed. And I do get a runtime error when I try to set a variable that doesn't exist, so internally the number must be known.
Thanks for trying, anyway.
Flado
Similar Messages
-
Using a record as parameter in dynamic SQL
Hi,
I'm trying to pass a record (%rowtype) as parameter
to a procedure which i call from inside a dynamic statement. This doesnt seem to work however, I get the reply "not a valid sql-statement".
Apparently, Oracle does not allow for this since records are not a SQL-type but a PL/SQL-type.
Have anyone found a way around this?
(Except for the obvious to pass just the primary key and
populate the record inside the procedure).
The code looks like:
declare
v_rec employee%rowtype;
v_stmt varchar2(500);
begin
select *
into v_rec
from emplyee
where rownum = 1;
v_stmt := 'some_proc ( :param )';
execute immediate v_stmt using v_rec;
end;
Any advice appreciated,
Thanks
Anders GrusellHi,
Here's a example of something similar which we had done for the data conversion excercise recently.
The script uses dynmanic PL/SQL block and executes it using Execute Immediate. AAnd within the dynamic PL/SQL block, a procedure Pr_Pb_Test is called which takes in %ROWTYPE as ainput parameter.
See if this helps.
-- Shailender Mehta --
Set ServerOutput On Size 999999;
Declare
i Number;
lValue Varchar2(10);
type rc is ref cursor;
iVar1 Varchar2(10) := 'Test Var';
l_cursor rc;
ltest1 Mr_Test1%RowType; -- RowType Structure for Mirror
lSql Varchar2(100);
lNewTab Tb_Test%RowType; -- RowType Structure for the New System Table
/* This procedure uploads to new system table the 1st time
The table Test1 after successful upload will be taken Offline
or deleted
Procedure abc Is
lSqlStr Long;
Begin
SQL> desc test1;
Name Null? Type
ID NUMBER
COL1 VARCHAR2(10)
lSqlStr := 'Declare
ltest Test1%RowType;
type rc is ref cursor;
l_cursor rc;
lNewTab Tb_Test%RowType; -- RowType Structure for new system Table
Begin
Open l_cursor For :lSql;
Loop
Fetch l_cursor Into ltest;
Exit When l_cursor%NotFound;
lNewTab.Id := ltest.Id;
lNewTab.Col1 := ltest.Col1;
-- Procedure which inserts into the new system
-- table using %ROWTYPE
Pr_Tb_Test (lNewTab);
End Loop;
End;
Execute Immediate lSqlStr USING lsql;
End abc;
Begin
Begin
Select code_value
Into lValue
From DC_CODES
Where code_type_cd = 'LASTRUNDT'
And code_value Is Not Null;
i := 1;
Exception
When No_Data_Found Then i := 0;
End;
If ( i = 0 ) Then
Delete From Tb_Test;
lSql := 'Select * from test1';
abc;
Else
-- Subsequent uploads to the new system tables using MIRROR table : Mr_Test1
SQL> desc mr_test1;
Name Null? Type
ID NUMBER
COL1 VARCHAR2(10)
ACTION_TYPE VARCHAR2(1)
lSql := 'Select * from mr_test1 Where Action_Type = ''I''';
Open l_cursor for lSql;
Loop
Fetch l_cursor Into ltest1;
Exit When l_cursor%NotFound;
lNewTab.Id := ltest1.Id;
lNewTab.Col1 := ltest1.Col1;
Pr_Tb_Test (lNewTab); -- Procedure which inserts into the new system
End Loop;
Close l_cursor;
End If;
Update dc_codes set code_value = sysdate;
End;
/ -
Help with dynamic statement returning values into collection
Hi All
I am trying to use dynamic statement to return values into a collection using the returning clause. However, I get an ORA-00933 error. Here is a simple setup:
create table t(
pk number,
id_batch varchar2(30),
date_created date,
constraint t_pk primary key ( pk )
create or replace type num_ntt is table of number;
create or replace type vc2_ntt is table of varchar2(30);
create or replace
package pkg
as
type rec is record(
pk num_ntt,
id_batch vc2_ntt
procedure p(
p_count in number,
p_rt out nocopy rec
end pkg;
create or replace
package body pkg
as
procedure p(
p_count in number,
p_rt out nocopy rec
is
begin
execute immediate '
insert into t
select level, ''x'' || level, sysdate
from dual
connect by level <= :p_count
returning pk, id_batch into :pk, :id_batch'
using p_count returning bulk collect into p_rt.pk, p_rt.id_batch;
end p;
end pkg;
declare
r pkg.rec;
begin
pkg.p( 5, r );
end;
/sanjeevchauhan wrote:
but I am working with dynamic statement and returning multiple fields into a collection.And using an INSERT...SELECT statement combined with a RETURNING INTO clause still does not work. Whether it's dynamic SQL or not: it doesn't work. The link describes a workaround.
By the way, I don't see why you are using dynamic SQL here. Static SQL will do just fine. And so you can literally copy Adrian's setup.
Regards,
Rob. -
Related to using dynamic statements
Hi,
Just when defining cursors, are there any other ways, by which we can use any dynamic statements? Such as depending on different conditions, we want to have different 'where' clauses.
Thks & Rgds,
HuaMinFor a straight in-line cursor which is what I think you are requiring, the closest thing I can think of would be something like....
PROCEDURE myproc(p_x IN NUMBER := NULL, p_y IN NUMBER := NULL, p_z IN NUMBER := NULL) IS
CURSOR cur_mycursor
SELECT a,b,c,d
FROM mytable
WHERE x = NVL(p_x, x)
AND y = NVL(p_y, y)
AND z = NVL(p_z, z);Obviously this is a basic example showing how you can restrict the query on just the values you supply, but you could adapt for more complex things. -
To find number of parameter from request
Freinds,
Is there any way to find out number of parameter submitted from request object. But the constraint will be with out going through loop.
Example
int count = 0;
Enumeration list = request.getParameterNames();
while (list.hasMoreElements()) {
count++;
list.nextElement();
}Can some body help me to resolve the warning created by this line
ArrayList paramList = null;
paramList = new ArrayList(Collections.list(request.getParameterNames()));CheckFilter.java:96: warning: [unchecked] unchecked conversion
found : java.util.Enumeration
required: java.util.Enumeration<T>
paramList = new ArrayList(Collections.list(request.getParameterNames()));
^
CheckFilter.java:96: warning: [unchecked] unchecked method invocation: <T>list(java.util.Enumeration<T>) in java.util.Collections is applied to (java.util.Enumeration)
paramList = new ArrayList(Collections.list(request.getParameterNames()));
^
CheckFilter.java:96: warning: [unchecked] unchecked call to ArrayList(java.util.Collection<? extends E>) as a member of the raw type java.util.ArrayList
paramList = new ArrayList(Collections.list(request.getParameterNames())); -
Pass table name as parameter in prepared Statement
Can I pass table name as parameter in prepared Statement
for example
select * from ? where name =?
when i use setString method for passing parameters this method append single colon before and after of this parameter but table name should be send with out colon as SQL Spec.
I have another way to make sql query in programing but i have a case where i have limitation of that thing so please tell me is it possible with prepared Statment SetXXx methods or not ?
Thanks
Haroon Idrees.haroonob wrote:
I know ? is use for data only my question is this way to pass table name as parameterI assume you mean "how can I do it?" As I have already answered "is this the way?" with no.
Well, I would say (ugly as it is) String concatenation, or stored procedures. -
Report to display number of items sold by state
Hello experts,
I would need a report with the following paramters:
Deliver doc number,posting date,ship to state,item number,item desc,quantity.Is it possible to have the selection for the date range?
ThanksHello Gordon,
This is what I noticed.
This query shows the ship to state for the order if they are not on the User defined fields on a delivery document.
Let me be more clear
This query is displaying only the customers where the ship to address is entered in the BP master data.If the ship to address is entered at the sales order level it is not displaying the ship to state.
I hope this makes sense
Thanks -
Parameter with Dynamic prompt - bug encountered
I am using CRD XI release 2 (SP2) against an Oracle 10 release 2 database
I have a report fully working with a static parameter
1. But I have an issue when trying to introduce a parameter with dynamic prompts
I have a data source (PointofSale retrieving data from a database view)
I am trying to have the newPointOfSale parameter to prompt the user for values taken out of the PointOfSale source.
I set up the parameter as indicated by the Crystal RD210 Guide.
But when I run the report I am prompted for Server Name(greyed out)/user name/password(something I have never had to do for this report until introducing the dynamic parameter)
In doubt I enter these of the database user I am using as a source for this report
I get a strange error message telling me there is a problem with another datasource on the report.
'Prompting failed with the following error message: 'List of Values failure: fail to get values. [Cause of erro: The table 'DLEX_REPORT.DLEX_REPORT_RETRIEVE.AIRLEGSUMMARY_SUM' could noyt be found. UNKNOWN.RPT]'.
Error source: prompt.ddl Error code 0x8004380D
There seem to be bug with parameters and dynamic list of values in Crystal as other people seem to encounter similar issue
Is there a fix or a workaround?
2. Also I believe this forum allows to escalate bugs with SAP/business objects. Does anyone know how to do this? As this is very obviously a bug....
Thanks
PhilippeI am not sure whether this will solve your problem since you are using a different implementation of Crystal Reports , but I've received the same error using CR XI Developer Release 2 in conjunction with the Crystal Reports Server XI Release 2. My solution was to go into the Business View Manager application and fix the Data Connection object associated with the problematic Dynamic prompt by supplying a user name and password for the data connection object and setting the "Runtime Prompt Mode" property to "Never Prompt". For some dumb reason, the Crystal Reports client will publish the data connection object to the Business Views database without any login credentials associated with it. So after creating such a prompt in a report, you have perform this extra step before running the report the first time. The good news is that if you reference this dynamic prompt in other reports, it will work - so you only need to fix it when it is first created.
-
How display number of row in select statement
How can I display number of row in select statement?
Table
data1 data2
xxx ccd
wss qwe
qws uij
I need get from SELECT statement:
1 xxx ccd
2 wss qwe
3 qws uijuser13734495 wrote:
Thank you from answer.
Statement
select rownum rn, data1, data2 from table
is good.
And what have I do went I use
select rownum rn, data1, data2 from table order by data1
and I get
3 qws uij
2 wss qwe
1 xxx ccd
I need
1 qws uij
2 wss qwe
3 xxx ccdhence the importance of describing the complete problem.
select
rownum,
data1,
data2
from(
select
data1,
data2
from
table
order by
data1) -
Create "dynamic" statements in a stored procedure
hello
in my stored procedure I need to write a statement like this:
FUNCTION myfunct (mytable IN VARCHAR2)
BEGIN
EXECUTE IMMEDIATE
'SELECT COUNT(*)
INTO myvar
FROM ' || mytable ||
'WHERE mycol = ' || currval;
In short I need to create a sort of "dynamic" statement in which the tablename (nad other...) is a variable....
but I do not guess it's ok...
How can I do?Hi,
With dyanmic SQL, the INTO clause is part of the EXECUTE IMMEDIATE statement, not the query.
Try something like this:
CREATE OR REPLACE FUNCTION myfunct
( mytable IN VARCHAR2
RETURN PLS_INTEGER
IS
return_num PLS_INTEGER;
sql_txt VARCHAR2 (1000);
BEGIN
sql_txt := 'SELECT COUNT (*)'
|| ' FROM ' || mytable;
dbms_output.put_line (sql_txt || ' = sql_txt in myfunct');
-- EXECUTE IMMEDIATE sql_txt INTO return_num;
RETURN return_num;
END myfunct
/It's a good idea to develop dynamic SQL as shown above; putting the dynamic statement into a variable that can easily be displayed for debugging.
When it looks right, then un-comment the EXECUTE IMMEDAITE statement.
Before moving the code into Production, comment out (or remove) the put_line statement. -
Insert 'text' in dynamic statement
Just one very simple question:
I have
insert into nn_nodes (lfdnr, layer_, type_) values (lfdnr#, 0, 'input');and want to make it to a dynamic Statement.
How must I write the 'input'?
stmt# := 'insert into nn_nodes (lfdnr, layer_, type_) values (lfdnr#, 0, 'input');'divides the String into 2 parts and gives an Error Message,
stmt# := 'insert into nn_nodes (lfdnr, layer_, type_) values (lfdnr#, 0, '||'input'||');'don't take the '
Thanks for help!
~MelYet better - use bind variables:
'insert into nn_nodes (lfdnr, layer_, type_) values (:x,:y,:z)'Best regards
Maxim -
Peoplecode compile error(wrong number of parameter)
i am getting the below error when i click on "MAINTAIN ITEMS" under the navigation "ENTERPRISE LEARNING->CATALOG" in ELM.
"PEOPLECODE COMPLIE ERROR(WRONG NUMBER OF PARAMETER(2,16)) FOR PROGRAM LECS.COMPONENTS.CATALOGITEMCOMMON.ONEXECUTE.(2,405). A PEOPLECODE PROGRAM FOR THE SPECIFIED REFERENCE FAILED TO COMPILE CORRECTLY FOR THE INDICATED REASON" .
Let me know if anyone has any idea on this and how to fix this.<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by SQLJ Development ([email protected]):
Mmmh. This may be a bug in the way SQLJ resolves functions/stored procedures. Could you send me your infile/.sql/.sqlj files so that I can reproduce your problem? Thanks!
In the meantime, if everything works at runtime, you may have to ignore the errors and do your final compile offline.<HR></BLOCKQUOTE>
I haven't forgotten. We've got a lot of code, and will try to boil down to an illustrative example when we can.
At the moment, an off-line compile seems to work - though you might want to check my other post today :-)
null -
How do the dynamic state to record image in the cell-phone?
Excuse me.How do the dynamic state to record image in the cell-phone?Or whether it has the feasibility or not?..Somebody can give me some opinions and data,please.
Thanks.I don't understand very well what you want, but to record and image (get and snapshot) you have to create an Player, realize the player, start it and then get the snapshot. ex:
player = Manager.createPlayer("capture://video");
player.realize();
VideoControl videoControl = (VideoControl) player.getControl("VideoControl");
player.start();
byte[] data = videoControl.getSnapshot(null);
Image image = Image.createImage(data, 0, data.length);To find out if a device can record images you can use this:
boolean mmapiAvailable = System.getProperty("microedition.media.version") != null;
boolean canGetSnapshots = System.getProperty("supports.video.capture") != null;Hope that answer your question. -
I want to cancel my New York Times subscription. How do I do this?
When I called the telephone number given on my bank statement, it referred me to this email address.
I need to cancel ASAP.You need to turn off "auto renew". This article shows you how:
iTunes Store: Purchasing and managing auto-renewing subscriptions
http://support.apple.com/kb/HT4098 -
I found several charges on my bank account from Apple on App that is completely free. After calling the number showing on my bank statement there an automated answering that tells you to go to apple website!!! There is nobody to talk to!! Complete rip OFF
And now because I want to communicate with apple support I have to go through the hectic website and community support, this is ridiculous.
I have 5 iPhones in my account and this makes me reconsider upgrading to iPhones again.
Why Apple put a phone number in the bank transaction, if there is nobody to talk to!!!!!!
I hope someone from Apple support can answer my question.Go to getsupport.apple.com. Or, call 1-800-MYAPPLE.
Just because an app is free to download doesn't mean that there aren't in-app purchases available.
Go to iTunes on your computer, log into the iTunes Store with your Apple ID & password, and check your purchase history. Be advised that all iTunes & App Store purchases are final.
Maybe you are looking for
-
Need iPhoto 8 or 9 for older iMac
Installed a copy of Snow Leopard on my mother-in-law's 2007 computer, but had to wipe the HD, which as corrupted to do so. I already tried to use her older bundled software to custom install the iPhoto software, but no luck. The install program giv
-
Error in promotion management tool in BI4.1 Sp1
Hi I am getting the following error when i try to add report folder objects using Promotion Management Tool in BI4.1 SP1. We are having Windows clustered environment. Can anybody help me to resolve this issue? HTTP Status 500 - java.lang.RuntimeExc
-
Can't make MPEG-2 with audio via Compressor
Hi guys, help, I'm trying to make a single file MPEG-2 with video AND audio exporting from FCP. This file is intented for broadcast television, so i can't end up with 2 seperate audio/video files. Every time I select MULTIPLEXED MPEG-1/LAYER 2 AUDIO
-
Currency format in excel download
From reports when I am downloading to excel the format of the currency changes in excel. For example in report Budget value 102.789,00 EUR gets converted to 102789.00 EUR in excel. I want to keep this format identical. Are there settings in the repor
-
How to convert SAP script to pdf format and send mail? What do we need to do in print program and configuration we need to achive? Thanks