Creating a table within a PL/SQL procedure
I recieve the following error:
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
begin case declare exit for goto if loop mod null pragma
The create statement is within the executable part of an if statement. Are we allowed to have CREATE statements within if statements?
"Are we allowed to have CREATE statements within if statements? "
Its nothing to do with IF, it applies throughout pl/sql to any DDL (data definition language).
When the procedure is compiled, oracle checks that all of your DML (data definition language) complies with your database structure. If you mess about with the structure within the procedure, this confuses the whole issue. You can do it with native dynamic sql as suggested by Ino, but will need to use execute immediate wherever you attempt to use your new table, otherwise it will not compile.
Similar Messages
-
How to call a host command/program within a PL/SQL Procedure OR Block
Hello ,
I want to call a host program (in my case it is unix shell program) from within a PL/SQL
Procedure..Please let me know if you have a clue...Thanks a bunch...AjeetAlternatively you could create a PL/SQL procedure that wraps a Java Runtime object.
You can find an example of this in the Ask Tom column of Oracle Magazine. You can get there from OTN home page. Type "Java Runtime" into the Search Archive engine.
HTH, APC -
How do I create a table within another table?
How do I create a table within another table?
As shown in image below (document created with Words), I already have a table with 3 columns. How do I create another table with 6 columns to tabulate the data (the one below "3.1 Overall")?Last time I checked in Pages 5.5.2 that is not possible.
Peter -
Does Create as table command works in sql server
Hi friends,
does Create as table command works in sql server,if yes pls help me with syntax> does Create as table command works in sql server,if
yes pls help me with syntax
Just out of interest, what is it supposed to do? There is no "CREATE AS TABLE" command in Oracle. -
Passing table data to pl sql procedure oaf
Hi All,
I have a requirement where i have to pass table data to plsql procedure.
In the first page i select the REQUISITION and click on RETURN button and it will take me to the next page.
and in the Next page i will click on APPLY button.
When i click on APPLY, it will call the procedure and will give input to the procedure whatever has been selected when i have selected requisition.
Please help. Please tell me the approach how to get this task done. A sample code will work.
Hope the requirement is clear.
Thanks in Advance.Hi Chinmay,
Refer below code for Your Requirement.
//Code For Quering Data
import java.sql.PreparedStatement;
import java.sql.ResultSet;
Connection conn = pageContext.getApplicationModule(webBean).getOADBTransaction().getJdbcConnection();
String Query = "SELECT organization_id FROM hr_operating_units WHERE organization_id = fnd_global.org_id";
PreparedStatement stmt = conn.prepareStatement(Query);
resultset=stmt.executeQuery();
while (resultset.next())
orgId = (String)resultset.getString("ORGANIZATION_ID").toString();
conn.commit();
catch(Exception e)
e.printStackTrace();
//Code for Pass Resulted column to Procedure Input for delete Particular Record
Execute parameterized PL SQL procedure from OAF page
Let us try to call PL/SQL package from OAF page. We will try to remove selected line from Database.
Package Spec
CREATE OR REPLACE PACKAGE APPS.genpack_pkg
AS
PROCEDURE roll_delete_proc (orgId IN VARCHAR2);
END genpack_pkg;
Package Body
CREATE OR REPLACE PACKAGE BODY APPS.genpack_pkg
AS
PROCEDURE roll_delete_proc (orgId IN VARCHAR2)
AS
BEGIN
DELETE FROM pklist_roll_details_temp
WHERE roll_line_id = orgId;
COMMIT;
END roll_delete_proc;
END genpack_pkg;
//in Controller PFR
import java.sql.CallableStatement;
if (pageContext.getParameter("ActionsButton") != null)
String val = pageContext.getParameter("ActionsChoice");
if ("DELLN".equals(val))
CallableStatement cstmt = null;
for (OAViewRowImpl row = (OAViewRowImpl)tempvo.first(); row != null; row = (OAViewRowImpl)tempvo.next()) {
if ((row.getAttribute("Selectflag") == null) ||
(!row.getAttribute("Selectflag").toString().equals("Y"))) continue;
try {
int rollid = Integer.parseInt((String)row.getAttribute("orgId"));
Connection conn = am.getOADBTransaction().getJdbcConnection();
if (rollid == 1)
temphm.put(row.getAttribute("orgId").toString(), row.getAttribute("PoNumber").orgId());
tempvo.removeCurrentRow();
else
try
StringBuilder sb = new StringBuilder();
sb.append(rollid);
String strI = sb.toString();
System.out.println("Inside else in delete");
cstmt = conn.prepareCall("{call GENPACK_PKG.tpc_roll_delete_proc(?)}");
cstmt.setString(1, strI);
System.out.println("Oracle Callable Statment Execution Init for Delete");
cstmt.execute();
catch (SQLException e) {
throw new OAException(e.toString(), (byte)0);
}tempvo.removeCurrentRow();
catch (OAException e) {
throw new OAException("No row selected", (byte)3);
Thanks,
Dilip -
Creating temp table within OPEN QUERY
I am having trouble in creating a temp table within my OPEN QUERY.
How do I modify the below script to do this?
declare @sql nvarchar(max)
set @sql =
'SELECT *
FROM audit.dbo.Comp AS a
INNER JOIN audit.dbo.Pat AS b ON b.key = a.key
AND b.reg = ''' + @id + '''
INNER JOIN [prod].nfegh.dbo.flTest AS c ON c.id COLLATE Latin1_General_CI_AS = b.reg
INNER JOIN (
SELECT ''M1Q'' UNION ALL
SELECT ''M0Q'' UNION ALL
SELECT ''S1N''
) AS f(x) ON f.x = CLIN
WHERE a.inv IN (''CR'', ''R'', ''EAT'')'
set @sql = N'select * into MS_test1
from openquery( ocles, ''' + replace (@sql , '''' , '''''') + ''' )'
exec (@sql)OPENQUERY is designed to provide rows or to be user as target for DML.
But even when this statement would create a temporary table, then it would be out of scope. -
Error in Creating Advance table within Advanvce Table via view link
Hii all,
i hve created a Advance table within Advanvce Table as given in the developer guide using the Detail functionality of the advance table
im facing the following error................
## Detail 0 ##
java.lang.NullPointerException
at oracle.apps.fnd.framework.webui.OAAdvancedTableHelper.updateInnerTableProperties(OAAdvancedTableHelper.java:1752)
i hve done all the steps as suggested by gurus to implement this Master Detail functionality. Pl help me out if any one had implemented it
thanks in advanve
PranavHi Reetesh,
thanks for the reply...
I hve already created a transient attribute in Master VO attached to the outter advance table and had set this attribute in detail attribute property of outter
advance table. But im facing the same error.
I u hve implemented this pl let me know the correct steps
thanks
Pranav -
Re : Hw to create a table and insert records using procedures
Hi..
I tried to run a procedure to create tables but is givin an error message "insufficient previlages" and when i tried to run it using a anonymous block i can create the tables..so can any one help me to resolve this issue.
Thanks in advance.
balveer.You don't have the privilege on creating the procedures. Hence you are not able to create tables through procedures. where as you can create table from anonymous blocks..
-
Read from Page Approval List Table in a PL/SQL procedure
Need help, I am new to OA Framework.
We have a requirement to validate the added requisition Approvers against some criteria.
The Approvers are added using Add approvers on the Requisition Creation page.
The source code shows: ApproverListRn.ApprListTable as the name of the table list which holds the approver names.
1) Is there a way to read the data from ApproverListRn.ApprListTable in a PL/SQL procedure?
2) How and when does this list of approvers get added to the po_approvallist_headers table? which package is used?
Please any help is greatly appreciated.
Thanks1) Is there a way to read the data from ApproverListRn.ApprListTable in a PL/SQL procedure?
Using OAF, you can read the value from the table and through OracleCallableStatement you can call a pl/sql procedure passing the read value.2) How and when does this list of approvers get added to the po_approvallist_headers table? which package is used?
This is page and code specific. You will have to debug and find out.--Shiv -
Create an ASCII file from pl/sql procedure
hello
I need to create a file starting from a pl/sql procedure launched by command line
I'll have my .sql file containing my procedure; I'll launch it via command line and it will create the ASCII file
In the procedure I'd like to use some stored procedures or functions
is all of this possible?itmick wrote:
I need to create a file starting from a pl/sql procedure launched by command line
I'll have my .sql file containing my procedure; I'll launch it via command line and it will create the ASCII file
In the procedure I'd like to use some stored procedures or functions
is all of this possible?You could have the procedure code as well as invocation in your .sql file. In that case, launching the .sql file will
(a) compile your procedure and
(b) invoke it as well
Yes, the compiled procedure can invoke other stored procedures or functions.
To create the ASCII file, you could:
(a) use UTL_FILE supplied package in your procedure; this will create the ASCII file on the Oracle server, or
(b) have DBMS_OUTPUT.PUT_LINE calls in your procedure. When invoked from SQL*Plus, this will print out the lines on the SQL*Plus interface and you could spool it to a file on your client filesystem.
HTH,
isotope -
Can't create a sequence within a pl/sql block with execute immediate.
Hi All. I created a user and granted it the 'create sequence' privilege though a role. In a pl/sql block I try to create a sequence using 'execute immediate' but get a 1031-insufficient privileges error. If I grant create sequence directly to the user, the pl/sql block completes successfully. Can anyone explain this behavior? We're running 11.2 Enterprise Editon.
Thanks,
MarkIn a definer's rights stored procedure (the default), you only have access to privileges that have been granted directly, not via a role.
There are two basic reasons for that. First, roles can be enabled or disabled, default and non-default, password-protected, etc. so the set of roles a particular user actually has is session-specific. Oracle needs to know at compile time what privileges the owner of the procedure has. The only way to do that (without deferring the privilege check) is to ignore privileges granted through roles.
Second, since 99% of privilege management DBAs do involves granting and revoking roles, it's helpful that changing role privileges will never cause objects to be marked invalid and recompiled which can have side-effects on applications. DBAs only need to worry about causing problems on those rare cases where they are granting or revoking direct privileges to users.
You can create an invoker's rights stored procedure by adding the clause (AUTHID CURRENT_USER). That defer's the security check to run-time but allows the procedure to see privileges granted through roles in the current session. But that means that the caller of the procedure would need to have the CREATE SEQUENCE privilege through the role, not the owner of the procedure.
And just to make the point, dynamic object creation in PL/SQL is almost always a red flag that there is something problematic in your design. If you are creating sequences dynamically, that means that you'd have to refer to them dynamically throughout your code which means that your inserts would need to use dynamic SQL. That's not a particularly easy or safe way to develop code.
Justin -
How to create a table with events in smartforms?
How to create a table with events view in smartforms?
It doesn't like general table with header, main area and footer.
for example:
in smartforms: LE_SHP_DELNOTE
table name is TABLEITEM(Delivery items table)Vel wrote:
I am creating XML file using DBMS_XMLGEN package. This XML file will contain data from two different database tables. So I am creating temporary table in the PL/SQL procedure to have the data from these different tables in a single temporary table.
Please find the below Dynamic SQL statements that i'm using for create the temp table and inserting the data into it.
Before insert the V_NAME filed, i will be appending a VARCHAR field to the original data.
EXECUTE IMMEDIATE 'CREATE TABLE TEMP_TABLE (UNIQUE_KEY NUMBER , FILE_NAME VARCHAR2(1000), LAST_DATE DATE)';
EXECUTE IMMEDIATE 'INSERT INTO TEMP_TABLE values (SEQUENCE.nextval,:1,:2)' USING V_NAME,vLastDate;What exactly i need is to eliminate the INSERT portion of it,Since i have to insert more 90,000 rows into it. Is there way to have the temp table created with data in it along with the sequence value as well.
I'm using Oracle 10.2.0.4 version.
Edited by: 903948 on Dec 22, 2011 10:58 PMWhat you need to do to eliminate the INSERT statement is to -- as already suggested by others - eliminate the temporary table. You don't need it. It is just necessary overhead. Please explain why you (apparently) believe that the suggestion of a view will not meet your requirements. -
How to create a table with data in it?
I need to have a temp table in a PL/SQL procedure for processing which can hold data values from two other tables and a sequence number.
Ex:
Existing tables:
table1 (col1 varchar2(100), col2 date, col3 number20) - Has more 1Lakh rows
table2 (col1 varchar2(100), col2 date) - Has more 900 rows
New table
temp_table (col1 PRY KEY(seq1.number), col2 varchar2(100), col3 date)
Currently i have created the temp_table and inserting all the data from both table1 & table2 (which is poor). Please suggest me a way to have the temp_table created with data(atleast from table1 which has more than 1Lakh rows). Please see i need a sequence number as well.
Thanks in advance.Vel wrote:
I am creating XML file using DBMS_XMLGEN package. This XML file will contain data from two different database tables. So I am creating temporary table in the PL/SQL procedure to have the data from these different tables in a single temporary table.
Please find the below Dynamic SQL statements that i'm using for create the temp table and inserting the data into it.
Before insert the V_NAME filed, i will be appending a VARCHAR field to the original data.
EXECUTE IMMEDIATE 'CREATE TABLE TEMP_TABLE (UNIQUE_KEY NUMBER , FILE_NAME VARCHAR2(1000), LAST_DATE DATE)';
EXECUTE IMMEDIATE 'INSERT INTO TEMP_TABLE values (SEQUENCE.nextval,:1,:2)' USING V_NAME,vLastDate;What exactly i need is to eliminate the INSERT portion of it,Since i have to insert more 90,000 rows into it. Is there way to have the temp table created with data in it along with the sequence value as well.
I'm using Oracle 10.2.0.4 version.
Edited by: 903948 on Dec 22, 2011 10:58 PMWhat you need to do to eliminate the INSERT statement is to -- as already suggested by others - eliminate the temporary table. You don't need it. It is just necessary overhead. Please explain why you (apparently) believe that the suggestion of a view will not meet your requirements. -
Creating web service from pl/sql procedure
Hello.
I need to create a web service from pl/sql procedure and i chose JDeveloper for this implementation. I have wsdl, but I never created web services. So, I created web service with document/literal message format.
But I have several troubles:
1. All element names have lower case letters.
2. The SOAP envelope must begin from words soapenv:Envelope but i have soap:Envelope.
3. And operation name has tail like "Element".
I know bad way for implement 1 and 3 points. It's a modification of java_wsdl_mapping.xml and wsdl files. But if I want to add new method to my service all changes will be cleaned. It's not critical but inconvenient to support.
But for point 3 i have no ideas.
This task is very important for me. Can somebody help me?
JDeveloper 10.1.3.3
Regards,
Alekseyhttp://www.oracle.com/technology/obe/obe1013jdev/10131/wsfromplsqlpackage/devwsfrom%20plsql.htm
Frank -
Create table dinamically using java sql types?
Hi! I've an application that reads an XML file. This file contains de definitions of some tables, using java sql types. For example:
<dbtable>
<dbtablename>Name of table</dbtablename>
<dbtablefield>
<name>Name of table field</name>
<type>java.sql.Types.VARCHAR</type>
<length>10</lenght>
<canNull>0</canNull>
<isPK>1</isPK>
</dbtablefield>
</dbtable>That's a little example of one table, with one field. Is a java.sql.Types.VARCHAR (or is equivalent in int), which has a size of 10, it cannot be null and is a primary key for the table.
Now, the lenght, null, and primary keys are not problem at all. What I want to know, is how do I create de table using the java.sql.Types. I mean, I don't want to hard code:
String s = "CREATE TABLE name (COLUMN VARCHAR(10)...";Instead, I want to use some "wild cards", as are used in PreparedStatement. The idea of this is that no matter what DB I'm using, I must always be capable of creating the tables not worrying for the DB. I mean, I must be able to create the table in Oracle, SQL Server, DB2, etc., using the same XML and the same java class.
Something like:
String s = "CREATE TABLE name (COLUMN ? (10)...";
someobject.setObject(1,java.sql.Types.VARCHAR);
someobject.execute(); //create tableIs this possible? Or do I have to make a map for each DB?
Thanks a lot for your help! Dukes available!you can provide some fields at runtime..
for example
"CREATE TABLE name (COLUMN" + arg[1] +"(10)..."
here arg is the string array passed into the main.
Maybe you are looking for
-
Problem with remote debuging web start application
Hi, There is the J2EE application with desktop client (it uses JNLP). In production everything is all right, but when i'm debugging it using eclipse, application always throws SecurityException (class "oracle.retail.sim.closed.item.StockItem"'s signe
-
"Transfer structure does not exist" while deleting data from a DSO
Hello experts, while deleting data from a DSO I get the following messages: @5B\QInformation@ Database table /BIC/AAKIVO1400 was deleted and recreated @5C\QError@ Transfer structure does not exist When I try it twice process works without an
-
Issue with BAPI_DOCUMENT_CREATE2
Hi experts, I have been facing an issue calling BAPI_DOCUMENT_CREATE2 from a third-party legacy based onto Java. I am calling it to create a document based on DIR(Document Info Record) in DMS(Document Management System) Before I do this I must have d
-
IPad 2 Freezing and Dropping WiFi
Over the last few days my iPad 2 continuously freezes whilst watching things through iPlayer / Sky Go / 4 OD etc. Sometimes the WiFi will go completely and I need to switch back on. I have checked our Internet and all is fine, tried using the apps vi
-
How can i view my ipod touch as a hard drive in windows explorer
nothing seems to work yet