Creating Views with DI APIs DoQuery-Method in SQL 2005
Hi @All,
I've had the following (solved) problem:
The DB installer of one of our AddOns is also creating a bunsh of views for our UDTs. The installer always executes the following two statements for each view:
IF OBJECT_ID ('[dbo].[@NSP_EXAMPLE_VIEW]', 'V' ) IS NOT NULL
DROP VIEW [dbo].[@NSP_EXAMPLE_VIEW];
CREATE VIEW [dbo].[@NSP_EXAMPLE_VIEW] AS
SELECT
T0.U_Field3,
T1.U_Field1,
FROM
[dbo].[@NSP_A] T0 INNER JOIN
[dbo].[@NSP_B] T1 ON
T0.U_Key=T1.U_Key AND
T0.U_CostNo=T1.U_CostNo;
This has worked fine for the first 3 views we need. Then came the 4th view and we get an exception from the doQuery. I had to change the SQL-2005 compatibility level back to 80 to create the 4th view because of an incompatible "FOR BROWSE"-statement.
When it was created under level 80 I saw the problem: ONLY the 4th view was extended with the "FOR BROWSE"-Statement by DI-API. I didn't see any difference in the 4th VIEW-statement which could be the reason that only this one gets the "FOR BROWSE"
Anyway! Big thanks to John Mackin and the users of this thread:
[Formatted search;
Adding an SQL-comment "--FOR BROWSE" at the end of the VIEW-creation statement has solved the problem.
(I hope the DI-API query parser will not change this behaviour in the future :-o )
Cheers,
Roland
Thanks for the replies, but casting gave me the original 'General Error' as well.
I tried to make a stored procedure out of it. I used this page as a guide:
http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx
The stored procedure looks like this:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
CREATE PROCEDURE [dbo].[TestItems]
@PageIndex INT,
@PageSize INT
AS
BEGIN
WITH tmpItems AS (
SELECT ROW_NUMBER() OVER (ORDER BY ItemCode DESC)AS Row, ItemCode, ItemName
FROM OITM)
SELECT ItemCode, ItemName
FROM tmpItems
WHERE Row between (@PageIndex - 1) * @PageSize + 1 and @PageIndex*@PageSize
END
I am able to call this stored procedure like this:
exec TestItems 10, 10 -- (returns item 91 to 100).
This solution meets my immediate requirements, but I don't like the fact that I added the stored procedure to the administration itself. Is it possible to add the stored procedure to a different database and still use the DI server?
Thanks for your time!
Vincent
Similar Messages
-
Create View with Force and No Force
Can Anyone Tell me how to create view with force and no force i have very little idea about this
This is the syntax.
CREATE [OR REPLACE] FORCE VIEW view
[(alias[, alias]...)]
AS subquery
[WITH CHECK OPTION [CONSTRAINT constraint]]
[WITH READ ONLY [CONSTRAINT constraint]];You can see interesting threads about this topic here.
Re: Creating view forcibly
Creating View forcefully
Cheers
Sarma. -
Is it possible to create views with parameters ?
Hi,
As MS-Access, is it possible to create views with parameters ?
Ms-Access syntax : parameters [a] text; select * from table where code = [a]
If yes, can you give samples ?
Regards
PascalI suggest you you write a stored procedure that returns a recordset in oracle. Then execute the stored procedure and loop through the record set.
Look in in MS Knowledgebase searching on ADO Stored Proceedures for the VB/C++/VBS .. code.
Look in in Oracle PL/SQL guide for the Stored Proceedure code. -
How I can create view with parameters?
I have very big query (2000 rows) and 2 parameters.
How I can create view with parameters?If I use this small part of my query than I have error :
java.lang.NullPointerException
at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:199)
at oracle.javatools.db.ora.OracleSQLQueryBuilder.buildQuery(OracleSQLQueryBuilder.java:147)
What does it means?
select
' Payroll ' as Revenue
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and ( nvl(a.scode, 0) between 60000 and 6009000 )
union all ---------------------------------------------------------------------------------------------------------------------------------
select
' Payroll Taxes '
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and
(nvl(a.scode, 0) between 60100 and 60690 )
union all -------------------------------------------------------------------------------------------------------------------------------
select
' Workers Comp/Disability '
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and
( nvl(a.scode, 0) between 61200 and 61260)
union all -------------------------------------------------------------------------------------------------------------------------------
select
' Pension and Hospitalization '
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and
( nvl(a.scode, 0) between 61000 and 61550 )
union all -------------------------------------------------------------------------------------------------------------------------------
select
' Other Labor Costs '
, t.umonth, nvl(p.hmy, 0), nvl(t.sMTD, 0), nvl(a.inormalbalance, 0), nvl(T.sbudget, 0), nvl(a.scode, 0)
from
acct a, total t, property p, param par
where
nvl(t.hacct, 0) = nvl(a.hmy, 0)
and nvl(par.hretain, 0) <> nvl(a.hmy, 0)
and nvl(t.iBook, 0) = 0
and nvl(a.iacctType, 0) = 0 /*Regular accts*/
and nvl(t.hppty, 0) = nvl(p.hmy, 0)
and
( nvl(a.scode, 0) between 616000 and 616400 ) -
Makes it possible to create view with parameters
makes it possibel to create view with paramater, example
create or replace view v_test(segment varchar2)
select * from ref_user where segment = segmentThanksthanks..
select count(distinct substr(a.svm_id,1,10)) jumlah " +
" from daily_distribution_pop a, ref_toko b " +
" where " +
" substr(a.svm_id,1,10)=b.id and b.segment_type = 'A' and enable_flag='Y' " +
" and a.tgl_visit between to_date('" + fromStartDate + "', 'dd/MM/yyyy') and to_date('" + fromEndDate + "', 'dd/MM/yyyy')
and " + whereA + "= '" + whereB + "' " +
" and substr(a.pom_id,1,2) = 'DP' and (a.qty_instore <> 0 or a.qty_delivered <> 0) ";
{code}
where fromStartDate, fromEndDate, whereA, whereB is variable parameter from asp.net.
how to i can implement with view -
Modifying ang Creating Participants with BPM API (10.3.1)
Hello,
I am trying to create and modify participants and their properties with the API in Studio 10.3.1.
I am using a "DirHumanParticipant" object in a new activity in the "ReassignTeamByParametricValue" screenflow of the demo. First, I am testing the DirHumanParticipant.fetchCurrent method.
When executing the activity with the predefined user "Rudy", the log shows that DirHumanParticipant.fetchCurrent doesn't return "Rudy" but a "root" user I don't know.
So, what is it ? What method should I use to get "Rudy" ? What about creating a participant and assigning him roles ?
+ Is it mandatory to get an organizational unit to create a participant ?
+ Is there a difference about participants between executing BPM in Studio vs executing BPM in Webcenter Interaction ?
Thanks for help,
Here is my code :
// Reuse Engine session to the Directory
DirectorySession session = DirectorySession.currentEngineSession;
logMessage("ReassignTeamByParametricValue.creationParticipant : session : "+session.organizationName);
logMessage("ReassignTeamByParametricValue.creationParticipant : session : "+session);
// Load the Organization Unit to which the participant will belong to
DirOrganizationalUnit myOU = DirOrganizationalUnit.fetchRoot(session : session);
logMessage("ReassignTeamByParametricValue.creationParticipant : DirOrganizationalUnit : "+myOU.displayName);
logMessage("ReassignTeamByParametricValue.creationParticipant : DirOrganizationalUnit : "+myOU);
// Load the Role that the participant will have assigned,
// and create a role assignment for it
DirOrganizationalRole myRole = DirOrganizationalRole.fetch(session : session, id : roleName);
RoleAssignment[] myAssignments;
RoleAssignment myAssignment = RoleAssignment.create(role : myRole, parametricValue : paramaterValue, permissions : 255);
myAssignments[0] = myAssignment;
logMessage("ReassignTeamByParametricValue.creationParticipant : myAssignments[0] : "+myAssignments[0].roleId +" "+myAssignments[0].parametricValue);
DirHumanParticipant currentPart = DirHumanParticipant.fetchCurrent(session);
logMessage("ReassignTeamByParametricValue.creationParticipant : participant : "+currentPart.displayName);
logMessage("ReassignTeamByParametricValue.creationParticipant : participant : "+currentPart);
Here is the log :
ReassignTeamByParametricValue.creationParticipant : session : ExpenseReimbursement
ReassignTeamByParametricValue.creationParticipant : session : fuegoblock.fdi.DirectorySession@93e4d1
ReassignTeamByParametricValue.creationParticipant : DirOrganizationalUnit :
ReassignTeamByParametricValue.creationParticipant : DirOrganizationalUnit : name: fullName: description:null|IN:-1|ID:|displayName:|internalId:/
ReassignTeamByParametricValue.creationParticipant : myAssignments[0] : AP Auditor West
ReassignTeamByParametricValue.creationParticipant : participant :
ReassignTeamByParametricValue.creationParticipant : participant : firstName:,lastName:,mail:,status:R,tel:null,fax:null,permissions:0|IN:-1|ID:root|displayName:null|internalId:rootI got the DirHumanParticipant "Rudy" of the demo by hardly coding : myParticipant.displayName == "Rudy".
I assigned him roles with : myParticipant.rolesAssignment[] = myAssignment;
(see above)
Now I get this error when I update the user !
A component failed while executing activity '/ExpenseReimbursement#Default-1.0/Grab[ReassignRegion]' (BP-method ReassignRegion) over instance '/ExpenseReimbursement#Default-1.0/1/0'.
Caused by: java.lang.UnsupportedOperationException
at fuego.directory.provider.UnsupportedParticipantAccessor.updateHumanParticipant(UnsupportedParticipantAccessor.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at fuego.directory.provider.DirectorySessionImpl$AccessorProxy.invoke(DirectorySessionImpl.java:756)
at $Proxy15.updateHumanParticipant(Unknown Source)
at fuego.directory.DirHumanParticipant.update(DirHumanParticipant.java:1752)
at fuegoblock.fdi.DirHumanParticipant.update(DirHumanParticipant.java:1951) -
Is there any way of create a view that asks for the value of some parameters?
something like...
CREATE VIEW "VIEW1" AS
SELECT NOMBRE
FROM EPTABLA_01
WHERE NOMBRE = ??? WITH READ ONLYThe method below won't "ask" for a value, but if you set the variable, this will work as a parametrized view.
SQL> create context my_ctx using my_proc
2 /
Context is aangemaakt.
SQL> create procedure my_proc (p_nombre in number)
2 is
3 begin
4 dbms_session.set_context('my_ctx','my_nombre',to_char(p_nombre));
5 end;
6 /
Procedure is aangemaakt.
SQL> create table eptabla_01 as select l nombre from (select level l from dual connect by level <= 10)
2 /
Tabel is aangemaakt.
SQL> create view view1
2 as
3 select nombre
4 from eptabla_01
5 where nombre = sys_context('my_ctx','my_nombre')
6 with read only
7 /
View is aangemaakt.
SQL> exec my_proc(5)
PL/SQL-procedure is geslaagd.
SQL> select * from view1
2 /
NOMBRE
5
1 rij is geselecteerd.
SQL> exec my_proc(8)
PL/SQL-procedure is geslaagd.
SQL> select * from view1
2 /
NOMBRE
8
1 rij is geselecteerd.Regards,
Rob. -
What is the use for CREATING VIEW WITH CHECK OPTION?
Dear Legends,
I have a doubt
What is the use for creating view?
A: First Data Integrity, Selecting Particular Columns..
What is the use for creating a view with check option?
A: As per oracle manual I read that its a referential integrity check through views.
A: Enforcing constraints at DB level.
A: using CHECK OPTION we can do INSERTS UPDATES for a view for those columns who have no constraints... is it right??
A: If we do a INSERT OR UPDATE for columns who have constraints it will show error... is it right???
Please clear my doubt's Legends
Lots of Thanks....
Regards,
KarthikHi, Karthick,
karthiksingh_dba wrote:
... What is the use for creating view?
A: First Data Integrity, Selecting Particular Columns..Most views are created and used for convenience. A view is a saved query. If the same operations are often done, then it can be very convenient to code those operations once, in a view, and refer to the view rather than explicitly doing those operations.
Sometimes, views are created and used for security reasons. For example, you many want to allow some users to see only certain rows or certain columns of a table.
Views are necessary for INSTEAD OF triggers.
What is the use for creating a view with check option?
A: As per oracle manual I read that its a referential integrity check through views.The reason is integrity, not necessarily referential integrity. The CHECK option applies only when DML is done through the view. It prohibits certain changes. For example, if a user can't see certain rows through a view, the CHECK option keeps the user from creating such rows.
A: Enforcing constraints at DB level.I'm not sure what you mean. Please give an example.
A: using CHECK OPTION we can do INSERTS UPDATES for a view for those columns who have no constraints... is it right??No. Using CHECK OPTION, you can do some inserts and updates, but not others. The columns involved may or may not have constraints in either case.
A: If we do a INSERT OR UPDATE for columns who have constraints it will show error... is it right???If you try to violate a constraint, you'll get an error. That happens in views with or without the CHECK OPTION, and also in tables. -
Error creating view with tables of other user
I am creating of view containing two tables of another user. I
am a dba-user.
The statement looks like this:
CREATE VIEW TEST
(SELECT ...
FROM DWH.TABLE_A A, DWH.TABLE_B B
WHERE A.ID = B.ID)
I get an error-message (ORA-00942: Table or view not found).
When I create the view as user DWH, everything went OK. I don't
think it has something to do with privileges since I am the dba-
user.
How can I create a view using other users tables?Hi
To create view on table of another user you need to have select
privilege grant directly to you - not to role granted to you. In
your case you can select tables because you have granted dba
role and it has select any table prvivilege, but you havent
directly granted this rights without role.
Regards -
Hi all,
I have tried to create a view with next code:
CREATE VIEW vista_urbanizacion AS SELECT
RUPI_URBANIZACIONES.NOMBRE_URBANIZACION,
RUPI_URBANIZACIONES.NRO_PREDIOS,
RUPI_URBANIZACIONES.NRO_URBANIZACION,
RUPI_URBANIZACIONES.ESTADO,
RUPI_URBANIZACIONES.FECHA_INGRESO,
RUPI_URBANIZACIONES.AREA_TERRENO,
RUPI_URBANIZACIONES.TIPO,
RUPI_URBANIZACIONES.UBICACION_ARCHIVO,
RUPI_URBANIZACIONES.NRO_SUPERURBANIZACION,
RUPI_URBANIZACIONES.ID_URBANIZADOR,
RUPI_URBANIZACIONES.AREA_TOTAL_CESION,
RUPI_ESCRITURAS.MATRICULA_INMOBILIARIA,
RUPI_ESCRITURAS.NOTARIA,
RUPI_ESCRITURAS.CIUDAD,
RUPI_ESCRITURAS.ACTO_JURIDICO,
RUPI_ESCRITURAS.FECHA_ESCRITURA,
RUPI_ESCRITURAS.NRO_ESCRITURA,
RUPI_ESCRITURAS.CONSECUTIVO,
RUPI_ESCRITURAS.URBANIZACI_NRO_URBANIZACION,
RUPI_ACTAS.TIPO_ACTA,
RUPI_ACTAS.NRO_ACTA,
RUPI_ACTAS.FECHA_ACTA
FROM
RUPI_URBANIZACIONES,
RUPI_ESCRITURAS,
RUPI_ACTAS
WHERE
RUPI_URBANIZACIONES.NRO_URBANIZACION =
RUPI_ESCRITURAS.URBANIZACI_NRO_URBANIZACION
AND
FECHA_ESCRITURA IN (SELECT MIN(FECHA_ESCRITURA) FROM RUPI_ESCRITURAS
WHERE
RUPI_URBANIZACIONES.NRO_URBANIZACION = RUPI_ESCRITURAS.URBANIZACI_NRO_URBANIZACION)
AND
RUPI_URBANIZACIONES.NRO_URBANIZACION =
RUPI_ACTAS.URBANIZACI_NRO_URBANIZACION
AND
FECHA_ACTA IN (SELECT MAX(FECHA_ACTA) FROM RUPI_ACTAS
WHERE
RUPI_URBANIZACIONES.NRO_URBANIZACION =
RUPI_ACTAS.URBANIZACI_NRO_URBANIZACION)
The problem is the condition "and" from the rupi_escrituras and rupi_actas tables that only will select elements of rupi_urbanizaciones included both in rupi_escrituras and rupi_actas.
I need to use something like "union" in order to include all the distinct elements of both tables rupi_escrituras and rupi_actas.
Could anyone help?
Thanks in advance
RomuloYep,
In this query you don't do any join between the tables. So let's get back to the basic.
Take you first query
SELECT CBR_ID,PLT_ID,SUM(COUNT_POL)
FROM
SELECT pcd_irs_id CBR_ID, pcd_plt_id PLT_ID , sum(pcd_amount_lc) SUM_PREM,0 COUNT_POL
FROM seema
where trunc(pcd_registry_date)=TRUNC(pcd_registry_date)
and pcd_plt_id in('U01','U02')
and pcd_irs_id in (55,56)
AND PCD_IRS_TYPE!=4
GROUP BY PCD_irs_ID,PCD_PLT_ID
UNION
SELECT PLM_CBR_ID CBR_ID,PLM_PLT_ID PLT_ID,0 SUM_PREM, COUNT(PLM_POLICY_NO) COUNT_POL
FROM sarah
WHERE trunc(PLM_registry_date)=TRUNC(PLM_registry_date)
AND PLM_PLT_ID IN('U01','U02)
GROUP BY PLM_CBR_ID,PLM_PLT_ID)
GROUP BY CBR_ID,PLT_ID
ORDER BY CBR_ID,PLT_IDThis query is quite near to the result that you need. You are very near to the result just add the filter that you need in the second query:
SELECT CBR_ID,PLT_ID,SUM(COUNT_POL)
FROM
SELECT pcd_irs_id CBR_ID, pcd_plt_id PLT_ID , sum(pcd_amount_lc) SUM_PREM,0 COUNT_POL
FROM seema
where trunc(pcd_registry_date)=TRUNC(pcd_registry_date)
and pcd_plt_id in('U01','U02')
and pcd_irs_id in (55,56)
AND PCD_IRS_TYPE!=4
GROUP BY PCD_irs_ID,PCD_PLT_ID
UNION
SELECT PLM_CBR_ID CBR_ID,PLM_PLT_ID PLT_ID,0 SUM_PREM, COUNT(PLM_POLICY_NO) COUNT_POL
FROM sarah
WHERE trunc(PLM_registry_date)=TRUNC(PLM_registry_date)
AND PLM_PLT_ID IN('U01','U02)
and PLM_CBR_ID in (55,56) --<<<<<<<<< ADDED FILTER
GROUP BY PLM_CBR_ID,PLM_PLT_ID)
GROUP BY CBR_ID,PLT_ID
ORDER BY CBR_ID,PLT_IDand you are done.
Bye
Antonio -
I am in a 8i SQL class where I "learned" that the order by clause can not be used when creating a view. This surprised me as I am sure I have done so in the past. After talking with the instructor we found that:
create view viewname as
select * from table order by column
worked, while:
create view viewname as
(select * from table order by column)
returns:
ORA-00907: missing right parenthesis
And
create view viewname as
(select * from table)
works as well.
Anyone understand why?
Thanks
nullThe queries are theoretically different.
Example 1 is a view with an order by clause.
Example 2 is a view of the result of an ordered query.
Example 3 is a view of the result of an unordered query
Just another example of how people are smarter than machines, I suppose. -
How to create view with schemabinding on cross datbases(partitioned views)
Hello Everyone,
Please help me to sort this issue. I know it is not possible bind the scheman in below example. But is there any solution to solve this issue.
I've tables like below
create database D1--First database
create table dbo.t1(
id int
create database D2--Second database
create table dbo.t2(
id int
i want to create a view with the schema binding option on this
create database D3
use d3
create view vw_v1
with schemabinding
as
select id from d1.dbo.t1
union all
select id from d2.dbo.t2
I'm getting this below error
Msg 4512, Level 16, State 3, Procedure vw_v1, Line 7
Cannot schema bind view 'vw_v1' because name 'd1.dbo.t12' is invalid for schema binding. Names must be in two-part format and an object cannot reference itself.
Many thanks
A-ZSQLCREATE VIEW
SCHEMABINDING
Binds the view to the schema of the underlying table or tables. When SCHEMABINDING is specified, the base table or tables cannot be modified in a way that would affect the view definition. The view definition itself must first be modified or dropped to remove
dependencies on the table that is to be modified.
> When you use SCHEMABINDING,
the select_statement must include the two-part names (schema.object)
of tables, views, or user-defined functions that are referenced.
>
All referenced objects must be in the same database.
José Diz Belo Horizonte, MG - Brasil -
Cannot create view with parameter bindings
Hi, I'm trying to create this view in SQLPlus:
SELECT order_no, SUM(cut_qty),
SUM(received_qty)
FROM (
SELECT order_no, cut.dated, DECODE(cut.bimetallic, 'F', cut.quantity, cut.quantity/2) cut_qty,0 AS received_qty
FROM cut_shop_orders_dated cut
WHERE cut.dated BETWEEN TO_DATE('&date1','DD/MM/YYYY') AND TO_DATE('&date2','DD/MM/YYYY')
UNION
(SELECT order_no, rec.dated, 0, rec.quantity
FROM received_shop_orders_dated rec
WHERE rec.dated BETWEEN TO_DATE('&date3','DD/MM/YYYY') AND TO_DATE('&date4','DD/MM/YYYY')))
GROUP BY order_no
The problem is that sqlplus asks me for the parameter values and then creates it with these values as literal dates in the to_date function, those not asking for parameter values in runtime.
How can I create it using parameters with no values at design time?
Thanks.
Leandro.if you want something like :
select * from emp $where_clause;
you can write a procedure with parameter and run it as dynamic sql for example
create or replace procedure pr1 ( p_where varchar2) is
begin
execute immediate 'create or replace view view_name as select * from emp '|| p_where;
end pr1;
/then run it on sql*plus
SQL> exec pr1('where deptno = 10');
make sure you give yourself "create any view" rights explicitly.
HTH
Ghulam -
CREATE VIEW with PreparedStatement
Hi guys,
I'm trying to run a CREATE VIEW statement, which I have been doing up till now just using a regular Statement, and using the executeUpdate() method. It's been working fine for a while, and now i've hit a bit of a problem.
I can't include a WHERE clause in a Statement, as it doesn't like the single quotations (') and wildcards. After searching this forum, I saw that I should be using a PreparedStatement, and using the setString() method to put in the ' and %'s.
Now when I try to run the PreparedStatement using the executeUpdate() method, I get the "Incorrect syntax near the keyword 'VIEW'" error. Can anyone tell me if i'm using the right method for executing the PreparedStatement, or what i'm doing wrong?
Regards,
Jack SmithSQL statements are often broken up into two classes, DML (data manipulation language) and DDL (data definition language). DML contains the normal CRUD statements, INSERT, SELECT, UPDATE, DELETE and anything else that modifes the data but not the data structure. DDL is the set of statements that manipulates the data structure, things like CREATE, ALTER, DROP.
As a general rule of thumb, you shouldn't do DDL in a PreparedStatement.
PreparedStatements exist primarily to allow late-binding of data-value objects into the internal datastructure within the database that represents a parsed SQL statement's execution plan. It is NOT a mechanism for doing string substitution (though I understand who it can look that way to beginners).
Another way of saying this is that PreparedStatement is based on the distinction between data and code; in a DDL statement, the entire statement is code.
There are a few drivers/databases where this might happen to work, because they aren't really seriously implementing PreparedStatement but merely doing string replacement to fake it. I very much doubt SQL server is going to be one of these. -
Create view With Ref cursor data
Hi friends,
I want to create view as follows.
Example:
Create or replace v_name
select job,sal, <funcation>
from emp;
Note:- Function not having out parameter.
Function returning ref cursor values datatype.
Requirement:-
I want to create view even function returing ref cursor datatype.
Please advise how to create view.
Regards,
Kishoreuser7284612 wrote:
Hi friends,
I want to create view as follows.
Example:
Create or replace v_name
select job,sal, <funcation>
from emp;
Note:- Function not having out parameter.
Function returning ref cursor values datatype.
Requirement:-
I want to create view even function returing ref cursor datatype.
Please advise how to create view.You perhaps are misunderstanding what a ref cursor is. It does not contain data like a table, so cannot be treated as one.
Take a read of this:
PL/SQL 101 : Understanding Ref Cursors
Maybe you are looking for
-
Open URL in a new window by closing the parent window
Hi Friends, Is there any option to open URL in a new window by closing the parent window on a button click? Already implemented the logics suggested in /people/mohammed.anzys/blog/2007/06/05/how-to-close-parent-window-in-webdynpro-applications , the
-
How do you remove purchased songs from the iCloud?
There are a bunch of songs that I have bought over the years that I have no intention of listening to again. Since I have signed up for iTunes Match, they now all appear again on all my devices that I use the iCloud on... Apple says that I can simply
-
Package Size parameter in Partner Profile
Hello guys, I'd need your advice. We have 2 systems (SAP and Non-SAP) and we need to connect them by mean of HR-PDC interface (IDoc communication is supported). We can create new Partner Profile in SAP and we can add a few IDoc types as Inbound Param
-
I am running FireFox5 on a 2008 (Santa Rosa) MacBook Pro. OSX 10.5 Leopard I have the current version of 1Password v.3.5.13 (FireFox5-friendly) I am running FireFox5 for Mac. I have the Add-on Compatibility Reporter 0.8.5 (which, by the way is readin
-
Currency field in Generic Data Source
Hi All, I have a case here, where i have few Amount field in my Generic Extractor which is based on a table ZXXX. Now the key figures have 0currency appended in theie currency tab which is coming from table ZYYY, now while saving the data source is g