unable to compile stored procedure in sybase ase11 - sap-ase

Hi i have a two stored procedure a and b, b called by a, in a one temp tables created and in the sp b trying to access temp table of sp a, at compile time getting error for missing object.

The compiler checks for all objects mentioned in your SQL without checking if they are created during execution.
You could create the temp table and then in the same session create the procs, that should work.
You can then drop the temp table.

Seriously? Version 11? Wow.
Any way, try adding "create table" for the temp table before creating sproc b.

Related

U-SQL error while table rebuild

Error occurs when I call ALTER TABLE REBUILD in one stored procedure and try to SELECT data in another simultaneously.
CREATE PROCEDURE IF NOT EXISTS RebuildContent()
AS
BEGIN
INSERT INTO dbo.Log (Date, Message)
VALUES ( DateTime.UtcNow, "Starting Content table rebuilding ..." );
ALTER TABLE dbo.Content REBUILD;
ALTER TABLE dbo.ContentCrc REBUILD;
INSERT INTO dbo.Log (Date, Message)
VALUES ( DateTime.UtcNow, "Completed Content table rebuilding ..." );
END;
Are there any solutions to avoid it?
Thank you in advance!
You are running into a race condition between rebuilding and reading from the same table.
Rebuilding a table creates a new file by compacting the files that got created by the insertion. Unfortunately right now, once the rebuild is deleting the old file, you will lose access to the old version and you will get an error message.
We are aware of this issue and have created a work item to preserve access to the old file for the started queries (providing snapshot semantics). However, I do not have an ETA at the moment.
Thus until then, please schedule your rebuild and read jobs without overlaps.
Note: You can still concurrently rebuild and insert or insert and read.

Bcp must be installed error when loading Adventureworks Azure datawarehouse

I'm trying to test the Azure Data Warehouse. I successfully created and connected to the database, but I've run into a snag as I attempt to load the tables. I'm trying to execute the following instructions:
To install AdventureWorksSQLDW2012:
-----------------------------------
4. Extract files from AdventureWorksSQLDW2012.zip file into a directory.
5. Edit aw_create.bat setting the following variables:
a. server=<servername> from step 1. e.g. mylogicalserver.database.windows.net
b. user=<username> from step 1 or another user with proper permissions
c. password=<passwordname> for user in step 5b
d. database=<database> created in step 1
e. schema=<schema> this schema will be created if it does not yet exist
6. Run aw_create.bat from a cmd prompt, running from the directory where the files were unzipped to.
This script will...
a. Drop any Adventure Works tables or views that already exist in the schema
b. Create the Adventure Works tables and views in the schema specified
c. Load each table using bcp
d. Validate the row counts for each table
e. Collect statistics on every column for each table
I completed the prerequisites of installing bcp and sqlcmd and used the -? command to confirm the installations.
Unfortunately, when I try to complete step 6 above I get the following error:
REM AdventureWorksSQLDW2012 sample database version 3.0 for DW Service Tue 06/27/2017 20:31:01.99 Bcp must be installed.
Has anyone else come across this error or can anyone suggest a potential solution.
UPDATE: I've also copied the path where BCP is located to my path environment variables. Still no luck.
The aw_create.bat contains a line where you need to provide the path of the bcp program. Once provided ans save the script worked like a charm.

Can I export matrix to Excel from SAS University on PC under VMWare

