Store procedure to calculate lcm and gcd of two number
Hi,
Can anyone please help me to write this procedure
---- to calculate lcm and gcd of two number
Thanks,
Deekay.
Hi, I am getting this error with the above query.
Error starting at line 1 in command:
select lcm(1,2), gcd(1,2) from dual
Error at Command Line:1 Column:17
Error report:
SQL Error: ORA-00904: "GCD": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Similar Messages
-
How to calculate percentage and difference of two values in matrix report in ssrs 2008
Hi everyone,
DB--SQL server
SSRS-2008
I am creating matrix report with grouping on WEEK and Fiscalyearweek,
I need to calculate of difference between FY14W01,FY15W01 ande percentage of those..
how to calculate in ssrs level.
Thank You, Manasa.VHi veerapaneni,
According to your description, you want to calculated the increment percentage and difference between two fiscal year week within each week. Right?
In this scenario, since we need to do calculation based on values between dynamically generated cells, we can't simply use expression to achieve this goal. In this scenario, we need to use custom code to record the value for fiscal 14 and fiscal 15, then
we can calculate the difference and percentage within the column group. We have tested your case in our local environment, please refer to the steps and screenshots below:
1. Add the custom code below into the report (you may need to modify the data type based on your scenario:
Public Shared Value1 as Integer
Public Shared Value2 as Integer
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as Integer,product as String,Week as String) as Integer
If product =previous and Week =previousweek Then
Value2=Value
Else
previous=product
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetPct()
return (Value2-Value1)/Value1
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
2. Design the matrix like below:
3. The result look like below:
If you have any question, please feel free to ask.
Best Regards,
Simon Hou -
is it possible to write store procedure for inserting records and multiplying them
description qt rate Amount
drop procedure a1;
create or replace procedure a1
a_description in varchar2,
a_qt in number,
a_rate in number,
a_amount in number)
as
begin
insert into employee_record values (a_description,a_qt,a_rate,a_qt * a_rate);
end;
is it possible that column amount calculates the amount itself
when i try to execute ( 'Hard Drive', 4, 100)
it gives me an error message .
wrong number or types of arguments in call to 'INSERT_a1'
when i try to run it with ('Hard Drive',4,100, 5) it inserts values and also updates column with correct amount which is 400 .
it would be kind of you if you could show me the a better way to write this store procedure or where i should makes changes.
so that my amount column calculates the total itself
thanksHi,
Someoneelse is right: storing columns that depend entirely on other columns is usually a bad idea. Compute the amount in queries, as needed, or create a view that computes amount.
If you really must store it in the table, then you can use a trigger, like this:
CREATE OR REPLACE TRIGGER employee_record_biu
BEFORE INSERT OR UPDATE OF qt, rate, amount
ON employee_record
FOR EACH ROW
BEGIN
:NEW.amount := :NEW.qt * :NEW.rate;
END;
/This will automatically run whenever you issue an INSERT or UPDATE statement that references the columns involved. If that statement provides a value for amount, that value will be ignored. Amount will always be calculated from qt and rate.
Starting in Oracel 11, you can create a virtual column, which will probably be better than a trigger.
http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_7002.htm#sthref7273 -
Oracle JBDC error while calling the store procedure
HI All,
I am get one strange error while calling a store procedure which has two parameter in and out.
I am pass the correct XML file which reaches the RDB and then PI receives a exception error message saying:
oracle.rdb.jdbc.common.RdbException: Closed Resultset
where as no error log is availble in RBD for the same.
Can anybody tell me what can be the cause of the error.
Let me know if you requires more information on this.
-adiHi Kiran,
Thanks..
But I am not able to understand you. I am calling a store procedure not a table. and we not doing anything in the store procedure except return one constant value in Out parameter.
-Adi -
Calling ORACLE Store Procedure with parameters in user define function
Hi everybody,
We have a scenario connecting Oracle DB thru JDBC adapter.
We have to call store procedure with input parameter and output parameter to retrieve data from DB. The implementation was made using JDBC adapter by building the correct XML message with EXECUTE action, and it works fine.
Now we need to use DB lookup within mapping. I wrote users define function with SELECT statement (using the JDBC adapter) and it works fine but I need to call store procedure in ORACLE instead of SELECT statement.
I found lot of examples concerning DB lookup but none of them explained how to write UDF calling store procedure in ORACLE with input and output parameters.
I am looking for an example.
Thanks in advance,
GigiI agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
If you think you are going to get existing MS Stored Procedures or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
You could use the EF backdoor, call Oracle Command object and use the Packages, if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
That's about your best shot.
http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx -
How to set store procedure parameters
Hello,
To summarize our problem, we are not able to set store procedure parameters using JRC and without using a Viewer.
Inside an rpt document we use a call to a store procedure that requires some input parameters.
We attempted to pass the required parameters to the report (please see below) but it seems that those parameters are somehow ignored.
In fact null values are always received by the store procedure.
For your information, if the document doesnu2019t contain a call to a store proc but SQL clause parameters instead, then that works.
Does that mean that sp parameters have to be set in a specific way?
Please can you advise?
Tanks a lot,
Joseph
This is how we set parameter values:
private void handleParameters(ReportClientDocument pm_document, List pm_parameters) throws Exception
ParameterFieldController pfc = pm_document.getDataDefController().getParameterFieldController();
pfc.setCurrentValue(reportName, parameterFieldName, parameterValue);
Then we export in a pdf file:
private InputStream createInputStream(ReportClientDocument pm_document, String pm_reportName) throws Exception
return (ByteArrayInputStream)pm_document.getPrintOutputController().export(ReportExportFormat.PDF);First question:
Do you set the parameters before the database logon?
Sincerely,
Ted Ueda -
Get the body of the store procedure
Hi All,
THe store procedure is created successfully and I don't know how to get the definition of the store procedure. In MSSQL server I used "sp_helptext <store procedure name>" but I don't know how to get text(description) of the store procedure in ORACLE. Your help is greatly appreciated.
Thanks,
JPHi all,
I ran the following statement to get the body of the store procedure:
select text from user_source where name = <store procedure>
and the long text(body of store procedure) is returned back. This store procedure is created with the error message return back as "Warning: Procedure created with compilation errors". So I were wondering why the store procdure is in user_source although the creation of this store procedure is returned an error message as mentioned above. Is there anyway that we can find out if the store procedure is created with the compilation errors.
Thanks,
JP -
I am trying to make a ssis package that get the data calling the store proc with two param one is ID and other is Sys_refcursor. Say Store Proc as ListName(Id int, myCur sys_refcursor), which gets the datas with the conditions inside it.
REATE OR REPLACE PROCEDURE schemaName.LISTNAME (P_ID IN INT, LST_NAME_REFCUR IN OUT SYS_REFCURSOR)
IS
P_NAMESOURCE_ID INT;
BEGIN
SELECT SOURCE_ID INTO P_NAMESOURCE_ID FROM SEARCHING_TABLE ST WHERE ST.ID = P_ID;
IF (P_NAMESOURCE_ID=1)
THEN
OPEN LST_SOURCE_REFCUR FOR
SELECT ST.ID,
ST.TRANSACTION_DATE AS TRAN_DATE,
IF (P_NAMESOURCE_ID=1)
THEN
OPEN LST_SOURCE_REFCUR FOR ....
then i need to get the data from that refcursor and fetch those data to excel sheet to a virtual directory.
Any help would be appreciated. I am new to SSIS. and i need to do this assignment this friday.Hi 11srk,
To fetch data from Oracle store procedure, you can use a Script Component as source to call the Oracle stored procedure by using System.Data.OracleClient OracleDataReader, and get the rows and add them to the pipeline buffer. For more information, please
see:
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/1d0b3a1b-8792-469c-b0d1-f2fbb9e9ff20/dump-oracle-ref-cursor-into-ms-sql-staging-table-using-ssis
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/fcdaa97e-8415-4c3e-8ffd-1ad45b590d57/executing-an-oracle-stored-procedure-from-ssis?forum=sqlintegrationservices
http://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracledatareader(VS.90).aspx
Regards,
Mike Yin
TechNet Community Support -
How to load and define Java Store Procedures using Consolidator Manager??
Hi,
I am trying to create a store procedure with a very easy example and I can not succeed. i am a bit new with OLite and I will appreciate any help from your side. I am quite lost now regarding of using java with OLite and it is becoming quite urgent for me. Thanks a lot in advanced.
Those are the steps that I follow:
- Creating the java class
I create the java file MYUPPER.java with next code :
public class MYUPPER {
public static String doUpper( String p_text )
return p_text.toUpperCase();
I compile it and I create the jar file:
C:\>javac MYUPPER.java
C:\>jar cf MYUPPER.jar MYUPPER.class
- This is an abstract of my java code using the API:
( m_cm is ConsolidatorManager)
// Create the java resource
m_cm.createStoredProc( "MYUPPER.jar", "MYUPPER", "doUpper", "doUpper");
// Add it to the publication
m_cm.addJavaResource( "PMTS", "MYUPPER" );
- After running that code I do not receive any exception and checking into the repository looks ok:
a) From the Mobile Server I can see the Java Ressource MYUPPER for that publication
b) I can see the entries in C$Resouces and in C$Pub_Objects as well
*** ON THE CLIENT:
Then I go to the client device a Windows XP labtop where I did install the jre 5.0 and I added the bin path to the system variable PATH.
- I get a POL-8000 error when synchronizing (could not start the Java Visrtual Machine)
- Anyway, I can see the MYUPPER.class file deployed in the same directory than the databases are.
- I have also tried next from msql:
c:\>msql system/manager@jdbc:polite:tomeu_conscli
Oracle Lite MSQL Version 10.3.0.2.0
Copyright (c) 1997, 2008, Oracle. All rights reserved.
Connected to: Oracle Lite ORDBMS
Database Name: CONSCLI (Read Write)
Database Version: 10.3.0.2.0
Auto Commit: off
Driver Name: oracle.lite.poljdbc.POLJDBCDriver (OLite 4.0)
SQL> select * from c$resources;
PUB_NAME | DB_NAME | RESOURCE_NAME | RESOURCE_TYPE | RESOURCE_DATA
PMTS | pmts | MYUPPER | JAVA CLASS | -¦¦¥ 1
1 row(s) returned
SQL>
SQL> exit
Disconnected from CONSCLI
c:\>msql system/*****@jdbc:polite:tomeu_pmts
Oracle Lite MSQL Version 10.3.0.2.0
Copyright (c) 1997, 2008, Oracle. All rights reserved.
Connected to: Oracle Lite ORDBMS
Database Name: PMTS (Read Write)
Database Version: 10.3.0.2.0
Auto Commit: off
Driver Name: oracle.lite.poljdbc.POLJDBCDriver (OLite 4.0)
SQL> select doUpper('fhjdjf') from dual;
[POL-8035] no such attribute or method
SQL> create table sp (id number(1) primary key );
Table created
SQL> alter table sp attach java source "MYUPPER" in '.';
[POL-8028] error in calling a Java method
SQL> commit;
Commit complete
SQL> select sp.doUpper('fhjdjf') from dual;
[POL-8035] no such attribute or method
Lost... :(
Tomeusorry to bother, similar like above, i tried many times on my computer to load a simple image in java application.. here's my code:
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import javax.swing.*;
public class View extends JFrame {
private URL imageURL;
private File file;
private Image sourceImage;
private String name, title, message;
private int width, height;
public static void main(String[] args) {
System.out.println( "Hello Eros!!!" );
View img = new View();
public View() {
name = "D:/shared/inputpic.gif";
file = new File( name );
Toolkit toolkit = Toolkit.getDefaultToolkit();
try {
imageURL = new URL("http://www.google.com.my/images/logo_sm.gif" );
} catch (MalformedURLException e) {
if ( file == null ) {
sourceImage = Toolkit.getDefaultToolkit().getImage( name );
System.out.println( file );
} else {
sourceImage = toolkit.getImage( imageURL );
System.out.println( file );
width = sourceImage.getWidth( this );
height = sourceImage.getHeight( this );
System.out.println( "Pixel = " + width + "x" + height );
if ( width * height == 1 ) {
title = "Greetings"; // Shown in title bar of dialog box.
if ( file == null ) {
message = "Unable to load the file " + name;
} else {
message = "Unable to load the link " + imageURL;
JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE);
}could anyone test this n give my the reason i couldnt even load the image -
Insert and update same record of table using store procedure in oracle 10g
Hi,
I am using oracle sql developer for this.
I have created Store procedure which run after every 30mins of interval.
the problem is Ii need to insert data for first time of day then later that same record should update for particular field(here its plan code).
if new field is coming (if new plan code is generated) then it should insert data and again update same for interval.
means for each plan individual record(i.e. plan wise summary) should be there for only a day. next day new record for same plan.Hi,
You should use Merge like shown below:-
Merge into original_table a
using second_table b
on (a.primary_key=b.primary_key and a.primary_key........)
when match then
update set column_list=b.column_list
when not match then
isert into (column list)
values(a.column_list)If you dont know much about merge then follow below link..
http://www.oracle-developer.net/display.php?id=203
http://www.oracle-base.com/articles/10g/merge-enhancements-10g.php -
Problem with Pie chart, Store Procedure and Category Axis
Hi All,
I'm having a problem when i try to use a Pie Chart with a store procedure
when Category Axis - Field value is "none", the chart appears, but the description say Undefined
but when i put any field from store procedure, the chart doesn't show.
when I try the same with a normal SQL statement, all data was displayed
my store procedure only have 2 columns
n - numeric
state - text
The Store Procedure and the SQL, returns the same data in the same order
Thanks in advance
CristianHi guys,
I need guide on creating a system using store procedure, referring to this thread: JDBC System Connection VS BI JDBC System Connection
Hope you can help me out.
Thanks a lot,
Sarah -
How to create a schema and assign roles with store procedure or function?
Hi All,
I am creating a webpage that will call oracle store procedure or function to create a schema and add roles. Please let me know if there a method to do that.
Thank youHi CristiBoboc,
Thank you very much for your help. Here is my code to create a user:
create or replace
FUNCTION user_create (user_name IN nvarchar2, user_pw IN nvarchar2)
RETURN number
IS
sql_stmt varchar2(200);
sql_stmt2 varchar2(200);
var_temp_count NUMBER(2);
un varchar2(30) := user_name;
up varchar2(30) := user_pw;
BEGIN
sql_stmt := 'create user :1 identified by :2
default tablespace users
temporary tablespace temp
quota 5m on users';
sql_stmt2 := 'grant developers to :1';
EXECUTE IMMEDIATE sql_stmt USING un,up;
EXECUTE IMMEDIATE sql_stmt2 USING un;
select count(*) into var_temp_count from dba_users where username = UPPER(user_name);
return var_temp_count;
END;
When I run, I get following error:
exec :myvar :=user_create('aaa','12345');
BEGIN :myvar :=user_create('aaa','12345'); END;
ERROR at line 1:
ORA-01935: missing user or role name
ORA-06512: at "CSDBA.USER_CREATE", line 15
ORA-06512: at line 1 -
Oracle Java Store Procedure and JNI
Hi ! 'Is the anybody out there ?'
We don't know. We are developing a java store procedure in Oracle 9i. We need to use a propetary .so file about cript/decript information (entrust file). So have to use in oracle a .jar file with all software infrastructure that use this .so file. But, we have a problem. 'Cause, in windows, we can use a .dll file from our java store procedure, but when we run under unix aix, we have problem about jni.
java.library.path in oracle console is empty.
So we cannot find our share object... have you got an idea ?
thanks!!
andreaOracle lite does not support the use of PL/SQL procedures or triggers in the database, so unfortunately you just cannot use them.
as an alternative you need to either
a) include the setting on the client records when they are created
b) use before insert/update triggers on the main oracle database to populate the columns. NOTE if doing this you will find that the user that is actually responsible for the inserts and updates to the main database is MOBILEADMIN (as it is running the apply process. If you just want to log the fact that it was client created fine, but will not tell you the creating user)
c) you should be able to use pure java stored procedures on the client (if in the main oracle database, they should replicate across, but beware of jvm differences and any advanced stuff that may not be supported. you will also have to get any necessary jar files over to the client as well)
We have used method a) as a standard method called for all inserts/updates in the java client APPLICATION software based on the existance of the audit columns, rather than within the database as it is simpler -
How to create store procedure using cursor, and looping condition with exce
Hi,
I am new in pl/sql development , please help me for follwoing
1. I have select query by joining few tables which returns lets say 100 records.
2. I want to insert records into another table(lets say table name is tbl_sale).
3. If first record is inserted into tbl_sale,and for next record if value is same as first then update into tbl_sale else
insert new row
4. I want to achieve this using store procedure.
Please help me how to do looping,how to use cursor and all other necessary thing to achieve this.DECLARE
b NUMBER;
BEGIN
UPDATE tbl_sale
SET a = b
WHERE a = 1;
IF SQL%ROWCOUNT = 0
THEN
INSERT INTO tbl_sale
(a
VALUES (b
END IF;
END;note : handle exceptions where ever needed
Regards,
friend
Edited by: most wanted!!!! on Mar 18, 2013 12:06 AM -
User define table and store procedure install
Hi there,
I like to deploy an addon, there are User define tables and store procedure need add to database, I wonder which chance is properly to add them, if add these user define objects in time of install, we can not get the enough information that connect to SQL server, and also create UDT need DIAPI. if put create UDT and UDsp in addon program, the problem is which DIAPI funciton or object can execute create store procedure SQL string.
Thanks for any help.
LanjunR. Schwachofer,
Thank you very much,
the way call isqlw.exe to run SQL script is a good way when install, but I confuse with two questions about this way. first, run isqlw.exe should provid loginid and password of SQL server, these two information need additional install dialog to get; second if use isqlw.exe the store procedure only create to the current company database, when create new compay DB the store procedure does not exist in new DB.
so I still do not know which way is the proper way to create SP for addon.
Thanks in advance.
Lanjun
Maybe you are looking for
-
Failed to Run Task Sequence (error ocurred while retrieving policy for the computer)
Hi, all of sudden we're getting an issue with SCCM when attempting to deploy an image we get a Failed to Run Task Sequence. Used to work previously, now suddenly it isn't working for any. Full error: Failed to Run Task Sequence An Error occurred whil
-
Need assistance conscerning Zen V (Application/Driver CD missi
Hello. I have lost my driver/application CD. I have installed drivers and can access my mp3 player trogh windows, but id doesn't suffice for me. I want to install Creative MediaSource As I did when I first got the player (using the supplied CD) Why i
-
Saving photo attachments in mail.app
Can anyone please tell me if there is a simple way to save multiple photo attachments from several emails to one folder in one go? I am hoping that I don't have to go to each individual email & save
-
UAG 2010 SP3 - OWA Exchange 2010 - Large attachments fail to open
We have a UAG 2010 SP3 server in front of Exchange 2010 CAS. On the UAG side we have disabled the component installation and activation for UAG within the session configuration. When users access OWA and open attachments it works fine up until a cert
-
Hi, I have recently created a site using Dreamweaver and posted it on to some forums. Some of the comments were that the code was poor and that Dreamweaver was not good enough. Is it not possible to build a site in Dreamweaver and tidy the code yours