Using a substitution variable to pull data from a table
Hello,
I am working with a simple program that asks the user to enter any info that will relate to a table in the db.
Thus far I have read 1,000 ways to accomplish this, and none of them work.
PROMPT
ACCEPT var PROMPT 'Enter var'
DECLARE
BEGIN
SELECT &var
FROM &table
WHERE var=tablevar;
END;
Thanks for the feedback. Though I understand your logic, it doesn't seem to properly apply here. This is a more detailed explanation of what I've done.
First, I create the table
CREATE TABLE starbright
(planet_num VARCHAR2(3),
planet VARCHAR2(20));
INSERT INTO starbright VALUES
(257, 'Neptune');
INSERT INTO starbright VALUES
(367, 'Venus');
INSERT INTO starbright VALUES
(586, 'Mars');
INSERT INTO starbright VALUES
(725, 'Earth');Now, with that table created, I want to be able to periodically use PL/SQL to call data from the table, such as below
DECLARE
p_no := '&planet_num';
BEGIN
INSERT p_no
INTO starbright;
SELECT planet_num
INTO p_no
FROM starbright
WHERE planet_num := p_no;
dbms_output.put_line( 'Result: ' || planet );
END;This is my generic error
Error report:
ORA-06550: line 2, column 6:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
constant exception <an identifier>
<a double-quoted delimited-identifier> table LONG_ double ref
char time timestamp interval date binary national character
nchar
The symbol "<an identifier>" was substituted for "=" to continue.
ORA-06550: line 6, column 8:
PLS-00103: Encountered the symbol "P_NO" when expecting one of the following:
into <a SQL statement>
ORA-06550: line 11, column 18:
PLS-00103: Encountered the symbol "=" when expecting one of the following:
. ( * @ % & = - + ; < / > at for in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
LIKE4_ LIKEC_ between group h
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Similar Messages
-
Using ABAP DATA FLOW to pull data from APO tables
I am trying to use an ABAP Data flow to pull data from APO and receive error 150301. I can do a direct table pull and receive no error, but when I try to put it in an ABAP data data flow I get the issue. Any help would be great.
Hi
I know you "closed" this, however someone else might read it so I'll add that when you use an ABAP dataflow, logic can be pushed to ECC - table joins, filters, etc. (Which can be seen in the generated ABAP).
Michael -
Pull data from a table in HTML format from external URL into a Servlet
How do I pull data from existing website html table into a Servlet?
I will need to pull the data into a servlet. So, the servelet will need to go to the URL and get the data and save them as variables.
I know I will need an array to store the data. I just dont know how to call the URL and have the servelet search the site for the <table> </table>.
I will later use this to save to a database.
Thanks
Edited by: DJMegabit on Apr 14, 2010 7:36 PMMaybe give us more details about what exactly You'd like to achieve. I guess that there might be better solutions to the problem.
-
Pull data from SQL Table and display it in mail
I have a requirement to pull the data from SQL table and send it in email. Currently I am sending the hard coded info in email but is it possible to pull some data from SQL Table and than format it and send it across in the same email?
Can you guide me with steps on this.
NeilThere are several ways to do this. First is to populate a file in a data flow and then send that as an attachment in the send mail task.
As far as including the results in the email body this becomes a bit trickier. To use a variable you would need to use an SSIS variable type of
Object, this is similar to a collection in .NET. The problem once the object is populated is that it isn't like a readable result set, but again more like an array or a collection. There is no native method to take the object variable and
specify .ToString() or cast its results as text. You would need to iterate through each row and append it to another variable of type string, this could be done with a script task or ForEach container.
Also you mentioned formatting the results. What type of formatting were you looking for. A limitation of the SMTP send mail task is that the message body doesn't support HTML so if you were looking at creating a table within the mail body you
would have to use a script task or a custom component
David Dye My Blog -
Is there any datasource available to pull data from NAST table?
The field I am trying to pull out of NAST (Message Status) table is NACHA. Please provide me hints if any Business Content Datasource uses this table or we have to create a custom extractor for the same?
Regards,
JoyI dont think there is a standard business content datasource to extract data from NAST table. If you are going to use this data in some other LO modules based on the requirement enhance the datasource and append fields and write code to populate the message types.
If you are going to use this as stand alone data, then you can go ahead and create a generic datasource based on table. -
Do I have to use lock when I am reading data from a table
Hi,
When i am reading data from a table , do I have to set a lock on that table .
Is it necessary for us to set the lock on a table when I am reading data from the table.
When I am updating the table , do I have to set a lock on the table ?
If yes, then what sort of lock-read lock,write lock or shared lock?
Regards,
Sushanth H.S.check it out,
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further accesses from the
same transaction.
You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
You have to use these function module in your program.
check this link for example.
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
tables:vbak.
call function 'ENQUEUE_EZLOCK3'
exporting
mode_vbak = 'E'
mandt = sy-mandt
vbeln = vbak-vbeln
X_VBELN = ' '
_SCOPE = '2'
_WAIT = ' '
_COLLECT = ' '
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3
if sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
1. enque_lockobject
1. deque_lockobject
before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
Select the radio button "Lock object"..
Give the name starts with EZ or EY..
Example: EYTEST
Press Create button..
Give the short description..
Example: Lock object for table ZTABLE..
In the tables tab..Give the table name..
Example: ZTABLE
Save and generate..
Your lock object is now created..You can see the LOCK MODULES..
In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
Reward if helpful -
Unable to pull data from 2 tables of a database linked to a 2nd database
I have a Crystal V7 Report I'm upgrading to Crystal 10 or 11. It uses the following formula that works (data is in ONE MS Access database containing all three tables):
If {PayrollCalc.qSource}=0 then {AuthorizedWithholding.qDesc
else If {PayrollCalc.qSource}=1 or {PayrollCalc.qSource}= 2 then {UnionBenefitDetail.qUBDesc}
else
If {PayrollCalc.qSource}=4 then "Extra Tax" + {PayrollCalc.qID} else
If {PayrollCalc.qSource}=5 then "Payroll Insurance" else
If {PayrollCalc.qSource}=6 then {PayrollCalc.qID} else
Mid ({PayrollCalc.qID},2 )
The upgraded application software uses TWO SQL 2005 Express databases, replacing the one Access database. PayrollCalc is a table in database A while UnionBenefitDetail & AuthorizedWithholding are tables in database B. The links are left outer joined from PayrollCalc table to each of the others (I've tried all the enforcement options) but the formula no longer works. If I remark out the part of the formula from one or the other of the "extra" tables, then the one still active works great but I can't get both to work in the same subreport. There's no error, I just get a blank returned for the formula. I'm not familiar with using the Add Command so I haven't tried that. Can anyone help me?I confirmed that the join fields are identical:
PRCalc Table - qConNo=int (32 bit), length 4
PRCalc Table - qID=varchar (byte), length 10
PRCalc Table - qSeg=int (32 bit), length 4
UnionBenefit Table - qUBID=varchar (byte), length 10
UnionBenefit Table - qUBSeg=int (32 bit), length 4
Both of these UnionBenefit fields are left outer joined FROM the PRCalc Table's qID & qSeg fields
Authorized Withholding - qConNo=int (32 bit), length 4
Authorized Withholding - qSeg=int (32 bit), length 4
These two fields are left outer joined FROM PRCalc's qConNo & qSeg fields.
The qDesc & qUBDesc fields that I'm trying to print in the same subreport using the formula that's not working are both varchar (bye), length 50 fields.
I have tried various other joins unsuccessfully. I'm convinced that the left outer join is the correct one to use since neither of the tables from Database B will always have records that match up with those in Database A (PayrollCalc's database). So yes, it appears that the left outer join does not work properly across two databases when more than one table in the 2nd database is used. It works fine if I just use one table from database B & do a separate subreport for the other table. -
How to Pull Data From CRT table PCL2 Cluster
Hi,
I want to show a Report, below is the Fields in the Report
<b>Descripton</b>----
<b>Table Name</b>
Total Current Month Salary----
CRT table PCL2 cluster
monthly member contribution-----CRT table PCL2 cluster
Net difference in Pay----
CRT table PCL2 cluster
How to get the Data from the CRT table PCL2 cluster in BW
is there any procedure to get the payroll data in BW?
I think CRT table is a internal Table.
any good idea's will be appricated...
Thanks
PriyaHi,
check whether is it populating when u call
Function Module - PYX X_READ_PAYROLL_RESULT .
If not Use this Marcro.
RP-IMP-C2-IN.
Call this macro and check EPF[ ].This marco will populate both RT and EPF.
Check transaction - PC00_M40_ EPF
Cheers,
Manoj. -
Using a caculated field to get data from another table.
I have a Products Table that I need to add a field to. This field gains data from a Supplier table by using the supplier code to find the correct supplier type. All Products have a Supplier Code. So for example in SQL this would be a simple where statement looking something like this.
SELET Supplier.Type
From Supplier , Product
Where Supplier.Code = Product.SupplierCode
And ProductID = someID
How would you write this as a caculated field in MDM?Hi Chauncey
My previous post seems to have disappeared into the ether, so here it is again.
If you only want to do this linking for display purposes, then consider the following possibility:
The main Products table has a field which looks up to the flat table Suppliers. The flat table Suppliers has a field that either A) looks up to a flat SupplierTypes table or B) is a normal field in which the supplier type is stored. Inside the flat Suppliers table, just set both the SupplierCode and SupplierType fields to be display fields. MDM will automatically display both pieces of data inside the single field in the Products table.
If you need the SupplierType in a separate field then you cannot do this with an expression (calculation or assignment.) You'll need to write a piece of code using one of the MDM APIs in order to do this lookup.
HTH,
Mark -
Need Help Pulling Data from Oracle Table (Newby)
Let me start of by saying I'm very new to Java so the code may be messy/poorly coded (I'm trying!). However, I've come a long way already and the code is almost working (it compiles and returns what I expect in one case). What I'm trying to do is prompt the user to enter a type, then a key. I use that type to determine the SQL statement to use then I use the key as part of the SQL statement.
If I enter 'custnum' as the type, then a string as my key, it finds the record fine.
If I any of my other valid types (lname, address or phone) and then enter my key, the result set is empty. I've verified that there are matching records for the type/key I'm entering.
I've tried stepping it through the debugger and looking at various variables along the way both with the working scenario and the not-working scenario, but I can't find anything. I'm sure it's a simple coding mistake, but I don't really know how to track it down.
Any ideas on what's going wrong would be greatly appreciated. Thanks!
//Start code
import java.sql.*;
import java.util.Scanner;
public class AccessCustomerTable
private static final String DEFAULT_DRIVER = "oracle.jdbc.driver.OracleDriver";
private static final String DEFAULT_URL = "jdbc:oracle:thin:@hostname.com:1521:orap1";
private static final String DEFAULT_USERNAME = "username";
private static final String DEFAULT_PASSWORD = "password";
//Set the SQL statements
private static final String SQLCUSTOMER_CUSTNUM =
"select CUSTNUM,CUST_LNAME,CUST_FNAME,CUST_PHONE,EMAIL,STAT_LVL,HH_NUM " +
"from EME.CUSTOMER " +
"where CUSTNUM=?";
private static final String SQLCUSTOMER_CUST_LNAME =
"select CUSTNUM,CUST_LNAME,CUST_FNAME,CUST_PHONE,EMAIL,STAT_LVL,HH_NUM " +
"from EME.CUSTOMER " +
"where CUST_LNAME=?";
private static final String SQLCUSTOMER_CUST_PHONE =
"select CUSTNUM,CUST_LNAME,CUST_FNAME,CUST_PHONE,EMAIL,STAT_LVL,HH_NUM " +
"from EME.CUSTOMER " +
"where CUST_PHONE=?";
private static final String SQLCUSTOMER_EMAIL =
"select CUSTNUM,CUST_LNAME,CUST_FNAME,CUST_PHONE,EMAIL,STAT_LVL,HH_NUM " +
"from EME.CUSTOMER " +
"where EMAIL=?";
private static final String SQLDETAIL =
"select TRANS_DATE,STORENUM,TERMINAL,TRANSID,OPERATOR,SALES_TOT," +
"AMOUNT_SPENT,AUTO_CPNS,PTS_EARNED,PTS_REDEEMED,RDMT_CPNS,ADD_CPNS," +
"USED_CPNS,OFFLINE_ALT_ID,RECON_IND " +
"from EME.CUSTOMERDETAIL " +
"where CUSTNUM=?";
private static final String SQLHOUSEHOLD =
"select PGM_PTS,PERIOD_PTS,PGM_RDM,PERIOD_RDM,SALES_TOT,AUTO_CPNS," +
"CARD_UCNT,MESSAGE,DISC_GRP,PT_MULTP,USERFEAT1,USERFEAT2,USERFEAT3,TARG_CPNS " +
"from EME.HOUSEHOLD " +
"where HH_NUM=?";
public static void main(String[] args)
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rset = null;
//declare all variables
String custNum = "";
String custLNm = "";
String transDt = "";
String storeNum = "";
String pgmPtsEarned = "";
String periodPtsEarned = "";
try {
//********** Get Customer Data **********
householdNum = "";
Class.forName(DEFAULT_DRIVER);
conn = DriverManager.getConnection(DEFAULT_URL,DEFAULT_USERNAME,DEFAULT_PASSWORD);
String lookupType = getUserInput("Lookup Type");
if (lookupType.toUpperCase().equals("CUSTNUM"))
stmt=conn.prepareStatement(SQLCUSTOMER_CUSTNUM);
else if (lookupType.toUpperCase().equals("LNAME"))
stmt=conn.prepareStatement(SQLCUSTOMER_CUST_LNAME);
else if (lookupType.toUpperCase().equals("PHONE"))
stmt=conn.prepareStatement(SQLCUSTOMER_CUST_PHONE);
else if (lookupType.toUpperCase().equals("ADDRESS"))
stmt=conn.prepareStatement(SQLCUSTOMER_EMAIL);
else
//stop execution with message
System.out.println("Invalid lookup type entered. Process stopping");
System.exit(0);
String lookupKey = getUserInput("Lookup Key");
System.out.println("Lookup Key is " + lookupKey);
stmt.setString(1,lookupKey);
rset = stmt.executeQuery();
//what if rset returns no records?
boolean empty=true;
while (rset.next())
empty=false;
custNum = rset.getString(1);
custLNm = rset.getString(2);
if (empty)
System.out.println("No records found for " + lookupKey);
System.exit(0);
//********** Get Detail Data **********
stmt=conn.prepareStatement(SQLDETAIL);
//stmt.setString(1,customerId);
stmt.setString(1,custNum);
rset = stmt.executeQuery();
empty = true;
while (rset.next())
empty = false;
transDt = rset.getString(1);
storeNum = rset.getString(2);
if (empty)
System.out.println("No detail records found for customer # " + custNum);
System.exit(0);
//********** Get Household Data **********
stmt=conn.prepareStatement(SQLHOUSEHOLD);
stmt.setString(1,householdNum);
rset = stmt.executeQuery();
empty = true;
while (rset.next())
empty = false;
pgmPtsEarned = rset.getString(1);
periodPtsEarned = rset.getString(2);
if (empty)
System.out.println("No household records found for " + householdNum);
System.exit(0);
catch(Exception x)
System.out.println(x.getMessage());
x.printStackTrace();
finally
close(rset);
close(stmt);
close(conn);
private static void close(Connection conn)
try
if (conn != null)
conn.close();
catch (SQLException e)
e.printStackTrace();
private static void close(Statement stmt)
try
if (stmt != null)
stmt.close();
catch (SQLException e)
e.printStackTrace();
private static void close(ResultSet rset)
try
if (rset != null)
rset.close();
catch (SQLException e)
e.printStackTrace();
public static String getUserInput(String getVal)
Scanner sc = new Scanner(System.in);
//for now, I'll be expecting "CustNum", "LName", "Phone", "Address"
System.out.println("Enter " + getVal + ": ");
String returnStr = sc.nextLine();
return (String) returnStr;
}You're new to Java, so you can be forgiven. You actually tried to do some good things, like close resources. Good for you.
Do yourself a favor and start trying to think in terms of objects.
Let's call that class CustomerTableGateway.
Let's write separate methods for each kind of SQL statement you have.
Get the logic out of the main method. It's almost useless there.
There's a computer science principle called DRY - Don't Repeat Yourself. When you see code being repeated, see if you can find a way to rewrite it so you only do it once.
I'd recommend that you start with a Customer class. Figure out how to map a row from your CUST table into the Customer object. Have an interface that would look like this:
public interface CustomerDao
Customer findById(String id);
List<Customer> findByLastName(String lastName);
List<Customer> findByName(String firstName, String lastName);
List<Customer> findByEmail(String email);
List<Customer> findByPhone(String phone);
}Have another interface called RowMapper:
public interface RowMapper
Object map(ResultSet rs);
}An implementation for one of those methods might look like this:
public Customer findById(String id)
Customer customer = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
stmt = this.connection.prepareStatement(FIND_CUSTOMER_BY_ID);
stmt.setString(1, id);
rs = stmt.executeQuery();
while (rs.next())
customer = (Customer)this.customerMapper.map(rs);
catch (SQLException e)
e.printStackTrace();
finally
DatabaseUtils.close(rs); // move those nice close methods into a utility class so you can reuse them.
DatabaseUtils.close(stmt);
return customer;
}You did a pretty good job. Just go further.
% -
Footer needs to pull data from main table
Hi Gurus,
I need to have a footer which displays the value of a tag from the main table in BI publisher. The main table in the BI Publisher has the customer information and the address information of the customer needs to print on the footer of the page that displays the customer. This address would change for each customer. There must be a way to do this. I searched through the BI Publisher forum but couldnt find any way to do this. Could you pls help.
Thanks,
Swarnahi Paolyn,
We can't insert data's from table using publisher desktop
just double click on the footer part and added the data with the following format
<?CUSTOMERNAME?>
<?CUSTOMERNUMBER?>
The tag value should be in upper case
then close the footer and try that
Thanks, -
Using SSIS Script task to populate data from one table to another
I have two tables Table A and Table B. Need to insert data into Table B from Table A. First, I truncate Table B and then insert. Few columns in Table A and Table are similar. However, I need to join with
other tables Table C, Table D etc with Table B in order to populate the columns in Table B. Could someone please provide the code snippet to achieve this.Appreciate your quick response Prasad. Below is the code I'm using to achieve.
Public Sub Main()
Dim connEOCDB As SqlClient.SqlConnection = GetDBProdConnection(Me)
Dim trans As SqlClient.SqlTransaction = connEOCDB.BeginTransaction()
Try
Dim TableA As New DataTable
Dim TableB As New DataTable
Dim DataadapterTableA As New SqlClient.SqlDataAdapter()
DataadapterTableA.SelectCommand = New SqlClient.SqlCommand("select * from TableA", connEOCDB, trans)
DataadapterTableA.Fill(TableA)
Dim DataAdapterTableB As New SqlClient.SqlDataAdapter()
DataAdapterTableB.DeleteCommand = New SqlClient.SqlCommand("Truncate table dbo.TableB", connEOCDB, trans)
DataAdapterEmpExtdT.InsertCommand = New SqlClient.SqlCommand("insert into dbo.TableB (Col1,Col2,Col3,.....) values (@Col1,@Col2,@Col3...)", connEOCDB, trans)
Could you please let me know how I can assign values to @Col1, @Col2 etc from
DataadapterTableA.Fill(TableA). Also, as mentioned earlier, I need to use joins to populate @Col3 etc as well.
Please advise. -
UNIQUE Problem in pulling DATA from DATA base table to internal table
Dear Experts,
I am new to ABAP. I have a very basic question but looks a quite puzzling one to me. Hemnce I am posting it here.
I am facing an unique problem in pulling data from database table and populating that data into internal table for further use.
The data in the database table "Zlt_mita" with fields M1 (Employee Name, Type: Char20) and M2 (Employee Code, Type Char7) are:
Plz refer the screenshot in the attached file:
My Code:
1) When I try to pull data from Dbase table by taking M2 as parameter.
This code is succcessful and I am able to populate data in internal table it_dat.
TYPES: Begin Of ty_DAT,
M1 TYPE Zlt_mita-M1,
M2 TYPE ZLT_mita-M2,
END OF ty_DAT.
DATA: it_dat TYPE STANDARD TABLE OF ty_dat with header line,
wa_dat TYPE ty_dat.
PARAMETERS: p_mitar TYPE Zlt_Mita-M2.
SELECT M1
M2
FROM ZLt_mita
INTO TABLE it_dat
Where M2 = p_mitar.
Loop at it_dat into wa_dat.
WRITE:/2 wa_dat-M1,
10 wa_dat-M2.
ENDLOOP.
2) When I try to pull data from Dbase table by taking M1 as parameter.
This code is NOT succcessful and I am NOT able to populate data in internal table it_dat.
TYPES: Begin Of ty_DAT,
M1 TYPE Zlt_mita-M1,
M2 TYPE ZLT_mita-M2,
END OF ty_DAT.
DATA: it_dat TYPE STANDARD TABLE OF ty_dat with header line,
wa_dat TYPE ty_dat.
PARAMETERS: P_Mita TYPE ZLT_Mita-M1.
SELECT M1
M2
FROM ZLt_mita
INTO TABLE it_dat
Where M1 = P_Mita.
Loop at it_dat into wa_dat.
WRITE:/2 wa_dat-M1,
10 wa_dat-M2.
ENDLOOP.
Why is this happening when both M1 and M2 are Type Character fields.
Looking forward for your replies.
Regards
Chandan KumarHi Chandan ,
Database fetch is case sensitive ,So u need to give exact format in where condition.
Make your parameter and database in same case so that you need not worry about case sensitivity .
Check the lowecase check box in the domain .
Then declare your parameter
PARAMETERS:
P_Mita
TYPE ZLT_Mita-M1 LOWER CASE .
You can do the vice versa also by unchecking lowercase and giving Upper case instead of lower in parameter declartion .
Regards ,
Juneed Manha -
One report to pull data from SQL or DB2
Hi Guys,
First post here. I have scoured the internet using our good friend google for answers and have come up empty. I hope someone can help me here!
Some Info: Crystal XI R2, Visual Studio 2005, Ms SQL Server 2005, DB2, VB.NET
What I am trying to accomplish is using one report to pull data from either SQL 2005 or DB2.
The problem I get is if the report is configured to pull data from SQL 2005, I cannot change it using the code below to pull data from DB2. The SQL Report uses the Microsoft OLEDB Provider. The DB2 report uses the IBM DB2 UDB for iSeries IBMDA400 OLEDB provider. When I quickwatch the oCRTable logon information, it seems to retain the other database's info.
Any ideas?
My code:
Private Sub LoadRpt(ByVal rpt As String)
Try
Dim strReport As String
Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim oCRTable As CrystalDecisions.CrystalReports.Engine.Table
Dim oCRConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo()
strRptNm = String.Format(".rpt", rpt )
strReport = String.Format("\{1}", Server.MapPath("Reports"), rpt )
crReportDocument.Load(rpr)
' check to make sure report is loaded; if not, then do nothing
If crReportDocument.IsLoaded Then
oCRConnectionInfo.DatabaseName = ConfigurationManager.AppSettings.Item("DataBase")
oCRConnectionInfo.ServerName = ConfigurationManager.AppSettings.Item("Server")
oCRConnectionInfo.UserID = ConfigurationManager.AppSettings.Item("Profile")
oCRConnectionInfo.Password = ConfigurationManager.AppSettings.Item("Password")
For Each oCRTable In crReportDocument.Database.Tables
oCRTable.LogOnInfo.ConnectionInfo = oCRConnectionInfo
oCRTable.ApplyLogOnInfo(oCRTable.LogOnInfo)
oCRTable.Location = oCRTable.Location
Next
For Each rpt In crReportDocument.Subreports()
For Each oCRTable In rpt.Database.Tables
oCRTable.LogOnInfo.ConnectionInfo = oCRConnectionInfo
oCRTable.ApplyLogOnInfo(oCRTable.LogOnInfo)
oCRTable.Location = oCRTable.Location
Next
Next
... other code ...
End If
Catch ex As Exception
... other code ...
End Try
End Sub
Edited by: Mace Windu on Feb 7, 2009 7:55 AM
Edited by: Mace Windu on Feb 7, 2009 7:56 AMDavid,
Your suggestion worked to near perfection. The only problem was that if I configured the datasource locations of the report and sub reports in CR to use the SQL ODBC, the .net program would successfully log in using the DB2 info but had a problem reading the data. If I configured the datasource locations of the report and subreports in CR to use the DB2 ODBC, everything worked! Thanks for the advice.
The force is strong with you.
Mace -
Using FDM to load data from oracle table (Integration Import Script)
Hi,
I am using Integration Import Script to load data from oracle table to worktables in FDM.
i am getting following error while running the script.
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done
Attaching the full error report
ERROR:
Code............................................. -2147217887
Description...................................... Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
At line: 22
Procedure........................................ clsImpProcessMgr.fLoadAndProcessFile
Component........................................ upsWObjectsDM
Version.......................................... 1112
Thread........................................... 6260
IDENTIFICATION:
User............................................. ******
Computer Name.................................... *******
App Name......................................... FDMAPP
Client App....................................... WebClient
CONNECTION:
Provider......................................... ORAOLEDB.ORACLE
Data Server......................................
Database Name.................................... DBNAME
Trusted Connect.................................. False
Connect Status.. Connection Open
GLOBALS:
Location......................................... SCRTEST
Location ID...................................... 750
Location Seg..................................... 4
Category......................................... FDM ACTUAL
Category ID...................................... 13
Period........................................... Jun - 2011
Period ID........................................ 6/30/2011
POV Local........................................ True
Language......................................... 1033
User Level....................................... 1
All Partitions................................... True
Is Auditor....................................... False
I am using the following script
Function ImpScrTest(strLoc, lngCatKey, dblPerKey, strWorkTableName)
'Oracle Hyperion FDM Integration Import Script:
'Created By: Dhananjay
'Date Created: 1/17/2012 10:29:53 AM
'Purpose:A test script to import data from Oracle EBS tables
Dim cnSS 'ADODB.Connection
Dim strSQL 'SQL string
Dim rs 'Recordset
Dim rsAppend 'tTB table append rs object
'Initialize objects
Set cnSS = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
Set rsAppend = DW.DataAccess.farsTable(strWorkTableName)
'Connect to SQL Server database
cnss.open "Provider=OraOLEDB.Oracle.1;Data Source= +server+;Initial Catalog= +catalog+;User ID= +uid+;Password= +pass+"
'Create query string
strSQL = "Select AMOUNT,DESCRIPTION,ACCOUNT,ENTITY FROM +catalog+.TEST_TMP"
'Get data
rs.Open strSQL, cnSS
'Check for data
If rs.bof And rs.eof Then
RES.PlngActionType = 2
RES.PstrActionValue = "No Records to load!"
Exit Function
End If
'Loop through records and append to tTB table in location’s DB
If Not rs.bof And Not rs.eof Then
Do While Not rs.eof
rsAppend.AddNew
rsAppend.Fields("PartitionKey") = RES.PlngLocKey
rsAppend.Fields("CatKey") = RES.PlngCatKey
rsAppend.Fields("PeriodKey") = RES.PdtePerKey
rsAppend.Fields("DataView") = "YTD"
rsAppend.Fields("CalcAcctType") = 9
rsAppend.Fields("Amount") = rs.fields("Amount").Value
rsAppend.Fields("Desc1") = rs.fields("Description").Value
rsAppend.Fields("Account") = rs.fields("Account").Value
rsAppend.Fields("Entity") = rs.fields("Entity").Value
rsAppend.Update
rs.movenext
Loop
End If
'Records loaded
RES.PlngActionType = 6
RES.PstrActionValue = "Import successful!"
'Assign Return value
SQLIntegration = True
End Function
Please help me on this
Thanks,
Dhananjay
Edited by: DBS on Feb 9, 2012 10:21 PMHi,
I found the problem.It was because of the connection string.The format was different for oracle tables.
PFB the format
*cnss.open"Provider=OraOLEDB.Oracle.1;Data Source= servername:port/SID;Database= DB;User Id=aaaa;Password=aaaa;"*
And thanks *SH* for quick response.
So closing the thread......
Thanks,
Dhananjay
Maybe you are looking for
-
On a Mac, in Adobe Photoshop CC 2014, when adding audio to an edit, i get the message "Could not complete your request, because Dynamiclink is not available". When performing the exact same operation in Adobe Photoshop CC, i can add audio in the same
-
i downloaded firefox 4 but did not notice that it required osx10.5 as my computer is running 10.4.11 installed program ok but when trying to open it i get message that it will not run on my system. how do i get back to 3.6 as firefox 4 appears to hav
-
I want to purchase my iPad in the US, and I want to get 4G. Do I have to use the US carriers or can I use a Canadan carrier? I spend 6 months in the US and 6 months in Canada. Thanks for any help. -Annie
-
Dealing with a dead laptop. Help needed
I am a college student and my acer computer just died on me. It has been having problems for the longest time the plg only works when it wants to and the battery won't hold a charge. Now the computer won't even charge. So i have ordered a dell but is
-
How could I create ObjectInputStream and use it indefinitely with Servlets?
Hi All, I would like to create the stream object between applet and server only once with urlConnection.openConnection() and use it to write objects to it indefinitely without reinstantiating it or getting another connection with urlConnection.openCo