CreateParameter
Hello All,
I have downloaded 8.02 and now the update statements have
changed to using CreateParameter
I have a problem which I need help with desperately:
I'm inserting into a msSQL data base. a date column
I'm being forced to use
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param3", 135, 1, -1,
MM_IIF(Request.Form("updateDate"), Request.Form("updateDate"),
null)) ' adDBTimeStamp
Request.Form("updateDate") is a hidden form element populated
with <%=now()%>
When the date is updated in the sql database it inserts as
MMDDYYYY however the date is going in as DDMMYYYY
anyone out there know how I can force the date on the server
to Accept DDMMYYYY using the connectionsrting? I think it was
something about GB?
I have added this to my connection string but it's still
inserting wrong?
Language=british;
Similar Messages
-
Help with MM_editCmd.CreateParameter insert syntax please
In the past (I guess older ASP version maybe?), the
automatically generated code that DW created using the "insert
record" wizard allowed for easy editing and debugging within the
SQL. I just installed CS3 and created a similar page and the code
used to build the insert statement is quite different.
Unfortunately, I'm not versed well enough in it yet!
I can see how the SQL insert is being built:
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_wp_STRING
MM_editCmd.CommandText = "INSERT INTO test (FName, LName,
Company, Email, BPhone, BFax, MPhone, Props, regDate, Password,
MBroker, MBID, Status, ARID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
MM_editCmd.Prepared = true
...and then it appears to uses some scripting functions to
build the values and replace the ?'s in the CommandText line:
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param1", 202, 1, 255,
Request.Form("FName")) ' adVarWChar
What I'm struggling with is the values inside each Append
line (202, 1, 255) and what the relate to AND more importantly, how
I can insert my own variable here instead of the form field data.
ex:
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param1", 202, 1, 255, StrMyStringValue)
' adVarWChar
I need help with the syntax. Would it be different if the
variable holds a number value vs. text (assuming the field it's
being inserted into hold numbers)
Also, i USED to be able to add a handly little Response.Write
before the execute insert line that would write the SQL insert
statement to the screen and stop so that I could SEE where the
issues were. I've tried:
Response.Write(MM_editCmd.Parameters)
Response.Write(MM_editCmd.CommandText)
Just can't get the SQL text to display. Is the SQL insert
statement not stored as a variable that i can call?
Thanks VERY much for any help!You can use the concatenate() function to build up your string, as you no doubt know.
As far as the wildcard goes ... your intention must be to try to SET the call variable and later on test the call variable with an IF node. Is that right?
You would be able to test parts of the string using the substr() function - which is based on character position. If that is a fixed value that you know, it's easy. If it's not, you can first use the find() function to locate something (like the "_9"), returning the position, and then use the substr() function to pull it off.
Can you write some pseudo-code here to define exactly your intention? You can set up a dummy script and send a dummy call through using Call Tracer and watch the output to see how your code is working.
Regards,
Geoff -
I have the following code:
<%
If (CStr(Request("MM_insert")) = "form1") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_NewFLSSARDB_STRING
MM_editCmd.CommandText = "INSERT INTO DocumentTable (Title, DocLink, UpdatedBy, UpdateDate, Type, Comments) VALUES (?, ?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("DocumentName")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("DocLocation")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("UpdatedBy")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 135, 1, -1, MM_IIF(Request.Form("UpdatedDate"), Request.Form("UpdatedDate"), null)) ' adDBTimeStamp
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("Type")) ' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 203, 1, 1073741823, Request.Form("Comments")) ' adLongVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "testFLSSARSuperAdminIndex.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
For param2 above I need to add the directory "Docs/" to the command so that the file can be found by the User. How do I do that?If all documents are going to the "/Docs" folder, then I wouldn't include it in the inserted data as you can just add it dynamically where needed. If you do want to include it and it's not part of the posted form data, then just concatenate it (&) prior to inserting into the table.
-
Returning array of values from a PL/SQL stored procedure
I try to run the following example, always happen errors: Run-time error'91' Object variable or With block variable not set.(in line: Set myRS.Source = myCmd1 and Set myRS.Source = myCmd2) Who can tell me where is wrong? I check variable, all set.
Option Explicit
Dim myCnn As ADODB.Connection
Dim myCmd1 As ADODB.Command
Dim myCmd2 As ADODB.Command
Dim myRS As ADODB.Recordset
Dim myConnStr As String
Dim mySQL As String
Dim inputssn As Long
Private Sub cmdGetEveryone_Click()
Dim myLine As String
Set myRS.Source = myCmd1
myRS.Open
myLine = ""
While Not myRS.EOF
myLine = myLine & myRS.AbsolutePosition & " " & _
myRS(0) & ", " & myRS(1) & ", " & myRS(2) & vbCrLf
myRS.MoveNext
Wend
MsgBox myLine
myRS.Close
End Sub
Private Sub cmdGetOne_Click()
Set myRS.Source = myCmd2
inputssn = InputBox("Enter the SSN you wish to retrieve:")
myCmd2(0) = inputssn
myRS.Open
If myRS.RecordCount = 0 Then
MsgBox "No data found"
Else
MsgBox "Person data: " & myRS(0) & ", " & myRS(1) & ", " & myRS(2)
End If
myRS.Close
End Sub
Private Sub Form_Load()
'Using an "On-the-fly" nameless ODBC connection
'Replace <User ID>, <Password>, and <Server> with the
'appropriate parameters.
' myConnStr = "UID=*****;PWD=*****;driver=" _
' & "{Microsoft ODBC for Oracle};SERVER=dseOracle;"
' myConnStr = "UID=CSUPerson;pwd=euclid;driver={Microsoft ODBC for Oracle};SERVER=company;"
'you may also use a named connection DSN such as "myOracleODBC" as follows
myConnStr = "user id=csuperson;password=euclid;DSN=myOracleODBC;"
Set myCnn = New ADODB.Connection
With myCnn
.ConnectionString = myConnStr
.CursorLocation = adUseClient
.Open
End With
'the entry RESULTSET 99 indicates the arguments (ssn, fname, lname)
'are arrays of up to 99 cells each.
'The binding vars (ssn, fname, lname) should be retrieved in VB using a recordSet
mySQL = "{call packperson.allperson({RESULTSET 99, ssn, fname, lname})}"
Set myCmd1 = New ADODB.Command
With myCmd1
Set .ActiveConnection = myCnn
.CommandText = mySQL
.CommandType = adCmdText
End With
mySQL = "{call packperson.oneperson(?,{RESULTSET 2, ssn, fname, " _
& "lname})}"
Set myCmd2 = New ADODB.Command
With myCmd2
Set .ActiveConnection = myCnn
.CommandText = mySQL
.CommandType = adCmdText
.Parameters.Append .CreateParameter(, adInteger, adParamInput)
End With
Set myRS = New ADODB.Recordset
With myRS
.CursorType = adOpenStatic
.LockType = adLockReadOnly
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
myCnn.Close
Set myCnn = Nothing
Set myCmd1 = Nothing
Set myCmd2 = Nothing
Set myRS = Nothing
End Sub
Package:
PACKAGE packperson AS
TYPE tssn is TABLE of NUMBER(10)
INDEX BY BINARY_INTEGER;
TYPE tfname is TABLE of VARCHAR2(15)
INDEX BY BINARY_INTEGER;
TYPE tlname is TABLE of VARCHAR2(20)
INDEX BY BINARY_INTEGER;
PROCEDURE allperson
(ssn OUT tssn,
fname OUT tfname,
lname OUT tlname);
PROCEDURE oneperson
(onessn IN NUMBER,
ssn OUT tssn,
fname OUT tfname,
lname OUT tlname);
END packperson;
BODY:
PACKAGE BODY packperson
AS
PROCEDURE allperson
(ssn OUT tssn,
fname OUT tfname,
lname OUT tlname)
IS
CURSOR person_cur IS
SELECT ssn, fname, lname
FROM employee;
percount NUMBER DEFAULT 1;
BEGIN
FOR singleperson IN person_cur
LOOP
ssn(percount) := singleperson.ssn;
fname(percount) := singleperson.fname;
lname(percount) := singleperson.lname;
percount := percount + 1;
END LOOP;
END;
PROCEDURE oneperson
(onessn IN NUMBER,
ssn OUT tssn,
fname OUT tfname,
lname OUT tlname)
IS
CURSOR person_cur IS
SELECT ssn, fname, lname
FROM employee
WHERE ssn = onessn;
percount NUMBER DEFAULT 1;
BEGIN
FOR singleperson IN person_cur
LOOP
ssn(percount) := singleperson.ssn;
fname(percount) := singleperson.fname;
lname(percount) := singleperson.lname;
percount := percount + 1;
END LOOP;
END;
END;DB table:
CREATE TABLE EMPLOYEE
(FNAME VARCHAR2(15) NOT NULL,
MINIT CHAR,
LNAME VARCHAR2(15) NOT NULL,
SSN VARCHAR2(9) NOT NULL,
BDATE DATE,
ADDRESS VARCHAR2(30),
SEX CHAR,
SALARY NUMBER(10,2),
SUPERSSN VARCHAR2(9),
DNO NUMBER NOT NULL,
PRIMARY KEY(SSN));
DESC EMPLOYEE;
INSERT INTO EMPLOYEE VALUES
('John','B', 'Smith', '123456789','09-JAN-65',
'731 fONDREN, hOUSTON, TX', 'M', 30000, '333445555',5);
INSERT INTO EMPLOYEE VALUES
('Frankin','T', 'Wong', '333445555','08-DEC-55',
'683 Voss, Houston,Tx', 'M', 40000, '888665555',5);
INSERT INTO EMPLOYEE VALUES
('Alicia','J', 'Zelaya', '999887777','19-JUL-68',
'3321Castle, Spring, TX', 'F',25000 , '987654321',4);
INSERT INTO EMPLOYEE VALUES
('Jennifer','S', 'Wallace', '987654321','20-JUN-41',
'291 Berry, Bellaire, TX', 'F',43000 , '888665555',4);
INSERT INTO EMPLOYEE VALUES
('Ramesh','K', 'Narayan', '666884444','15-SEP-62',
'975 Fire Oak, Humble, TX', 'F',38000 , '333445555',5);
INSERT INTO EMPLOYEE VALUES
('Joyce','A', 'English', '453453453','31-JUL-72',
'5631 Rice,Houston,TX', 'F',25000 , '333445555',5);
INSERT INTO EMPLOYEE VALUES
('Ahmad','V', 'Jabbar', '987987987','29-MAR-69',
'980 Dallas,Houston, TX', 'M',25000 , '987654321',4);
INSERT INTO EMPLOYEE VALUES
('James','E', 'Borg', '888665555','10-NOV-37',
'450 Stone, Houston, TX', 'M',55000 , null,1);All help I will appreciat it.I can't comment on the problem returning PL/SQL arrays, but I will suggest that a more appropriate method of achieving your goal is to call a procedure which returns a REF CURSOR.
See the examples here:
http://asktom.oracle.com/~tkyte/ResultSets/index.html -
Upload image to directory and data to database from the same form
Hello all
I'm playing at building a shopping cart (never done one
before) from a tutorial by Gordon Knapp at www.webthang.com.
I have created the site and it works perfectly. Now I want to
extend it.
There is a form that allows the user to add data to the
database. I would also like to be able to upload an image to a
directory on the server and add the data to the database at the
same time from the same form. It would be good if the input field
"<input name="product_picture" type="text" id="product_picture"
tabindex="6" size="50" />" could be populated automatically by
the filename of the image being uploaded, but this isn't a
neccessity.
I have looked at various ASP Upload packages and I can upload
an image alone but none of them make it clear how to upload the
image and add data to the database at the same time.
As this is a private project I need any suggestions to by
free.
The tutorial shows how to create the site in Ultra Dev but
worked perfectly well in DW. The page concerned looks like this. It
is named 'admin_add.asp':
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../Connections/con_ecom.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" &
Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "add_form") Then
If (Not MM_abortEdit) Then
' execute the insert
Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_con_ecom_STRING
MM_editCmd.CommandText = "INSERT INTO products
(product_category, product_name, product_price, product_briefdesc,
product_fulldesc, product_picture) VALUES (?, ?, ?, ?, ?, ?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param1", 202, 1, 50,
Request.Form("product_category")) ' adVarWChar
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param2", 202, 1, 50,
Request.Form("product_name")) ' adVarWChar
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param3", 5, 1, -1,
MM_IIF(Request.Form("product_price"),
Request.Form("product_price"), null)) ' adDouble
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param4", 203, 1, 536870910,
Request.Form("product_briefdesc")) ' adLongVarWChar
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param5", 203, 1, 536870910,
Request.Form("product_fulldesc")) ' adLongVarWChar
MM_editCmd.Parameters.Append
MM_editCmd.CreateParameter("param6", 202, 1, 50,
Request.Form("product_picture")) ' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_editRedirectUrl
MM_editRedirectUrl = "admin_control.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0)
Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" &
Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" &
Request.QueryString
End If
End If
Response.Redirect(MM_editRedirectUrl)
End If
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Administration - Add Product</title>
<link href="../scripts/admin.css" rel="stylesheet"
type="text/css" />
<script type="text/javascript"
src="../scripts/ecom.js"></script>
</head>
<body onLoad="adminTitle()">
<div id="wrapper">
<div id="pageHeading">ADMINISTRATION - ADD
PRODUCT</div>
<div id="navBar"><a
href="admin_control.asp">Control</a> | Add | <a
href="admin_view.asp">View</a> | <a
href="admin_update1.asp">Update</a> | <a
href="admin_delete1.asp">Delete</a> | <a
href="../Default.asp">Shop</a></div>
<br />
<form name="add_form" id="add_form" method="POST"
action="<%=MM_editAction%>">
<table border="1" align="center" id="tblArea">
<tr>
<td class="tdLabel">Product Category</td>
<td colspan="2"><input name="product_category"
type="text" id="product_category" tabindex="1" size="50"
/></td>
</tr>
<tr>
<td class="tdLabel">Product Name</td>
<td colspan="2"><input name="product_name"
type="text" id="product_name" tabindex="2" size="50"
/></td>
</tr>
<tr>
<td class="tdLabel">Product Price</td>
<td class="tdContent" colspan="2"><input
type="text" name="product_price" id="product_price" tabindex="3"
size="50" /></td>
</tr>
<tr>
<td class="tdLabel">Product Short
Desciption</td>
<td class="tdContent" colspan="2"><textarea
name="product_briefdesc" id="product_briefdesc" cols="47" rows="4"
tabindex="4"></textarea></td>
</tr>
<tr>
<td class="tdLabel">Product Full
Description</td>
<td class="tdContent" colspan="2"><textarea
name="product_fulldesc" id="product_fulldesc" cols="47" rows="5"
tabindex="5"></textarea></td>
</tr>
<tr>
<td class="tdLabel">Product Image File Name</td>
<td class="tdContent" colspan="2"><input
name="product_picture" type="text" id="product_picture"
tabindex="6" size="50" /></td>
</tr>
<tr>
<td class="tdLabel"> </td>
<td align="center"><input type="reset" name="Reset"
id="Reset" value="Reset Form" /></td>
<td align="center"><input type="submit"
name="Submit" id="Submit" value="Add To Shop" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="add_form"
/>
</form>
</div>
</body>
</html>
Hope you can help.
Warm regards
MartinGot it sorted.
Found an excellent tutorial at Webthang.
http://www.webthang.co.uk/tuts/tuts_dmx/rob15/rob15.asp -
How can I use a button to trigger a SQL Stored Procedure?
I have a stored procedure (UpdateAdsUsers) that performs updates on multiple tables all tied together with one
parameter - @username
(I'm using DWCS5, SQL SERVER 2008, ASP VB)
UPDATE users SET defaultview='0' WHERE user_name=@username
UPDATE db_settings SET valuestr='MM/DD/YYYY' WHERE keyword='dateformat' AND user_name=@username
UPDATE db_settings SET valuestr='Y' WHERE keyword='COPY_MSG_VIA_EMAIL' AND user_name=@username
UPDATE db_settings SET valuestr='4' WHERE keyword='web_download_rend' AND user_name=@username
UPDATE db_settings SET valuestr='Y' WHERE keyword='cpy_confirm' AND user_name=@username
UPDATE db_settings SET valuestr='WLPG:12' WHERE keyword='INITIAL_ASSETS' AND user_name=@username
UPDATE db_settings SET valuestr='20' WHERE keyword='thumb_disp_row' AND user_name=@username
UPDATE db_settings SET valuestr='20' WHERE keyword='text_disp_row' AND user_name=@username
UPDATE db_settings SET valuestr='5' WHERE keyword='para_disp_row' AND user_name=@username
UPDATE db_settings SET valuestr='a.editorial.company_name' WHERE keyword='sortorder1' AND user_name=@username
UPDATE db_settings SET valuestr='a.editorial.title' WHERE keyword='sortorder2' AND user_name=@username
UPDATE db_settings SET valuestr='a.editorial.production_type' WHERE keyword='sortorder3' AND user_name=@username
UPDATE tnailview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='adsx_type', fourth_field='adsx_status' WHERE user_name=@username
UPDATE textview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='title_desc', fourth_field='production_type', fifth_field='audio_summary', sixth_field='totalruntime', seventh_field='adsx_type', eighth_field='adsx_status' WHERE user_name=@username
UPDATE paraview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='title_desc', fourth_field='production_type', fifth_field='audio_summary', sixth_field='totalruntime', seventh_field='adsx_type', eighth_field='adsx_status' WHERE user_name=@username
SELECT * FROM adsx_preferences WHERE user_name=@username
This functions perfectly in SQL.
Using Dreamweaver CS5, I've added the Procedure as a Command (ADS_User) with the one variable (@username).
<%
set ADS_User = Server.CreateObject("ADODB.Command")
ADS_User.ActiveConnection = MM_ADSX_STRING
ADS_User.CommandText = "dbo.UpdateAdsUser"
ADS_User.Parameters.Append ADS_User.CreateParameter("@RETURN_VALUE", 3, 4)
ADS_User.Parameters.Append ADS_User.CreateParameter("@username", 129, 1,32,ADS_User__username)
ADS_User.CommandType = 4
ADS_User.CommandTimeout = 0
ADS_User.Prepared = true
ADS_User.Execute()
%>
In a perfect world, either an image click or a form submit would run the procedure. The parameter (@username) is currently sent to the page as a URL Querystring of the same name.
I'm sure it's something obvious, but I'm new.
Thanks in advanceI'm not sure what your question is. Is this currently failing? Or are you not able to figure out how to send the username to the script page? You really just need to create a form and pass the value in a form field.
>The parameter (@username) is currently sent to
>the page as a URL Querystring of the same name.
Never use a querystring to update data. It is too dangerous. Use the post method instead. -
How to call a Oracle Stored Procedure from Excel?
Hi,
I am new to Oracle database programming.I have an application in excel which has to update info in every row to the database.I am calling a stored procedure in excel for this.The stored procedure is as follows which is executing without a hitch in Oracle:
CREATE OR REPLACE PROCEDURE APD_MASS_UPLOAD_UNITS
(PRODUCT_ID VARCHAR2,Product_Code VARCHAR2, str_Adpt_Grp VARCHAR2,str_Adpt_Type VARCHAR2,
str_PDC VARCHAR2,str_Release_ID VARCHAR2,str_Created_by VARCHAR2,
str_Last_Updated_By VARCHAR2, dt_created_Date VARCHAR2,dt_Last_Updated_Date VARCHAR2,
StrMonth1 VARCHAR2,strMth2 VARCHAR2,StrMth3 VARCHAR2,StrMth4 VARCHAR2,
StrMth5 VARCHAR2,StrMth6 VARCHAR2,Sample Varchar2,str_message OUT Varchar2)
AS
type Month_type is table of VARCHAR2(10) index by binary_integer;
str_month Month_Type;
Fac_ID VARCHAR2(20);
Org_ID VARCHAR2(20);
Cnt_Units NUMBER;
i_POS NUMBER;
i_Month NUMBER;
i_UNITS NUMBER;
CURSOR C1 IS
SELECT * FROM TBLLINE_ADOPT_PLAN WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_Adpt_Grp AND ADOPT_TYPE = str_Adpt_Type
AND RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
CURSOR C2 IS
SELECT FACILITY_ID FROM TBLADOPT_GROUP_CSC WHERE ADOPT_GROUP = str_Adpt_Grp;
CURSOR C3 IS
SELECT ORG_ID FROM APD_DV_PRODUCT_V WHERE SPEC_ID = Product_ID;
CURSOR C4 IS
SELECT * FROM TBLPROD_CSC WHERE PROD_SPEC_ID = Product_ID;
Adopt_Rec C1%ROWTYPE;
Fac_Rec C2%ROWTYPE;
PMORG_REC C3%ROWTYPE;
CSC_Rec C4%ROWTYPE;
i_Count NUMBER;
Message VARCHAR2(20);
BEGIN
Message := APD_SPECID_VALIDATE(Product_ID,Product_code,Str_PDC, str_Release_ID);
IF TRIM(Message) is null then
OPEN C1;
FETCH C1 INTO Adopt_Rec;
IF C1%NOTFOUND THEN
INSERT INTO TBLLINE_ADOPT_PLAN (SPEC_ID,ADOPT_GROUP, ADOPT_TYPE,RELEASE_ID, SAMPLES,CREATED_BY,CREATED_DATE, LAST_UPDATED_BY,LAST_UPDATED_DATE,SAMPLE_ONLY_IND, GRID_TYPE_CD) VALUES
(Product_ID,str_Adpt_Grp ,str_Adpt_Type,
APD_Get_Release_ID(str_PDC,str_Release_Id), 0,str_Created_By,
TO_DATE(dt_Created_Date,'DD/MM/YYYY'),str_Last_Updated_By,
TO_DATE(dt_Last_Updated_Date,'DD/MM/YYYY'),'N','C');
END IF;
CLOSE C1;
str_Month(1) := strMonth1;
str_Month(2) := strMth2;
str_Month(3) := strMth3;
str_Month(4) := strMth4;
str_Month(5) := strMth5;
str_Month(6) := strMth6;
OPEN C2;
FETCH C2 INTO Fac_REC;
Fac_ID := Fac_Rec.FACILITY_ID;
CLOSE C2;
OPEN C3;
FETCH C3 INTO PMORG_Rec;
Org_ID := PMORG_Rec.Org_ID;
CLOSE C3;
OPEN C4;
FETCH C4 INTO CSC_Rec;
IF C4%NOTFOUND THEN
INSERT INTO TBLPROD_CSC(PROD_SPEC_ID,CSC_FACILITY_ID, PROFIT_CENTER_CD,DEFAULT_IND, CREATED_BY, CREATED_DATE, LAST_UPDATED_BY, LAST_UPDATED_DATE) VALUES
(Product_ID , Fac_ID,Org_id, 'N', str_Created_by ,
To_date ( dt_Created_Date,'DD/MM/YYYY') ,str_Last_updated_by ,
To_Date (dt_Last_Updated_Date ,'DD/MM/YYYY'));
END IF;
CLOSE C4;
IF Sample > 0 Then
UPDATE TBLLINE_ADOPT_PLAN
SET SAMPLES = Sample
WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_adpt_grp AND
ADOPT_TYPE = str_Adpt_Type AND
RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
END IF;
str_Message := 'Updated';
END IF;
END;
The code to call the stored procedure in Excel is as follows:
Dim Conn As New ADODB.Connection
Dim InputParam1 As New ADODB.Parameter
Dim InputParam2 As New ADODB.Parameter
Dim InputParam3 As New ADODB.Parameter
Dim InputParam4 As New ADODB.Parameter
Dim InputParam5 As New ADODB.Parameter
Dim InputParam6 As New ADODB.Parameter
Dim InputParam7 As New ADODB.Parameter
Dim InputParam8 As New ADODB.Parameter
Dim InputParam9 As New ADODB.Parameter
Dim InputParam10 As New ADODB.Parameter
Dim InputParam11 As New ADODB.Parameter
Dim InputParam12 As New ADODB.Parameter
Dim InputParam13 As New ADODB.Parameter
Dim InputParam14 As New ADODB.Parameter
Dim InputParam15 As New ADODB.Parameter
Dim InputParam16 As New ADODB.Parameter
Dim InputParam17 As New ADODB.Parameter
Dim InputParam18 As New ADODB.Parameter
Dim OutputParam As New ADODB.Parameter
Dim Mth1, Mth2, Mth3, Mth4, Mth5, Mth6 As String
Dim Rs_data As New ADODB.Recordset
Conn.ConnectionString = ("Provider=MSDAORA.1;User ID=" & "cnbg" & ";PASSWORD=" & "cnbg" & ";Data Source=" & "DAQ01" & ";Persist Security Info=False")
Conn.Open
OraCmd.ActiveConnection = Conn
OraCmd.CommandText = "APD_MASS_UPLOAD_UNITS"
OraCmd.CommandType = adCmdStoredProc
Conn.CursorLocation = adUseClient
OraCmd.Parameters.Refresh
Set InputParam1 = OraCmd.CreateParameter("Product_ID", adVarChar, adParamInput, 20)
InputParam1.Value = spec_id
Set InputParam2 = OraCmd.CreateParameter("Product_code", adVarChar, adParamInput, 20)
InputParam2.Value = str_product_code
Set InputParam3 = OraCmd.CreateParameter("str_Adpt_Type", adVarChar, adParamInput, 10)
InputParam3.Value = Adopt_Group
Set InputParam4 = OraCmd.CreateParameter("str_Adpt_Type", adVarChar, adParamInput, 10)
InputParam4.Value = Adopt_Type
Set InputParam5 = OraCmd.CreateParameter("str_pdc", adVarChar, adParamInput, 10)
InputParam5.Value = ThisWorkbook.strDbPDC
Set InputParam6 = OraCmd.CreateParameter("str_Release_ID", adVarChar, adParamInput, 10)
InputParam6.Value = str_Release_Id
Set InputParam7 = OraCmd.CreateParameter("str_created_by", adVarChar, adParamInput, 10)
InputParam7.Value = ThisWorkbook.User_Name
Set InputParam8 = OraCmd.CreateParameter("str_last_updated_by", adVarChar, adParamInput, 10)
InputParam8.Value = ThisWorkbook.User_Name
Set InputParam9 = OraCmd.CreateParameter("dt_created_date", adVarChar, adParamInput, 10)
InputParam9.Value = Sheet1.Cells(8, 2)
Set InputParam10 = OraCmd.CreateParameter("dt_Last_Updated_Date", adVarChar, adParamInput, 10)
InputParam10.Value = Sheet1.Cells(8, 2)
Set InputParam11 = OraCmd.CreateParameter("strMonth1", adVarChar, adParamInput, 10)
InputParam11.Value = Mth1
Set InputParam12 = OraCmd.CreateParameter("strMth2", adVarChar, adParamInput, 10)
InputParam12.Value = Mth2
Set InputParam13 = OraCmd.CreateParameter("strMth3", adVarChar, adParamInput, 10)
InputParam13.Value = Mth3
Set InputParam14 = OraCmd.CreateParameter("strMth4", adVarChar, adParamInput, 10)
InputParam14.Value = Mth4
Set InputParam15 = OraCmd.CreateParameter("strMth5", adVarChar, adParamInput, 10)
InputParam15.Value = Mth5
Set InputParam16 = OraCmd.CreateParameter("strMth6", adVarChar, adParamInput, 10)
InputParam16.Value = Mth6
Set InputParam17 = OraCmd.CreateParameter("Sample", adInteger, adParamInput, 10)
InputParam17.Value = 0
Set InputParam18 = OraCmd.CreateParameter("str_message", adVarChar, adParamOutput, 10)
OraCmd.Parameters.Append InputParam1
OraCmd.Parameters.Append InputParam2
OraCmd.Parameters.Append InputParam3
OraCmd.Parameters.Append InputParam4
OraCmd.Parameters.Append InputParam5
OraCmd.Parameters.Append InputParam6
OraCmd.Parameters.Append InputParam7
OraCmd.Parameters.Append InputParam8
OraCmd.Parameters.Append InputParam9
OraCmd.Parameters.Append InputParam10
OraCmd.Parameters.Append InputParam11
OraCmd.Parameters.Append InputParam12
OraCmd.Parameters.Append InputParam13
OraCmd.Parameters.Append InputParam14
OraCmd.Parameters.Append InputParam15
OraCmd.Parameters.Append InputParam16
OraCmd.Parameters.Append InputParam17
OraCmd.Parameters.Append InputParam18
Set Rs_data = New ADODB.Recordset
Set Rs_data = OraCmd.Execute
I am getting an error at this point which
ORA-06550:line 1,column 54:
PLS-00103:Encountered the symbol ">" when expecting one of the following:
. ( ) * @ % & = - + < / > at in is mod not rem
<an exponent(**)> <> or != or ~= or >= <= <> and or like
between ||
Can anyone pls help me?Thanks.You do not need to code an explicit cursor for a single fetch. An implicit cursor is less code to write, read, maintain and execute.
E.g. Instead of all this:
CURSOR C2 IS
SELECT FACILITY_ID FROM TBLADOPT_GROUP_CSC WHERE ADOPT_GROUP = str_Adpt_Grp;
OPEN C2;
FETCH C2 INTO Fac_REC;
Fac_ID := Fac_Rec.FACILITY_ID;
CLOSE C2;
Simply code this:SELECT
Fac_Rec.FACILITY_ID INTO Fac_ID
FROM BLADOPT_GROUP_CSC
WHERE ADOPT_GROUP = str_Adpt_Grp;PL/SQL procedure calls have to be made (to Oracle) as anonymous PL/SQL blocks. This means that you need to wrap the procedure call into BEGIN..END tags.
So instead of coding this:
OraCmd.CommandText = "APD_MASS_UPLOAD_UNITS"
You need to code something like:
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS; END;"
However, this will not work as APD_MASS_UPLOAD_UNITS expects a bunch of input parameters. And you're on the right track about attempting to bind your Excel variables' values to the PL/SQL procedure's parameters.
Unsure how ADO works, but typically you can bind by name or by position. Let's assume bind by position (typically in PHP):
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS( ?, ?, ?, ?, ?. ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); END;"
Then you will bind values to positions 1 to 18 (did I count the number of params right?). Something like:
OraCmd.CreateParameterByPosition( 1, adVarChar, adParamInput, 20)
Or you can bind by name. E.g.
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS( :pid, :pcode, ..etc.. ); END;"
And:
OraCmd.CreateParameterByName( 'pid', adVarChar, adParamInput, 20)
Read up on your OraCmd.CreateParameter() to see how to correctly use it.
A few more comments. 18 parameters in a call is something I would seriously reconsider. It is quite easy to get it wrong - transpose two parameters. It is very difficult to read and check. Very difficult to maintain. It is much safer to rather define a %ROWTYPE structure to pass, or a PL/SQL record structure.
You are passing date values as VARCHAR2. Rather pass the parameter as the correct data type. E.g.
create or replace procedure foo( custID number, invoiceDate date )...
And then when you call it (in your client code), you specify the date string and date format and make it into a date. E.g.
OraCmd.CommandText = "begin foo( :myCust, TO_DATE(:myDateString,:myDateFormat) ); end;" -
Not able to retrive the recordset from oracle stored procedure in VC++
Hi,
I am trying to retrieve the records from the reference cursor which is an out parameter for an oracle 9i store procedure in VC++ application. But it is giving the record count as -1 always. Meanwhile i am able to get the required output in VB application from the same oracle 9i store procedure .
Find the code below which i used.
Thanks,
Shenba
//// Oracle Stored Procedure
<PRE lang=sql>CREATE OR REPLACE
PROCEDURE GetEmpRS1 (p_recordset1 OUT SYS_REFCURSOR,
p_recordset2 OUT SYS_REFCURSOR,
PARAM IN STRING) AS
BEGIN
OPEN p_recordset1 FOR
SELECT RET1
FROM MYTABLE
WHERE LOOKUPVALUE > PARAM;
OPEN p_recordset2 FOR
SELECT RET2
FROM MYTABLE
WHERE LOOKUPVALUE >= PARAM;
END GetEmpRS1;</PRE>
///// VC++ code
<PRE lang=c++ id=pre1 style="MARGIN-TOP: 0px">ConnectionPtr mpConn;
_RecordsetPtr pRecordset;
_CommandPtr pCommand;
_ParameterPtr pParam1;
//We will use pParam1 for the sole input parameter.
//NOTE: We must not append (hence need not create)
//the REF CURSOR parameters. If your stored proc has
//normal OUT parameters that are not REF CURSORS, you need
//to create and append them too. But not the REF CURSOR ones!
//Hardcoding the value of i/p paramter in this example...
variantt vt;
vt.SetString("2");
m_pConn.CreateInstance (__uuidof (Connection));
pCommand.CreateInstance (__uuidof (Command));
//NOTE the "PLSQLRSet=1" part in
//the connection string. You can either
//do that or can set the property separately using
//pCommand->Properties->GetItem("PLSQLRSet")->Value = true;
//But beware if you are not working with ORACLE, trying to GetItem()
//a property that does not exist
//will throw the adErrItemNotFound exception.
m_pConn->Open (
bstrt ("Provider=OraOLEDB.Oracle;PLSQLRSet=1;Data Source=XXX"),
bstrt ("CP"), bstrt ("CP"), adModeUnknown);
pCommand->ActiveConnection = m_pConn;
pParam1 = pCommand->CreateParameter( bstrt ("pParam1"),
adSmallInt,adParamInput, sizeof(int),( VARIANT ) vt);
pCommand->Parameters->Append(pParam1);
pRecordset.CreateInstance (__uuidof (Recordset));
//NOTE: We need to specify the stored procedure name as COMMANDTEXT
//with proper ODBC escape sequence.
//If we assign COMMANDTYPE to adCmdStoredProc and COMMANDTEXT
//to stored procedure name, it will not work in this case.
//NOTE that in the escape sequence, the number '?'-s correspond to the
//number of parameters that are NOT REF CURSORS.
pCommand->CommandText = "{CALL GetEmpRS1(?)}";
//NOTE the options set for Execute. It did not work with most other
//combinations. Note that we are using a _RecordsetPtr object
//to trap the return value of Execute call. That single _RecordsetPtr
//object will contain ALL the REF CURSOR outputs as adjacent recordsets.
pRecordset = pCommand->Execute(NULL, NULL,
adCmdStoredProc | adCmdUnspecified );
//After this, traverse the pRecordset object to retrieve all
//the adjacent recordsets. They will be in the order of the
//REF CURSOR parameters of the stored procedure. In this example,
//there will be 2 recordsets, as there were 2 REF CURSOR OUT params.
while( pRecordset !=NULL ) )
while( !pRecordset->GetadoEOF() )
//traverse through all the records of current recordset...
long lngRec = 0;
pRecordset = pRecordset->NextRecordset((VARIANT *)lngRec);
//Error handling and cleanup code (like closing recordset/ connection)
//etc are not shown here.</PRE>It can be linked to internal conversion. In some case, the value of internal or extranal value is not the same.
When you run SE16 (or transaction N), you have in option mode the possibility to use the exit conversion or not.
Christophe -
Hi all,
We have a table like this:
create table tblSales
(sku varchar2(100),
selling_date date,
sales_vol integer
);Records in this table will be like this:
SKU1 15-JUL-07 300
SKU2 15-JUL-07 400
SKU3 15-JUL-07 500
SKU4 15-JUL-07 600
SKU1 16-JUL-07 500
SKU2 16-JUL-07 600
SKU3 16-JUL-07 700
SKU4 16-JUL-07 800
SKU1 17-JUL-07 250
SKU2 17-JUL-07 300
SKU3 17-JUL-07 550
SKU4 17-JUL-07 480I want the output like:
SKU 15-JUL-02 16-JUL-02 17-JUL-02 18-JUL-02
SKU1 300 500 250 0
SKU2 400 600 300 0
SKU3 500 700 550 0
SKU4 600 800 480 0I am using Oracle 10.1.02 and PL/SQL developer as developing tool. I have found a piece of code from AskTom which is very helpful as below:
create or replace procedure get_query(p_start date, p_end date, p_cursor out SYS_REFCURSOR)
is
l_query long := 'select sku ';
begin
for i in 1 .. trunc(p_end)-trunc(p_start) + 1
loop
l_query := l_query || ', sum( decode( trunc(selling_date), ' ||
'to_date( ''' || to_char(p_start+i-1,'dd/mm/yyyy') ||
''', ''dd/mm/yyyy'' ), sales_vol, 0 )) "' ||
to_char(p_start+i-1) || '"';
end loop;
l_query := l_query || ' from tblSales group by sku';
open p_cursor for l_query;
end;when I ran the procedure in SQL plus, i was able to get the desired output.
SQL>
SQL> set autoprint on
SQL> variable x refcursor
SQL> exec get_query(to_date('19/06/2005', 'dd/mm/yyyy'), to_date('21/06/2005', 'dd/mm/yyyy'), :x);
SKU_BKEY 19-JUN-05 20-JUN-05 21-JUN-05
1235074 0 0 0
1113006 0 0 0
1217230 0 0 0
6552011 0 0 0
6012969 3607 0 0
6029089 1956 0 0
6030825 20098 0 0
6017078 11273 0 0
6265298 5318 0 0
6297515 10504 0 0
1458 150523 0 0But I can't produce the same output in PL/SQL developer. Why?
SQL> variable x refcursor
REFCURSOR not supported
SQL> exec get_query( :x,to_date('19/06/2005', 'dd/mm/yyyy'), to_date('21/06/2005', 'dd/mm/yyyy'));
begin get_query( :x,to_date('19/06/2005', 'dd/mm/yyyy'), to_date('21/06/2005', 'dd/mm/yyyy')); end;
Cursor variable :X cannot be nil
x
0
SHow can I use this result set. I need to create a report based on this in VBA excel via ADO connection. Is there a way I can export the output to a temp table, and do the select from the temp table. The problem is the columns must be always dynamic, based on the date that user provided. Any idea how can I achieve this?
Thanks very much for your time and help.
Pete
Message was edited by:
lcpx
Message was edited by:
lcpx
Edited by: jkestely on Sep 29, 2008 2:49 PMHi,
Thanks very much for your time. I tried to store the ref_cursor in Recordset of VB base on the example you gave, have been spending days but couldn't make this work. Here is my code:
Public Sub PopulateData()
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command
Dim par1, par2 As ADODB.Parameter
Dim pStartDate, pEndDate As Date
pStartDate = "19/06/2005"
pEndDate = "19/07/2005"
Set conn = New ADODB.Connection
conn.Open "Driver={Microsoft ODBC for Oracle};" & _
"Server=dwl;" & _
"Uid=scott;" & _
"Pwd=tiger"
Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandText = "get_query"
cmd.CommandType = adCmdStoredProc
Set par1 = cmd.CreateParameter("p_start", adDate, adParamInput)
par1.Value = pStartDate
cmd.Parameters.Append par1
Set par2 = cmd.CreateParameter("p_end", adDate, adParamInput)
par2.Value = pEndDate
cmd.Parameters.Append par2
Set rst = New ADODB.Recordset
Set rst = cmd.Execute
Sheet1. Cells(4, 1).CopyFromRecordset rst
Set cmd = Nothing
Set par1 = Nothing
Set par2 = Nothing
rst.Close
Set rst = Nothing
conn.Close
Set conn = Nothing
End Sub
I am getting an "ODBC Drive does not support the requested properties" error on the Set rst = cmd.Execute line of code.
Thanks again!
Message was edited by:
lcpx -
Help with multiple recordsets and pulling an ID value (ASP)
I started this discussion when first developing my project and posted on the General Tab. I have figured out that issue (trying to get my Insert to work in ASP) but now am having trouble retrieving an ID value. It should be simple. I want to insert a new record into a single table and want to create a unique ID field. I am using SQL Server and tried the Identity setting but won't be able to have admin privileges which are required to set the ID. So, I'd like to just take the ID value from the last record and just add '1' to it to get a new unique ID manually. My INSERT portion was working, so I just decided to query the records to retrieve the last CatalogID and add '1' to get my new ID. But it's not working! I tried opening both a command and a recordset, but get various errors on invalid command use.
Any help would be great! I'm new to all of this!
I've posted a code snippet of what I thought I should do:
<%LANGUAGE = “VBSCRIPT” CODEPAGE=”65001”%)
<!--#include file=”Connections/CapConnect.asp”” -->
<%
If (Cstr(Request(“MM_insert”)) = “form1”) Then
Dim MM_editCmd
Dim MM_Lookup
Dim NextCatalogID
Set MM_Lookup = Server.CreateObject (“ADOB.Recordset”)
MM_Lookup.ActiveConnection = MM_CapConnect_STRING
MM_Liikup.Source = “Select CatalogID From dbo.tblCatalogItems ORDERBY CatalogID Ascending”
MMLookup.Open
MM_Lookup.MoveLast
NextCatalogID = MM_Lookup.Fields(“CatalogID”) + 1 'this is supposed to be my new ID value
Set MM_Lookup = Nothing
Set MM_editCmd = Server.CreateObject(“ADOB.Command”)
MM_editCmd.ActiveConnection = MM_CapConnect_STRING
MM_editcmd.CommandText = “INSET INTO dbo.tblCatalogItems (CatalogID, ModelName, Description, POCName, [POCPhone]) VALUES (NextCatalogID, ?,?,?,?)
MM_editcmd.Prepared = True
MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param2”, 202, 1, 100, Request.Form(“modelname”) )
MM_edit.Parameters.Append MM_editcmd.CreateParameter(“param3”, 202, 1, 300, Request.Form(“Description”) )
[Subject line edited by moderator to add server model]Ok, you've got lots of problems. First, explain again why you are not able to modify the CatologID to be an identity column? What is the datatype of that column now?
Next, you are going about selecting your recordset incorrectly. If you are just looking for the last value inserted, there is no need to return all values to the recordset. Just select the max value:
MM_Liikup.Source = “Select MAX (CatalogID) From dbo.tblCatalogItems”
Next, you have a typo in your insert statement "“INSET INTO" should be "INSERT INTO"
Next, your CommandText is wrong. There is no ending quote, and NextCatalogID will be treated as a string literal, not a variable. Use a ? placeholder for it and use the CreateParameter method to populate it.
Next, your command text includes 4 placeholder, but you are only populating 2.
But even when you get this to work it will be problematic. What happens when 2 users execute this at the same time? They both read the same value for the max record and increment by one, but the first will succeed and the second will fail. That's why it is always better to use an auto increment (Identity) column. -
Custom Data Processing Extension and Parameters
Hello,
I have successfully implemented a custom data processing extension. Now I'm trying to add parameters, but the documentation is very weak on this topic. Also all examples of custam data processing extensions I have found so far are working without parameter support. Using a search engine I have found a custom data processing extension's sequence diagram during report execution. The related article also gives some hints about the IDbCommandAnalysis interface.
The GetParameters implementation creates a parameter collection based on the current command text and returns this collection. So far no problem.
My question is how to implement the IDbCommand's CreateParameter method and Parameters property? In CreateParameter I just return a new instance of my IDataParameter implementation, and the Parameters property returns a new parameter collection based on the current command text.
Is this ok so? At least this is the first implementation which seems to work in the data designer. If I share an instance variable for GetParameters and Parameters I will either get all parameters twice or BIDS will crash when pressing the execute button in the dataset designer - depending on my actual implementation.
What I'm still missing is how to get the parameters added automaticall to the dataset's properties parameter register?
thanx in advance and kind regards, GeraldI think that finally (after some days of trying) I could make it work. The dataset and report parameters are reflecting the command text's parameters now (BTW: to answer my last question - the dataset's properties are updated after pressing the refresh button only). The road to success was not to use the same member variable for the collections returned by IDbCommandAnalysis:GetParameters() and IDbCommand:Parameter and not to fill the latter one with the command text's parameters (see partial source code below).
public sealed class MyCommand : IDbCommand, IDbCommandAnalysis
private string m_commandText;
private MyParameterCollection m_parameters = new MyParameterCollection();
public string CommandText
get { return this.m_commandText; }
set { SetCommandText(value); }
public IDataParameterCollection Parameters
get { return m_parameters; }
public IDataParameter CreateParameter()
return new MyParameter();
public IDataParameterCollection GetParameters()
return GetParameterCollection();
private void SetCommandText(string commandText)
m_commandText = commandText;
private MyParameterCollection GetParameterCollection()
// ... create parameter collection based on m_commandText
Still there are some open questions:
How can I update the report parameter's properties? Now the parameter's data type is always string, but I'd like to assign the right data type. I'd also like to tag the parameters as hidden and supply a non-queried default value. Is this possible? How?
Although I my implementation of IDbCommandAnalysis:GetParameters() returns a collection containing the parameter names and values the "prompt query parameters" dialog (after pressing the query designer's execute button in the toolbar) shows a "<blank>" value for the parameters. What could be the problem?
Thanx in advance and regards,
Gerald -
Page Numbering w/ASP and Dreamweaver CS3
I am new to this so please bear with me if this question has been asked a million times. I have a single search parameter searching for a "Department", the result displays on the next page (The Results page). This works fine. I am using DW CS3 and I am now finding out that when I use it with ASP it only allows the Previous, Next, First, Last, Specific records to be displayed.
I really want it to display the total amount of pages by numbers Example: (1-10, 11-21, etc...). Can someone please help me? I have searched the web and came across this site http://www.dmxzone.com/go?12449. I am not following where to put the code he suggest. Can someone please help me?
Thanks for any help in advance.
Here is the asp code I have for my Results page:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/BishopsLogin.asp" -->
<%
Dim rs_Results__MMColParam
rs_Results__MMColParam = "1"
If (Request.QueryString("Department") <> "") Then
rs_Results__MMColParam = Request.QueryString("Department")
End If
%>
<%
Dim rs_Results
Dim rs_Results_cmd
Dim rs_Results_numRows
Set rs_Results_cmd = Server.CreateObject ("ADODB.Command")
rs_Results_cmd.ActiveConnection = MM_BishopsLogin_STRING
rs_Results_cmd.CommandText = "SELECT Department, SubpageTitle, LinkDescription, URL, DateLastModified FROM dbo.Episcopal_Data_Files WHERE Department = ?"
rs_Results_cmd.Prepared = true
rs_Results_cmd.Parameters.Append rs_Results_cmd.CreateParameter("param1", 200, 1, 30, rs_Results__MMColParam) ' adVarChar
Set rs_Results = rs_Results_cmd.Execute
rs_Results_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = 5
Repeat1__index = 0
rs_Results_numRows = rs_Results_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
Dim rs_Results_total
Dim rs_Results_first
Dim rs_Results_last
' set the record count
rs_Results_total = rs_Results.RecordCount
' set the number of rows displayed on this page
If (rs_Results_numRows < 0) Then
rs_Results_numRows = rs_Results_total
Elseif (rs_Results_numRows = 0) Then
rs_Results_numRows = 1
End If
' set the first and last displayed record
rs_Results_first = 1
rs_Results_last = rs_Results_first + rs_Results_numRows - 1
' if we have the correct record count, check the other stats
If (rs_Results_total <> -1) Then
If (rs_Results_first > rs_Results_total) Then
rs_Results_first = rs_Results_total
End If
If (rs_Results_last > rs_Results_total) Then
rs_Results_last = rs_Results_total
End If
If (rs_Results_numRows > rs_Results_total) Then
rs_Results_numRows = rs_Results_total
End If
End If
%>
<%
Dim MM_paramName
%>
<%
' *** Move To Record and Go To Record: declare variables
Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined
Dim MM_param
Dim MM_index
Set MM_rs = rs_Results
MM_rsCount = rs_Results_total
MM_size = rs_Results_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter
if (Not MM_paramIsDefined And MM_rsCount <> 0) then
' use index parameter if defined, otherwise use offset parameter
MM_param = Request.QueryString("index")
If (MM_param = "") Then
MM_param = Request.QueryString("offset")
End If
If (MM_param <> "") Then
MM_offset = Int(MM_param)
End If
' if we have a record count, check if we are past the end of the recordset
If (MM_rsCount <> -1) Then
If (MM_offset >= MM_rsCount Or MM_offset = -1) Then ' past end or move last
If ((MM_rsCount Mod MM_size) > 0) Then ' last page not a full repeat region
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If
' move the cursor to the selected record
MM_index = 0
While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
If (MM_rs.EOF) Then
MM_offset = MM_index ' set MM_offset to the last possible record
End If
End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range
If (MM_rsCount = -1) Then
' walk to the end of the display range for this page
MM_index = MM_offset
While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
' if we walked off the end of the recordset, set MM_rsCount and MM_size
If (MM_rs.EOF) Then
MM_rsCount = MM_index
If (MM_size < 0 Or MM_size > MM_rsCount) Then
MM_size = MM_rsCount
End If
End If
' if we walked off the end, set the offset based on page size
If (MM_rs.EOF And Not MM_paramIsDefined) Then
If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
If ((MM_rsCount Mod MM_size) > 0) Then
MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
Else
MM_offset = MM_rsCount - MM_size
End If
End If
End If
' reset the cursor to the beginning
If (MM_rs.CursorType > 0) Then
MM_rs.MoveFirst
Else
MM_rs.Requery
End If
' move the cursor to the selected record
MM_index = 0
While (Not MM_rs.EOF And MM_index < MM_offset)
MM_rs.MoveNext
MM_index = MM_index + 1
Wend
End If
%>
<%
' *** Move To Record: update recordset stats
' set the first and last displayed record
rs_Results_first = MM_offset + 1
rs_Results_last = MM_offset + MM_size
If (MM_rsCount <> -1) Then
If (rs_Results_first > MM_rsCount) Then
rs_Results_first = MM_rsCount
End If
If (rs_Results_last > MM_rsCount) Then
rs_Results_last = MM_rsCount
End If
End If
' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth
Dim MM_removeList
Dim MM_item
Dim MM_nextItem
' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If
MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""
' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
End If
Next
' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
MM_nextItem = "&" & MM_item & "="
If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
End If
Next
' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "") Then
MM_keepURL = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If
' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
If (firstItem <> "") Then
MM_joinChar = "&"
Else
MM_joinChar = ""
End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links
Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev
Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam
MM_keepMove = MM_keepBoth
MM_moveParam = "index"
' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 1) Then
MM_moveParam = "offset"
If (MM_keepMove <> "") Then
MM_paramList = Split(MM_keepMove, "&")
MM_keepMove = ""
For MM_paramIndex = 0 To UBound(MM_paramList)
MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
End If
Next
If (MM_keepMove <> "") Then
MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
End If
End If
End If
' set the strings for the move to links
If (MM_keepMove <> "") Then
MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If
MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="
MM_moveFirst = MM_urlStr & "0"
MM_moveLast = MM_urlStr & "-1"
MM_moveNext = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
MM_movePrev = MM_urlStr & "0"
Else
MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
nbArr[nbArr.length] = img;
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) {
img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr)
for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
//-->
</script><script language="JavaScript" src="mm_menu.js"></script>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body onLoad="MM_preloadImages('images/nav_about_on.gif','images/nav_departments_on.gif','image s/nav_calendar_on.gif','images/nav_links_on.gif','images/nav_contact_on.gif','images/nav_h ome_on.gif','images/nav_forms_on.gif')">
<script language="JavaScript1.2">mmLoadMenus();</script>
<div align="center">
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#ffffff" valign="top">
<td><a href="index.html"><img src="images/logobar_left.gif" alt="GCFA: Serving the Church through the ministry of administration" width="186" height="103" border="0" /></a><img src="images/blurb.gif" alt="General Council on Finance and Administration. The United Methodist Church" /></td>
</tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0" height="20">
<form method="get" action="http://google.umc.org/search" name="xxx">
<tr height="20" style="vertical-align: middle;">
<td bgcolor="#000000" width="580"><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('about','','images/nav_about_on.gif',1)"><img src="images/nav_about.gif" alt="About Us" name="about" width="70" height="20" border="0" id="about" onMouseOver="MM_showMenu(window.mm_menu_0523125900_0,0,20,null,'about')" onMouseOut="MM_startTimeout();" /></a><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('departments','','images/nav_departments_on.gif',1)"><img src="images/nav_departments.gif" alt="Departments & Services" name="departments" width="146" height="20" border="0" id="departments" onMouseOver="MM_showMenu(window.mm_menu_0516155917_0,0,20,null,'departments')" onMouseOut="MM_startTimeout();" /></a><a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('forms','','images/nav_forms_on.gif',1)"><img src="images/nav_forms.gif" alt="Forms/Reports" name="forms" width="105" height="20" border="0" id="forms" onMouseOver="MM_showMenu(window.mm_menu_0523125955_0,0,20,null,'forms')" onMouseOut="MM_startTimeout();" /></a><a href="calendar.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('calendar','','images/nav_calendar_on.gif',1)"><img src="images/nav_calendar.gif" alt="UM Calendar" name="calendar" width="89" height="20" border="0" id="calendar" /></a><a href="links.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('links','','images/nav_links_on.gif',1)"><img src="images/nav_links.gif" alt="Helpful Links" name="links" width="39" height="20" border="0" id="links" /></a><a href="contactus.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contact','','images/nav_contact_on.gif',1)"><img src="images/nav_contact.gif" alt="Contact Us" name="contact" width="78" height="20" border="0" id="contact" /></a><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('home','','images/nav_home_on.gif',1)"><img src="images/nav_home.gif" alt="Home" name="home" width="38" height="20" border="0" id="home" /></a></td>
<td bgcolor="#990000" width="51" align="center" style="font: 11px arial, helvetica, sans-serif; color: #ffffff;"><img src="images/btn_search.gif" alt="Search" width="51" height="20" /></td>
<td bgcolor="#990000"><input name="q" type="text" size="15" style="font: 10px arial, helvetica, sans-serif;"/></span></td>
<td width="33" bgcolor="#990000"><input type="image" name="submit" src="images/btn_go.gif" alt="GO!" width="31" height="20" /></td>
</tr>
<input type="hidden" name="sort" value="date:D:L:d1">
<input type="hidden" name="output" value="xml_no_dtd">
<input type="hidden" name="ie" value="UTF-8">
<input type="hidden" name="oe" value="UTF-8">
<input type="hidden" name="client" value="GCFA_GCFAorg_Frontend">
<input type="hidden" name="proxystylesheet" value="GCFA_GCFAorg_Frontend">
<input type="hidden" name="site" value="GCFA_GCFAorg_Collection">
</form>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<td height="353" style="background-color: #dddddd; width: 150px;">
<table width="150" border="0" cellspacing="0" cellpadding="0">
<tr style="background-color: #990000;" height="25">
<td style="font: bold 11px arial, helvetica, sans-serif; color: #ffffff; text-align: center;">Department Resources</td>
</tr>
<tr>
<td><div style="font: 11px arial, helvetica, sans-serif; color: #000000; text-align: left; margin-left: 10px; margin-right: 10px; margin-bottom: 5px; margin-top: 5px;">
<p>PDF documents require using the<span class="style5"><a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank"> latest version</a> </span>of the freely available Adobe Reader for proper viewing. Click on
the <span class="style5"><a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank">Get Adobe Reader</a></span> link below for
download and installation instructions. <br />
<br />
<a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank"><img src="images/get_adobe_reader.gif" alt="Get Adobe Reader" width="112" height="33" border="0" /></a></span><br>
<a href="images/get_adobe_reader.gif" target="_blank"></a><br />
</p>
</div></td>
</tr>
<tr style="background-color: #3C5D15;" height="25">
<td bgcolor="#DDDDDD" style="font: bold 12px arial, helvetica, sans-serif; color: #ffffff; text-align: center;"> </td>
</tr>
<tr>
<td>
<div style="font: 11px arial, helvetica, sans-serif; color: #000000; text-align: left; margin-left: 10px; margin-right: 10px; margin-bottom: 5px; margin-top: 5px;">
<p><br />
<br />
<br />
</p>
</div> </td>
</tr>
</table>
<p> </p></td>
<td style="background-color: #000000; width: 2px;"><img src="images/pixel_black.gif" width="2" height="10" /></td>
<td bordercolor="#FFFFFF" bgcolor="#FFFFFF" style="background-color: #ffffff; width: 610px;">
<div style="margin-left: 20px; margin-right: 20px; margin-bottom: 20px; margin-top: 5px;">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td height="285" align="left" valign="top"><p><font face="Arial" color="#990000"><span style="font-size: 16px; font-weight: 700">Episcopal Services Data Files</span></font></p>
<p><font face="Arial" color="#990000"><span style="font-size: 16px; font-weight: 700"><br />
</span></font>
</p>
<br />
<%
While ((Repeat1__numRows <> 0) AND (NOT rs_Results.EOF))
%>
<table border="0" cellpadding="1" cellspacing="1">
<tr>
<td width="132" height="27" bgcolor="#DDDDDD"><div align="center"><strong>Department</strong></div></td>
<td width="371" bgcolor="#DDDDDD"><%=(rs_Results.Fields.Item("Department").Value)%></td>
</tr>
<tr>
<td height="22"><div align="center"><strong>Subpage Title</strong></div></td>
<td><%=(rs_Results.Fields.Item("SubpageTitle").Value)%></td>
</tr>
<tr>
<td height="26" bgcolor="#DDDDDD"><div align="center"><strong>Link Description</strong></div></td>
<td bgcolor="#DDDDDD"><%=(rs_Results.Fields.Item("LinkDescription").Value)%></td>
</tr>
<tr>
<td height="25"><div align="center"><strong>Date Last Modified</strong></div></td>
<td><%=(rs_Results.Fields.Item("DateLastModified").Value)%></td>
</tr>
<tr>
<td height="26" bgcolor="#DDDDDD"><div align="center"><strong>URL</strong></div></td>
<td bgcolor="#DDDDDD"><%=(rs_Results.Fields.Item("URL").Value)%></td>
</tr>
</table>
<br />
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs_Results.MoveNext()
Wend
%>
<%
rs_Results.Close()
Set rs_Results = Nothing
%>Please ignore my first post, it isn't right.
I am new at this, although I did figure out the tutorial it still isn't what I am wanting. I am going to send an example page of want I my page to look like when I said page numbering (I don't want first,prev,next, or last). I want numbers like the results you will get from this page. http://www.gcfa.org/Department_Resources.aspx Can I do this with ASP?
If so so can someone please show me how? Thanks in advance. Maybe I have the right question this time. -
Using stored procedures with a timestamp parameter with Delphi and ADO
Dear Oracle experts,
I have a problem concerning using a stored procedure with Delphi.
I try to use a stored procedure which hast two input parameters ( a integer and a timestamp).
The timestamp parameter is my problem since I would like to use the "to_timestamp"
Oracle-function to create the timestamp parameter to be inserted into my procedure.
If I insert the to_timestamp statement as a adodatetime I have to perform the conversion to the oracle timestamp in my application.
If I want to use the to_timestamp statement I have to use the ftstring datatype but in that case I get an error because I use a string as input for my procedure were it awaits a timestamp.
So the problem seems to be that the function call "to_timestamp" is not interpreted if it is transferred through my ADO component.
Do you know how to use a procedure with Delphi (ADO) with a function as input parameter ?
Best regards,
Daniel Wetzler
P.S. :
This is the Delphi code to use my Procedure.
FactsTempDS:=TADODataset.Create(nil);
Sproc1 := TAdoStoredProc.Create(nil);
Sproc1.Connection := TDBConnection(strlistConnectionstrings.objects[iConnectionIndex]).Connection;
Sproc1.ProcedureName := 'ECSPACKAGE.PROCFINDINITIALSWITCHSTATE';
Sproc1.Parameters.CreateParameter ('SwitchID',ftInteger,pdinput,0,0);
//Sproc1.Parameters.CreateParameter ('StartTime',ftdatetime,pdinput,50,0);
Sproc1.Parameters.CreateParameter ('StartTime',ftString,pdinput,50,0);
Sproc1.Parameters.Findparam('SwitchID').value:=SwitchID;
Sproc1.Parameters.FindParam('StartTime').Value:= 'to_timestamp(''2005/12/30 19:36:21'', ''YYYY/MM/DD HH:MI:SS'')';
Sproc1.CursorType := ctKeyset;
Sproc1.ExecuteOptions:=[];
Sproc1.Open;
Sproc1.Connection := nil;
FactsTempDS.Recordset:= sproc1.Recordset;
if FactsTempDS.RecordCount=0
then raise Exception.Create('No line switch variable found for switch '+IntToStr(SwitchID)+' before starttime. Check BDE dump filter.')I have my entity manager setup in a singleton.
I'm finding it's costly to generate the emf, but if I don't close the em (enitity manager) and emf (entity manager factory) my open cursor count climbs until I exceed the max number of open cursors on the database (11g RAC)
I'm committing the connection, and uow, and closing the em at the end of each call.
But until I close the emf, the open cursors aren't released.
TransactionhistoryPkg tranPkg = new TransactionhistoryPkg(conn); //Class created over database package via JPublisher
tranPkg.transactionhistoryInsSp(insertTrans.getCardId()); // executes db package
tranPkg.closeConnection();
conn.commit();
uow.commit();
uow.getAccessor().decrementCallCount();
em.close();
Am I missing something really obvious here??
btw - I found this link helpful in troubleshooting the max cursors issue: https://support.bea.com/application_content/product_portlets/support_patterns/wls/InvestigatingORA-1000MaximumOpenCursorsExceededPattern.html -
SQL Injection, replace single quote with two single quotes?
Is replacing a single quote with two single quotes adequate
for eliminating
SQL injection attacks? This article (
http://www.devguru.com/features/kb/kb100206.asp
) offers that advice, and it
enabled me to allow users to search name fields in the
database that contain
single quotes.
I was advised to use "Paramaterized SQL" in an earlier post,
but I can't
understand the concept behind that method, and whether it
applies to
queries, writes, or both.Then you can use both stored procedures and prepared
statements.
Both provide better protection than simply replacing
apostrophes.
Prepared statements are simple:
Set myCommand = Server.CreateObject("ADODB.Command")
...snip...
myCommand.CommandText = "INSERT INTO Users([Name], [Email])
VALUES (?, ?)"
...snip...
myCommand.Parameters.Append
myCommand.CreateParameter("@Name",200,1,50,Name)
myCommand.Parameters.Append
myCommand.CreateParameter("@Email",200,1,50,Email)
myCommand.Execute ,,128 'the ,,128 sets execution flags that
tell ADO not to
look for rows to be returned. This saves the expense of
creating a
recordset object you don't need.
Stored procedures are executed in a similar manner. DW can
help you with a
stored procedure through the "Command (Stored Procedure)"
server behavior.
You can see a full example of a prepared statement by looking
at DW's
recordset code after you've created a recordset using version
8.02.
"Mike Z" <[email protected]> wrote in message
news:eo5idq$3qr$[email protected]..
>I should have repeated this, I am using VBScript in ASP,
with an Access DB.
> -
DBMS_XMLSave issues with different databases
This is a brainteaser...
I have set up a couple of stored procedures in a package that inser / update and delete values in a database table using the DBMS_XMLSave functions as per the article 'Using XML-SQL Utility (XSU), 24 of 26' and re-use the context handle.
This is being used for an ASP application and as such I am using the Oracle 8.1.7 OLEDb provider and passing the XML string as a clob to the stored procedures using a command object.
I am now moving the application to another database in preparation for it going to staging and have come across a very interesting error. On the old database everything worked correctly, though on this new database (same IIS server) when i try to insert, update or delete on any table using the XML functions i get the following error:
Unable to insert the details. SQL ERROR:[ORA-29532: Java call terminated by uncaught Java exception: oracle.xml.sql.OracleXMLSQLException: Expected name instead of ??.]
Using the same ASP i connected to the old database and successfully ran the page, i change it to the new database and get the above error.
However I can successfully execute the stored procedure from a command prompt (TOAD) on the new database.
I have done some digging and found that it might have something to do with the NLS settings in the database.
if i change the NLS registry key (HKEY_LOCAL_MACHINE\Software\Oracle\HOME0\NLS_LANG) from AMERICAN_AMERICA.WE8ISO8859P1 to AMERICAN_AMERICA.UTF8 on the IIS server i am running my ASP from, i can get both to return the same error though the question marks turn upside down.
Here's an example of the sample code i am using. Note how i have to convert a CLOB to a string and back to a CLOB. This was because originally Oracle would not accept CLOBS from ASP (as the createParameter method did not really have a clob datatype but did have a longvarchar though Oracle recognises it as a clob because i can do clob operations on it. If anyone has an idea to get around this could you tell me as well?)
Here's a snippit of the package i use
saveCtx := DBMS_XMLSave.newContext('USER_FAVOURITE'); -- create the context once..!
DBMS_XMLSave.setKeyColumn(saveCtx, 'FAVOURITE_ID'); -- set the key column name.
PROCEDURE insert_XML(
o_result OUT NUMBER,
o_result_msg OUT VARCHAR2,
xmlDoc in clob
) is
e_processing_error EXCEPTION;
v_processing_msg VARCHAR2(1990);
v_result_msg VARCHAR2(1990);
insXML CLOB;
BEGIN
-- Create a temp LOB as an input parameter
DBMS_LOB.CREATETEMPORARY(insXML,TRUE);
-- Write the XML doc to the LOB
DBMS_LOB.WRITE(insXML, DBMS_LOB.GETLENGTH(xmlDoc), 1, DBMS_LOB.SUBSTR(xmlDoc, 32767));
rows := DBMS_XMLSave.insertXML(saveCtx, insXML);
-- Free the LOB space in memory
DBMS_LOB.FREETEMPORARY(insXML);
END;XSU don't suppose to support databases other than Oracle.
Maybe you are looking for
-
Using Web Service as Data source (Pluggable Data Source) in Oracle Reports
Anyone using Webservice as a pluggable data source in oracle 10g reports.(Report builder version:10.1.2.0.2)? We need to be able to use web service as one of the data source to create reports.Tried the following and ran into issues: Imported the wspd
-
I am looking for an app, for my ipod, that allows me to speak into the ipod and then it translates what I said into a different language. Any suggestions?
-
My 13inch Macbook Pro 2012 model randomly forced me to restart (OS X Lion). Is this something to be concerned about?
-
Problem creating CalculationView using Eclipse on MacOSX
Hi guys, I'm trying to follow the steps of tutorial Using HANA Modeler in SAP HANA Cloud Platform, but it's giving a error when creating the Join of SO_CV view when running on MacOS Leopard. When I link the tables SNWD_BPA and SNWD_SO the link is
-
Will I lose all my settings if I have to restore my iPhone 4?
I was updating my phone via a computer then wifi crashed now my iPhone 4 is stuck with a picture of a cable pointing towards the iTunes symbol. I connected it back to my computer hoping it would start updating again but it tells me I have to restore