Help with Command - Stored Procedure
Hi all,
I'm having a great deal of difficulty getting my head around
an update command / stored procedure, I've pulled out all of my
books and spent the last two days on Google which has made my
confusion worse. In simple terms what I'm trying to do is update a
field in a table with the value y, but based on certain criteria.
So my table has the following fields -
JBAID
JBASiteID
JBADatePosted
JBAPostFor
JBANotified
What i want to do is update the value of field JBANotified on
all records that meeting the following criteria to Y
The criteria is -
WHERE DATEADD(d,JBAPostFor,JBADatePosted) BETWEEN DATEADD(d,
-7, GETDATE()) AND GETDATE() AND JBANotified = 'n' AND JBASiteID =
MMColParam (where MMColParam is Session("SITEID"))
So I've just tried building a command / stored procedure -
which reads (see attached code)(more than likely all wrong)
The things that I cant get my head around are -
Firstly getting the code right in the first place, running
the command on page load and then when the command has run
redirecting to the next page.
I really would appreciate some help with this -
thanks all
Ed Stewart wrote:
> Are you using CS3 with ASP/VBScript? There is a bug in
the command
> implementation that has this function broken.
>
> I asked about it in this forum several months ago, but
now I can't find my
> original post, but I did find another post that talks
about the same thing:
>
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=12&catid=26
> 3&threadid=1281539&enterthread=y
>
> My solution is to drop back to DW8 for command editing,
but use CS3 for
> everything else. I don't know what you're supposed to do
if you don't have an
> earlier version.
>
> It looks like your sql is correct, but the bug prevents
the second code block
> is not being updated with the correct values.
>
> I hope a solution is forthcoming....
>
Create a stored procedure and then use a recordset to
exectute it,
making sure the recordset has matching parameters that the
stored
procedure expects.
Commands are broken, I reported it to Adobe and they said it
might get
fixed in the next version.
Steve
Similar Messages
-
Need Help With a Stored Procedure
Help With a Stored Procedure
Hi everyone.
I am quite new relative to creating stored procedures, so I anticipate that whatever help I could get here would be very much helpful.
Anyway, here is my case:
I have a table where I need to update some fields with values coming from other tables. The other tables, let us just name as tblRef1, tblRef2 and tblRef3. For clarity, let us name tblToUpdate as my table to update. tblToUpdate has the following fields.
PlanID
EmployeeIndicator
UpdatedBy
CreatedBy
tblRef1, tblRef2 and tblRef3 has the following fields:
UserName
EmpIndicator
UserID
In my stored procedure, I need to perform the following:
1. Check each row in the tblToUpdate table. Get the CreatedBy value and compare the same to the UserName and UserID field of tblRef1. If no value exists in tblRef1, I then proceed to check if the value exists in the same fields in tblRef2 and tblRef3.
2. If the value is found, then I would update the EmployeeIndicator field in tblToUpdate with the value found on either tblRef1, tblRef2 or tblRef3.
I am having some trouble writing the stored procedure to accomplish this. So far, I have written is the following:
CREATE OR REPLACE PROCEDURE Proc_Upd IS v_rec NUMBER;
v_plan_no tblToUpdate.PLANID%TYPE;
v_ref_ind tblToUpdate.EMPLOYEEINDICATOR%TYPE;
v_update_user tblToUpdate.UPDATEDBY%TYPE;
v_created_by tblToUpdate.CREATEDBY%TYPE;
v_correct_ref_ind tblToUpdate.EMPLOYEEIDICATOR%TYPE;
CURSOR cur_plan IS SELECT PlanID, EmployeeIndicator, UPPER(UpdatedBy), UPPER(CreatedBy) FROM tblToUpdate;
BEGIN
Open cur_plan;
LOOP
FETCH cur_plan INTO v_plan_no, v_ref_ind, v_update_user, v_created_by;
EXIT WHEN cur_plan%NOTFOUND;
BEGIN
-- Check if v_created_by has value.
IF v_created_by IS NOT NULL THEN
-- Get the EmpIndicator from the tblRef1, tblRef2 or tblRef3 based on CreatedBy
SELECT UPPER(EmpIndicator)
INTO v_correct_ref_ind
FROM tblRef1
WHERE UPPER(USERNAME) = v_created_by
OR UPPER(USERID) = v_created_by;
IF v_correct_ref_ind IS NOT NULL THEN
-- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
ELSIF
-- Check the Other tables here????
END IF;
ELSIF v_created_by IS NULL THEN
-- Get the EmpIndicator based on the UpdatedBy
SELECT UPPER(EmpIndicator)
INTO v_correct_ref_ind
FROM tblRef1
WHERE UPPER(USERNAME) = v_update_user
OR UPPER(USERID) = v_created_by;
IF v_correct_ref_ind IS NOT NULL THEN
-- Update the Reference Indicator Field in the table TRP_BUSPLAN_HDR_T.
UPDATE TRP_BUSPLAN_HDR_T SET ref_ind = v_correct_ref_ind WHERE plan_no = v_plan_no;
ELSIF
-- Check the Other tables here????
END IF;
END IF;
END;
END LOOP;
CLOSE cur_plan;
COMMIT;
END
Please take note that the values in the column tblToUpdate.UpdatedBy or tblToUpdate.CreatedBy could match either the UserName or the UserID of the table tblRef1, tblRef2, or tblRef3.
Kindly provide more insight. When I try to execute the procedure above, I get a DATA NOT FOUND ERROR.
Thanks.Ah, ok; I got the updates the wrong way round then.
BluShadow's single update sounds like what you need then.
I also suggest you read this AskTom link to help you see why you should choose to write DML statements before choosing to write cursor + loops.
In general, when you're being asked to update / insert / delete rows into a table or several tables, your first reaction should be: "Can I do this in SQL?" If you can, then putting it into a stored procedure is usually just a case of putting the sql statement inside the procedure header/footers - can't really get much more simple than that! *{;-) -
I need Help with the stored procedure
Hello, I new with VS.Net
I'm tring to call a stored procedure, but when i try to retrive the data don't return nothing.
my VB code is the follows
ocm_comando.Connection = ocn_coneccion
ocm_comando.CommandText = "WPROC_PRUEBA"
ocm_comando.CommandType = CommandType.StoredProcedure
ocm_comando.Parameters.Add("PNI_ID_ESTUDIO", OracleDbType.Decimal).Direction = ParameterDirection.Input
ocm_comando.Parameters("PNI_ID_ESTUDIO").Value = CType(vc_id_estudio, Integer)
ocm_comando.Parameters.Add("pco_precalificada", OracleDbType.Varchar2).Direction = ParameterDirection.Output
ocm_comando.Parameters.Add("pco_resultado", OracleDbType.Varchar2).Direction = ParameterDirection.Output
Txb_empresa.Text = ocm_comando.Parameters("pco_precalificada").Value
My stored procedure only take the parameter that I sent and make a simple select and return the value in the variable pco_precalificada
thank for your help
**** Sorry for mi EnglishYou forgot to actually execute the command. Before the last line, where you ask for the value of pco_precalificada, you need to:
1. Open the connection (if it's not already open)
2. Call ocm_comando.ExecuteNonQuery()
HTH,
Tom -
Help! Need oracle help with constructing stored procedure that return resultsets
Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
ResultSet rs = cs.executeQuery();
Thats if you build your stored procedure something like this ...
String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
(p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
is
begin
open p_cursor for
select * from suppliers
In which case the above mentioned sun code doesn't work.
We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them?Suns tutorial path for returning resultsets from stored procedures indicates that the following should work...
CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
ResultSet rs = cs.executeQuery();
Thats if you build your stored procedure something like this ...
String createProcedure = "create procedure SHOW_SUPPLIERS " + "as " + "select SUPPLIERS.SUP_NAME, COFFEES.COF_NAME " + "from SUPPLIERS, COFFEES " + "where SUPPLIERS.SUP_ID = COFFEES.SUP_ID " + "order by SUP_NAME";
We are using oracle 8.1.6. However I've been told that with oracle procedures when you return a result set from a called procedure you return a p_cursor variable. Somthing like this
(p_cursor in out SHOW_SUPPLIERS.SHOCurTyp)
is
begin
open p_cursor for
select * from suppliers
In which case the above mentioned sun code doesn't work.
We want to use jdbc to call a stored procedure that returns a resultset that does not require us to import any proprietary oracle objects...
Is there another way to write these stored procedures, rather than using this cursor construct? Are we missing something in the way we invoke them? -
Help with a stored procedure....
i'll be honest, i have never written one, and i have been doing research all day to do one and i have not had much luck. Seems like they mostly all take variables or require data that i just do not want it to require.
I have a query (using TOAD fyi) that is run every morning.... i am trying to make it a stored procedure because i am in the process of automating this for people who want it as opposed to sending it to everyone.
This is the query i am trying to turn into a stored procedure.... (some details removed for sake of security)
SELECT CASE
WHEN stuff
ELSE 'Unknown'
END aging,
a.transaction_type, a.status_code, b.description, a.exception_code,
c.description,
decode(a.exception_code,'XXXX','YYYY',
'XXXX','YYYY',
'XXXX','YYYY','EXCEPTION') "CATEGORY"
,COUNT (*)
FROM (SELECT TO_DATE
(DBMS_LOB.SUBSTR (clob_details,10,DBMS_LOB.INSTR (clob_details,
'<TransactionDate>') + 17 ),'yyyy-mm-dd') receipt_date,
transaction_type, status_code, exception_code
FROM thisdb.TRANSACTION
WHERE status_code = 'MX'
AND clob_details IS NOT NULL) a,
thisdb.status b,
thisdb.EXCEPTIONS c
WHERE a.exception_code = c.exception_code
AND a.status_code = b.status_code
and a.status_code = 'MX'
GROUP BY a.status_code,
b.description,
a.transaction_type,
a.exception_code,
c.description,
CASE
WHEN Stuff
ELSE 'Unknown'
END;
now, please do not worry about the contents of the query, it works nicely and does its job :)
but how can i take this and encapsulate it so that i can turn it into a stored procedure?
Thank you all very much for any and all advice, i do greatly appreciate it!Hi,
user12733751 wrote:
it is just a query, the results will be going to excel later, all that is created already (the connection and runnign basic queries via excel VBA), so perhaps you are right, i do not need a stored procedure but a view?
I have not heard of a view (stored query), how does that work?You create a view once for all like this:
CREATE OR REPLACE VIEW fubar
AS
SELECT CASE
WHEN stuff
... -- the rest of your original query goes here
END;And you use it just like a table:
SELECT *
FROM fubar;A user who runs this last, extremely short, query gets the exact same results as someone who runs your original query.
Here's a completely different approach.
Depending on your front-end, you could also save your original query in a script, called fubar.sql, and people could run it by simply saying
@fubar -
Help with calling stored procedure and preparing statement
hi guys help please..I want to call a procedure set the ResultSet to TYPE_SCROLL_INSENSITIVE and CONCUR_UPDATABLE in order for me to scroll thru the resultset from 1st row to end row and vice-versa..but currently, my code has an error becuase im hot sure on how to do this..Can you please help me guys to solve this? Thanks in advance!
CODE:
int c = 0;
String searchArg = txtSearch.getText();
String studName, mInitial;
searchArg = searchArg.replace('*', '%');
con = FuncCreateDBConnection();
con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}");
*cStmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);*
cStmt.setString("searchArg", searchArg);
cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());
rs = cStmt.executeQuery();
if (rs != null){
listModel = new DefaultListModel();
lstSearchResult.setModel(listModel);
while (rs.next()){
mInitial = rs.getString(4).substring(0, 1).toUpperCase();
studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";
listModel.addElement(studName);
System.out.println("Rows:"+ rs.getString(2));
c++;
ERROR:
Incompatible Types
Found : java.sql.Statement
Required: java.sql.CallableStatementNevermind guys..i got it..
CODE:
int c = 0;
String searchArg = txtSearch.getText();
String studName, mInitial;
searchArg = searchArg.replace('*', '%');
con = FuncCreateDBConnection();
cStmt = con.prepareCall("{call dbsample.usp_StudentInfo_SEARCH(?, ?)}",ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
cStmt.setString("searchArg", searchArg);
cStmt.setString("searchType", cmboSearchBy.getSelectedItem().toString());
rs = cStmt.executeQuery();
if (rs != null){
listModel = new DefaultListModel();
lstSearchResult.setModel(listModel);
while (rs.next()){
mInitial = rs.getString(4).substring(0, 1).toUpperCase();
studName = rs.getString(3) + ", " + rs.getString(2) + " " + mInitial + ".";
listModel.addElement(studName);
System.out.println("Rows:"+ rs.getString(2));
c++;
} Edited by: daimous on Jan 31, 2008 6:04 PM -
Performance problem with java stored procedure
hi,
i developped a java class, then I stored it in Oracle 8.1.7.
This class contains several import of other classes stored in the database.
It works, but the execution perfomances are disappointing. It's very long. I guess, that's because of the great number of classes to load that are necessary for my class execution.
I tried to increase the size of the java pool (I parameter 70 Mo in the java_pool_size parameter of the init.ora), but the performance is not much better.
Has anyone an idea to increase the performance of this execution of my class ?
In particular, is there a way to keep permanently in memory the java objects used by my class ?
Thanks in advance
bye
[email protected]
nullbefore running Java, the database session needs to be Java enabled; this might be the reason why it is taking so long. If this is the case, you should see an improvement in subsequent calls, once a database session is Java enabled, other users can benefit from it.
Kuassi
I have some performance issue with java stored procedure. Hope some one will be able to help me out. I'm using java stored procedures in my application and basically these procedures are used to do some validation and form the XML message of the database tables. I have noticed that when I call the PL/SQL wrapper function, it is taking time to load the java class and once the class is loaded the execution is faster. Most of the time is spent for loading the class rather than executing the function. if I reduce the class load time, I can improve the performance drastically. Do any one of you know how to reduce the class load time. The following are the platform and oracle version.
O/S: IBM AIX
Oracle: 8.1.7 -
Help: using a stored procedure to insert a record in DB
A stored procedure:
PROCEDURE db_insert
db_block IN OUT plsql_table)
is created in DB.
db_select and db_update are created too. They both work fine as
db_select is called by go_block execute_query (block populated) and
db_update is called by commit (DB updated);
I am trying to have db_insert called as:
1. DO_KEY('Create_Record');
2. fill in fields and then
3. commit.
These 3 steps do not cause the call of the auto generated block trigger insert_procedure. I think that after filling in the fields and there should be a way to call this insert_procedure trigger. I am not sure how this will work.
Any suggestions are greatly appreciated.I went through quite a deep search and yet not found any good answers. Knowing that select and update all done well with execute_query(stored procedure is called) and commit(stored procedure is called), but not insert.
Logically there must be some FORM build in that will trigger the call of stored procedure insert.
I am still looking for answers and just to remind that there are quite number of similar posts and I do not think that any clear answers were delivered.
Please help. -
How to verify the user information pass by the form with a stored procedure?
Hi,
I would like to know how to verify user information pass by the form with a stored procedure.
I want make a portal which accepts to new user registration, but I want verify the new user's informations (like the name don't contain a number etc).
Thanks for your help
regards
jlaHi Samson,
You can use the UI API to do this. You can catch the form_ADD event and then validate the input from the users. You can even block the event from completing (and stop the document from being added) if your code finds some incorrect data using the bubbleEvent functionality.
I don't have one specific example to show you, but if you look at some of the SDK samples (for example C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\02.CatchingEvents) to see how to work with events, you can then create your own validation to ensure the users data is valid.
Regards,
Niall -
What is the problem with this Stored Procedure
Hi ,
What is the problem with this Stored Procedure ?Why is it giving errors ??
CREATE or replace PROCEDURE getEmpName
*(EMP_FIRST OUT VARCHAR2(255))*
BEGIN
SELECT ename INTO EMP_FIRST
FROM Emp
WHERE EMPNO = 7369;
END ;
*/*You don't specify precision in procedure arguments.
(EMP_FIRST OUT VARCHAR2(255))should be
(EMP_FIRST OUT VARCHAR2)Since you asked what's wrong with it, I could add that it needs formatting and the inconsistent use of upper and lower case is not helping readability. -
How do I merge data from table1 on server 1 to final table on server 2 with a stored procedure to execute every so
many hours.How big is the table on server B? Is that possible to bring the all data into a server A and merge the data locally?
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How do I merge data from table1 on server 1 to final table on server 2 with a stored procedure to execute every so many hours.
Hello,
If you had configure server2 as
linked server on the server1, you can run the following statement inside stored proceduce to copy table data. And then create a job to the run stored proceduce every 4 hours.
Insert Into Server2.Database2.dbo.Table2
(Cols)
Select Cols From Server1.Database1.dbo.Table1
Or you can use the SQL Server Import and Export Wizard to export the data from server1 to server2, save the SSIS package created by the wizard on the SQL Server, create a job to run the SSIS package.
Reference:http://technet.microsoft.com/en-us/library/ms141209.aspx
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support -
Invoking Unix command with java stored procedure
Hi,
I have a perfectly working environment and now I am trying to replicate the same in another server. I have a java stored procedure which invokes the Unix command using java Runtime.exec() in my code named "run". I am sure that the code is called and the java class run is resolved in oracle as I could see that in dba_java_resolvers dictionary. But I am not sure whether the function in java is called or whether a exception is thrown. how to identify this? Could there be any thing to do with settings in oracle side? please help me.
Thanks in advance,
MaruthaHi,
Do you get any output while running the code?
I'm testing similar solution and if there are any errors or Oracle can't execute the program due to permissions or other issues the error information will be displayed. Also in the Java class itself you need to catch exceptions and print stack trace to standard output.
declare
x number;
begin
dbms_output.enable(1000000);
dbms_java.set_output(1000000);
x:=system_command.run_command('testconnect.sh');
dbms_output.put_line('Returned value='||x);
exception
when others then dbms_output.put_line('Sql error='||substr(sqlerrm,1,250));
end;
<system_command.run_command> - replace with a call to your java stored procedure. -
Need Help in with Querying Stored Procedures from UCCX Database
Hi All
We are trying to build a custom reporting solution using a BI tool and for which we have provided the ODBC connectivity to the UCCX database to our SQL server.
We have installed the ODBC drivers on our SQL server and made a connection to UCCX version 10.0 successfully. we are using the username 'uccxhruser' to connect to the DSN.
We want to query the stored procedure sp_csq_activity from the Microsoft SQL Server Management Studio. When we add the Linked Server in the SQL Server, we are able to see the Data Tables and also query them using the select statement. However, we are not able to see any of the Stored procedures within the Linked Server Tab.
Can someone guide us in the right direction as to how to go about the process. Is calling the stored proedure the right way or we need to query the individual tables as mentioned in the Database Schema Guide and then once the historical tables our there in our server , then build the report.
Any help will be much appreciated.
Regards
AbhinavHi,
what happens if you try to execute the above SP? They should be accessible AFAIK.
G. -
Help Required on Cross Referencing with Oracle Stored Procedure
Hi Experts,
I have a requirement which is having the requirements as follow,
Web Application initially sends a request number to SAP ECC to fetch the response details through SAP PI (HTTP to RFC u2013 Synchronous). While fetching the response from SAP ECC system, SAP PI has to invoke a Oracle Stored Procedure based on some parameter from SAP ECC System and then composited data has to send back to Web Application by SAP PI.
Request you to kindly suggest how to achieve the above. JDBC lookup is not much extended to call stored procedure. It would be helpful if it will be a step by step as I am novice to SAP PI.
Regards
Archanayou might very well have to use a BPM.
open a sync/async bridge ->
do a sync call to RFC ->
Do a sync call to DB (use SP here) ->
do a transformation from the response message of RFC and Response of DB (N:1) to for your response to original caller (http)
Close the sync async bridge using the response message
Maybe you are looking for
-
Hi Apex Experts, I am having application 101(SALES) with APEX 4.2.2, for the same i have configured SSO with clean URL, but when user logged into application it is showing the edit mode URL (Dirty URL). Ex:- Clean URL = https://forums.oracle.com but
-
Important question for reading File
Good morning i need help... any one know 1 class for oper all document? example: http:sitoclient.com/?file?filename.txt or /home/class/filename.txt i need 1 class for open file in all mode where is this class? one class for read file in url or in abs
-
How to arrange albums in CoverFlow of Classic
somebody tell me how to arrange albums in ipod classic's coverflow mode followed by the name of each album, rather than the name of each artist. This is REALLY troublesome when a album has multiple artists. Many thanks
-
List of 3rd party hdds/ssds that do/do not work in the MacBook Pro
Hi everyone, so after following the discussion(s) regarding the problems with hdds in the MacBook Pros after the firmware update I decided to start this thread with the hope that we can create a list of hdds/sdds that do or do not work in the MacBook
-
Has Time Machine really not backed up my iPhoto???
A book project is mysteriously missing from my iPhoto (9), so I thought I'd try to restore it from my Time Machine backup. However, when I selected Browse Backups from the File menu, there doesn't appear to be any previous versions of iPhoto availabl