Query or function that returns distinct values and counts
For the following table:
ID number
address varchar(100)
Where the ID is the primary key and addresses might be repeated in other rows, I'd like to write a query that returns distinct addresses and the count for the number of times the address exists in the table. What's the best way to do this? Thank you in advance.
Jlokitz,
select address, count(*)
from table
group by address;
HTH
Ghulam
Similar Messages
-
Function that returns N values, without using a string
Hi, how can i make a function that returns several valures (that hasn't a exact number of returned values, it could return 3 values, or 7) without using a string?
When i need to return several values from a function, i put the values inside a varchar like thus 'XXX,YYY,ZZZ' and so on. Don't know if this has a poor performance.
If you can supply simple examples for what im asking, i would be nice.
(without using a string)Can i create the type objects inside a package? If i
can, they will be local to the package, right?Yes, you're right.
Pipeline returns a row or several?You can use pipelined function in the same way you use table:
SELECT * FROM TABLE(pipelined_funct(agr1, agr2));
It returns results as separate rows. -
Function which returns multiple values that can then be used in an SQL Sele
I'd like to create a function which returns multiple values that can then be used in an SQL Select statement's IN( ) clause
Currently, the select statement is like (well, this is a very simplified version):
select application, clientid
from tbl_apps, tbl_status
where tbl_apps.statusid = tbl_status.statusid
and tbl_status.approved > 0;
I'd like to pull the checking of the tbl_status into a PL/SQL function so my select would look something like :
select application, clientid
from tbl_apps
where tbl_apps.statusid in (myfunction);
So my function would be running this sql:
select statusid from tbl_status where approved > 0;
... will return values 1, 5, 15, 32 (and more)
... but I haven't been able to figure out how to return the results so they can be used in SQL.
Thanks for any help you can give me!!
Trisha GorrPerhaps take a look at pipelined functions:
Single column example:
SQL> CREATE OR REPLACE TYPE split_tbl IS TABLE OF VARCHAR2(32767);
2 /
Type created.
SQL> CREATE OR REPLACE FUNCTION split (p_list VARCHAR2, p_delim VARCHAR2:=' ') RETURN SPLIT_TBL PIPELINED IS
2 l_idx PLS_INTEGER;
3 l_list VARCHAR2(32767) := p_list;
4 l_value VARCHAR2(32767);
5 BEGIN
6 LOOP
7 l_idx := INSTR(l_list, p_delim);
8 IF l_idx > 0 THEN
9 PIPE ROW(SUBSTR(l_list, 1, l_idx-1));
10 l_list := SUBSTR(l_list, l_idx+LENGTH(p_delim));
11 ELSE
12 PIPE ROW(l_list);
13 EXIT;
14 END IF;
15 END LOOP;
16 RETURN;
17 END SPLIT;
18 /
Function created.
SQL> SELECT column_value
2 FROM TABLE(split('FRED,JIM,BOB,TED,MARK',','));
COLUMN_VALUE
FRED
JIM
BOB
TED
MARK
SQL> create table mytable (val VARCHAR2(20));
Table created.
SQL> insert into mytable
2 select column_value
3 from TABLE(split('FRED,JIM,BOB,TED,MARK',','));
5 rows created.
SQL> select * from mytable;
VAL
FRED
JIM
BOB
TED
MARK
SQL>Multiple column example:
SQL> CREATE OR REPLACE TYPE myrec AS OBJECT
2 ( col1 VARCHAR2(10),
3 col2 VARCHAR2(10)
4 )
5 /
Type created.
SQL>
SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myrec
2 /
Type created.
SQL>
SQL> CREATE OR REPLACE FUNCTION pipedata(p_str IN VARCHAR2) RETURN myrectable PIPELINED IS
2 v_str VARCHAR2(4000) := REPLACE(REPLACE(p_str, '('),')');
3 v_obj myrec := myrec(NULL,NULL);
4 BEGIN
5 LOOP
6 EXIT WHEN v_str IS NULL;
7 v_obj.col1 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
8 v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
9 IF INSTR(v_str,',')>0 THEN
10 v_obj.col2 := SUBSTR(v_str,1,INSTR(v_str,',')-1);
11 v_str := SUBSTR(v_str,INSTR(v_str,',')+1);
12 ELSE
13 v_obj.col2 := v_str;
14 v_str := NULL;
15 END IF;
16 PIPE ROW (v_obj);
17 END LOOP;
18 RETURN;
19 END;
20 /
Function created.
SQL>
SQL> create table mytab (col1 varchar2(10), col2 varchar2(10));
Table created.
SQL>
SQL> insert into mytab (col1, col2) select col1, col2 from table(pipedata('(1,2),(2,3),(4,5)'));
3 rows created.
SQL>
SQL> select * from mytab;
COL1 COL2
1 2
2 3
4 5 -
Updating a table with a query that return multiple values
Hi,
I'm trying to update a table which contain these fields : ItemID, InventoryID, total amounts
with a query that return these values itemId, inventoryid and total amounts for each items
Mind you, not all the rows in the table need to be updated. only a few.
This what i wrote but doesn't work since the query return multiple values so i can't assign it to journalAmounts.
UPDATE [bmssa].[etshortagetemp]
SET JournalAmounts = (SELECT sum(b.BomQty) FROM [bmssa].[Bom] b
JOIN [bmssa].[SalesLine] sl ON sl.ItemBomId = b.BomId
JOIN [bmssa].[SalesTable] st ON st.SalesId = sl.SalesId
WHERE st.SalesType = 0 AND (st.SalesStatus IN (0,1,8,12,13)) AND st.DataAreaId = 'sdi'
GROUP BY b.itemid, b.inventdimid)
Any advise how to do this task?Remember that link to the documentation posted above that explains exactly how to do this. When you read it which part exactly were you having trouble with?
-
I get an error when i try to execute a function that returns a date value
Hi,
I'm new in ODP.NET, i'm make a package that contains a function that returns a date i.e.
Package Body General_pkg is
Function Get_Day Return Date is
vd_day date;
Begin
select sysdate into vd_day from dual;
return vd_day;
end Get_Day;
End General_pkg;
i use the next code to execute the function:
OracleCommand cmdData = new OracleCommand("General_pkg.Get_Day", cnx);
cmdData.CommandType = Commandtype.StoredProcedure;
OracleParameter PRM;
PRM = new OracleParameter();
PRM.ParameterName = "VDATE";
PRM.OracleDbType = OracleDbType.Date;
PRM.Direction = ParameterDirection.ReturnValue;
cmdData.Parameters.Add(PRM);
try
cmdData.ExecuteNonQuery();
catch(OracleException e);
When i execute this code, i have and exception, which say "identifier GENERAL_PKG.Get_Day must be declare..."
Obviously the package is correctly created in ORACLE i tested first in sql plus and it works but in ODP.NET they don't recognize the package or the function i don't know... please help!!!OOOOOPSS.... i forgot that i change the user in my conecction string that's why it didn't work...
i guess i had to much beer last night.;. :)
thanks. -
SOLVED: How can I use or call a function that returns %ROWTYPE?
Hi
edit: you can probably skip all this guff and go straight to the bottom...In the end this is probably just a question of how to use a function that returns a %rowtype. Thanks.
Currently reading Feuerstein's tome, 5th ed. I've downloaded and run the file genaa.sp, which is a code generator. Specifically, you feed it a table name and it generates code (package header and package body) that will create a cache of the specified table's contents.
So, I ran:
HR@XE> @"C:\Documents and Settings\Jason\My Documents\Work\SQL\OPP5.WEB.CODE\OPP5.WEB.CODE\genaa.sp"
749 /
Procedure created.
HR@XE> exec genaa('EMPLOYEES');which generated a nice bunch of code, viz:
create or replace package EMPLOYEES_cache is
function onerow ( EMPLOYEE_ID_in IN HR.EMPLOYEES.EMPLOYEE_ID%TYPE) return HR.EMPLOYEES%ROWTYPE;
function onerow_by_EMP_EMAIL_UK (EMAIL_in IN HR.EMPLOYEES.EMAIL%TYPE) return HR.EMPLOYEES%ROWTYPE;
procedure test;
end EMPLOYEES_cache;
create or replace package body EMPLOYEES_cache is
TYPE EMPLOYEES_aat IS TABLE OF HR.EMPLOYEES%ROWTYPE INDEX BY PLS_INTEGER;
EMP_EMP_ID_PK_aa EMPLOYEES_aat;
TYPE EMP_EMAIL_UK_aat IS TABLE OF HR.EMPLOYEES.EMPLOYEE_ID%TYPE INDEX BY HR.EMPLOYEES.EMAIL%TYPE;
EMP_EMAIL_UK_aa EMP_EMAIL_UK_aat;
function onerow ( EMPLOYEE_ID_in IN HR.EMPLOYEES.EMPLOYEE_ID%TYPE)
return HR.EMPLOYEES%ROWTYPE is
begin
return EMP_EMP_ID_PK_aa (EMPLOYEE_ID_in);
end;
function onerow_by_EMP_EMAIL_UK (EMAIL_in IN HR.EMPLOYEES.EMAIL%TYPE)
return HR.EMPLOYEES%ROWTYPE is
begin
return EMP_EMP_ID_PK_aa (EMP_EMAIL_UK_aa (EMAIL_in));
end;
procedure load_arrays is
begin
FOR rec IN (SELECT * FROM HR.EMPLOYEES)
LOOP
EMP_EMP_ID_PK_aa(rec.EMPLOYEE_ID) := rec;
EMP_EMAIL_UK_aa(rec.EMAIL) := rec.EMPLOYEE_ID;
end loop;
END load_arrays;
procedure test is
pky_rec HR.EMPLOYEES%ROWTYPE;
EMP_EMAIL_UK_aa_rec HR.EMPLOYEES%ROWTYPE;
begin
for rec in (select * from HR.EMPLOYEES) loop
pky_rec := onerow (rec.EMPLOYEE_ID);
EMP_EMAIL_UK_aa_rec := onerow_by_EMP_EMAIL_UK (rec.EMAIL);
if rec.EMPLOYEE_ID = EMP_EMAIL_UK_aa_rec.EMPLOYEE_ID then
dbms_output.put_line ('EMP_EMAIL_UK lookup OK');
else
dbms_output.put_line ('EMP_EMAIL_UK lookup NOT OK');
end if;
end loop;
end test;
BEGIN
load_arrays;
end EMPLOYEES_cache;
/which I have run successfully:
HR@XE> @"C:\Documents and Settings\Jason\My Documents\Work\SQL\EMPLOYEES_CACHE.sql"
Package created.
Package body created.I am now trying to use the functionality within the package.
I have figured out that the section
BEGIN
load_arrays;
end EMPLOYEES_cache;
/is the initialization section, and my understanding is that this is supposed to run when any of the package variables or functions are referenced. Is that correct?
With that in mind, I'm trying to call the onerow() function, but it's not working:
HR@XE> select onerow(100) from dual;
select onerow(100) from dual
ERROR at line 1:
ORA-00904: "ONEROW": invalid identifier
HR@XE> select employees_cache.onerow(100) from dual;
select employees_cache.onerow(100) from dual
ERROR at line 1:
ORA-06553: PLS-801: internal error [55018]
HR@XE> select table(employees_cache.onerow(100)) from dual;
select table(employees_cache.onerow(100)) from dual
ERROR at line 1:
ORA-00936: missing expressionHe provides the code genaa.sp, and a very brief description of what it does, but doesn't tell us how to run the generated code!
Now, I have just done some googling, and it seems that what I am trying to do isn't possible. Apparently %ROWTYPE is PL/SQL, and not understood by SQL, so you can't call onerow() from sql. Correct?
So I try wrapping the call in an exec:
HR@XE> exec select employees_cache.onerow(100) from dual;
BEGIN select employees_cache.onerow(100) from dual; END;
ERROR at line 1:
ORA-06550: line 1, column 30:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PLS-00428: an INTO clause is expected in this SELECT statement
HR@XE> exec select table(employees_cache.onerow(100)) from dual;
BEGIN select table(employees_cache.onerow(100)) from dual; END;
ERROR at line 1:
ORA-06550: line 1, column 14:
PL/SQL: ORA-00936: missing expression
ORA-06550: line 1, column 7:
PL/SQL: SQL Statement ignored
HR@XE> exec employees_cache.onerow(100)
BEGIN employees_cache.onerow(100); END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'ONEROW' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignoredNo joy.
Of course, now that I'm looking at it again, it seems that the way to go is indicated by the first error:
PLS-00428: an INTO clause is expected in this SELECT statement
So am I supposed to create a type of EMPLOYEES%ROWTYPE in a PL/SQL procedure, and the idea of this code, is that the first call to onerow() runs the initialiation code, which populates the cache, and all subsequent calls to onerow() (whether by my session or any other) will use the cache?
I've had a stab at this, but still, no joy:
create or replace procedure testcache is
emp employees%rowtype;
begin
select employees_cache.onerow(100) from dual into emp;
dbms_output.put_line('Emp id: ' || emp.employee_id);
end testcache;
show errors
HR@XE> @testcache.sql
Warning: Procedure created with compilation errors.
Errors for PROCEDURE TESTCACHE:
LINE/COL ERROR
4/9 PL/SQL: SQL Statement ignored
4/54 PL/SQL: ORA-00933: SQL command not properly ended
HR@XE>Have a feeling this should be really easy. Can anybody help?
Many thanks in advance.
Jason
Edited by: 942375 on 08-Feb-2013 11:45>
Ha, figured it out
>
Hopefully you also figured out that the example is just that: a technical example of how to use certain Oracle functionality. Unfortunately it is also an example of what you should NOT do in an actual application.
That code isn't scaleable, uses expensive PGA memory, has no limit on the amount of memory that might be used and, contrary to your belief will result in EVERY SESSION HAVING ITS OWN CACHE of exactly the same data if the session even touches that package.
Mr. Feuerstein is an expert in SQL and PL/SQL and his books cover virtually all of the functionality available. He also does an excellent job of providing examples to illustrate how that functionality can be combined and used. But the bulk of those examples are intended solely to illustrate the 'technical' aspects of the technology. They do not necessarily reflect best practices and they often do not address performance or other issues that need to be considered when actually using those techniques in a particular application. The examples show WHAT can be done but not necessarily WHEN or even IF a given technique should be used.
It is up to the reader to learn the advantages and disadvantages of each technicalogical piece and determine when and how to use them.
>
Now, I have just done some googling, and it seems that what I am trying to do isn't possible. Apparently %ROWTYPE is PL/SQL, and not understood by SQL, so you can't call onerow() from sql. Correct?
>
That is correct. To be used by SQL you would need to create SQL types using the CREATE TYPE syntax. Currently that syntax does not support anything similar to %ROWTYPE.
>
So am I supposed to create a type of EMPLOYEES%ROWTYPE in a PL/SQL procedure, and the idea of this code, is that the first call to onerow() runs the initialiation code, which populates the cache, and all subsequent calls to onerow() (whether by my session or any other) will use the cache?
>
NO! That is a common misconception. Each session has its own set of package variables. Any session that touches that package will cause the entire EMPLOYEES table to be queried and stored in a new associative array specifically for that session.
That duplicates the cache for each session using the package. So while there might be some marginal benefit for a single session to cache data like that the benefit usually disappears if multiple sessions are involved.
The main use case that I am aware of where such caching has benefit is during ETL processing of staged data when the processing of each record is too complex to be done in SQL and the records need to be BULK loaded and the data manipulated in a loop. Then using an associative array as a lookup table to quickly get a small amount of data can be effective. And if the ETL procedure is being processed in parallel (meaning different sessions) then for a small lookup array the additional memory use is tolerable.
Mitigating against that is the fact that:
1. Such frequently used data that you might store in the array is likely to be cached by Oracle in the buffer cache anyway
2. Newer versions of Oracle now have more than one cache
3. The SQL query needed to get the data from the table will use a bind variable that eliminates repeated hard parsing.
4. The cursor and the buffer caches ARE SHARED by multiple sessions globally.
So the short story is that there would rarely be a use case where ARRAYs like that would be preferred over accessing the data from the table. -
Function not returning right value
I have this following function, based on the return value from this function, I am inserting a row into the GROUP_MAP table.
This function is returning a value greater than zero even though constrains would not let it select any rows.
It looks as if it is not applying the "AND STRING_CODE = String_Code" constraint to the result set. If there are two records matching the groupOID I passed it is returning two as the count(*). I checked by executing the query directly and I got 0 as the result. I sounds so strange. Is there any thing I am doing wrong ?
Thanks in Advance,
-Bhasker
FUNCTION FIND_CODE_GROUP (groupOID IN NUMBER, String_Code IN VARCHAR2)
RETURN NUMBER
AS
RETURN_VAL NUMBER(10);
BEGIN
RETURN_VAL := 0;
SELECT
COUNT(*)
INTO
RETURN_VAL
FROM
GROUP_MAP
WHERE
STRING_GROUP = groupOID AND STRING_CODE = String_Code;
DBMS_OUTPUT.PUT_LINE('RETURN_VAL:'|| RETURN_VAL || ' String code : ' || STRING_CODE);
RETURN(RETURN_VAL);
EXCEPTION
WHEN OTHERS THEN
RETURN(0);
END FIND_CODE_GROUP;FUNCTION FIND_CODE_GROUP (groupOID IN NUMBER, String_Code IN VARCHAR2)
RETURN NUMBER
AS
RETURN_VAL NUMBER(10);
BEGIN
RETURN_VAL := 0;
SELECT
COUNT(*)
INTO
RETURN_VAL
FROM
GROUP_MAP
WHERE
STRING_GROUP = groupOID AND STRING_CODE = String_Code;The second parameter to your function has the same name as the column name "STRING_CODE" in your table. You should change
the name of your second parameter to something other than "STRING_CODE". -
Is there any function that returns the latest DDL statement
can anyone tell me if there is any FUNCTION that returns latest DDL statement performed in a schema.
OR
if there is any TABLE that will be populated with latest
DDL statement in schema.
THANK YOU.The table all_objects (and/or dba_objects) contains a column called last_ddl_time. Thus, a query like
scott@jcave > SELECT max(last_ddl_time)
2 FROM all_objects
3 WHERE owner = 'SCOTT';
MAX(LAST_DDL_TI
28-NOV-03will tell you the last time any object owned by SCOTT had DDL issued against it.
Justin
Distributed Database Consulting, Inc.
www.ddbcinc.com/askDDBC -
How to define a function that returns a void?
Hi all,
How can I define a custom function that returns a void?
My understanding is simple UDF can only return a string.
Is there any way around this limitation?
Thanks.
Ron> Hi,
> User Defined Function in XI always return a String.
>
> If you requirement is that you want to perfrom some
> operation in an user defined function, one option is
> to move it to the Java Section in your mapping and do
> it in the intialization / clean up section.
>
> Else, wite a UDF that will return a Blank string as
> the output, and map it to the root node of the
> target.
>
Hi all,
Thank you all for your kind responses.
The scenario I have is I need to insert the value of a particular field into a database table. E.g. MessageId, to keep track of the messages going through XI.
Naturally, such operations return void. These operations are already encapsulated in a custom jar file.
My purpose of using a UDF is solely to invoke the operation.
But I realized I each UDF has to have a return type, and the output of this UDF must be mapped to a node in the outgoing message.
Currently, my UDF returns an empty string, by using the implementation as below, I manage to perform my desired operation without affecting the result:
MessageId -- UDF -- CONCAT -
InstitutionCD_Transformed
InstitutionCode_____
But as you can see, this is not an elegant way of doing things.
That's why I'm seeking alternative solutions for this problem.
Bhavesh, you mentioned something about doing the operation in the initialization/cleanup section.
Can you please explain more?
Thanks.
Ron -
I need a function that will go through and encrypt all the strings
I want to use one way enryption and need a function that will
go through and encrypt all the strings in my password column in sql
server 2003.
I also need a function that compares a test password string
is equal to the hash value in the database. Can anyone give me some
advice in this?Apparently it's not as simple as I thought. My first instinct
was
update yourtable set password = '#hash(password)#'
but that will crash
This is inefficient, but you only have to do it once.
query1
select id, password thepassword
from yourtable
cfloop query="query1"
update yourtable
set password = '#hash(thepassword)#'
where id = #id# -
Function that returns currently selected cell address or column
Is there a function that returns the address (or just the column) of the currently selected cell? Simply put, something like =selectedcolumn.
Background: I want to display help text in a cell, and I want that help text to change according to which cell (actually, which column) the user has selected. I have put the help texts in a hidden row. They take up too much space to be displayed all the time. I want one cell to contain the help text of the column of the currently selected cell.
Trying to not use Filemaker for this project if possible
Thanks for any help /MattThe Numbers method, using comments as Barry showed, is probably the best method. An alternate method which is more complex would be to use an Applescript running in the background. The Applescript can scan in the background for which cell/column is currently selected and write that cell/column address into a cell in your table. A formula in your table (most likely a lookup formula) can use that address to serve up the correct help text in a diffrerent cell in the table or in another table.
Some problems with this methodare
The script is not part of the document. It is a separate entity.
The script must be started manually. It will not automatically start when the Numbers document is opened.
If the Numbers document is to be used on other Macs, each would also need the script installed. -
XMLTABLE function not returning any values if xml has attribute "xmlns"
Hi,
XMLTABLE function not returning any values if xml has attribute "xmlns". Is there way to get the values if xml has attribute as "xmlns".
create table xmltest (id number(2), xml xmltype);
insert into xmltest values(1,
'<?xml version="1.0"?>
<emps>
<emp empno="1" deptno="10" ename="John" salary="21000"/>
<emp empno="2" deptno="10" ename="Jack" salary="310000"/>
<emp empno="3" deptno="20" ename="Jill" salary="100001"/>
</emps>');
insert into xmltest values(2,
'<?xml version="1.0"?>
<emps xmlns="http://emp.com">
<emp empno="1" deptno="10" ename="John" salary="21000"/>
<emp empno="2" deptno="10" ename="Jack" salary="310000"/>
<emp empno="3" deptno="20" ename="Jill" salary="100001"/>
</emps>');
commit;
SELECT a.*
FROM xmltest,
XMLTABLE (
'for $i in /emps/emp
return $i'
PASSING xml
COLUMNS empno NUMBER (2) PATH '@empno',
deptno NUMBER (3) PATH '@deptno',
ename VARCHAR2 (10) PATH '@ename',
salary NUMBER (10) PATH '@salary') a
WHERE id = 1;
The above query returning results but below query is not returning any results because of xmlns attribute.
SELECT a.*
FROM xmltest,
XMLTABLE (
'for $i in /emps/emp
return $i'
PASSING xml
COLUMNS empno NUMBER (2) PATH '@empno',
deptno NUMBER (3) PATH '@deptno',
ename VARCHAR2 (10) PATH '@ename',
salary NUMBER (10) PATH '@salary') a
WHERE id = 1;
how to get rid out of this problem.
Thanks,
-ManiAdded below one in xmltable, its working now.
XmlNamespaces(DEFAULT 'http://emp.com') -
Error with function that returns a rowtype...
i have a function that returns a rowtype. below is a simplified version:
create or replace function "GETC"
return mytable%rowtype
is
rec mytable%rowtype;
begin
rec.rowid := 1;
return rec;
end;
eventually i'll want to call this from java. but for now i'd settle for calling it from the XE web front end (and sqlplus).
SQLPLUS: i try to call it from sqlplus by first declaring a variable where i can store the return:
var a mytable%rowtype;
it instantly stops me saying that i can only declare a var of a particular type. so what do i do?
XE interface: i tried various ways to call getc(), but they were all unsuccessful. what should i be doing?
thanks so much for your time.
markoGiven a function like this:
CREATE OR REPLACE FUNCTION get_employee
( p_empno emp.empno%TYPE )
RETURN emp%ROWTYPE
AS
v_result emp%ROWTYPE;
BEGIN
SELECT * INTO v_result
FROM emp
WHERE empno = p_empno;
RETURN v_result;
END get_employee;You can call it within PL/SQL like this:
DECLARE
rec emp%ROWTYPE;
BEGIN
rec := get_employee(7902);
DBMS_OUTPUT.PUT_LINE(rec.ename);
END;However,
1. Unless there is a column named "ROWID" in the table (unlikely since it would conflict with the actual rowid and is therefore not allowed), the type will not have an attribute named "rowid".
2. "1" would not be a valid rowid anyway.
3. %ROWTYPE defines a PL/SQL type, which will not be recognised in other environments such as SQL and Java. -
BAPI OR RFC THAT RETURNS THE VALUE TABLE CONTENTS THAT IS SPECIFIED IN DOM
HI ALL,
i have requirement of BAPI or RFC that returns the value table contants(text table) in CRM..
for ex:
if i pass the dataelement or domain or checktable as input parameter,could i get the contents of its text table associated with it....
please if there is way help me on this..
thanks and regards,
goutham,Check these FM
RFC_READ_TABLE
RFC_GET_TABLE_ENTRIES -
Deploy resulset of PL\SQL function, that returns ANYTABLE%TYPE
How can deploy resulset of PL\SQL function, that returns ANYTABLE%TYPE in SQL?
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by angelrip:
Hello everyone,
I've come through the following problem:
1.- I created an PL/SQL stored procedure which returns a REF CURSOR element, definition looks like this:
PACKAGE PKG_LISTADOS AS
TYPE tuplas IS REF CURSOR;
/* Procedimientos exportados por el paquete */
PROCEDURE inicializarModuloListados;
FUNCTION recaudacionUltimoMes(medioPago DEF_MEDIO_PAGO.MEDIO_PAGO%TYPE)
RETURN tuplas;
2.- Now I would like to call the stored procedure and retrieve the PL/SQL cursor as a ResultSet Java Object. The code I wrote is this:
Connection conn;
XmlDocument paramDef;
conn=poolMgr.getConnection str_poolDBConnection);
try
CallableStatement cstmt=conn.prepareCall("{?=call PKG_LISTADOS.recaudacionUltimoMes(?)}");
cstmt.registerOutParameter(1, java.sql.Types.OTHER);
cstmt.setString(2, "MONEDA");
cstmt.executeQuery();
ResultSet rs=(ResultSet)cstmt.getObject(1);
catch(SQLException sqlE)
3.- However, I can't make it OK, all the time I get the following error:
SQL Error(17004), java.sql.SQLException: Non valid column type
May anyone help me with this, thanks in advance:
Miguel-Angel<HR></BLOCKQUOTE>
Do something like the following:
cstmt = conn.prepareCall("{call customer_proc(?, ?)}");
//Set the first parameter
cstmt.setInt(1, 40);
//Register to get the Cursor parameter back from the procedure
cstmt.registerOutParameter(2, OracleTypes.CURSOR);
cstmt.execute();
ResultSet cursor = ((OracleCallableStatement)cstmt).getCursor(2);
while(cursor.next())
System.out.println("CUSTOMER NAME: " + cursor.getString(1));
System.out.println("CUSTOMER AGE: " + cursor.getInt(2));
cursor.close();
null
Maybe you are looking for
-
ITunes Says "Other" takes up 1.31 GB of memory on my ipod
this makes it impossible for me to add anything to my ipod. it says that the "other" category (orange) takes up about 1/3 of my ipod. i have no album artwork on it. any ideas what could be causing this problem?
-
Hi I'm trying to update my iPhone 5 to the iOS 7 but all when it is activating it doesn't work
Hi I'm trying to update my phone but it won't activate I need help
-
HT5312 But what if I accidentally used the wrong rescue email address? What do I do?
So I for got my account question like "what's your favorite band?" Etc., so I go onto my account to resend the email containing that information. Problem is, I put the wrong email in it. It is suppose to be .aol but I put .gmail Can anyone help? It w
-
Hi all, I just have a really quick question about QT Pro. When I'm viewing clips online and want to save, what's the difference between "Save as Source..." and "Save as QuickTime Movie..."? Thanks, Andrew
-
Can professors from Russia create book in iBooks Author?
Can professors from Russia create book in iBooks Author?