Solved

OO4O Bind variables

Posted on 2004-08-05
2
314 Views
Last Modified: 2013-12-25
I am creating a report and ask the users to select which divisions they want to see the report for.  They can choose mulitple divisions.  I am trying to figure out if it is possible to select all the information I need without having to create a new bind variable for each division and then changing my sql statement to fit the number of divisions.  I've tried the following with little success.

Private opaDivisions As OraParamArray
Private rs As OraDynaset

DB.Parameters.AddTable "DIVISIONS", ORAPARM_INPUT, ORATYPE_VARCHAR, 10, 5

Set opaDivisions = DB.Parameters("DIVISIONS")

opaDivisions.put_Value "M", 0
opaDivisions.put_Value "T", 1
opaDivisions.put_Value "L", 2

strSql = "SELECT " _
    & "Order.Cabinet_style_info.ItemType, " _
    & "Order.Barcode.Location Location, " _
    & "B.n_status_code Status, " _
    & "count (Order.Barcode.Location) " _
    & "FROM Order.tbl_barcode B " _
    & "INNER JOIN Order.tbl_order_header OH " _
    & "ON B.n_order_number = OH.n_order_number  " _
    & "AND  OH.c_division IN (:DIVISIONS)  " _
    & "WHERE B.n_status_code < 9 " _
    & "AND B.n_deleted_flag = 0 " _
    & "GROUP BY Order.Cabinet_style_info.ItemType , Order.Barcode.Location, B.n_status_code"

Set rs = DB.CreateDynaset(strSql, ORADYN_READONLY)

This will only return the records for division "M" or whatever division I set first.

Any way I can do something like this without having the code simply build the sql string to say exactly which divisions I want to select?

Thanks.
0
Comment
Question by:LoriNeirynck
2 Comments
 

Author Comment

by:LoriNeirynck
ID: 11732623
Solved this problem on my own.  Stopped using the OraParamArray and used a regular bind variable to which I then did an instr.  Looks like this:

Private rs As OraDynaset

DB.Parameters.Add "Division", "", ORATYPE_VARCHAR2

DB.Parameters("Division").Value = "MT"

strSql = "SELECT " _
    & "Order.Cabinet_style_info.ItemType, " _
    & "Order.Barcode.Location Location, " _
    & "B.n_status_code Status, " _
    & "count (Order.Barcode.Location) " _
    & "FROM Order.tbl_barcode B " _
    & "INNER JOIN Order.tbl_order_header OH " _
    & "ON B.n_order_number = OH.n_order_number  " _
    & "INSTR(:DIVISION, OH.c_division) > 0  " _
    & "WHERE B.n_status_code < 9 " _
    & "AND B.n_deleted_flag = 0 " _
    & "GROUP BY Order.Cabinet_style_info.ItemType , Order.Barcode.Location, B.n_status_code"

Set rs = DB.CreateDynaset(strSql, ORADYN_READONLY)

Then I simply build the string for the bind variable and do not have to change my sql statement.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 11735755
Question closed and points refunded

PashaMod
Cs Moderator
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
to transfer string from C lanaguage to VBA 4 78
SQL VB connection works in one PC and doesn't in another 15 74
Visual Studio 2005 text editor 10 49
MsgBox 4 71
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question