Hey all- I have been reading this forum for quite some time now but I have never posted- this place is a great tool for young developers.
Anyway, I have a specific question.
I have a table (members)- with PK member_id- that holds member names and personal info etc.
My goal is for each member_id in the members table, insert that member_id into my fk column in a logins table. then, when each member_id is inserted, i want to insert the first initial of the member_name and first 4 characters of the last_name, along with the member_id into the logins table in the login_name column.
i also want to insert a unique 6 digit string into the logins table (login_password). I'm not great with script, so any help would be appreciated.
Thanks,
sudeep.Suppose you have this situation:
CREATE TABLE members
(member_id NUMBER(2) CONSTRAINT pk_mem PRIMARY KEY,
member_name VARCHAR2(10),
last_name VARCHAR2(10)
);
CREATE TABLE logins
(member_id NUMBER(2) CONSTRAINT fk_log_mem
REFERENCES members (member_id)
INITIALLY DEFERRED DEFERRABLE,
login_name VARCHAR2(20),
login_password VARCHAR2(6)
);
CREATE SEQUENCE seq_mem_login START WITH 100000;
/* The sequence is used to generate unique login passwords in this example */
CREATE OR REPLACE TRIGGER trg_member
AFTER INSERT
ON members
FOR EACH ROW
BEGIN
INSERT INTO logins
(member_id,
login_name,
login_password
)
VALUES (:NEW.member_id,
SUBSTR (:NEW.member_name, 1, 1)
|| SUBSTR (:NEW.last_name, 1, 4)
|| TO_CHAR (:NEW.member_id),
seq_mem_login.NEXTVAL
);
END;
/
insert into members values (1, 'john', 'smith');
select * from members;
MEMBER_ID MEMBER_NAM LAST_NAME
---- ---- ----
5 john smith
select * from logins;
MEMBER_ID LOGIN_NAME LOGIN_
---- ------- --
5 jsmit5 100000|||thanks man- i'll let you know how it goes in a few.|||whats wrong with this code? anyone?
it gives me the following error:
Server: Msg 128, Level 15, State 1, Procedure trigPassword_CreateMember, Line 9
The name 'member_id' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
--Create the trigger
CREATE TRIGGER trigPassword_CreateMember ON Accounts
AFTER Insert
AS
BEGIN
BEGIN TRAN
INSERT INTO Logins(member_id, login_name, login_password)
VALUES (inserted.member_id, SUBSTRING(inserted.first_name,1,1) + SUBSTRING(last_name,1,1) + CONVERT(char(5),inserted.member_id),
inserted.account_id)
COMMIT TRAN
END
GO
Showing posts with label tool. Show all posts
Showing posts with label tool. Show all posts
Thursday, March 22, 2012
Create a Letter
hi there,
Anybody know how to create a letter using Sql Reporting. My report
format is given below please advice which tool item i should use and
how to justify the letter body.
where xxx is from database
Dear Mr xxxx
xxxx is pleased to confirm the receipt of the sub amt for the xxx
project. the details of which are as follows
sub for : xxx
all : xxx
two sentence here
please advice how can i do this...
thnxJust drag a list control expand till you get a decent size of the letter and
place various text box's inside, each will be placed as per your letter eg.
some has fixed text and couple of variable textbox eg. Name of the person.
in the properties of the listbox create group and give a page break. in your
case the group will be set on emp name.. so it prints in different page for
each emp.
Amarnath
"Murali" wrote:
> hi there,
> Anybody know how to create a letter using Sql Reporting. My report
> format is given below please advice which tool item i should use and
> how to justify the letter body.
> where xxx is from database
> Dear Mr xxxx
> xxxx is pleased to confirm the receipt of the sub amt for the xxx
> project. the details of which are as follows
> sub for : xxx
> all : xxx
> two sentence here
>
> please advice how can i do this...
> thnx
>
Anybody know how to create a letter using Sql Reporting. My report
format is given below please advice which tool item i should use and
how to justify the letter body.
where xxx is from database
Dear Mr xxxx
xxxx is pleased to confirm the receipt of the sub amt for the xxx
project. the details of which are as follows
sub for : xxx
all : xxx
two sentence here
please advice how can i do this...
thnxJust drag a list control expand till you get a decent size of the letter and
place various text box's inside, each will be placed as per your letter eg.
some has fixed text and couple of variable textbox eg. Name of the person.
in the properties of the listbox create group and give a page break. in your
case the group will be set on emp name.. so it prints in different page for
each emp.
Amarnath
"Murali" wrote:
> hi there,
> Anybody know how to create a letter using Sql Reporting. My report
> format is given below please advice which tool item i should use and
> how to justify the letter body.
> where xxx is from database
> Dear Mr xxxx
> xxxx is pleased to confirm the receipt of the sub amt for the xxx
> project. the details of which are as follows
> sub for : xxx
> all : xxx
> two sentence here
>
> please advice how can i do this...
> thnx
>
Create a grants rights script fails during configuration
I am in the reporting services configuration tool. When I am on database setup I get Create a Grants Scripts Right with a red X. Everything else passes. I am using sql server credentials and the user is sa on the database server. Any help would be appreciated.
Joni,
Validate that sa user is in the security/users on your "ReportServer" database and also give to access to the RSExec Role for reporting services. When I encounter this issue by user Id did not have RSExec Role after adding it then I was able to configure my services correctly.
Ham
sqlSunday, March 11, 2012
CR 8.5, dual monitor printing issues, delphi
Hi Guys,
We develop software in Delphi and Crystal Report 8.5 is used as reporting tool. Delphi's crystal component is used for coding.
I have a situation with a potential client. They have toshiba tecra m2 laptop which has GEForce FX 5200 video card which is dual monitor card. The OS is XP with SP2. When I click preview it is fetching data from the database and after that it hangs for ever neither displays view window or print. If the Harware accelaration is changed to 0 and Enable write combining is checked for this hardware properties the reports can be viewed and printed. But the client said these hardware properties are required for other applications on the machine.
Could any one help me resolving the issue? Is there any one have similar kind of problem?
Thanks in advance.
-KtuserThis behaviors can occur because of the 'Hardware acceleration' setting in Microsoft Windows. Reducing hardware acceleration on your computer will resolve these behaviors.
To access the 'Hardware acceleration' setting in Microsoft Windows, click Start > Settings > Control Panel > System > Display > Settings > Advanced > Troubleshooting.
There are typically six possible settings for 'Hardware acceleration': from 'None' to 'Full'. Reduce this value one setting at a time until the above behaviors are resolved.
The behavior of 'Enable write combining' has not been tested so not sure about it. Try the following along with the 'Enable write combining' checked and unchecked.
We develop software in Delphi and Crystal Report 8.5 is used as reporting tool. Delphi's crystal component is used for coding.
I have a situation with a potential client. They have toshiba tecra m2 laptop which has GEForce FX 5200 video card which is dual monitor card. The OS is XP with SP2. When I click preview it is fetching data from the database and after that it hangs for ever neither displays view window or print. If the Harware accelaration is changed to 0 and Enable write combining is checked for this hardware properties the reports can be viewed and printed. But the client said these hardware properties are required for other applications on the machine.
Could any one help me resolving the issue? Is there any one have similar kind of problem?
Thanks in advance.
-KtuserThis behaviors can occur because of the 'Hardware acceleration' setting in Microsoft Windows. Reducing hardware acceleration on your computer will resolve these behaviors.
To access the 'Hardware acceleration' setting in Microsoft Windows, click Start > Settings > Control Panel > System > Display > Settings > Advanced > Troubleshooting.
There are typically six possible settings for 'Hardware acceleration': from 'None' to 'Full'. Reduce this value one setting at a time until the above behaviors are resolved.
The behavior of 'Enable write combining' has not been tested so not sure about it. Try the following along with the 'Enable write combining' checked and unchecked.
Subscribe to:
Posts (Atom)