Sql query from plsql type or temp variable
Hi,
I have no rights to create or drop table in the production
But I want to see the data after processing this is multi record data which may need to store in the table or plsql type
variable.
What should I do In this case ?
For ex. I will pass My name in a function it will show each character in rows and how many time that character is repeated and what is the position.
name 'SUBHASISH'
S 3 1,6,8
H 2 4,9
please suggest.. thanks in adv...
Hi,
you can do:
with word as(select 'SUBHASISH' w from dual),
occ as(select w,substr(w,rownum,1) s,length(w)-length(replace(w,substr(w,rownum,1),'')) occurences,rownum ord from word
connect by rownum<=length(w)),
res as(
select ord,w,s,occurences,instr(w,s,1,row_number() over(partition by s order by s)) p from occ c
connect by prior occurences=occurences-1 and prior s=s
select s ch,occurences cnt, LTRIM(MAX(SYS_CONNECT_BY_PATH(p,',')) KEEP (DENSE_RANK LAST ORDER BY curr),',') AS pos
FROM (SELECT w,
s||' '||occurences what,
p,
s,
occurences,
ord,
ROW_NUMBER() OVER (PARTITION BY s ORDER BY occurences) AS curr,
ROW_NUMBER() OVER (PARTITION BY s ORDER BY occurences) -1 AS prev
FROM res)
GROUP BY s,occurences
CONNECT BY prev = PRIOR curr AND s = PRIOR s
START WITH curr = 1
CH CNT POS
A 1 5
B 1 3
H 2 4,9
I 1 7
S 3 1,6,8
U 1 2Edited by: user11268895 on Aug 27, 2010 9:58 AM
Similar Messages
-
Report failed to parse SQL query:ORA-01745: invalid host/bind variable name
Hi,
We are currently upgrading from v2.2.0.00.32 to v4.0.0.00.46.
I have copied the applications onto our test server along with the various database objects and data etc.
When I am running a report in v4, it is failing with the following error: "failed to parse SQL query: ORA-01745: invalid host/bind variable name".
When I copy the SQL that builds the report into TOAD (on out test server) it runs OK so really cant see why it would fail in APEX. It works fine when I run the query in our APEX v2 and in TOAD in our live server.
The query is as follows:
SELECT
aea.ALTERATION_ID
,aea.ALTERATION_ID "ALTERATION_ID_DISPLAY"
,aea.assembly_name "Revised BOM"
,assembly.description "Revised BOM Description"
,assembly.INVENTORY_ITEM_STATUS_CODE "Revised BOM Status"
,aea.BEFORE_CHANGE_QTY
,flv.MEANING "Alteration Type"
,aea.component_name "Part No"
,component.description "Part No Description"
,component.INVENTORY_ITEM_STATUS_CODE "Part No Status"
,aea.AFTER_CHANGE_QTY
,TO_CHAR(aea.last_update_date,'DD-MM-YYYY HH24:MI:SS')"Last Update Date"
,aea.LAST_UPDATE_BY
,aea.COMMENTS
,aea.ORACLE_CHANGE_NOTICE
,AEA.SELECTION_CRITERIA
FROM XXMEL_APEX_ECO_ALTERATIONS aea
, fnd_lookup_values flv
, (SELECT INVENTORY_ITEM_STATUS_CODE
,segment1
,description
FROM mtl_system_items_b
WHERE 1=1
AND organization_id = 26) component
, (SELECT INVENTORY_ITEM_STATUS_CODE
,segment1
,description
FROM mtl_system_items_b
WHERE 1=1
AND organization_id = 26) assembly
WHERE 1=1
AND aea.COMPONENT_NAME = component.segment1 (+)
AND aea.assembly_NAME = assembly.segment1 (+)
AND flv.lookup_code = aea.acd_type
AND aea.eco = :P13_ECO
AND flv.lookup_type = 'ECG_ACTION'
AND modify_flag = 'Y'
ANy help would be great,
Thanks
Chris
Edited by: Cashy on 22-Nov-2010 04:13
Edited by: Cashy on 22-Nov-2010 04:14For some reason, the updatable fields (this is a updateable report) where not connecting to the database properly. Whn I changed them to a report columns and removed the database field reference, the report rendered
-
See sql query from crystal report without crystal report
see sql query from crystal report without crystal report
Hi,
Depends on datasource type but you could have a look at ODBC trace or if you have access to the SQL Server you could use profiler to monitor the session.
Regards,
Craig
And this will only be of use if you know which Server/Insstance/Database the Report is connecting to...
Please click "Mark As Answer" if my post helped. Tony C. -
Help with translating SQL query from SQL Server syntax to Oracle syntax
Hi,
is it someone that can help me translate following SQL query from SQL Server syntax to Oracle syntax.
SELECT ID,
[LMT(MTR)] = MAX(case when TYPE = 'LMT' then VALUE end),
[AAD(KGM)] = MAX(case when TYPE = 'AAD' then VALUE end),
[VOL(MTQ)] = MAX(case when TYPE = 'VOL' then VALUE end)
FROM yourtable
GROUP BY ID
Your help is highly appreciated, thanks in advance.Like this,
SELECT ID,
MAX(case when TYPE = 'LMT' then VALUE end) LMT_MTR,
MAX(case when TYPE = 'AAD' then VALUE end) AAD_KGM ,
MAX(case when TYPE = 'VOL' then VALUE end) VOL_MTQ
FROM yourtable
GROUP BY ID-Arun -
How to transport SQL Query from SQVI Tcode?
Dear Friends,
Can any one tell me how to transport SQL Query from <b>SQVI</b> Tcode.
Full Points will be rewarded.
Thanks & Reagrds
Ravigo to sqvi tool .....
select u r query name ......in the menubar ....quickview....> additianal functions.......>generate program
after doing generate program ....go to again same menu path as i have mentioned above [quickview....> additianal functions.......>display report name it will give the report name of the select query ..........copy the report name and give it abap editor[se38] u will get u r query program......with all authority checks.....
in start of selection event of u r program u will find u r select query.
reward points if helpful -
Retrieve SQL Query from report without RAS.
We have a fat client application which uses Crystal Reports. We upgraded from the RDC/ActiveX viewer to the .Net SDK/.Net Viewer. One feature that we miss is that we used to read the SQL Query that a report used and wrote it to our log file. This helped with debugging and with troubleshooting problems in the field.
Since we only deploy the freely distributable Crystal Reports model and I don't think that RAS falls into this category is there a way which we can read the SQL Query from a report? If not, could you add this to a list of requested features for future versions.
I understand why you removed the ability to set the SQL query, but simply reading it does add value. Maybe it is difficult for you to return this before the report is run in which case giving us the ability to read the value after the report has been run would also be fine.
Alternatively some sort of event that is fired each time a query is executed would also be helpful as this would allow Crystal Reports clients to monitor SQL from sub-reports. You could even build a robust logging mechanism which could report additional information (i.e. number of rows returned, formula evaluations, or anything related to report execution). All of this would make troubleshooting report issues easier for those of us who use Crystal Reports.Need to know what version of CR you are using?
You can use InProc RAS, it comes with CR and is distributed with the runtime files.
If you are using CR Basic or the version that comes with Visual Studio .NET then no this will not be added to that product line. It is basic functionality only. You will need to upgrade to a Developer version of Crystal reports to take advantage of the the RCAPI features as well as more general API's.
There is logging for our DB drivers but the log files get very large. If you use ODBC then you have the option to turn on tracing also. Using RAS you don't need to turn on logging as you can get the SQL. This won't be added either.
Thank you
Don -
Passing variables to SQL query from checkboxes
Hello,
I have a cursor which gets different ids from an id table. The cursor is something like this:
CURSOR id IS
SELECT distinct id_ FROM I
order by id_;I then iterated through the cursor to made checkboxes to choose multiple ids:
FOR i IN id
LOOP
htp.p('<tr>
<DIV align="left"><td><input type="checkbox" name="option" value=ID '||i.id_||'> </td></tr>');
htp.p('<font size="'||3||'">'
ID'||i.id_||'</a></font>'
||'</a>' );
htp.br;
END LOOP;The values of the checkboxes were extracted by:
var ids ="";
for (var j = 0;j < document.form.option.length; j++)
if (document.form.option[j].checked)
ids = ids + document.lf.option1[j].value + "\n";
}I have the following SQL query:
Select * from Persons where Identification = ...; I would like to use to pass the values of the checkboxes (i.e. the variable ids ) to my SQL query. I want the user to select multiple values for the checkboxes. For example, they can select 4 and 3. I want to pass the difference to my SQL query....that is, I want the id to be 1. So, I want this:
Select * from Persons where Identification = 1; Any ideas how to do this? Also my code above is in different procedures within a single package.Your requirement is not very clear. What happens when you select 3 checkboxes? What will be the difference between them? How do you pass that information to the oracle report?
-
Get SQL Query from the Region Source
Hi,
The below query gives me the region source code,
SELECT region_source into p_sql_stmt
FROM apex_application_page_regions
WHERE region_id = 01129836282 AND
page_id = 54 AND
application_id = 215;
Initially I use to have only the SQL region source code as mentioned below , So using the above query i use to pass the sql code to p_sql_stmt
SELECT PROJECT_ID,EMPLOYEE_ID,EFFECTIVE_DATE FROM AR_V_ADDRESS_HISTORY WHERE PROJECT_ID = :P51_PROJECT_ID
Now the changes what i did in the page region source is i am using a PLSQL return query which is mentioned below
declare
qry varchar2(32000);
begin
qry := ' SELECT PROJECT_ID,EMPLOYEE_ID,EFFECTIVE_DATE';
for c1 in ( SELECT * FROM AR_ADDRESS_TYPE)
loop
qry := qry ||
' , GET_ADDRESS_LINE_1(PROJECT_ID,EMPLOYEE_ID,' || c1.address_type_id || ' ,TO_DATE(EFFECTIVE_DATE)) "' || c1.name ||'_ADDRESS_TYPE_1"';
qry := qry ||
' , GET_ADDRESS_LINE_1(PROJECT_ID,EMPLOYEE_ID,' || c1.address_type_id || ' ,TO_DATE(EFFECTIVE_DATE)) "' || c1.name ||'_ADDRESS_TYPE_2"';
end loop;
qry := qry || ' FROM AR_V_ADDRESS_HISTORY
WHERE
PROJECT_ID = :P51_PROJECT_ID ';
return(qry);
end;
If i execute the above code in the with dbms_output.put_line in the SQL developer or TOAD it prints the sql query which i wanted, Since i am using this in a apex page i need to get the SQL code from the apex page.
Can any one please suggest me how to get this sql code using the above plsql code.
Please suggest me in this issue
Thanks
SudhirOne way to get the sql statement is
Create a global variable in the package spec where your function returns sql statement and assign the final sql statement to the package spec variable before the return.
Write a wrapper function to return the stored sql statement value.
Example code below:
create or replace package xx_test_pkg as
g_sql_stmt CLOB;
function get_sql() return clob;
function get_stored_val() return clob;
end;
create or replace body package xx_test_pkg as
function get_sql return clob ..
v_sqlstmt clob;
begin
v_sqlstmt := 'select * from emp';
-- assign to global variable before returning the value
g_sql_stmt := v_sqlstmt;
return v_sqlstmt;
end;
function get_stored_val() ....
begin
return g_sql_stmnt;
end;
end; -
How to run a sql query from a button in apex 3.0
Hi,
I am brand new and went through/installed the obe project tracker. I have need to create a simple application that displays a result (2 fields, name and license number) based on two parameters (dob and login id) which all are stored in 1 table in the database. I could this very simply in VB or VB.net but have no idea how to do it in apex.
Please provide guidance,
Thank you,
TomHi Tom,
Sounds like a report region will satisfy your requirements.
Create a new report region on one of your pages.
Choose SQL Report and give the region a title.
When you get to the "Enter SQL Query or PL/SQL function returning a SQL Query:" step, type:
SELECT name, license_number
FROM <insert_your_table_name_here>
WHERE dob = :P<n>_dob
AND login_id = :P<n>loginid(replace <n> with the page number that the region is on and use your own table name).
Don't try to run the page yet - it will give 'No data found'
Now, go back to the Page Definition screen and add two items in the region you just created - call them P<n>dob and P<n>login_id
Then, create a button in the same region (to be displayed amongst the region's items) - call it P<n>_GO and click 'Create' (take all the other defaults).
Now you can run the page, put some values into the fields and click go.
If you want to get fancier, you can change the text items to select lists etc. - let us know if you need help with that.
Hope this helps,
Bryan. -
Export SQL query from link or button
I want to list several 'canned' SQL queries on one page as buttons or links; and have the result of selection be an immediate extract/download to excel of the data.
How can I best do this?
I suppose I could create separate hidden regions with their own reports that could somehow be referenced in the link. I would like to avoid doing all that, if I can create a package or process that includes the SQL query and that can be called in the link.
Thanks in advance,
Rich
Edit:
Found 'Report Query' functionality in Apex v3.2.1: However I am unable to get this to work; tells me my printer is not set up. I don't want to print the detail, I want it to be downloaded into excel... I don't have a printer configured - & don't want to. The URL provided for download as attachment is:
f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=reportname
I also have no page 0.
Help?
Edited by: rdarlin2 on Sep 16, 2011 11:14 AMrdarlin2 wrote:
I want to list several 'canned' SQL queries on one page as buttons or links; and have the result of selection be an immediate extract/download to excel of the data.
How can I best do this?
I suppose I could create separate hidden regions with their own reports that could somehow be referenced in the link. I would like to avoid doing all that, if I can create a package or process that includes the SQL query and that can be called in the link.10,000ft overview of one way to do this:
<li>Create a package with private functions that return the SQL for each "canned query", and a public switch function that returns a query function based on an input parameter:
create or replace package qry
is
function selector (p_req_qry in varchar2) return varchar2;
end qry;
create or replace package body qry
is
function emp_qry return varchar2
is
begin
return 'select * from emp';
end emp_qry;
function dept_qry return varchar2
is
begin
return 'select * from dept';
end dept_qry;
function selector (p_req_qry in varchar2) return varchar2
is
begin
return
case p_req_qry
when 'EMP' then emp_qry()
when 'DEPT' then dept_qry()
end;
end selector;
end qry;
/<li>Create 2 pages
<li>On page 2 create a standard SQL report region of type SQL Query (PL/SQL function body returning SQL query):
Region Source
return qry.selector(:request);*(o) Use Generic Column Names (parse query at runtime only)*
Maximum number of generic report columns
number of columns in your biggest query
Report Template
export: CSV
<li>On page 1 create an HTML region (or use an APEX list) with a link for each query, where the REQUEST component of the URL is the parameter used to select a query in the <tt>qry.selector</tt> function:
<ul>
<li><a href="f?p=&APP_ID.:2:&SESSION.:EMP">Emp</a></li>
<li><a href="f?p=&APP_ID.:2:&SESSION.:DEPT">Dept</a></li>
</ul>However this begs the question: Why bother? What's Excel got that APEX hasn't? -
API to retrieve SQL query from a Webi Document
Hi,
Which API can be used to retrieve the Oracle SQL query for a webi report using BO XI web services SDK? The report is connected to a Oracle database in the backend.
A sample code is greatly appreciated.
Thanks a lot!
LizHi Liz,
The libraries for the Enterprise and Report Engine SDKs are included with your Enterprise installation and the location will vary with each version:
XI Release 1 and Release 2
XI Release 1 (assuming it's installed on C:\):
- Windows: C:\Program Files\Common\3.0\java\lib
- Linux/UNIX: (INSTALL_DIR)/java/lib
XI Release 2:
- Windows: (INSTALL_DIR)\Business Objects\Common\3.5\java\lib
- Linux/UNIX: (INSTALL_DIR)/java/lib
There are quite a few JAR files in this location, but you should only need the following set for Enterprise & REBean with XI Release 1 or XI Release 2:
From the java\lib directory
- boconfig.jar
- cecore.jar
- celib.jar
- ceplugins.jar
- cereports.jar
- cesession.jar
- ceutils.jar
- cexsd.jar
- corbaidl.jar
- ebus405.jar
- jtools.jar
- keycodeDecoder.jar
- rebean.common.jar
- rebean.fc.jar
- rebean.jar
- rebean.wi.jar
- rpoifs.jar
- Serialization.jar
- URIUtil.jar
- wilog.jar
From the java\lib\external directory:
- Concurrent.jar
- freessl201.jar
- icu4j.jar
- jaxrpc.jar
- jsafe.jar
- log4j.jar
- pullparser.jar
- saaj.jar
- sslj.jar
- xbean.jar
- xercesImpl.jar
- xml-apis.jar
BusinessObjects Enterprise XI 3.0
- Windows: (INSTALL_DIR)\Business Objects\Common\4.0\java\lib
- Linux/UNIX: (INSTALL_DIR)/java/lib
You can find a list of required JAR files in the [XI 3.0 Enterprise SDK Developer Guide|https://boc.sdn.sap.com/node/7298].
Cheers,
Parin
Edited by: Parin Patel on Jun 25, 2008 11:03 AM -
Oracle SQL Query from EXCEL 2007 with prompt
Hello,
I have many excel reports where I am pulling information from our Oracle 9 db through Excel using the following method:
http://blog.mclaughlinsoftware.com/microsoft-excel/how-to-query-oracle-from-excel-2007/
http://blog.mclaughlinsoftware.com/2009/11/30/sql-query-in-excel-2007/
However, I am having trouble when I try the following query due to the prompt:
SELECT
IM.ITEM_GROUP,
IM.ITEM,
IM.DESCRIPTION
FROM
LAWSON.ITEMMAST IM
WHERE
IM.ITEM = '&ITEM';
Does any one know how I can connect a prompt to an excel cell and then pass the query on to Oracle, or have a PL SQL prompt work from Excel?
Thanks,
BenThe 'prompt' as you call it is a sqlplus feature, so does not belong to the SQL language
You would need to write a stored procedure returning a resultset.
create or replace procedure foo(rc in out sys_refcursor, p_item) as
begin
open rc for
'SELECT
IM.ITEM_GROUP,
IM.ITEM,
IM.DESCRIPTION
FROM
LAWSON.ITEMMAST IM
WHERE
IM.ITEM = '||p_item;
end;
and call that using ODBC or asp.net
Obviously this is profusely documented.
Sybrand Bakker
Senior Oracle DBA -
Sql query from Oracle/Hyperion
Hi, guys. my problem is:
My work environment is windows 2003 server sp2 on both servers, to have a Hyperion System 9.2 and the other Hyperion System 9.3.1. I have an Oracle ODBC server to fetch data.
When you load data from an Oracle database (version 9.2.0.5) to an Essbase cube through a rule file sql Hyperion System with version 9.2 everything works fine, I am all the necessary information. But when I try to do the same (in another server, version 9.3.1 Hyperion System) with the sql query does not do well. What is the problem. the bag is a bad version or set the ODBC
please help me
Thank you very much.
Alberto.without knowing more information, I'm going to guess the probem is with the ODBC driver. Try using the SQL in a tool like toad to use the ODBC to query the data. That will tell you if it is an ODBC issue or not.
-
SQL query from toplink expression
Hi,
I have a oracle.toplink.expressions.Expression object with me which has been created using oracle.toplink.expressions.ExpressionBuilder. I want to find its equivalent SQL query(say select emp.empname,emp.empId from employee emp) which will be fired in order to fetch data i.e. find its equivalent Statement/PreparedStatement or anything which will help me obtain the raw SQL statement about to be fired.
Please let me know if there is any soln.
Thanks,
Adithya.You can create ReadAllQuery with the expression and get the query's SQL using query.prepareCall() and then query.getSQLString().
James : http://www.eclipselink.org -
It is possible to execute a SQL query from OMBPlus?
We have some simple SQL scripts we'd like to be able to incorporate into our existing TCL scripts, instead of having to run them outside of OMBPlus in sqlplus. Is is possible to run a SQL SELECT query from OMBPlus and/or TCL? And get a result set back to iterate through?
Thanks,
Jim C.You can execute SQLPlus from OMB or just get down and use JDBC to execute the SQL, see others posts on forum such as below;
How to run SQL from OMB+
Cheers
David
Maybe you are looking for
-
Change Data Capture in SQL Server
Post Author: rtamanji CA Forum: Data Integration I am having primary key constraint problems whenever there is a failure during the data flow from the source to the target, and I have to restart the process. It looks like check points only occurs if
-
Call an action From Other View
Hi all, I have two views view1 and view2. View1 also have an action Action1, View2 have Action2. I wanna call Action1 from view2(action2) . Is it possible ? How can i do that ? View1 and view have different contexts. Regards, Orhan
-
Query gives me ORA-01722 invalid number
I'm on Release 12 and when I run this query I get ORA-01722 invalid number: select api.invoice_num, to_char(api.invoice_date,'MM/DD/YYYY'), to_char(api.terms_date,'MM/DD/YYYY'), to_char(glh.posted_date,'MM/DD/YYYY'), NVL(glj.entered_dr,0)-NVL(glj.ent
-
Mail 8.2 - Fonts & Colors Defaults?
I've just installed Yosemite on my iMac. Previously I had altered/changed the Fonts & Colors in Mail. So, could someone please tell me (or better, show me) what the default settings are for Fonts & Colors in Mail 8.2? Thanks. Here's what I'm currentl
-
Hello, I am coming up with the spreadhseet retreival error very frequently and get Essbase Error 1130203. I went through the Error interpretation and found that Data Cache might be causing it. Here are the details of cache settings on my databases cu