How to create stored procedures automatically when creating new company
I need to create a method in our add-on Business One application that will create stored procedures at the time we install the add-on (when the new company is created). Where would I store the SQL scripts, and what SAP Business One commands do I need to use to build the stored procedures into the new company database? Can someone give me an example of how to do this? We are coding in C#, but an example in visual basic would also be helpful if no one out there in forum land uses C#
Thanks,
Nancy Walk
[email protected]
Hi Nancy!
Of course are there people here that use C#
To solve your problem, create a routine in your add-on that checks at startup if the stored procedures are present. If they are not, create them. You can use the DI-API, or just add them directly to your database.
<i>Note: SAP does not like it when you play around directly in the SAP databases, and does not supply support for databases that are changed manually. You'd better use the DI-API...</i>
Hope it helps...
Grtz, Rowdy
Similar Messages
-
Create credit memo automatically when creating returns to vendor...
How can i create create "Credit Memo" automatically upon creating
returns to vendor (Movement Type 122) considering right calculation of
the sales tax & withholding tax.Hi,
There is a special display variant in the item list for invoice reduction. You enter
the invoice quantities or values that differ to the quantities or values suggested by
the system separately into the item list. (You can only enter data in these fields
when you have flagged the item as Vendor error: reduce invoice).
When you post a reduced invoice, the system creates two accounting documents.
The first document contains the invoice postings with the actual quantities and
values. The second document contains a credit memo for the difference between
the actual quantities and values and the default quantities and values.
Therefore, with invoice reduction, you do not actually reduce an invoice. Instead,
you also post a credit memo for the amount of the reduction. The amount payable
to the vendor is the value of the invoice reduced by the credit memo amount.
The PO history is updated with the unchanged default values.
When you post an invoice reduction, the system creates a message record. You
can use this to send a letter of complaint (notification of credit memo posting)
to the vendor.
Regards
Ankur -
Creating Stored Procedure Logs when executed via dbms_jobs..
Hello Everybody,
I am having a stored procedure which we are executing it via dbms_jobs..
I wanted to print the dbms_output of my stored procedure to some log file or in short just wanted to create some logs for this stored procedure..
I know if i run this procedure using cron i will be able to create a logfile..
But how can i achieve this in using dbms_jobs
Database Version : 10.2.0.1
Any help would be great..
ThanksThere are several choices, you can log things into database table, and the review the table.
Another option is to use UTL_FILE package to write log file in operating system.
With kind regards
Krystian Zieja
[Project Envision|http://www.projectenvision.com] -
How to set country field automatically when creating new customer??
Hi Gurus,
when customer number is entered in account identification, if there is no matching account, a new one is created. While creating , in the screen there is an country field and I want to set this field to a fixed value of our country. How can I do this??Hi everybody,
I got a simple question. Can I use BADI: BADI_CRM_BP_UIU_DEFAULTS of Enhancement Spot CRM_UIU_BP_ENHANCEMENT
to make the country 'US' as a default value for component: ICCMP_BP_DETAIL (NOT: BP_HEAD)?
Component ICCMP_BP_DETAIL is Interaction Center.
If not which Badi or way I can use to make country 'US' as default value?
Best Regards
Oliver
Edited by: Oliver Schultze on Dec 9, 2010 4:33 PM -
Creating a master automatically when creating a detail row
Hi,
I'm using Jdev. 11.1.2.3.0
I have three tables (with their corresponding view objects) with a master/detail/detail relationship.
The first-level detail table contain a maximum of one row for each master row.
The ids of the first-level and second-level details are automatically generated with a groovy expression and a sequence.
The views are added on the page as table(master/)form(detail)/table(detail).
I have a case where a master record has no details and i need to create a row in the second-level detail table.
So is there a way to tell ADF to automatically create the first-level detail row (since the master is known) ? or i should manually check that such a row doesn't exists in the first-level detail table and thus create it before creating the row in the second-level detail table?
Thank you.So is there a way to tell ADF to automatically create the first-level detail row (since the master is known) ? or i should manually check that such a row doesn't exists in the first-level detail table and thus create it before creating the row in the second-level detail table?
Thank you.
No, there is no such option so you will need to manually create this row.
Dario -
How can I create stored procedure?
I am new in this field, I was reading in this web site on how to create stored procedure,and this is what I did :
SQL> CREATE PROCEDURE test.proc1 (n IN NUMBER)
2 AS BEGIN
3 select * from districts
4 where doe = n;
5 END;
6
Please direct me. I don't know if I am wrong or right, test is the name of the database, and proc1 is the stored procedure that I want to create, why when I hit Enter after END; I got the number 6.
How can I call this stored procedure, if it works.
Thanks in advance
nullSome reading and training might prove useful. Even if you are using Linux, this forum is no place for a question like that.
-
how do you shuffle the image order when creating a new slideshow in apterture 3? i would like to do this automatically when creating a new slideshow. i see how you do it with presets when you just play a slideshow, but i don't see an option to randomly shuffle the slide order when you create a new slideshow. i know you can sort it by different fields, but i want it to be random. thanks.
If you want to rearrange images in random order you can try an AppleScript:
retrieve a list of selected images from Aperture
shuffe the list properly
create an album in Aperture and add the images from the list to the album (make sure that the album set to be orederd manually)
Here is a sample script that shuffles the selected images and displays them in random order in Full Screen Mode:
on removeItem(ims, i)
-- remove the item at position "i" from a list ims
if ims is {} then return {}
if (length of ims is 1) then return {}
if i < 2 then return rest of ims
if (i = length of ims) then return (items 1 thru (i - 1) of ims)
if i > (length of ims) then return ims -- should be error?
return (items 1 thru (i - 1) of ims) & (items (i + 1) thru (length of ims) of ims)
end removeItem
on shuffle_items(ims)
-- shuffle the items of the list "ims" randomly
local numitems, ims_shuffled, nextrest, nextpick, i
set numitems to length of ims
if length of ims < 2 then return ims
set ims_shuffled to {}
set nextrest to ims
repeat until nextrest is {}
set i to (random number (numitems - 1)) + 1
set nextpick to item i of nextrest
set beginning of ims_shuffled to nextpick
set numitems to numitems - 1
set nextrest to removeItem(nextrest, i)
end repeat
return ims_shuffled
end shuffle_items
on shuffleIms()
-- retrieve the selected images from Aperture
-- and display them in random order in full screen mode
local imageSel, shuffled, i
tell application "Aperture"
activate
set imageSel to (get selection)
set shuffled to my shuffle_items(imageSel)
set fullscreen to true
if imageSel is {} then error "Please select some images."
repeat with i from 1 to count of shuffled
reveal {item i of shuffled}
delay 3 -- chnage that to the time you want
end repeat
set fullscreen to false
return shuffled
end tell
end shuffleIms
shuffleIms()
Some more code snippets to go from here:
To create an album:
tell library 1
if not (exists album "shuffledAlbum") then
make new album with properties {name:"shuffledAlbum", image version:shuffled}
end if
end tell
And to add the images from the shuffled list to the album:
repeat with i from 1 to count of shuffled
duplicate item i of shuffled to album "shuffledAlbum"
end repeat
Regards
Léonie -
How can I create accurate decimal dimensions when creating a new document or using the art board in Illustrator CS6? When I type in a number with a decimal, it automatically rounds the number up.
For my part you are welcome, sdowers.
Unfortunately, the uncertainty arising from the rounding has been up several times here in this forum.
I just came to remember a warning that needs to be given:
The rounding of the representation of a numerical value may be harmless in itself, but if you use it for any operation that changes the value, such as multiplication or whatever, things will go wrong because the operation will be made on the basis of the rounded value instead of the true value. So, as in your first case in post #2, 39.625 rounded to 39.63 will become 79.26 instead of 79.25. -
HOW TO CREATE STORED PROCEDURE IN DATA INTEGRATOR
Hi to every one,
Can any one help in giving me a solution for creating stored procedure in Data Integrator.
I m new to this fieldHi nath,
Firstly are you using MYSQL or Oracle as the database,if its oracle database then follow this
http://obiee101.blogspot.com/2008/01/obiee-using-oracle-stored-procedure-to.html
http://oraclebizint.wordpress.com/2008/02/20/oracle-bi-ee-101332-executing-stored-proceduresfunctions-before-reports-before-report-triggers-and-global-temporary-tables/
EXEC [DATABASE_NAME].[SCHEMA_NAME].[PROCEDURE_NAME][DATABASE_NAME] --> is the database name your creating your procedure
[SCHEMA_NAME]-->is the user with which your creating
[PROCEDURE_NAME] --> the name given to procedure
You dont know how to get those run this SQL in TOAD and see select sys_context('userenv','db_name'), sys_context('userenv','session_user') from dual
(OR) open you connection pool properties window in RPD,you will get the DB name and the user name as the schema name
hope answered your question.
CHeers,
KK -
How can i create stored procedures dynamically?
I have tried to create a stored procedure building a string with the PL/SQL code needed to create the procedure. If i run the code using SQL+ works fine, but using the following code:
Public Sub CreateStoredProcedure()
Dim strSql As String
strSql = "CREATE OR REPLACE PACKAGE OPSPRUEBAS AS " & vbCrLf
strSql = strSql & vbTab & "PROCEDURE consulta (resultado OUT VARCHAR2); " & vbCrLf
strSql = strSql & "END OPSPRUEBAS; " & vbCrLf
strSql = strSql & "/ " & vbCrLf
strSql = strSql & ". " & vbCrLf
strSql = strSql & "CREATE OR REPLACE PACKAGE BODY OPSPRUEBAS AS " & vbCrLf
strSql = strSql & "PROCEDURE consulta (resultado OUT VARCHAR2) IS " & vbCrLf
strSql = strSql & "oc_ref" & vbTab & vbTab & "REF Content_Ontology; " & vbCrLf
strSql = strSql & "oc" & vbTab & vbTab & "Content_Ontology; " & vbCrLf
strSql = strSql & "ori" & vbTab & vbTab & "role_def; " & vbCrLf
strSql = strSql & "ori_ref" & vbTab & vbTab & "ref role_def; " & vbCrLf
strSql = strSql & "conce" & vbTab & vbTab & "concept; " & vbCrLf
strSql = strSql & "conce_ref" & vbTab & "REF concept; " & vbCrLf
strSql = strSql & "b" & vbTab & vbTab & "boolean; " & vbCrLf
strSql = strSql & "BEGIN " & vbCrLf
strSql = strSql & "b:=false; " & vbCrLf
strSql = strSql & "select REF(oi) into ori_ref from rol_table oi where oi.name='Playing'; " & vbCrLf
strSql = strSql & "select deref(ori_ref) into ori from dual; " & vbCrLf
strSql = strSql & "select REF(oi) into oc_ref from c_ontologies oi where oi.web_source_prop=websource('FilmContentOntology'); " & vbCrLf
strSql = strSql & "select deref(oc_ref) into oc from dual; " & vbCrLf
strSql = strSql & "if oc.if_has_co_class('Film')='TRUE' AND " & vbCrLf
strSql = strSql & "oc.if_has_co_class('theater')='TRUE' AND " & vbCrLf
strSql = strSql & "oc.if_has_co_relationship('is_scheduled')='TRUE' AND " & vbCrLf
strSql = strSql & "oc.if_has_co_attributes('Film', lista('is_scheduled', 'title', 'actor'))='TRUE' AND " & vbCrLf
strSql = strSql & "oc.if_has_co_attributes('theater', lista('theatername', 'address', 'email'))='TRUE' " & vbCrLf
strSql = strSql & "then resultado:='FilmContentOntology'; " & vbCrLf
strSql = strSql & "else resultado:='No Existe'; " & vbCrLf
strSql = strSql & "end if; " & vbCrLf
strSql = strSql & "END consulta; " & vbCrLf
strSql = strSql & "END OPSPRUEBAS; " & vbCrLf
strSql = strSql & "/ " & vbCrLf
strSql = strSql & ". " & vbCrLf
strSql = strSql & "COMMIT;" & vbCrLf
TextBox2.Text = strSql
'Dim myConnectionString As String = "User Id=system;Password=daniel;Data Source=websogo;"
'Dim oraConn As Oracle.DataAccess.Client.OracleConnection = New Oracle.DataAccess.Client.OracleConnection(myConnectionString)
Dim myCmd As New System.Data.OleDb.OleDbCommand()
Dim MyConnection As New System.Data.OleDb.OleDbConnection()
MyConnection.ConnectionString = "Provider=MSDAORA;Data Source=websogo;password=daniel;User ID=system"
MyConnection.Open()
'oraConn.Open()
myCmd.Connection = MyConnection
myCmd.CommandType = CommandType.Text
myCmd.CommandText = strSql
myCmd.ExecuteNonQuery()
'Dim e As Oracle.DataAccess.Client.OracleException
'Try
' myCmd.ExecuteNonQuery()
'Catch e
' Dim error1 As Oracle.DataAccess.Client.OracleError
' error1 = e.Errors.Item(0)
' Textbox3.Text = error1.Source & " " & error1.Message
'End Try
MyConnection.Close()
End Sub
I've tried using Microsoft ODP, OLEDB and Oracle's ODP.NET
Also tried to catch any error but there are no errors!
Has anybody achived a successful dynamically stored procedure creation using .net?
thanks in advance
DanI'm trying to create Stored Procedures via .NET and able to do so but when I look in Oracle Enterprise Manager Console, the Stored Procedures are marked as INVALID... If I edit the Stored Procedure (i.e. delete a space or something minor) and SAVE then it compiles fine.....
Any ideas ????
will be using this against 9i & 10g db -
How to create stored procedure directely in RPD
Hi Gurus,
I am trying to create stored procedure directly in physical table in rpd level in OBIEE.for this one i have gone through below website.
http://obiee101.blogspot.com/2011/01/obiee-using-mssql-stored-procedure-as.html
in that blog they mentioned to write some query which is...........
EXEC [DATABASE_NAME].[SCHEMA_NAME].[PROCEDURE_NAME]
in above query i am not getting what is DATABASE_NAME,SCHEMA_NAME,PROCEDURE_NAME
can any one elobrate this oneHi nath,
Firstly are you using MYSQL or Oracle as the database,if its oracle database then follow this
http://obiee101.blogspot.com/2008/01/obiee-using-oracle-stored-procedure-to.html
http://oraclebizint.wordpress.com/2008/02/20/oracle-bi-ee-101332-executing-stored-proceduresfunctions-before-reports-before-report-triggers-and-global-temporary-tables/
EXEC [DATABASE_NAME].[SCHEMA_NAME].[PROCEDURE_NAME][DATABASE_NAME] --> is the database name your creating your procedure
[SCHEMA_NAME]-->is the user with which your creating
[PROCEDURE_NAME] --> the name given to procedure
You dont know how to get those run this SQL in TOAD and see select sys_context('userenv','db_name'), sys_context('userenv','session_user') from dual
(OR) open you connection pool properties window in RPD,you will get the DB name and the user name as the schema name
hope answered your question.
CHeers,
KK -
Cannot create stored procedure in Azure SQL database
When I try to create a stored procedure using Management Studio
(Snippet follows
use
PPSC_Sky_Data
go
/****** Object: StoredProcedure [dbo].[sp_RegisterProd] Script Date: 17-02-2015 17:52:50 ******/
SET
ANSI_NULLS
ON
GO
SET
QUOTED_IDENTIFIER
ON
GO
CREATE
proc [dbo].[sp_RegisterProd]
@inputMachid nvarchar(50),@inputDomainname
nvarchar(255),@inputwsid
nvarchar(255),@inputipv4
nvarchar(50),
@custno
as
nvarchar(50),@email
as
nvarchar(50),@telephone
as
nvarchar(50),@RegType
as
int
(end of snippet)
It fails with message 40508 - (not allowed to switch between databases) then tells me I am not authorized to create an SP in the Master db.
So....
How can I create a procedure in AZURE Sql?
Thanks
Murray
M WhippsHi 9gwcycn,
Creating stored procedures is not allowed in Master Database. You have to switch to Database
PPSC_Sky_Data manually, use statement is not supported. After that could you please confirm again? As Creating and altering Stored procedures work fine from my SSMS.
If you have any feedback on our support, please click
here.
Eric Zhang
TechNet Community Support -
Creating Stored Procedure in Java
Hi All,
I would like to ask how to create a stored procedure in Java.
My project now is to create a program that will open a DB2 SQL File (Creating Table and Stored Procedure) and then Execute it.
Executing the CREATE TABLE command is not that difficult since I can break the execution down by statement (divide by ";" in the SQL file).
The logic I applied here are:
1. Open the SQL file and store the contents into a String object.
2. Call the executeUpdate(string_sql_fileContent) method of Statement Object.
Example: SQL File contect to be executed.
===========================================================
CREATE TABLE MDMTEST.sample
(firstname CHARACTER(40),
middlename CHARACTER(40),
lastname CHARACTER(40),
idNo SMALLINT NOT NULL
DATA CAPTURE NONE;
#SYNC 10;
ALTER TABLE MDMTEST.sample
LOCKSIZE ROW
APPEND OFF
NOT VOLATILE;
#SYNC 20;
ALTER TABLE MDMTEST.sample
ADD PRIMARY KEY
(idNo
#SYNC 30;
RUNSTATS ON TABLE MDMTEST.sample
AND INDEXES ALL
SHRLEVEL REFERENCE;
===========================================================
I can divide this by ";" and execute them by statement.
But my problem is when creating Stored Procedure... Since in stored procedure there are so many stub-statements...
Example: Content of SQL File for creating stored procedure.
===========================================================
CREATE PROCEDURE MDMTEST.DROP_ALL_OBJECTS ( )
SPECIFIC MDMTEST.SQL051109115453000
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
MODIFIES SQL DATA
INHERIT SPECIAL REGISTERS
BEGIN
Delete Statement;
Insert Statement;
Update Statement;
END;
===========================================================
Take note there are three statements inside the CREATE..BEGIN.. and END.. (namely Delete, Insert, and Update Statements).
How can I execute the command for creating the procedure in Java? I believe that creating stored procedures in other databases are almost the same...
So... anyboby who have tried creating stored procedure in Java?
Please help me in this... I wanna pass the subject hehe..I have used these files as a sample:
Java Program:
import java.io.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import my.db.components.*;
public class ProcedureUploader {
private MyDBConnection dbConn=new MyDBConnection();
private Statement statement;
public ProcedureUploader() {
try{
dbConn.connectDB ("206.206.206.206","12345","DEV","mdmtest","mdmtest");
this.statement=dbConn.getStatement ();
}catch(SQLException sqle){
sqle.printStackTrace();
public String getContents(String fileName) throws IOException{
File inputFile = new File(fileName);
FileReader in = new FileReader(inputFile);
int c; String contents="";
while ((c = in.read()) != -1) contents+=(char) c;
in.close();
return contents;
public void executeSQLCommand(String file) throws IOException{
String command="";
try{
command=getContents(file);
statement.executeUpdate(command);
System.out.println("Command Execution Successful.");
}catch(Exception ex){
System.out.println("There is a problem executing the command. Please check the SQL file and re-execute again.");
ex.printStackTrace();
public static void main(String args[]) throws IOException{
ProcedureUploader uploader=new ProcedureUploader();
uploader.executeSQLCommand("C:\\I2\\Development\\ProcedureUploader\\sample.sql");
SQL File:
CREATE PROCEDURE MDMTEST.sampleProc ( )
SPECIFIC MDMTEST.sampleProc
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
MODIFIES SQL DATA
INHERIT SPECIAL REGISTERS
delete from SAMPLE;
commit;
select * from SAMPLE;;
#SYNC 10;
===========================================================
The problem is that ... there will be an error:
===========================================================
There is a problem executing the command. Please check the SQL file and re-execute again.
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: delete from SAMPLE;;PECIAL REGISTERS
;<psm_repeat>
at com.ibm.db2.jcc.c.fg.e(fg.java:1596)
at com.ibm.db2.jcc.c.fg.b(fg.java:1160)
at com.ibm.db2.jcc.b.gb.h(gb.java:217)
at com.ibm.db2.jcc.b.gb.b(gb.java:46)
at com.ibm.db2.jcc.b.w.b(w.java:40)
at com.ibm.db2.jcc.b.vb.f(vb.java:118)
at com.ibm.db2.jcc.c.fg.m(fg.java:1155)
at com.ibm.db2.jcc.c.fg.a(fg.java:1865)
at com.ibm.db2.jcc.c.fg.c(fg.java:517)
at com.ibm.db2.jcc.c.fg.executeUpdate(fg.java:501)
at ProcedureUploader.executeSQLCommand(ProcedureUploader.java:44)
at ProcedureUploader.main(ProcedureUploader.java:54)
===========================================================
But still the procedure will be created but until the first ";" only... OR.. creates a stored procedure having the following lines only.
===========================================================
CREATE PROCEDURE MDMTEST.sampleProc ( )
SPECIFIC MDMTEST.sampleProc
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
MODIFIES SQL DATA
INHERIT SPECIAL REGISTERS
delete from SAMPLE;
=========================================================== -
I'd like to learn how to create stored procedures in Oracle 10g. I'm proficient at this with MS SQL but I can't get to first base with Oracle.
I am not using SQL *Plus and really I don't want to use it. I'd rather use a DB access program like Aqua Data Studio. When I attempt to create a procedure I get a "Compiled with errors" message. I don't know how to see the errors because I can't do a "Show Errors" message.
Is there a way to create stored procedures using standard SQL and staying away from SQL *Plus?The two best free tools I know of are:
http://sourceforge.net/projects/tora/
and
http://www.oracle.com/technology/products/database/sql_developer/
TOra is more a database system tool, and SQL Developer is more of a development tool, but see if either of those will be to your liking ;)
~Jer -
I have created stored procedure with %rowtype as IN OUT parameter.I want to
i have created stored procedure with %rowtype as IN OUT parameter.I want to call it in java program
Hi Avi,
I have the same problem as the person asking before me, so I'll try and clarify:
I have a Java client and a PL/SQL database procedure that looks something along the lines of:
Create of Replace procedure myProc(myRow IN myTable%Rowtype)
It's very easy to pass a parameter into this procedure from another procedure within the database because creating another myTable%Rowtype is not a problem.
However, Java doesnt know what "Rowtype" is.
I was wondering how I would pass a "rowtype" from Java.
I was thinking along the lines of creating an object in the DB like that:
Create Type myObj AS myTable%Rowtype (<-- is that even allowed?)
And then create a procedure in the DB with the header:
Create of Replace procedure myProc(myRow IN myObj)
And then, in my Java,just create a STRUCT of my DB object and pass it to the DB:
myCallableStatement.setObject(1, myStruct);
Would that work?
Is there a better way?
Thanks,
Dan
Maybe you are looking for
-
How to use a variable to specify the color when setting an attribute
Hi We are using BI Publisher (XDO) embedded in e-Business Suite. So we are effectively on version 5.6.3. I would like to conditionally set the background-color attribute of cells in a table by using a variable reference; something like this (the ways
-
How to make xml validation with automatic error fixed
Hi', i have some string which i want to validate it: String word = "<style>body {background-color:transparent}"; byte[] bytes = word.getBytes(); InputStream inputStream = new ByteArrayInputStream(bytes); DocumentBuilderFactory docBuilderFactory
-
Query of SRM components landscape
Hi friends Actually i want to know a scenario where in which EBP,SUS,CCM(as supplier directory replicated from SUS),Strategic sourcing are used in Service Procurement of Extended Classic Scenario thanks regards krishna
-
How to load java applet to java-enabled card
I have downlaoded the sdk n run some samples. but when i connect the card as through pcsc reader, and tried to install some ready applet in the card explorer,it fail n give me 6a80. How can i load a java card applet into a java-card?
-
Having problem with DirectPath API LoadStream
Hi, I am attempting to use the direct path API in Oracle 8.1.7 (SUN OS 5.8) to perform large data loads. For the most part I've got the interface doing what I want it to do, however I am also doing statement caching. For instance, after a transaction