I wish to write to Excel on my PC a "big" matrix of p rows and c columns, e.g.
3,000 rows and 20 columns. But it's not easy, and I'm wondering if I can simplify it by using a fixed number for rows and columns instead of:
array mat {&periods,&columns};
Right now, I'm on the free version of SAS called "SAS University Edition", which has only community help.
I would like to output it to Excel, but using VMWARE on a PC to get SAS Studio to run, you can't write directly to disk (although there is a myfolder).
I tried this, but got this error log:
proc export data=WORK.CPAPMONTE1
file= "/folders/myfolders/outfile1.xlsx"
DBMS=xlsx
;
run;
ERROR: XLSX file can not be created -> /folders/myfolders//outfile1.xlsx. Make sure the path name is correct and that you have
write permission.
ERROR: Too many variables for the output file
I figure that the 2nd error is just due to the first error, which has a // instead of a /
I have defined a special folder for my data in SAS University Edition as:
/folders/myfolders/CPAP1
but I haven't figured out how to point to there
You can write directly to disk, you need to set up a shared folder similar to myfolders and then you reference its as
/folders/myshortcuts/myname
The folder and shortcut must be exactly correct, and all need to be lower case as it's case sensitive. If you have myfolders set up, all you need to do is right click on the folder>Properties and you'll get the path to the folder. Use that in your export. A similar process can be used for the custom shared folder you set up.
SAS University Edition Help Center/FAQ
https://support.sas.com/software/products/university-edition/faq/main.htm
Your specific question - How do I create a folder shortcut to my existing SAS files?
https://support.sas.com/software/products/university-edition/faq/shared_folder_access_existing.htm

How can I reference another DB from a VS DB project?

We have several databases, say DB1, DB2, DB3 etc.
They have to have identical code base, so we use a DB project in Visual Studio 2012 and generate a SQL script for deployment based on comparison between the project and UAT/Prod DB1. Then this script is applied to DB1-DBn.
For the very first time in the history of this DB project I had to create a function that contained a hardcoded database name, example:
inner join DB1.schema.table1 as t1 on
And now the project cannot be built or comparison cannot be updated or script generated (Update and Generate Script buttons disabled) due to a number of errors pertaining to that database reference, as VS seems to believe that DB1 does not exist.
I tried to add a project level SQLCMD variable $(DB) and set it to DB1 default value and use it as
inner join [$(DB1)].schema.table1 as t1 on
to work around the errors, but it did not seem to make any difference.
Edit:
A suggestion was made to add a circular project reference to itself and assign to it the same variable I was trying to add manually, not sure how to accomplish that.
As per this article the reference should be added to a manually extracted .dacpac file as follows:
Extracted .dacpac file from the targed DB with the following command:
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\sqlpackage.exe" /SourcePassword:p /SourceUser:u /Action:Extract /ssn:192.168.2.1 /sdn:DB1 /tf:DB1.dacpac
Included that as a database reference. It automatically assigned the correct SQLCMD variable name and the error disappeared.
From the source control point, even though when adding a database reference to a .dacpac file automatically creates a SQLCMD variable, it does not add the file to the project. The .dacpac file used still has to be added to the project as an existing item, which is kind of lame. Doing that in the solution explorer I encountered an error and had to do that through the team explorer instead, where that worked.

sql71501 sql parameter has unresolved reference to build-in type

from VS2012 I created a Database project and created ad custom type
CREATE TYPE dbo.TypeProductCategoryTable AS TABLE
( ProductID int, CategoryID int )
Now when I write stored procedure with using this type, i get compile error
sql71501 sql parameter has unresolved reference to build-in type
Procedure
CREATE PROCEDURE [dbo].[usp_ProductCategory_Mapping]
#tvProdCat dbo.ProductCategoryTableType READONLY
AS
insert into tProductCategories(ProductId,CategoryId)
SELECT #tvProdCat
RETURN 0
How to handle this? Can we create custom type on Visual studio Database project
you can use pre-deployment script in visual studio project.
for doing this you need to add 2 files in VS:
1.
create UserDefinedTableType.sql in your database project in VS and put the scrip of creating table type inside this script.
2.in your database project add UserScripts -> pre-Deployment script and call the script in the step 1 here . using this code :
:r .\Scripts\Pre-Deployment\UserDefinedTableType.sql
the unresolved reference will be resolved with this solution
I had this issue and realized that somehow the build node for the TVP was inserted below the SP where it was used within my .sqlproj file. once I moved the TVP above the SP I no longer received the error in VS and the project deployed as expected with no errors.
I had not realized previously that the order of the build nodes in the .sqlproj mattered but apparently the the DACPAC Compiler wasn't built to intelligently determine the order of the build process which makes sense in retrospect. I'd rather have that control even if it did in this case trip me up.

Resources