Transform a Query into a procedure or a trigger
Hello All
How could i put this Query in a procedure or function to call it from form a form
*SELECT ADD_MONTHS (TO_DATE ('01/01/2001', 'dd/mm/yyyy'), (12 * 4) + 3)*
*FROM DUAL* Then the value should be added in multiple rows in a loop
CREATE OR REPLACE TRIGGER emp_alert_trig
BEFORE INSERT ON emp
FOR EACH ROW
BEGIN
DBMS_OUTPUT.PUT_LINE('New years employees experience periods 2 be added');
END; Regards,
Abdetu...
I have to admit that it's a bit disconcerting that you don't seem to want to invest any time in solving your own problems while hoping that some volunteers will happily solve the problem for you.
That said, I'm afraid that I don't understand what you are looking for.
How could i put this Query in a procedure or function to call it from form a formWhat does "form" mean in this context? Oracle Forms? APEX? Something else? Forms is a bit of a special case because you may be talking about client-side PL/SQL.
SELECT ADD_MONTHS (TO_DATE ('01/01/2001', 'dd/mm/yyyy'), (12 * 4) + 3)
FROM DUAL So you want to create a function that returns a constant? Why bother with all the calculations? Maybe you're looking for
CREATE FUNCTION get_hard_coded_date
RETURN date
IS
BEGIN
RETURN ADD_MONTHS (TO_DATE ('01/01/2001', 'dd/mm/yyyy'), (12 * 4) + 3);
END;I'm somewhat hard pressed to understand how that might be useful to anyone, but that's the closest thing to what you're asking that I can come up with.
Then the value should be added in multiple rows in a loopOK. Now you've totally lost me
CREATE OR REPLACE TRIGGER emp_alert_trig
BEFORE INSERT ON emp
FOR EACH ROW
BEGIN
DBMS_OUTPUT.PUT_LINE('New years employees experience periods 2 be added');
END;And I have no idea what this trigger has to do with anything that came before. Particularly since the trigger isn't doing anything (I certainly hope that you're not expecting that dbms_output.put_line is going to cause text to appear in your application).
Justin
Similar Messages
-
Transform sap query into transaction
hi!
my question is not related to mm but also not to other forums in this site.
i'm trying to transform sap query into transaction using se93 transaction.
i just learing sap in a class and we use an old version of sap.
user group name: ofer6
infoset name: ofer9
query name: ofer8
all created in global area
when i enter se93 i write t-code ZSTART and press "create".
then i choose: "transaction with parameters" in the popup window.
in the second screen i write the transaction ZSTART again.
i mark "skip initial screen" and "inherit gui attributes"
at the bottom of the page in "default values" i use the following:
D_SREPOVARI-EXTDREPORT OFER8
D_SREPOVARI-REPORT OFER6 G
D_SREPOVARI-REPORTTYPE AQ
when i press enter i get messages:
transaction ZSTART does not exist
Screen 0000 of program does not exist
The field D_SREPOVARI-REPORTTYPE does not exist on the called screen
The field D_SREPOVARI-REPORT does not exist on the called screenHi,
Please check the link below:
http://www.freesaptutorial.com/how-to-create-transaction-code-in-sap-using-se93/
Hope this will be helpful to you.
Thanks,
Neeraj -
Hi! I am a newbie in PL/SQL..
Can somebody teach me on how to make this SQL QUERY into a PROCEDURE?
TABLE 1: LOGS
TABLE 2: MASTER LIST
Logs = records the logs
Master list = list of all registered name.
select * from table1
where not exists
select host, user, name
from table2
where table2.host = table1.host and
table2.user = table1.user and
table2.name = table1.name
TABLE 1
HOST | USER | NAME
==============
1 | A | A1
1 | A | A1
1 | A | A1
1 | A | D1
TABLE 2
HOST | USER | NAME
=============
1 | A | A1
1 | A | B1
1 | A | C1
Result:
HOST | USER | NAME
===============
1 | A | D1
Thanks. :)QKWS wrote:
Hi! I am a newbie in PL/SQL..
Can somebody teach me on how to make this SQL QUERY into a PROCEDURE?
TABLE 1: LOGS
TABLE 2: MASTER LIST
Logs = records the logs
Master list = list of all registered name.
select * from table1
where not exists
select host, user, name
from table2
where table2.host = table1.host and
table2.user = table1.user and
table2.name = table1.name
TABLE 1
HOST | USER | NAME
==============
1 | A | A1
1 | A | A1
1 | A | A1
1 | A | D1
TABLE 2
HOST | USER | NAME
=============
1 | A | A1
1 | A | B1
1 | A | C1
Result:
HOST | USER | NAME
===============
1 | A | D1
Thanks. :)Hi,
Question is not clear, really.
Do you want that, I don't sure?
CREATE TABLE t1 ( CHOST NUMBER, CUSER VARCHAR2(10), CNAME VARCHAR2(10));
INSERT INTO t1 VALUES(1,'A','A1');
INSERT INTO t1 VALUES(1,'A','A1');
INSERT INTO t1 VALUES(1,'A','A1');
INSERT INTO t1 VALUES(1,'A','D1');
Commit;
CREATE TABLE t2 AS SELECT * FROM t1;
INSERT INTO t2 VALUES(1,'A','A1');
INSERT INTO t2 VALUES(1,'A','B1');
INSERT INTO t2 VALUES(1,'A','C1');
commit;
select * from t1 table1
WHERE NOT EXISTS
( SELECT 1 FROM t2 table2
WHERE table2.chost = table1.chost
AND table2.cuser = table1.cUSER
AND table2.cNAME = table1.cNAME
DECLARE
P_HOST T1.CHOST%TYPE;
P_USER T1.CUSER%TYPE;
P_NAME T1.CNAME%TYPE;
BEGIN
select CHOST, CUSER,CNAME INTO P_HOST,P_USER, P_NAME
from t1 table1
WHERE NOT EXISTS
( SELECT 1 FROM t2 table2
WHERE table2.chost = table1.chost
AND table2.cuser = table1.cUSER
AND table2.cNAME = table1.cNAME
dbms_output.put_line('HOST | USER | NAME : '|| TO_CHAR(P_HOST)||' | '||P_USER||' | '||P_NAME);
END;
/Regards
Mahir M. Quluzade -
How to convert my query to SQL Procedure
Hi all,
I am running an SQL Query in my page process to set few items on my page.
begin
declare
l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
begin
IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
END IF;
IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
END IF;
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
:P32_SUBJECT := l_vc_arr2(1);
:P32_TYPE := l_vc_arr2(2);
:P32_BODY := l_vc_arr2(3);
END LOOP;
end;
end;
It is running perfectly fine. Now i want to convert this query into custom procedure. I am writing follwing code to create SQL Procedure,
create or replace
procedure Edit_EmailTemplate as
begin
declare
l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
begin
IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
END IF;
IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
END IF;
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
v(P32_SUBJECT) := l_vc_arr2(1);
v(P32_TYPE) := l_vc_arr2(2);
v(P32_BODY) := l_vc_arr2(3);
END LOOP;
end;
end;
but it is not getting compiled. Do anyone know what the problem is???
With Regards,
Sunil Bhatiahey thanks,
but my problem is not of creating,
it has been created and i can see it in sql browser. but it is not getting compiled
it is returning with the following error
Compilation failed,line 18 (13:22:08)
PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 18 (13:22:08)
PL/SQL: Statement ignoredCompilation failed,line 19 (13:22:08)
PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 19 (13:22:08)
PL/SQL: Statement ignoredCompilation failed,line 20 (13:22:08)
PLS-00306: wrong number or types of arguments in call to 'V'Compilation failed,line 20 (13:22:08)
PL/SQL: Statement ignored
my statement is
create or replace
procedure Edit_EmailTemplate as
begin
declare
l_vc_arr2 APEX_APPLICATION_GLOBAL.VC_ARR2;
begin
IF APEX_APPLICATION.G_F01.COUNT = 0 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a email template to edit!!!');
END IF;
IF APEX_APPLICATION.G_F01.COUNT > 1 THEN
RAISE_APPLICATION_ERROR(-20001, 'Please select a single email template to edit at a time!!!');
END IF;
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
l_vc_arr2 := APEX_UTIL.STRING_TO_TABLE(APEX_APPLICATION.G_F01(i),'$');
v('P32_SUBJECT') := l_vc_arr2(1);
v('P32_TYPE') := l_vc_arr2(2);
v('P32_BODY') := l_vc_arr2(3);
END LOOP;
end;
end; -
Procedure to save the output of a query into excel file or flat file
Procedure to save the output of a query into excel file or flat file
I want to store the output of my query into a file and then export it from sql server management studio to a desired location using stored procedure.
I have run the query --
DECLARE @cmd VARCHAR(255)
SET @cmd = 'bcp "select * from dbo.test1" queryout "D:\testing2.xlsx;" -U "user-PC\user" -P "" -c '
Exec xp_cmdshell @cmd
error message--
SQLState = 28000, NativeError = 18456
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'user-PC\user'.
NULL
Goel.AmanHello,
-T:
Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security. The security credentials of the network user,
login_id, and password are not required. If
–T is not specified, you need to specify
–U and –P to successfully log in.
-U:
Specifies the login ID used to connect to SQL Server.
Note: When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the
-T option (trusted connection) instead of the
user name and password combination
I would suggest you take a look at the following article:
bcp Utility: http://technet.microsoft.com/en-us/library/ms162802.aspx
A similar thread regarding this issue:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b450937f-0ef5-427a-ae3b-115335c0d83c/bcp-connection-error-sqlstate-28000-nativeerror-18456?forum=sqldataaccess
Regards,
Elvis Long
TechNet Community Support -
Ora-04044 error on a Select . . . Into query in a procedure in an Form
Hi,
I am getting the following error upon the execution of any select . . . into query in my procedure.
Ora-04044 procedure, function, package or type is not allow here.
I am using an Oracle 10g database on Linux with a client/server configuration of Forms 6i.
Here is the code snippet that is erroring:
procedure validate_area is
begin
if :ib.area_id is not null then
declare
s_ds_type varchar2(1);
begin
select building, ds_id, ds_allow_issue, ds_emp_id, latitude, longitude, map_num, room, loc_descr, n_area_code, ds_type
into :ib.building, :ib.ds_id, :ib.allow_issue, :ib.rpt_emp_id, :ib.latitude, :ib.longitude, :ib.map_num, :ib.room, :ib.loc_descr, :n_area_code, s_ds_type
from area, dosi_subj
where area.area_id = :ib.area_id and area.ds_id = dosi_subj.id;
... more code ....
end;
end if;
end validate_area;
It is on this select . . . into statement that the above error was thrown.
Any ideas?Ernie,
Please check all the tables and columns involved in that query if there is a function, package or procedure with that same name.
I tried myself, but everything seems fine. I included an example of an ORA-04044 at the end, however.
SQL> create table area
2 as
3 select 1 area_id, 1 ds_id from dual
4 /
Tabel is aangemaakt.
SQL> create table dosi_subj
2 as
3 select 1 id, 1 building, 1 ds_allow_issue, 1 ds_emp_id, 1 latitude, 1 longitude, 1 map_num
4 , 1 room, 'z' loc_descr, 'A' n_area_code, 'A' ds_type
5 from dual
6 /
Tabel is aangemaakt.
SQL> select building, ds_id, ds_allow_issue, ds_emp_id, latitude, longitude, map_num, room, loc_descr, n_area_code, ds_type
2 from area, dosi_subj
3 where area.area_id = 1 and area.ds_id = dosi_subj.id
4 /
BUILDING DS_ID DS_ALLOW_ISSUE DS_EMP_ID LATITUDE LONGITUDE MAP_NUM ROOM L N D
1 1 1 1 1 1 1 1 z A A
1 rij is geselecteerd.
SQL> create procedure validate_area is
2 l_ib_building dosi_subj.building%type;
3 l_ib_ds_id area.ds_id%type;
4 l_ib_allow_issue dosi_subj.ds_allow_issue%type;
5 l_ib_rpt_emp_id dosi_subj.ds_emp_id%type;
6 l_ib_latitude dosi_subj.latitude%type;
7 l_ib_longitude dosi_subj.longitude%type;
8 l_ib_map_num dosi_subj.map_num%type;
9 l_ib_room dosi_subj.room%type;
10 l_ib_loc_descr dosi_subj.loc_descr%type;
11 l_n_area_code dosi_subj.n_area_code%type;
12 c_area_id number := 1;
13 begin
14 if 1 is not null then
15
16 declare
17
18 s_ds_type varchar2(1);
19
20 cursor c1 (c_area_id NUMBER) is
21 select building, ds_id, ds_allow_issue, ds_emp_id, latitude, longitude, map_num, room, loc_descr, n_area_code, ds_type
22 from area, dosi_subj
23 where area.area_id = c_area_id and area.ds_id = dosi_subj.id;
24
25 begin
26 dbms_output.put_line('open c1 cursor to retrieve data');
27 open c1(1); --code errors when opening the cursor
28
29 dbms_output.put_line('fetch area data variables');
30 fetch c1 into l_ib_building, l_ib_ds_id, l_ib_allow_issue, l_ib_rpt_emp_id, l_ib_latitude, l_ib_longitude, l_ib_map_num
31 , l_ib_room, l_ib_loc_descr, l_n_area_code, s_ds_type;
32 dbms_output.put_line('area data has been fetched');
33 end;
34 end if;
35
36 end validate_area;
37 /
Procedure is aangemaakt.
SQL> exec validate_area
open c1 cursor to retrieve data
fetch area data variables
area data has been fetched
PL/SQL-procedure is geslaagd.
SQL> drop table area
2 /
Tabel is verwijderd.
SQL> create procedure area is begin null; end;
2 /
Procedure is aangemaakt.
SQL> select building,ds_emp_id
2 from dosi_subj, area
3 /
from dosi_subj, area
FOUT in regel 2:
.ORA-04044: procedure, function, package, or type is not allowed hereRegards,
Rob. -
Need to turn this PLSQL into a procedure
Hi All,
I have the following PLSQL which declares a cursor, then loops using the cursor variable. I'm new to creating procedures and packages and i'm having trouble turning this PLSQL into one of those. When i put my PLSQL code in a procedure it doesn't like the DECLARE statement or the CURSOR section. I'm not sure how to tweak it to get the syntax correct for a procedure. Can someone point me in the right direction?
Here is the PLSQL:
DECLARE
/* Output variables to hold the result of the query: */
groupid assignment_group.id%TYPE;
/* Cursor declaration: */
CURSOR Asset_Rank_HistoryCursor IS
select distinct id from assignment_group;
BEGIN
OPEN Asset_Rank_HistoryCursor;
LOOP
/* Retrieve each row of the result of the above query into PL/SQL variables: */
FETCH Asset_Rank_HistoryCursor INTO groupid;
/* If there are no more rows to fetch, exit the loop: */
EXIT WHEN Asset_Rank_HistoryCursor%NOTFOUND;
/* Insert the the new rows */
insert into ASSET_RANK_GROUPED (asset_id , dt, rank, score, ASSIGNMENT_GROUP_ID)
select asset_id, max_dt, rownum, score, groupid from (
SELECT <big nasty select statement>
END LOOP;
/* Free cursor used by the query. */
CLOSE Asset_Rank_HistoryCursor;
END;
How do i change my DECLARE and CURSOR statement so the procedure will create. Do i need to break it out into a function?I figured it out... just had to play w/ the syntax. Had to make sure the BEGIN statement was AFTER the CURSOR declaration and had to make sure any variables are declared up top, didn't need a DECLARE section in procedure. I just put the groupid variable right after IS at the top of procedure creation statement.
-
Loading an Oracle SQL query into an MSSQL table
I have a select query on an Oracle table. I want to load this data into an MSSQL table.
Problem is that I cannot create an interim table on the Oracle database (lack of privelages)
Is there a way to load an Oracle query into the MSSQL table without an interim table?
Many thanks
ZYes,
1) Create an ODI procedure
2) Create a step inside
3) at source tab put the oracle query
4) at target tab put the sql insert code
Refer to the oracle returned values like "#column_name_from_oracle_query"
Make sense?
Cezar Santos
[www.odiexperts.com] -
Index in Query inside Stored procedure
How to put a index on Select query inside a stored procedure.Please help me on below to write a index
Coalesce ((select sum (ICD.mAmount)
from ItemCommonData ICD (Index(PK_ItemCommonData))
Join ItemsInBundle IIBun on
(ICD.iBundleDocId = IIBun.iBundleDocId) and
(ICD.iDocId = IIBun.iDocId)
Join ItemsInBlock IIB (Index(ItemsInBlockbyBlockDoc)) on
(ICD.iDocId = IIB.iDocId)
where (Bundles.iDocId = ICD.iBundleDocId
and IIBun.fDeleted = False
and IIB.iBlockId = iBlockId)),Are you migrating to Oracle SQL and PL/SQL?
Anyway, you don't define an Index on the fly in Oracle. You create them ahead of time on the table. You can use hints to manipulate the query into using a certain execution path. -
I have a stored procedure that dynamically creates a pivot query. The procedure works and returns the correct data. Now I have a requirement to show this data in reporting system that can only pull from a table or view. Since you can not
create a dynamic query in a view I tried to do a select from using openquery.
Example 'Select * from OpenQuery([MyServername], 'Exec Instance.Schema.StoredProcedure')
I get the error back "the linked server indicates the object has no columns". I assume this is because of the first select statement that is stuffing the variable with column names.
CODE FROM PROCEDURE
Alter PROCEDURE [dbo].[Procedure1]
AS
BEGIN
SET NOCOUNT ON
Declare @cols nvarchar(2000),
@Tcols nvarchar(2000),
@Sql nvarchar (max)
select @cols = stuff ((
Select distinct '], ['+ModelName + ' ' + CombustorName
from CombustorFuel cf
join Model m on cf.modelid = m.modelid
join Combustors cb on cf.CombustorID = cb.CombustorID
where cf.CombustorID > 0
for XML Path('')
),1,2,'')+']'
Set @Tcols = replace(@Cols, ']', '] int')
--Print @Tcols
--Print @Cols
Set @Sql = 'Select GasLiquid, FuelType, '+ @Cols +'
from
Select GasLiquid, FuelType, ModelName+ '' '' +CombustorName ModelCombustor, CombFuelStatus+''- ''+CombFuelNote CombFuelStatusNote
from Frames f
join Family fa on f.Frameid = fa.frameid
join Model m on fa.FamilyID = m.FamilyID
join CombustorFuel cf on m.Modelid = cf.modelid
Join Combustors c on cf.CombustorId = c.CombustorID
join FuelTypes ft on cf.FuelTypeID = ft.FuelTypeID
where cf.CombustorFuelID > 0
and CombustorName <> ''''
) up
Pivot
(max(CombFuelStatusNote) for ModelCombustor in ('+ @Cols +')) as pvt
order by FuelType'
exec (@Sql)Then again, a good reporting tool should be able to do dynamic pivot on its own, because dynamic pivoting is a presentation feature.
SSRS Supports dynamic columns: Displaying Dynamic Columns in SSRS Report
SQL Reporting Services with Dynamic Column Reports
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014
Displaying and reading are two very different things.
#1) SSRS Needs a fixed field list on the input side to know what what to make available in the designer.
#2) SSRS cant read "exec (@Sql)" out of a proc, even if there is a fixed number of columns (at
least it can't use it to auto build the field list from the proc)
I use dynamic SQL in my report procs on a fairly regular basis and I've found it easiest to simply dump
the results of my dynamic sql into a temp table at the end of the procs and then select from the temp table.
Basically, Erland is correct. Stop trying to pivot in the query and let SSRS (or whatever reporting software you're using) handle it with a Martix.
Jason Long -
Plugging a sql query into OWB.
Hi,
I have a complex Sql query which returns some records. I want to use this query in OWB. But i don't want to write any procedures or functions. Is there a way just to plug this code into OWB to run it.
vasuAny objection to putting the query into a view?
The only other possible way I can think of that might work would be to create an expression object, define your desired output columns in the output group, and then copy in your query per column as the defined expression for that column. (hardly the efficient option!). I think you might have to create some sort of dummy input for this to pass through the validation for expressions too (e.g. perhaps also use a constant defined as sysdate passed as an input to the expression, but then never referenced in the queries).
Can't say for sure if you can fool OWB into using your query in an expression object or not - but that would be the only way I can think of which might be possible to avoid using a view/function/procedure. -
Hi All,
For the First time i got a chance to work on portal.
Now i need to insert a query into portal..Before that i want to know the whole process.
I have searched in SDN for this creteria...but found some different answers and i got bit confussed.
So requesting all to let me know the whole procedure that means
1.what are the settings to be done to execute the report through portal(Required Installations....etc)
2.How to insert a query into portal....
if any document is there which gives fundamental idea about portal and inserting query into portal , Please share with me.
regards
SahaHi Saha,
If you are executing queries on portal from role menu then in this case you need to change the URL of report in menu role. This can be done using transaction PFCG. Here you need to maintain the URL format which will point to the Java stack in portal.
if you are executing the reports on portal by clicking on the Infoarea where you can select queries by infoprovider, you need not to do any setting.
To execute report on portal you will need to have Business Intelligence role on portal.
Regards,Niraj -
Passing a table into a procedure to be used in a curor
Hi,
I'm using Oracle 9.2.0.6
I have a procedure that searches all objects for a passed in string value. The procedure is below.
CREATE OR REPLACE PROCEDURE Find_String (
pin_referenced_name IN dba_dependencies.referenced_name%TYPE)
IS
cursor cur_get_dependancy
is
SELECT distinct owner, name, type
FROM [email protected]
WHERE lower(referenced_name) = lower(pin_referenced_name) --'ftbv_salesrep_all_1d'
AND referenced_type != 'SYNONYM'
order by name;
v_owner varchar2(40);
v_name varchar2(50);
v_type varchar2(40);
BEGIN
dbms_output.put_line(upper(pin_referenced_name)||' is found in the following objects.');
dbms_output.put_line(' ');
dbms_output.put_line(RPAD('OWNER', 30, ' ')||RPAD('NAME', 60, ' ')||RPAD('OBJECT TYPE', 30, ' '));
dbms_output.put_line('-------------------------------------------------------------------------------------------------------------------');
FOR i IN cur_get_dependancy
LOOP
v_owner := RPAD(i.owner, 30, ' ');
v_name := RPAD(i.name, 45, ' ');
v_type := RPAD(i.type, 30, ' ');
dbms_output.put_line(v_owner ||v_name|| v_type);
END LOOP;
END find_string;I was wondering if there's any way I could pass in the table name, and the name of the DB link to be used in the cursor, into the procedure and rig the cursor to be able to accept that as a parameter. I want our users to be able to search different databases using this utility code.
I thought of NDS, and that would be a way to do it, however I'm not sure if I could use an NDS statement in conjunction with a cursor.
Does anybody have any suggestions?
ThanksOne approach (there are obviously many ways to skin this particular cat)
SQL> ed
Wrote file afiedt.buf
1 declare
2 c1 sys_refcursor;
3 l_val number;
4 l_table_name varchar2(30) := 'dual';
5 begin
6 open c1 for 'select 1 from ' || l_table_name;
7 loop
8 fetch c1 into l_val;
9 exit when c1%notfound;
10 dbms_output.put_line( l_val );
11 end loop;
12 close c1;
13* end;
SQL> /
1
PL/SQL procedure successfully completed.Justin -
Can I put a SQL query into a bind variable and then use it to output report
Hi,
Can I put a SQL query into a bind variable and then use it to output report?
I want to create a report and an item "text area" (say P1_TEXT) which can let user to input a SQL query(they are all technical users and knows SQL very well). Then, I use a bind variable (that text area) to store the SQL statement. Then, I add a submit button and I want to use the following to output the report:
select * from (:P1_TEXT);
Do you think it is possible to do that? Any known limitations for APEX in this area?
Thanks a lot,
AngelaYou can, but make sure it's what you really want to do. Make sure you are VERY familiar with SQL Injection. Most people who know what it is, go out of their way to prevent SQL Injection. You're going out of your way to allow it.
You can try using &P1_TEXT. instead of bind variable syntax. Bind variables are one of the best ways to prevent SQL Injection, which is why it's not working for you.
Once again, I strongly urge you to consider the implications of your app, but this suggestion should get it working.
Tyler -
How to insert a query into a NEW workbook ?
Hi Friends,
Could some one tell me how to insert a query into a new workbook? i am trying to run query in NW2004S BEx Query Designer, which always open the query on web when executed. i want to run the query in NW2004S BEx Query Designer and want it to open the result in Excell.
If i am not wrong then to do the same, i need to embed the query into workbook. Correct me if i am wrong. If i am right then plzz tell me the steps to insert the query into workbook.
Ur help will be rewarded in terms of points.
Thanks,Hello,
If you open the BEx Query Designer from the desktop, you cannot execute the query directly to the BEx Analyzer for an Excel view. You can only execute it directly to the Web. This is true for the SAP BW 3.x version as well as the SAP NetWeaver 2004s version.
If you open the BEx Query Designer from within BEx Analyzer, once you select (or create) your query, you will have a green check mark icon that will then allow you to deploy the query directly to the BEx Analyzer for the Excel view.
However, this would only make sense if you are creating or modifying the query. If not, you would simply open BEx Analyzer and use the Open Query option in this tool to see your query in an Excel format, as has been previously suggested by the other respondents to this posting.
Regards,
Katie Beavers
SAP NetWeaver Product Management
Maybe you are looking for
-
Hi.. Please send me configuration steps of Free Goods in Third Party.. Thanks in Advance Shriniwas
-
NVIDIA GeForce 8600M GT with 512MB vs. 256MB - MEMORY QUESTION
how much difference will i see between the NVIDIA GeForce 8600M GT with 512MB of GDDR3 memory, and the NVIDIA GeForce 8600M GT with 256MB of GDDR3 memory?? i will be doing HD editing on FCP.
-
LiveCycle Designer ES2 global variable manipulation trouble
I'm using LiveCycle Designer ES2. I've created a global form variable and would like to increment and decrement it based on the state of many checkboxes across many subforms. Ultimately, a script on a button will query the value of this variable an
-
The small icon that is associated with a website & appears to the left in the address bar when a website loads no longer appears for 6 of my most frequently used websites. This began about a week ago.
-
How do I turn off auto focus/open/maximize when new email arrives?
If I have mac mail minimized, when a new email arrives, it automatically maximize/open it and focus on the mail window. This is really annoying. It started happening with recent updates. Is there a way to turn this 'feature' off? thanks.