I have a web form from where I insert data to Oracle. There are at least 20 fileds on the form. For INSERT I want to use Stored Procedure. But in this case for VALUES section of the INSERT statement I need to send that many- in this case 20 parameters. Is this normal for a procedure to receive 20 parameters? If it's not, then what way should I follow to perform this? I know technically there's no problem but is this normal programming or database managementwise? I think this is the basic thing all web developer do all the time.
Related
Hi I'm pretty much a beginner in SQL, but I would like to know if there is a way to know how old are the records contained in the stored procedure.
For example, if I execute a stored procedure, is there an extra statement that I can add to be able to see this last update date on each row?
When I run the stored procedure, it doesn't have a column that shows that information, but at least I would like to know how old is the data that is displaying.
I use PowerBI (October 2020), and I have one dashboard with a drop down DATE slicer. I have two problems with it:
I need to pass the value of slicer to a stored procedure to use there as a where condition. I mean the query has used in stored procedure, filtered by the date has picked in slicer.
I need keep update the value of slicer too. I means if today is 2021/08/10, this date shows in slicer and tomorrow is become 2020/08/11 automatically.
If somebody can provide some solution that would be great.
Thanks in advance
1).
You have to create 2 parameters for selecting data range if you use stored procedure.
Similar thing happen to me earlier, so I switched from stored procedure to mysql or sql views. I managed to get data via join queries and optimize it.
Because if you use Views you have some limitations.
If you have correct requirement hardcode lower bound date, and if you use view it act as mysql table.
2).
If you have date slicer in the filters you can change it to relative date to selected time, then your upper bound date will update accordingly.
After hours of testing I have the strong opinion that it is not possible to call SQL stored procedures with parameters and DirectQuery, affected by user controls in a PowerBI dashboard.
This is easily done in PowerBI Report Builder.
You can create parameters in PowerBI that affect the parameter-values in your SQL-stored procedures but they are not adjustable by the user in your dashboard.
The syntax for the call to SQL SP is:
let
Source = Sql.Database("[server]", "[database]", [Query="EXEC direct.sp_[stored procedure] '" & DateTime.ToText(prmStartDatum) & "', '" & DateTime.ToText(prmEindDatum) & "'", CommandTimeout=#duration(0, 0, 10, 0), HierarchicalNavigation=true, MultiSubnetFailover=true])
in
Source
The error you get is:
Microsoft SQL: Incorrect syntax near the keyword 'EXEC'. Incorrect
syntax near ')'.
When this is fixed, it would be a great improvement to PowerBI dashboards.
Is it possible to created a Stored Procedure in SAS Enterprise Guide and allow the user to enter in a list of values, without having to manually enter in the list?
I use more Base SAS than EG, so I'm not an expert on Stored Procedures. Currently, an analyst in my area may have to search for a list of values like so:
012345678
123456789
231456789
091236574
439857345
120129038
230918239
....
....
N
and is using a Stored Procedure that was built to enter in these values. However, this is not efficient as this last can be >40 values, and SAS will only allow you to enter in one at a time.
I've been messing around with the prompt manager for an hour or so and haven't had any luck. I've also tried 'User selects from a static list', using an excel doc that I imported. Which worked great ad-hoc, but, because the values will always be different, I can't figure out how to make EG first import this excel doc, then bring up the prompt for her to select all the (new) values, then run the rest of the program.
Also, it seems that I would have to change the 'Static Value List' in the prompt manager every time the doc was imported, even if the rest of the program was conditioned on the import of the excel doc. I'm going to continue playing around with this, but looking for ideas as to if anyone has done this previously.
Sounds like you want "select multiple values from a dynamic list". I suggest you read the excel file that holds all the response options into a SAS dataset. Then register that dataset in the SAS metadata server. When you create a dynamic prompt you point to the source SAS dataset that holds the response options. After creating the prompt, you can update the dataset any time you want (add/delete records), and then STP user will see those updated response options in the prompts.
It may also be possible to register an Excel file in metadata instead of reading it into a SAS dataset. But I always try to limit Excel usage as much as possible.
While querying BAPI, we are generally interested in only few columns of a table.
For example PO_ITEMS table (under BAPI_PO_GETITEMS) has 58 columns. While querying, I am interested in only 10 of those columns. But the BAPI response contains all the columns which is a
overhead.
In SQL world, we can always select which columns we want to retrieve. The query response contains only those columns, not all the columns.
I remember I have read somewhere that we can disable unwanted columns coming in response. But when I need it now, I am not able to find information about it.
Can anybody share a code snippet to achieve this? Or specific online resource/pointers would help?
Thanks
Depending on which technology you use to call the BAPI, you can sometimes restrict which parameters are transferred. For example, if you use the SAP Java Connector (JCo 3), you can use the method setActive of a parameter to restrict whether the parameter is transferred. However:
As far as I know, you can only enable or disable entire TABLES parameters or other parameters. You can't enable or disable individual columns.
As far as I know, the BAPI itself does not know about this setting - and even if it would know, few implementations would care.
Sometimes there are additional parameters that allow you selectively enable or disable fields, but that is part of the actual BAPI implementation and not some omnipresent basic technology.
this is not exact answer for your question.i hope it will help.I think we have no option to select certain number of column from a function module tables.but we can access particular row from that table like passing mandatory values from java side .....like this sample code here i did for function module(not table table).
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME);
JCoFunction jf=destination.getRepository().getFunction("ZUSER_DET");
jf.getImportParameterList().setValue("FIRST_NAME","username");
jf.execute(destination);
String jfex=jf.getExportParameterList().getString("some column name from return table");
System.out.println(jfex);
it will return a row of table value.you can manipulate whatever you want
I have a python program that calls a stored procedure from db2 database. I am using results = cursor.fetchall() to process the results of my stored procedure. However, my stored procedure returns two cursors. results only contains the first one. I need a way to loop through as many cursors as I want. I was hoping fetchmany() would be my answer but it is not.
I need to be able to do multiple result sets as the program I am writing can only call one stored procedure. It would take a lot to go back and make it to be able to call two. Besides with one of these things I need to make 10 cursors return. Everything is dynamic, so the application doesn't know what procedure it is running, it just gets the data and spits it into excel not knowing the meaning. I need one cursor for the data, and the other cursors for different types of counts and totals.
I am looking for a built in function to do this, or maybe even a different library because I have done my share of googling and it looks like pyodbc does not do this for DB2. DB2 is a requirement.
Use the nextset() method of the cursor: https://github.com/mkleehammer/pyodbc/wiki/Cursor#nextset
Sample code:
# fetch rows from first set
rows = cursor.fetchall()
# process first set rows here
# advance to next result set
while (cursor.nextset()):
# fetch rows from next set, discarding first
rows = cursor.fetchall()
# process next set rows here
nextset() will return True if additional result sets are available, and subsequent cursor fetch methods will return rows from the next set. The method returns None if no additional sets are available.
Just a small simplification for the record:
while True:
rows = cursor.fetchall()
# process all result sets in the same place
if not cursor.nextset():
break