Table Type Stored Procedure in OBIEE Physical table properties
Hi,
Any one has ever used the Stored Procedure in OBIEE Physical table properties??
I've a procedure & a table i want to plopulate the tabel using the Procedure from OBIEE physical layer.
It would be nice if we know more details about 'Populating table'...
Using connection pool->connection pool scripts tab you may go for inserting/updating (Populating table) records into table.
It would be nice if you use dedicated connection pool for init blocks...
Ex: I want to insert user login time some xyz table my query would be like
insert into xyz values ('valueof(NQ_SESSION.USER)',sysdate)
without knowing your requirements its hard to tell anything apart from what is said.
If helps pls mark
Edited by: Srini VEERAVALLI on Jan 16, 2013 10:37 PM
Similar Messages
-
Drop and recreate table in stored procedure
Hi all
When creating tables using Transact-SQL scripts, I have always preferred to drop the table if it exists and then create it explicitly using CREATE TABLE. For two reasons:
1) It does not matter if it is the first time the SP is run ie. if I create the table manually in the first instance and just use TRUNCATE TABLE it could fail if the table is deleted
2) I have control over the data types of the table fields
Just recently though I discovered the error that can occur when dropping and creating a table in the same batch (see link below)
Microsoft Website
This causes me a problem when dropping and creating tables in stored procedures, as I understand that a stored procedure is in itself a single batch?
Can I avoid this error in a stored procedure whilst continuing to drop and create tables? Or should I be taking a different approach?
Coding best practice advice would be greatly appreciated.
Thank youThanks Ronen
Please see my second post immediately before your reply.
Given that I need to store the data output in a physical table for use in QlikView, would you suggest truncating the table each time the SP runs? And then having a script that handles both dropping and creating the physical table, and also creating
the SP?
>> QlikView
QlikView is an Israeli company, right?
In any case I am not familiar with QlikView's application, therefore I can only give you general information, based on assumptions regarding the application, and facts regarding the SQL Server.
>> for use in QlikView
I assume that external application use specific database structure (table
structure) and it is change only in rare situations (for example CMS interface might change the tables if and when a module s update/install). In this case there is no need to drop the table and recreate it and TRUNCATE is the solution.
>> would you suggest truncating the table each time the SP runs
I am sorry but i cant recommend on TRUNCATE a table each time you execute SP, without know the exact reason for this logic. It sound to me, at this point of time (with the information that we have), that this
is very bad logic (application architecture). As I wrote above, basing your application on TRUNCATING the table each time mean that you have problems with multi users. Thins about 2 people that try to execute the same SP at almost the same time. Think about
locking in the SQL Server and bad data (one truncate while the other already inserted the new data and get no rows, if there is no locking).
But TRUNCATE is much better in this case probably then DROP and DELETE, since it is faster, and locking will be shorter (hopefully the application use the correct locking). There are other reasons why TRUNCATE is better, and other people already mentioned
most of them, but time in this scenario might be critical.
>> having a script that handles both dropping and creating the physical table, and also creating the SP?
I do not undestand what is this second step. we said that you truncate the table, so why do you need to
dropping and creating the physical table and who
creating the SP?
Are you meaning that the application create the tables and SP?
There are lot of application that during installation create the database structure. is this what you mean?
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
Find tables in Stored Procedures
Hi...
Is there a way I can find the names of stored procedures where a certain table is referenced without having to look through all of them? I tried using dba_dependencies, but it did not return any rows even when I knew the table was referenced in two stored procs. No rows were returned. This is the query I issued:
select
referenced_name,
referenced_type
from
dba_dependencies
where
name LIKE '%DATA.GL_Activity_Fact%'
Any ideas? I need to modify all the stored procs which reference this table.
Thanks so much!Assuming DATA is the schema name and GL_ACTIVITY_FACT is the table name
1) You would want to use DBA_DEPENDENCIES to search for objects that reference the table, not for objects that are referenced by the table. So you'd want to search on REFERENCED_NAME and REFERENCED_OWNER, not the other way around.
2) Regardless of how you specify the table in your code, the owner and object name will be stored separately in the data dictionary. And both will be all upper case (unless you happen to have created tables with case sensitive names).
So you probably want
SELECT owner, name, type
FROM dba_dependencies
WHERE referenced_owner = 'DATA'
AND referenced_name = 'GL_ACTIVITY_FACT'
AND referenced_type = 'TABLE'Be aware that if you use dynamic SQL to reference the table, there will be no entries in DBA_DEPENDENCIES for that.
Justin -
Using temporary tables in stored procedures
Suppose that I have created a temporary table in a stored procedure using an "EXECUTE IMMEDIATE" statement. When I compile the procedure, that table is not created yet, so the compiler says that the table does not exist.
What is the way of using temporary tables in stored procedures?It's a good practice to avoid using DDL statements being executed from stored procedures. "Truncate Table" via dynamic SQL from stored procedure is a different story and is useful in DSS environments.
But if you insist on "creating" tables using Dynamic SQL from Stored Procedures then you must also embed your DML statements in Dynamic SQL to avoid compilation errors.
Example:
Create or Replace Procedure Proc_TestDynamicSQL is
Begin
Execute Immediate 'Create table myTable as select * from user_tables' ;
Execute Immediate 'Update myTable set table_name = ''Test'' ' ; --two single quotes before and after the string "Test"
End;
In this case, Oracle wouldn't care about the table references during compilation. -
Sys Tables In Stored Procedure
How can I use Sys Table in Stored Procedure.
I want to use DBA_TAB_COLOUMNS, in stored procedure.
When I used this table in stored procedure I got an error
ORA - 00942 Table or View Does not exists.
Thanks,
AhamedFrom http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#i1006224
>
Note:
To create without errors (to compile the procedure or package successfully) requires the following additional privileges:
The owner of the procedure or package must be explicitly granted the necessary object privileges for all objects referenced within the body of the code.
The owner cannot obtain required privileges through roles.
>
You need to run
grant select on dba_tab_columns to <owner of procedure>; -
How to implement Stored procedure in OBIEE
Hi experts
How to implement Stored Procedure in OBIEE..
My Input is Date..
Thanks in advance
Regards
FrndsDouble post :
Re: How to get the previous monthend data and currentdate data in OBIEE report
You don't need a stored procedure.
If you want the amount only for one date, you can use the filter option in the formula :
FILTER("Sales Facts"."Amount Sold" USING (Time.Day = '31 jan'))You can calculate the last day with the timestampdiff function
31Jan = 1 Feb - 1 dayIf you want the amount of the month see my post here :
Re: How to get the previous monthend data and currentdate data in OBIEE report -
Stored procedure and function - return table type
Hello again :)
I have one simple question :) Maybe on this forum the question was asked, but I found only similar question and they didn't help me.
It's possible return in Stored Function (with StoredProcedureFunction) as result return TABLE type? Or return table type with output parametr with Stored Procedure? Or instead of the table return the db object, but it is similar problem:)
Now, I can using db types TABLES or DB OBJECTS as INPUT parameters with call stored functions or procedures, for example:
I have this simple db object:
create or replace type BUFFER_DATA_R as object( detail VARCHAR2(4000 ))
And this simple table:
CREATE OR REPLACE TYPE BUFFER_DATA_T IS TABLE OF BUFFER_DATA_R
I create simple domain class object:
*public class DMBufferDataStruct {*
public String bufferData;
And I mapped in java with ObjectRelationalDataTypeDescriptor:
ObjectRelationalDataTypeDescriptor descriptor = new ObjectRelationalDataTypeDescriptor();
descriptor.setJavaClass(DMBufferDataStruct.class);
descriptor.setTableName("BUFFER_DATA_T");
descriptor.setStructureName("BUFFER_DATA_R");
descriptor.setPrimaryKeyFieldName("DETAIL");
descriptor.addFieldOrdering("DETAIL");
descriptor.addDirectMapping("bufferData", "DETAIL");
and join to server session ...
Well, i using this doimain class object as input parametr wih stored procedure call:
ObjectRelationalDatabaseField ordf = new ObjectRelationalDatabaseField("");
ordf.setSqlType(Types.STRUCT);
spCall.addNamedArgument(key, key,
Types.ARRAY,
"BUFFER_DATA_T",
ordf);
query.addArgument(key);
args.add(paramsInputs.get(key));
in paramsInputs is Vector of DMBufferDataStruct...
Well, this work fine!
But I can not figure, how to return this table from output parameters of stored procedure or as a return value from stored function?
Example of exceptions:
The number of arguments provided to the query for execution does not match the number of arguments in the query definition. - return as output parameter
PLS-00382: expression is of wrong type - used as result from stored function
So, my question is: Is possible return this table type from stored procedure or function? And if YES, how can I set output argument for call?
Thx advance!
Sorry for my English! :)
Best regards, KLDYour question is: what is faster PL/SQL or PL/SQL? And the answer is: it is PL/SQL of course!
As a general rule, you use a function when you return exactly one result: a number or a string or (more complex) instance of an object type or REF CURSOR or PL/SQL collection.
You use a procedure when:
a) you just do the job and return no result
b) you return multiple results - you can use multiple IN/OUT or OUT parameters
Imagine you have to write a program unit that performs a partitioned table maintenance by adding a partition.
You can implement this unit:
a) if you want return a "status code" (0 on successful completion or non-zero in case of error) then you should use a function
b) if you want no "status code" (in case of error an exception is raised that is handled outside of the program unit) then you should use a procedure
c) if you want "status code", name of tablespace where a partition was created (assume you program is so complex that it can choose different tablespaces based on metadata and free space available) and free space in that tablespace after the creation of a new partition then you should use a procedure with 3 OUT parameters.
But these are good programming practices that can be applied to (almost) any 3rd generation programming language, not only PL/SQL. -
Error calling a stored procedure returning a PLSQL table / REF cursor
stored proceure declares -
TYPE A_rec IS RECORD (
date DATE,
id NUMBER(10),
start NUMBER (10),
end NUMBER (10)
TYPE tmp_tbl IS TABLE OF A_rec ;
PROCEDURE get_B(
p_id IN NUMBER,
p_startdate IN DATE,
p_enddate IN DATE,
p_tbl OUT tmp_tbl
My Java code reads -
StoredProcedureCall storedProcedureCall = new StoredProcedureCall();
storedProcedureCall.setProcedureName("get_B");
DataReadQuery query = new DataReadQuery();
query.setCall(storedProcedureCall);
Vector parameters = new Vector();
/** For all input params **/
query.addArgument(param.getInputParamName(" name");
parameters.add("values");
/** Now comes the OUT part .. i am not sure what to do **/
storedProcedureCall.useNamedCursorOutputAsResultSet("p_tbl ");
/** execute query **/
Vector result = (Vector) getSession(ctx).executeQuery(query, parameters);
------------- My program does not throw any error ... but does not return anything ----TopLink currently doesn't support pl/sql types to be used as stored procedures parameters - but version 11 will.
However you can use a single cursor as an out parameter in your stored procedure:
p_tbl OUT CURSOR_TYPE.ANY_CURSOR,
and it will be returned by TopLink. -
Need to insert data in 2 tables thro stored procedure
I need to create a stored procedure which will insert data in two tables. The procedure will get
its inputs from an Oracle Developer Form which will be inserted into the tables.
The 2 tables structure:
1.FEES_MASTER
Name Null? Type
FEES_ID NOT NULL NUMBER(8) -- Primary Key
CS_ID NOT NULL NUMBER(8) -- Class Student ID; An enrolled student
REC_DATE NOT NULL DATE -- Fees receipt date
REC_AMOUNT NOT NULL NUMBER(6) -- Fees receipt amount
2.FEES_DETAIL
Name Null? Type
FEES_ID NOT NULL NUMBER(8) -- Foreign Key
MONTH NOT NULL DATE -- First of each month to identify fee month
Scenario:
A student submits fees for 3 months through Master/Detail related blocks in a Developer Form as
Under:
Fees Master
Fees ID : 11002
Class Student ID : 356
Receipt Date : 06-JAN-2001
Receipt Amount : 1500
Fees Detail
Fees ID Fees Month
11002 01-JAN-2001
11002 01-FEB-2001
11002 01-MAR-2001
I need to check each fees detail record for fees month duplication as well before inserting new records.
How can this be achieved?
Thanks in advance.<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Fan Liu ([email protected]):
create primary key in the detail table. i think it's FEES_ID + MONTH. then mark the columns in Forms as primary key property true, then call check_record_uniqueness built-in in on-check-unique trigger.<HR></BLOCKQUOTE>
Thanks very much. But what I need is to ensure transaction integrity thro stored procedure. The system allows a certain CS_ID (i.e. Class Student ID, which is assigned a new one to every student annually) to submit fees for 12 months only, because a student stays in a class for a year. The 2 columns in the FEES_DETAIL table are composite primary key which only ensures that a certain FEES_ID will not be repeated for the same month. But suppose:
1)this data already exist in the tables:
Fees Master
Fees ID : 11002
Class Student ID : 356
Receipt Date : 06-JAN-2001
Receipt Amount : 1500
Fees Detail
Fees ID Fees Month
11002 01-JAN-2001
11002 01-FEB-2001
11002 01-MAR-2001
2)And this data is currently being inserted:
Fees Master
Fees ID : 11300
Class Student ID : 356
Receipt Date : 04-FEB-2001
Receipt Amount : 1500
Fees Detail
Fees ID Fees Month
11300 01-JAN-2001
11300 01-FEB-2001
11300 01-MAR-2001
The data in the 2nd condition is perfectly valid but the application can't allow a student to submit fees for a month which he has already submitted. Now only a stored procedure can make sure after checking that the same student doesn't pay fees for duplicate months. Another reason for my emphasis on stored procedure is that what if a user tries to insert data thro an SQL* Plus session instead of the Form.
PROBLEM: Now the problem I am having is I don't know how the procedure will take input for multiple records from the FEES_DETAIL block in the Form.
Please assist in this regard. Thanks. -
How to save images to table using stored procedures?
hi all,
i created a stored procedure
create table members ( id number, name varchar2(30), avatar blob );
create or replace add_ member ( id number, name varchar2, avatar blob )
is
begin
insert into members values ( id, name, avatar);
commit;
end;i have 3 items in page..
1. Hidden -> P1_ID
2. Text field - > P1_NAME
3. File Browse - P1_AVATAR
but when invoking the procedure in Processes like
begin
add_member ( id => :P1_ID, name => :P1_NAME, avatar => :P1_AVATAR );
end;i get an error
1 error has occurred
* ORA-06550: line 3, column 3: PLS-00306: wrong number or types of arguments in call to 'ADD_MEMBERR' ORA-06550: line 3, column 3: PL/SQL: Statement ignoredcan anyone tell me why it errors out?
thanks
allenDid you do as fac586 suggested:
create table members ( id number, name varchar2(30), avatar blob );
create or replace add_ member ( id number, name varchar2, avatar blob )
is
begin
insert into members values ( id, name, avatar);
commit;
end;should be something like:
create table members ( id number, name varchar2(30), avatar blob );
create or replace add_ member ( id number, name varchar2, avatar blob )
is
begin
insert into members (id, name, avatar) values ( id, name, avatar);
commit;
end;You need to specify the columns of the table that you will be inserting values into.
Also, you should probably rename the parameters of your procedure so you can differentiate between the parameters, and the database columns.
i.e.:
create or replace add_ member ( p_id number, p_name varchar2, p_avatar blob ) -
Calling Write Stored procedure from xsodata with table/list as input
I have a stored procedure which takes table type as input and insert data in a table
PROCEDURE "C"."abcd.procedures::InsertResData" ( IN resourcelist "abcd.procedures.ResourceT",out error "abcd.data:abcd.procedures.tt_error" )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER abc
--DEFAULT SCHEMA <default_schema_name>
AS
BEGIN
---some insert logic-
END
Now I have exposed the SP using XSODATA so that UI can consume it.
service namespace "abcd.hana.service"{
"abcd.views/Resourceview.attributeview" as "resourceitem"
key("RESOURCE_ID")
create using "abcd.procedures::InsertResData";
Question: How can I pass array of input records to XSODATA. from UI? Is it supported?
I could test with single record (JSON input) but could not test with multiple records
Please help me on this if you have some expert opinion
Regards,
ApoorvI have a stored procedure which takes table type as input and insert data in a table
PROCEDURE "C"."abcd.procedures::InsertResData" ( IN resourcelist "abcd.procedures.ResourceT",out error "abcd.data:abcd.procedures.tt_error" )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER abc
--DEFAULT SCHEMA <default_schema_name>
AS
BEGIN
---some insert logic-
END
Now I have exposed the SP using XSODATA so that UI can consume it.
service namespace "abcd.hana.service"{
"abcd.views/Resourceview.attributeview" as "resourceitem"
key("RESOURCE_ID")
create using "abcd.procedures::InsertResData";
Question: How can I pass array of input records to XSODATA. from UI? Is it supported?
I could test with single record (JSON input) but could not test with multiple records
Please help me on this if you have some expert opinion
Regards,
Apoorv -
Visual Basic, DAO, Temp tables in stored procedures
Client code currently uses DAO with SQLPassthrough option in VB to connect to SQl 6.5 db.
I migrated all stored procedures with default options except Oracle 8i temp tables. For every procedure a package and a procedure was created. We use SQL server temporary tables extensively in a few hundred stored procedures. The ref cursor created refers to the temporary table. While migratiing, Create table statement is commented. How are SQL6.5 equivalent of temp tables handled in Oracle? Is there an alternative to temp tables?
I also migrated to another oracle db using the INOUT type for stored procedures. This time only procedures were created. Can these procedures return a record set in DAO with SQLPAssthrough?
How do you call a procedure using DAO in VB to get recordsets?
What is the best way to migrate to Oracle with minimal client code changes?
Thank you in advance.
Umesh
nullKarthick_Arp wrote:
BluShadow wrote:
I agree with Karthick, there's no need for a temporary table in this situation.
And to add, temporary tables should not be created at runtime, they should be part of the initial design of the database, created once and used as needed. Creating them at runtime is just wrong.The problem is the name oracle has given to GTT. The word Temporary mislead lot of SQL Server developers and they think its something same as the temporary table used in SQL Server :)Yeah, Ingres does something similar to SQL Server too, in that you can create a temporary table (Ingres assigned it a unique name and tells you what it is), and you set an expiry time on it (i.e. set it to expire in 1 days time), and then a background process is supposed to clean up the tables that have expired. Unlike Oracle, they are not session specific, but become visible to all once created.
I think there's room for both types of temporary table, but Oracle's does the job (except when you want to use them from a stateless application front end). -
Create Dates table as stored procedure
I want to modify this statement to use todays date as the start date and add 50 years to insert into table instead of entering a date range and execute it as a stored procedure. Can someone help me to modify this? Thanks
/**Drop Tables*/
DROP TABLE [dbo].[DimDate]
GO
/** Create Date Dimension Table **/
/* Create First numbers table for key generation */
CREATE TABLE Numbers_Small (Number INT);
INSERT INTO Numbers_Small
VALUES (0)
,(1)
,(2)
,(3)
,(4)
,(5)
,(6)
,(7)
,(8)
,(9);
GO
/* Create Second numbers table for key generation */
CREATE TABLE Numbers_Big (Number_Big BIGINT);
INSERT INTO Numbers_Big (Number_Big)
SELECT (tenthousands.number * 10000 + thousands.number * 1000 + hundreds.number * 100 + tens.number * 10 + ones.number) AS number_big
FROM numbers_small tenthousands
,numbers_small thousands
,numbers_small hundreds
,numbers_small tens
,numbers_small ones;
GO
/* Create Date Dimension Table */
CREATE TABLE [dbo].[DimDate] (
[DateKey] [int] NOT NULL
,[Date] [datetime] NOT NULL
,[Day] [char](10) NULL
,[DayOfWeek] [smallint] NULL
,[DayOfMonth] [smallint] NULL
,[DayOfYear] [smallint] NULL
,[PreviousDay] [datetime] NULL
,[NextDay] [datetime] NULL
,[WeekOfYear] [smallint] NULL
,[Month] [char](10) NULL
,[MonthOfYear] [smallint] NULL
,[QuarterOfYear] [smallint] NULL
,[Year] [int] NULL
GO
/* Create Date Key and Date Fields */
INSERT INTO [DimDate] (
DateKey
,DATE
SELECT number_big
,DATEADD(day, number_big, '1900-01-01') AS DATE
FROM numbers_big
WHERE DATEADD(day, number_big, '1900-01-01') BETWEEN '1900-01-01'
AND '2050-12-31'
ORDER BY number_big;
GO
/* Update all other fields with appropriate data. */
UPDATE [DimDate]
SET Day = DATENAME(DW, DATE)
,DayOfWeek = DATEPART(WEEKDAY, DATE)
,DayOfMonth = DAY(DATE)
,DayOfYear = DATEPART(DY, DATE)
,PreviousDay = DATEADD(DAY, - 1, DATE)
,NextDay = DATEADD(DAY, 1, DATE)
,WeekOfYear = DATEPART(WK, DATE)
,Month = DATENAME(MONTH, DATE)
,MonthOfYear = MONTH(DATE)
,QuarterOfYear = DATEPART(Q, DATE)
,Year = YEAR(DATE);
GO
/* Drop Temp Tables */
DROP TABLE Numbers_Small;
DROP TABLE Numbers_Big;SQL is a database language, so why do you want to re-compute constant data over and over, hundreds of times a day for years? UGH!
There are 365.2422 days per year, so a century of calender data is only 36,525 rows! Maybe 40 bytes per row? About 1.5 Kbytes total? This will fit into main storage
What you did post was wrong. DATE is a reserved word in SQL and it is unit of temporal measurement. You also seem to confuse columns and fields. In SQL a field is a sub-unit of a temporal measurement (YEARS, MONTH, DAY, HOUR, MINUTE, SECOND). Please
learn the ISO-11179 rules for data element names.
You crammed too much in the table. The new DATE data type is only 3 bytes! Your other columns are mostly redundant and have attribute splitting problems. Try this:
CREATE TABLE Calendar
(cal_date DATE NOT NULL PRIMARY KEY,
julian_date INTEGER NOT NULL,
julian_business_day INTEGER NOT NULL,
ordinal_date CHAR(8) NOT NULL
CHECK (ordinal_date
LIKE '[12][0-9][0-9][0-9]-[0-9][0-9][0-9]') NOT NULL,
week_date CHAR(9) NOT NULL
CHECK (week_date LIKE '[12][0-9][0-9][0-9]W[0-5][0-9]-[0-7])
The julianized date is a sequential number over the whole calendar. It makes temporal math easier.
ISO-8601 week_date is the week-within-year. This format is 'yyyyWww-d' where yyyy is the year, W is a separator token, ww is (01-53) week number and d is (1-7) day of the week.
There are several websites with calendars you can cut & paste, but you can start your search with: http://www.calendar-365.com/week-number.html
The Julian business day is a good trick. Number the days from whenever your calendar starts and repeat a number for a weekend or company holiday.
CREATE TABLE Calendar
(cal_date DATE NOT NULL PRIMARY KEY,
julian_business_nbr INTEGER NOT NULL,
INSERT INTO Calendar
VALUES ('2007-04-05', 42),
('2007-04-06', 43), -- good Friday
('2007-04-07', 43),
('2007-04-08', 43), -- Easter Sunday
('2007-04-09', 44),
('2007-04-10', 45); --Tuesday
To compute the business days from Thursday of this week to next
Tuesdays:
SELECT (C2.julian_business_nbr - C1.julian_business_nbr)
FROM Calendar AS C1, Calendar AS C2
WHERE C1.cal_date = '2007-04-05',
AND C2.cal_date = '2007-04-10';
Why store things like the month name in the table? This is a display field, not a schema column value. It is language dependent! It is only part of a scalar value, too; why not normalize?
But if you need them, then use computed columns that are not materialized until needed. Also, use the SUBSTRING() for things that are not numeric. Why use SMALLINT for the day of the week? Are you going to divide Thursday by 42? It is a name, not a numeric.
You saw the tricks with a Series table wanted to use them, but do not be the boy with a new hammer who thinks everything is a nail. I find that a spreadsheet is the best way to create such a calendar table because they have so many temporal options and
functions.
Also, putting the comma at the start of a line is an old punchcard trick that we do not use any more. Back in the 1960's, it let us re-arrange the deck and re-use the cards. All it cost us was readable code –- your eyes expect to see a comma after a string,
so this makes a twitch as you read.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Creating table types for procedures at design time: Where is the "Local Table Type" tab?
Hello,
I want to write a stored procedure (development perspective, repository object) and need to create a table type for the result table.I am working on HANA Studio 1.80.1 and the documentation tells me that I should open the "Local Table Types" tab. However, I do not see where this tab is.
I get an SQLScript tab nothing else. Any hints?
Regards,
AndreasHi ,
Have a look on this discussion:
Table type creation via HS repository / CDS / DDl Source
Regards,
Krishna Tangudu -
Line 390 Under the (Insert into SALES_TRADEIN Table)
I need to insert (TradeIn_1_VIN) Values If there is no values in (TradeIn_1_VIN) then i have to insert (TradeIn_2_VIN) values to the (SALES_TRADEIN) Table.
After i run then below script only (TradeIn_2_VIN) values are get inserted in the table. (TradeIn_1_VIN) are not getting loaded in to the table.
I think there is the problem from Line No (404 to 414) Please help me change those particular lines to insert (TradeIn_1_VIN) Values also.If there is no details then (TradeIn_2_VIN) need to be inserted.
-- =============================================
-- Stored Procedure for Flatfile_Sales
-- =============================================
USE [IconicMarketing]
---==========Sales_Cursor
--USE [IconicMarketing]
--GO
DECLARE
@FileType
varchar(50),
@ACDealerID
varchar(50),
@ClientDealerID
varchar(50),
@DMSType
varchar(50),
@DealNumber
varchar(50),
@CustomerNumber
varchar(50),
@CustomerName
varchar(50),
@CustomerFirstName
varchar(50),
@CustomerLastName
varchar(50),
@CustomerAddress
varchar(50),
@CustomerCity
varchar(50),
@CustomerState
varchar(50),
@CustomerZip
varchar(50),
@CustomerCounty
varchar(50),
@CustomerHomePhone
varchar(50),
@CustomerWorkPhone
varchar(50),
@CustomerCellPhone
varchar(50),
@CustomerPagerPhone
varchar(50),
@CustomerEmail
varchar(50),
@CustomerBirthDate
varchar(50),
@MailBlock
varchar(50),
@CoBuyerName
varchar(50),
@CoBuyerFirstName
varchar(50),
@CoBuyerLastName
varchar(50),
@CoBuyerAddress
varchar(50),
@CoBuyerCity
varchar(50),
@CoBuyerState
varchar(50),
@CoBuyerZip
varchar(50),
@CoBuyerCounty
varchar(50),
@CoBuyerHomePhone
varchar(50),
@CoBuyerWorkPhone
varchar(50),
@CoBuyerBirthDate
varchar(50),
@Salesman_1_Number
varchar(50),
@Salesman_1_Name
varchar(50),
@Salesman_2_Number
varchar(50),
@Salesman_2_Name
varchar(50),
@ClosingManagerName
varchar(50),
@ClosingManagerNumber
varchar(50),
@F_AND_I_ManagerNumber
varchar(50),
@F_AND_I_ManagerName
varchar(50),
@SalesManagerNumber
varchar(50),
@SalesManagerName
varchar(50),
@EntryDate
varchar(50),
@DealBookDate
varchar(50),
@VehicleYear
varchar(50),
@VehicleMake
varchar(50),
@VehicleModel
varchar(50),
@VehicleStockNumber
varchar(50),
@VehicleVIN
varchar(50),
@VehicleExteriorColor
varchar(50),
@VehicleInteriorColor
varchar(50),
@VehicleMileage
varchar(50),
@VehicleType
varchar(50),
@InServiceDate
varchar(50),
@HoldBackAmount
varchar(50),
@DealType
varchar(50),
@SaleType
varchar(50),
@BankCode
varchar(50),
@BankName
varchar(50),
@SalesmanCommission
varchar(50),
@GrossProfitSale
varchar(50),
@FinanceReserve
varchar(50),
@CreditLifePremium
varchar(50),
@CreditLifeCommision
varchar(50),
@TotalInsuranceReserve
varchar(50),
@BalloonAmount
varchar(50),
@CashPrice
varchar(50),
@AmountFinanced
varchar(50),
@TotalOfPayments
varchar(50),
@MSRP varchar(50),
@DownPayment
varchar(50),
@SecurityDesposit
varchar(50),
@Rebate
varchar(50),
@Term varchar(50),
@RetailPayment
varchar(50),
@PaymentType
varchar(50),
@RetailFirstPayDate
varchar(50),
@LeaseFirstPayDate
varchar(50),
@DayToFirstPayment
varchar(50),
@LeaseAnnualMiles
varchar(50),
@MileageRate
varchar(50),
@APRRate
varchar(50),
@ResidualAmount
varchar(50),
@LicenseFee
varchar(50),
@RegistrationFee
varchar(50),
@TotalTax
varchar(50),
@ExtendedWarrantyName
varchar(50),
@ExtendedWarrantyTerm
varchar(50),
@ExtendedWarrantyLimitMiles
varchar(50),
@ExtendedWarrantyDollar
varchar(50),
@ExtendedWarrantyProfit
varchar(50),
@FrontGross
varchar(50),
@BackGross
varchar(50),
@TradeIn_1_VIN
varchar(50),
@TradeIn_2_VIN
varchar(50),
@TradeIn_1_Make
varchar(50),
@TradeIn_2_Make
varchar(50),
@TradeIn_1_Model
varchar(50),
@TradeIn_2_Model
varchar(50),
@TradeIn_1_ExteriorColor
varchar(50),
@TradeIn_2_ExteriorColor
varchar(50),
@TradeIn_1_Year
varchar(50),
@TradeIn_2_Year
varchar(50),
@TradeIn_1_Mileage
varchar(50),
@TradeIn_2_Mileage
varchar(50),
@TradeIn_1_Gross
varchar(50),
@TradeIn_2_Gross
varchar(50),
@TradeIn_1_Payoff
varchar(50),
@TradeIn_2_Payoff
varchar(50),
@TradeIn_1_ACV
varchar(50),
@TradeIn_2_ACV
varchar(50),
@Fee_1_Name
varchar(50),
@Fee_1_Fee
varchar(50),
@Fee_1_Commission
varchar(50),
@Fee_2_Name
varchar(50),
@Fee_2_Fee
varchar(50),
@Fee_2_Commission
varchar(50),
@Fee_3_Name
varchar(50),
@Fee_3_Fee
varchar(50),
@Fee_3_Commission
varchar(50),
@Fee_4_Name
varchar(50),
@Fee_4_Fee
varchar(50),
@Fee_4_Commission
varchar(50),
@Fee_5_Name
varchar(50),
@Fee_5_Fee
varchar(50),
@Fee_5_Commission
varchar(50),
@Fee_6_Name
varchar(50),
@Fee_6_Fee
varchar(50),
@Fee_6_Commission
varchar(50),
@Fee_7_Name
varchar(50),
@Fee_7_Fee
varchar(50),
@Fee_7_Commission
varchar(50),
@Fee_8_Name
varchar(50),
@Fee_8_Fee
varchar(50),
@Fee_8_Commission
varchar(50),
@Fee_9_Name
varchar(50),
@Fee_9_Fee
varchar(50),
@Fee_9_Commission
varchar(50),
@Fee_10_Name
varchar(50),
@Fee_10_Fee
varchar(50),
@Fee_10_Commission
varchar(50),
@ContractDate
varchar(50),
@InsuranceName
varchar(50),
@InsuranceAgentName
varchar(50),
@InsuranceAddress
varchar(50),
@InsuranceCity
varchar(50),
@InsuranceState
varchar(50),
@InsuranceZip
varchar(50),
@InsurancePhone
varchar(50),
@InsurancePolicyNumber
varchar(50),
@InsuranceEffectiveDate
varchar(50),
@InsuranceExpirationDate
varchar(50),
@InsuranceCompensationDeduction
varchar(50),
@TradeIn_1_InteriorColor
varchar(50),
@TradeIn_2_InteriorColor
varchar(50),
@PhoneBlock
varchar(50),
@LicensePlateNumber
varchar(50),
@Cost varchar(50),
@InvoiceAmount
varchar(50),
@FinanceCharge
varchar(50),
@TotalPickupPayment
varchar(50),
@TotalAccessories
varchar(50),
@TotalDriveOffAmount
varchar(50),
@EmailBlock
varchar(50),
@ModelDescriptionOfCarSold
varchar(50),
@VehicleClassification
varchar(50),
@ModelNumberOfCarSold
varchar(50),
@GAPPremium
varchar(50),
@LastInstallmentDate
varchar(50),
@CashDeposit
varchar(50),
@AHPremium
varchar(50),
@LeaseRate
varchar(50),
@DealerSelect
varchar(50),
@LeasePayment
varchar(50),
@LeaseNetCapCost
varchar(50),
@LeaseTotalCapReduction
varchar(50),
@DealStatus
varchar(50),
@CustomerSuffix
varchar(50),
@CustomerSalutation
varchar(50),
@CustomerAddress2
varchar(50),
@CustomerMiddleName
varchar(50),
@GlobalOptOut
varchar(50),
@LeaseTerm
varchar(50),
@ExtendedWarrantyFlag
varchar(50),
@Salesman_3_Number
varchar(50),
@Salesman_3_Name
varchar(50),
@Salesman_4_Number
varchar(50),
@Salesman_4_Name
varchar(50),
@Salesman_5_Number
varchar(50),
@Salesman_5_Name
varchar(50),
@Salesman_6_Number
varchar(50),
@Salesman_6_Name
varchar(50),
@APRRate2
varchar(50),
@APRRate3
varchar(50),
@APRRate4
varchar(50),
@Term2
varchar(50),
@SecurityDeposit2
varchar(50),
@DownPayment2
varchar(50),
@TotalOfPayments2
varchar(50),
@BasePayment
varchar(50),
@JournalSaleAmount
varchar(50),
@IndividualBusinessFlag
varchar(50),
@InventoryDate
varchar(50),
@StatusDate
varchar(50),
@ListPrice
varchar(50),
@NetTradeAmount
varchar(50),
@TrimLevel
varchar(50),
@SubTrimLevel
varchar(50),
@BodyDescription
varchar(50),
@BodyDoorCount
varchar(50),
@TransmissionDesc
varchar(50),
@EngineDesc
varchar(50),
@TypeCode
varchar(50),
@SLCT2
varchar(50),
@DealDateOffset
varchar(50),
@AccountingDate
varchar(50),
@CoBuyerCustNum
varchar(50),
@CoBuyerCell
varchar(50),
@CoBuyerEmail
varchar(50),
@CoBuyerSalutation
varchar(50),
@CoBuyerPhoneBlock
varchar(50),
@CoBuyerMailBlock
varchar(50),
@CoBuyerEmailBlock
varchar(50),
@RealBookDate
varchar(50),
@CoBuyerMiddleName
varchar(50),
@CoBuyerCountry
varchar(50),
@CoBuyerAddress2
varchar(50),
@CoBuyerOptOut
varchar(50),
@CoBuyerOccupation
varchar(50),
@CoBuyerEmployer
varchar(50),
@Country
varchar(50),
@Occupation
varchar(50),
@Employer
varchar(50),
@Salesman2Commission
varchar(50),
@BankAddress
varchar(50),
@BankCity
varchar(50),
@BankState
varchar(50),
@BankZip
varchar(50),
@LeaseEstimatedMiles
varchar(50),
@AFTReserve
varchar(50),
@CreditLifePrem
varchar(50),
@CreditLifeRes
varchar(50),
@AHRes
varchar(50),
@Language
varchar(50),
@BuyRate
varchar(50),
@DMVAmount
varchar(50),
@Weight
varchar(50),
@StateDMVTotFee
varchar(50),
@ROSNumber
varchar(50),
@Incentives
varchar(50),
@CASS_STD_LINE1
varchar(50),
@CASS_STD_LINE2
varchar(50),
@CASS_STD_CITY
varchar(50),
@CASS_STD_STATE
varchar(50),
@CASS_STD_ZIP
varchar(50),
@CASS_STD_ZIP4
varchar(50),
@CASS_STD_DPBC
varchar(50),
@CASS_STD_CHKDGT
varchar(50),
@CASS_STD_CART
varchar(50),
@CASS_STD_LOT
varchar(50),
@CASS_STD_LOTORD
varchar(50),
@CASS_STD_URB
varchar(50),
@CASS_STD_FIPS
varchar(50),
@CASS_STD_EWS
varchar(50),
@CASS_STD_LACS
varchar(50),
@CASS_STD_ZIPMOV
varchar(50),
@CASS_STD_Z4LOM
varchar(50),
@CASS_STD_NDIAPT
varchar(50),
@CASS_STD_NDIRR
varchar(50),
@CASS_STD_LACSRT
varchar(50),
@CASS_STD_ERROR_CD
varchar(50),
@NCOA_AC_ID
varchar(50),
@NCOA_COA_ADDSRC
varchar(50),
@NCOA_COA_MATCH
varchar(50),
@NCOA_COA_MOVTYP
varchar(50),
@NCOA_COA_DATE
varchar(50),
@NCOA_COA_DELCD
varchar(50),
@NCOA_COA_RTYPE
varchar(50),
@NCOA_COA_RTNCD
varchar(50),
@NCOA_COA_LINE1
varchar(50),
@NCOA_COA_LINE2
varchar(50),
@NCOA_COA_CITY
varchar(50),
@NCOA_COA_STATE
varchar(50),
@NCOA_COA_ZIP
varchar(50),
@NCOA_COA_ZIP4
varchar(50),
@NCOA_COA_DPBC
varchar(50),
@NCOA_COA_CHKDGT
varchar(50),
@NCOA_COA_CART
varchar(50),
@NCOA_COA_LOT
varchar(50),
@NCOA_COA_LOTORD
varchar(50),
@NCOA_COA_URB
varchar(50),
@NCOA_COA_Z4LOM
varchar(50),
@NCOA_COA_ACTION
varchar(50),
@NCOA_COA_QNAME
varchar(50),
@NCOA_DPV_AA
varchar(50),
@NCOA_DPV_A1
varchar(50),
@NCOA_DPV_BB
varchar(50),
@NCOA_DPV_CC
varchar(50),
@NCOA_DPV_M1
varchar(50),
@NCOA_DPV_M3
varchar(50),
@NCOA_DPV_N1
varchar(50),
@NCOA_DPV_P1
varchar(50),
@NCOA_DPV_P3
varchar(50),
@NCOA_DPV_RR
varchar(50),
@NCOA_DPV_R1
varchar(50),
@NCOA_DPV_STATUS
varchar(50),
@NCOA_DPV_F1
varchar(50),
@NCOA_DPV_G1
varchar(50),
@NCOA_DPV_U1
varchar(50),
@myerror
varchar(500),
@SalesID
int,
@errornumber int,
@errorseverity varchar(500),
@errorstate int,
@errorprocedure varchar(500),
@errorline varchar(50),
@errormessage varchar(1000);
DECLARE Sales_Cursor CURSOR FOR
SELECT * from FLATFILE_SALES;
OPEN Sales_Cursor;
:r C:\Clients\BlackBook\BlackBookMarketing\Bharath\LOG_SALES_INSERT.sql
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @VehicleVIN ;
--===============================================================================
-- ****************** insert into Sales Table ***********
BEGIN TRY
INSERT INTO Sales
IconicDealerID,
DealNumber,
CustomerNumber,
DMSType,
ContractDate
VALUES (@ClientDealerID,@DealNumber,@CustomerNumber,@DMSType,@ContractDate);
END TRY
BEGIN CATCH
SELECT
@errornumber = ERROR_NUMBER()
,@errorseverity = ERROR_SEVERITY()
,@errorstate = ERROR_STATE()
,@errorprocedure = ERROR_PROCEDURE()
,@errorline = ERROR_LINE()
,@errormessage = ERROR_MESSAGE();
:r C:\Clients\BlackBook\BlackBookMarketing\Bharath\LOG_SALES_INSERT.sql
@errornumber ,
@errorseverity ,
@errorstate,
@errorprocedure,
@errorline,
@errormessage);
END CATCH
PRINT @errornumber;
PRINT @errorseverity;
PRINT @errorprocedure;
PRINT @errorline;
PRINT @errormessage;
PRINT @errorstate;
set @myerror = @@ERROR;
-- This PRINT statement prints 'Error = 0' because
-- @@ERROR is reset in the IF statement above.
PRINT N'Error = ' + @myerror;
set @SalesID = scope_identity();
PRINT @SalesID;
--================================================================================
--Insert into SALES_TRADEIN Table
BEGIN TRY
INSERT INTO SALES_TRADEIN
SalesID,
TradeIn_VIN,
TradeIn_Make,
TradeIn_Model,
TradeIn_ExteriorColor,
TradeIn_Year,
TradeIn_Mileage,
TradeIn_Gross,
TradeIn_Payoff,
TradeIn_ACV,
TradeIn_InteriorColor
VALUES
@SalesID,
case when @TradeIn_1_VIN is not null then @TradeIn_2_VIN end,
case when @TradeIn_1_Make is not null then @TradeIn_2_Make end,
case when @TradeIn_1_Model is not null then @TradeIn_2_Model end,
case when @TradeIn_1_ExteriorColor is not null then @TradeIn_2_ExteriorColor end,
case when @TradeIn_1_Year is not null then @TradeIn_2_Year end,
case when @TradeIn_1_Mileage is not null then @TradeIn_2_Mileage end,
case when @TradeIn_1_Gross is not null then @TradeIn_2_Gross end,
case when @TradeIn_1_Payoff is not null then @TradeIn_2_Payoff end,
case when @TradeIn_1_ACV is not null then @TradeIn_2_ACV end,
case when @TradeIn_1_InteriorColor is not null then @TradeIn_2_InteriorColor end
END TRY
BEGIN CATCH
SELECT
@errornumber = ERROR_NUMBER()
,@errorseverity = ERROR_SEVERITY()
,@errorstate = ERROR_STATE()
,@errorprocedure = ERROR_PROCEDURE()
,@errorline = ERROR_LINE()
,@errormessage = ERROR_MESSAGE();
:r C:\Clients\BlackBook\BlackBookMarketing\Bharath\LOG_SALES_INSERT.sql
END CATCHThis is what I've understood from your question. You want to replace @TradeIn_2_VIN value if @TradeIn_1_VIN
is NULL, else the value of @TradeIn_1_VIN.
If this is the requirement then, your CASE statement is missing ELSE part. You can re-write this as below
case when @TradeIn_1_VIN is null then @TradeIn_2_VIN
ELSE @TradeIn_1_VIN end,
or simply you can replace the CASE statement with the below
COALESCE function,
COALESCE(@TradeIn_1_VIN, @TradeIn_2_VIN),
Krishnakumar S
Maybe you are looking for
-
Experts, In one crystal report, there are more than 20 pages. Now in first page data coming fine, but in most of the pages, the lines (column lines, vertical lines) are not ending or not touching the horizontal line which really looks very odd. Pleas
-
Problems with the compiler?
Hi all-, Can someone look into this?: In the below test, if I uncomment the first line, JSR014's javac fails, but CodeGuide (www.omnicore.com, features its own compiler) is OK. If I uncomment the second comment, both compilers complain: import java.u
-
System default email client (Thunderbird) does not appear in mailto applications.
I should like to use Thunderbird as the mailto application in Firefox. The only options listed for mailto are GMail, Yahoo mail, always ask, and choose application; use default does not appear.
-
There are days when I need to burn many different DVD projects using iDVD from my computer. 1. Is there a way to have more than one active iDVD window open, like in iMovie? 2. Can you select external burners in iDVD? 3. Is it feasible to have multipl
-
RV220W and inbound communication
I am hoping that CISCO is considering a firmware update to this useful and powerful Small Business Router. One of the main items that needs to be fixed in the RV220W relates to the incoming firewall rules. It is not possible to block incoming packets